From 3f6f510e4f8e6e3921b9092fe54f9c060fb42304 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 22 Jun 2022 23:06:41 +0800 Subject: [PATCH] fix(client): non-empty judgment --- .../antd/form-item/FormItem.tsx | 104 +++++++++--------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx index c0b0ea24b..2b7dbafdf 100644 --- a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx @@ -16,9 +16,11 @@ export const FormItem: any = (props) => { return ( { }} /> )} - {!form.readPretty && collectionField.interface !== 'o2m' && ( + {!form?.readPretty && collectionField?.interface !== 'o2m' && ( { - console.log('v', v); - const schema: ISchema = { - ['x-uid']: fieldSchema['x-uid'], - }; + key="pattern" + title={t('Pattern')} + options={[ + { label: t('Editable'), value: 'editable' }, + { label: t('Readonly'), value: 'readonly' }, + { label: t('Easy-reading'), value: 'read-pretty' }, + ]} + value={readOnlyMode} + onChange={(v) => { + console.log('v', v); + const schema: ISchema = { + ['x-uid']: fieldSchema['x-uid'], + }; - switch(v) { - case 'readonly': { - fieldSchema['x-read-pretty'] = false; - fieldSchema['x-disabled'] = true; - schema['x-read-pretty'] = false; - schema['x-disabled'] = true; - field.readPretty = false; - field.disabled = true; - break; + switch (v) { + case 'readonly': { + fieldSchema['x-read-pretty'] = false; + fieldSchema['x-disabled'] = true; + schema['x-read-pretty'] = false; + schema['x-disabled'] = true; + field.readPretty = false; + field.disabled = true; + 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': { - 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; - } - } - dn.emit('patch', { - schema - }); + dn.emit('patch', { + schema, + }); - dn.refresh(); - }} - /> + dn.refresh(); + }} + /> )} {collectionField?.target && ( { key="remove" removeParentsIfNoChildren confirm={{ - title: t('Delete field') + title: t('Delete field'), }} breakRemoveOn={{ 'x-component': 'Grid',