fix(client): non-empty judgment

This commit is contained in:
chenos 2022-06-22 23:06:41 +08:00
parent 22c6591162
commit 3f6f510e4f

View File

@ -16,9 +16,11 @@ export const FormItem: any = (props) => {
return ( return (
<BlockItem className={'nb-form-item'}> <BlockItem className={'nb-form-item'}>
<Item <Item
className={`${css`& .ant-space{ className={`${css`
flex-wrap:wrap; & .ant-space {
}`}`} flex-wrap: wrap;
}
`}`}
{...props} {...props}
extra={ extra={
field.description ? ( field.description ? (
@ -185,56 +187,58 @@ FormItem.Designer = () => {
}} }}
/> />
)} )}
{!form.readPretty && collectionField.interface !== 'o2m' && ( {!form?.readPretty && collectionField?.interface !== 'o2m' && (
<SchemaSettings.SelectItem <SchemaSettings.SelectItem
key="pattern" key="pattern"
title={t('Pattern')} title={t('Pattern')}
options={ options={[
[{ label: t('Editable'), value: 'editable' }, { label: t('Readonly'), value: 'readonly' }, { label: t('Easy-reading'), value: 'read-pretty' }] { label: t('Editable'), value: 'editable' },
} { label: t('Readonly'), value: 'readonly' },
value={readOnlyMode} { label: t('Easy-reading'), value: 'read-pretty' },
onChange={(v) => { ]}
console.log('v', v); value={readOnlyMode}
const schema: ISchema = { onChange={(v) => {
['x-uid']: fieldSchema['x-uid'], console.log('v', v);
}; const schema: ISchema = {
['x-uid']: fieldSchema['x-uid'],
};
switch(v) { switch (v) {
case 'readonly': { case 'readonly': {
fieldSchema['x-read-pretty'] = false; fieldSchema['x-read-pretty'] = false;
fieldSchema['x-disabled'] = true; fieldSchema['x-disabled'] = true;
schema['x-read-pretty'] = false; schema['x-read-pretty'] = false;
schema['x-disabled'] = true; schema['x-disabled'] = true;
field.readPretty = false; field.readPretty = false;
field.disabled = true; field.disabled = true;
break; break;
}
case 'read-pretty': {
fieldSchema['x-read-pretty'] = true;
fieldSchema['x-disabled'] = false;
schema['x-read-pretty'] = true;
schema['x-disabled'] = false;
field.readPretty = true;
// field.disabled = true;
break;
}
default: {
fieldSchema['x-read-pretty'] = false;
fieldSchema['x-disabled'] = false;
schema['x-read-pretty'] = false;
schema['x-disabled'] = false;
field.readPretty = false;
field.disabled = false;
break;
}
} }
case 'read-pretty': { dn.emit('patch', {
fieldSchema['x-read-pretty'] = true; schema,
fieldSchema['x-disabled'] = false; });
schema['x-read-pretty'] = true;
schema['x-disabled'] = false;
field.readPretty = true;
// field.disabled = true;
break;
}
default: {
fieldSchema['x-read-pretty'] = false;
fieldSchema['x-disabled'] = false;
schema['x-read-pretty'] = false;
schema['x-disabled'] = false;
field.readPretty = false;
field.disabled = false;
break;
}
}
dn.emit('patch', {
schema
});
dn.refresh(); dn.refresh();
}} }}
/> />
)} )}
{collectionField?.target && ( {collectionField?.target && (
<SchemaSettings.SelectItem <SchemaSettings.SelectItem
@ -268,7 +272,7 @@ FormItem.Designer = () => {
key="remove" key="remove"
removeParentsIfNoChildren removeParentsIfNoChildren
confirm={{ confirm={{
title: t('Delete field') title: t('Delete field'),
}} }}
breakRemoveOn={{ breakRemoveOn={{
'x-component': 'Grid', 'x-component': 'Grid',