fix(client): collection field does not exist
This commit is contained in:
		
							parent
							
								
									91ae780e4f
								
							
						
					
					
						commit
						345080f92e
					
				@ -25,7 +25,7 @@ FormItem.Designer = () => {
 | 
				
			|||||||
  const compile = useCompile();
 | 
					  const compile = useCompile();
 | 
				
			||||||
  const collectionField = getField(fieldSchema['name']);
 | 
					  const collectionField = getField(fieldSchema['name']);
 | 
				
			||||||
  const originalTitle = collectionField?.uiSchema?.title;
 | 
					  const originalTitle = collectionField?.uiSchema?.title;
 | 
				
			||||||
  const targetFields = collectionField.target ? getCollectionFields(collectionField.target) : [];
 | 
					  const targetFields = collectionField?.target ? getCollectionFields(collectionField.target) : [];
 | 
				
			||||||
  const initialValue = {
 | 
					  const initialValue = {
 | 
				
			||||||
    title: field.title === originalTitle ? undefined : field.title,
 | 
					    title: field.title === originalTitle ? undefined : field.title,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
@ -40,93 +40,95 @@ FormItem.Designer = () => {
 | 
				
			|||||||
    }));
 | 
					    }));
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <GeneralSchemaDesigner>
 | 
					    <GeneralSchemaDesigner>
 | 
				
			||||||
      <SchemaSettings.PopupItem
 | 
					      {collectionField && (
 | 
				
			||||||
        title={'编辑'}
 | 
					        <SchemaSettings.PopupItem
 | 
				
			||||||
        schema={
 | 
					          title={'编辑'}
 | 
				
			||||||
          {
 | 
					          schema={
 | 
				
			||||||
            title: '编辑字段',
 | 
					            {
 | 
				
			||||||
            'x-component': 'Action.Modal',
 | 
					              title: '编辑字段',
 | 
				
			||||||
            'x-decorator': 'Form',
 | 
					              'x-component': 'Action.Modal',
 | 
				
			||||||
            'x-decorator-props': {
 | 
					              'x-decorator': 'Form',
 | 
				
			||||||
              initialValue,
 | 
					              'x-decorator-props': {
 | 
				
			||||||
            },
 | 
					                initialValue,
 | 
				
			||||||
            type: 'void',
 | 
					 | 
				
			||||||
            properties: {
 | 
					 | 
				
			||||||
              title: {
 | 
					 | 
				
			||||||
                'x-decorator': 'FormItem',
 | 
					 | 
				
			||||||
                'x-component': 'Input',
 | 
					 | 
				
			||||||
                title: '字段标题',
 | 
					 | 
				
			||||||
                'x-component-props': {},
 | 
					 | 
				
			||||||
                description: `原字段标题:${collectionField?.uiSchema?.title}`,
 | 
					 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
              required: {
 | 
					              type: 'void',
 | 
				
			||||||
                'x-decorator': 'FormItem',
 | 
					              properties: {
 | 
				
			||||||
                'x-component': 'Checkbox',
 | 
					                title: {
 | 
				
			||||||
                'x-content': '必填',
 | 
					                  'x-decorator': 'FormItem',
 | 
				
			||||||
                'x-hidden': field.readPretty,
 | 
					                  'x-component': 'Input',
 | 
				
			||||||
              },
 | 
					                  title: '字段标题',
 | 
				
			||||||
              footer: {
 | 
					                  'x-component-props': {},
 | 
				
			||||||
                type: 'void',
 | 
					                  description: `原字段标题:${collectionField?.uiSchema?.title}`,
 | 
				
			||||||
                'x-component': 'Action.Modal.Footer',
 | 
					                },
 | 
				
			||||||
                properties: {
 | 
					                required: {
 | 
				
			||||||
                  cancel: {
 | 
					                  'x-decorator': 'FormItem',
 | 
				
			||||||
                    type: 'void',
 | 
					                  'x-component': 'Checkbox',
 | 
				
			||||||
                    title: '{{t("Cancel")}}',
 | 
					                  'x-content': '必填',
 | 
				
			||||||
                    'x-component': 'Action',
 | 
					                  'x-hidden': field.readPretty,
 | 
				
			||||||
                    'x-component-props': {
 | 
					                },
 | 
				
			||||||
                      useAction() {
 | 
					                footer: {
 | 
				
			||||||
                        const ctx = useActionContext();
 | 
					                  type: 'void',
 | 
				
			||||||
                        return {
 | 
					                  'x-component': 'Action.Modal.Footer',
 | 
				
			||||||
                          async run() {
 | 
					                  properties: {
 | 
				
			||||||
                            ctx.setVisible(false);
 | 
					                    cancel: {
 | 
				
			||||||
                          },
 | 
					                      type: 'void',
 | 
				
			||||||
                        };
 | 
					                      title: '{{t("Cancel")}}',
 | 
				
			||||||
 | 
					                      'x-component': 'Action',
 | 
				
			||||||
 | 
					                      'x-component-props': {
 | 
				
			||||||
 | 
					                        useAction() {
 | 
				
			||||||
 | 
					                          const ctx = useActionContext();
 | 
				
			||||||
 | 
					                          return {
 | 
				
			||||||
 | 
					                            async run() {
 | 
				
			||||||
 | 
					                              ctx.setVisible(false);
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					                          };
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
                      },
 | 
					                      },
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                  },
 | 
					                    submit: {
 | 
				
			||||||
                  submit: {
 | 
					                      type: 'void',
 | 
				
			||||||
                    type: 'void',
 | 
					                      title: 'Submit',
 | 
				
			||||||
                    title: 'Submit',
 | 
					                      'x-component': 'Action',
 | 
				
			||||||
                    'x-component': 'Action',
 | 
					                      'x-component-props': {
 | 
				
			||||||
                    'x-component-props': {
 | 
					                        type: 'primary',
 | 
				
			||||||
                      type: 'primary',
 | 
					                        useAction() {
 | 
				
			||||||
                      useAction() {
 | 
					                          const form = useForm();
 | 
				
			||||||
                        const form = useForm();
 | 
					                          const ctx = useActionContext();
 | 
				
			||||||
                        const ctx = useActionContext();
 | 
					                          return {
 | 
				
			||||||
                        return {
 | 
					                            async run() {
 | 
				
			||||||
                          async run() {
 | 
					                              const { title, required, label } = form.values;
 | 
				
			||||||
                            const { title, required, label } = form.values;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            const schema = {
 | 
					                              const schema = {
 | 
				
			||||||
                              ['x-uid']: fieldSchema['x-uid'],
 | 
					                                ['x-uid']: fieldSchema['x-uid'],
 | 
				
			||||||
                            };
 | 
					                              };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (title) {
 | 
					                              if (title) {
 | 
				
			||||||
                              field.title = title;
 | 
					                                field.title = title;
 | 
				
			||||||
                              fieldSchema['title'] = title;
 | 
					                                fieldSchema['title'] = title;
 | 
				
			||||||
                              schema['title'] = title;
 | 
					                                schema['title'] = title;
 | 
				
			||||||
                            }
 | 
					                              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            field.required = required;
 | 
					                              field.required = required;
 | 
				
			||||||
                            fieldSchema['required'] = required;
 | 
					                              fieldSchema['required'] = required;
 | 
				
			||||||
                            schema['required'] = required;
 | 
					                              schema['required'] = required;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            ctx.setVisible(false);
 | 
					                              ctx.setVisible(false);
 | 
				
			||||||
                            dn.emit('patch', {
 | 
					                              dn.emit('patch', {
 | 
				
			||||||
                              schema,
 | 
					                                schema,
 | 
				
			||||||
                            });
 | 
					                              });
 | 
				
			||||||
                            refresh();
 | 
					                              refresh();
 | 
				
			||||||
                          },
 | 
					                            },
 | 
				
			||||||
                        };
 | 
					                          };
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
                      },
 | 
					                      },
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                  },
 | 
					                  },
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
            },
 | 
					            } as ISchema
 | 
				
			||||||
          } as ISchema
 | 
					          }
 | 
				
			||||||
        }
 | 
					        />
 | 
				
			||||||
      />
 | 
					      )}
 | 
				
			||||||
      {collectionField?.target && (
 | 
					      {collectionField?.target && (
 | 
				
			||||||
        <SchemaSettings.SelectItem
 | 
					        <SchemaSettings.SelectItem
 | 
				
			||||||
          title={'标题字段'}
 | 
					          title={'标题字段'}
 | 
				
			||||||
@ -152,7 +154,7 @@ FormItem.Designer = () => {
 | 
				
			|||||||
          }}
 | 
					          }}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
      )}
 | 
					      )}
 | 
				
			||||||
      <SchemaSettings.Divider />
 | 
					      {collectionField && <SchemaSettings.Divider />}
 | 
				
			||||||
      <SchemaSettings.Remove
 | 
					      <SchemaSettings.Remove
 | 
				
			||||||
        removeParentsIfNoChildren
 | 
					        removeParentsIfNoChildren
 | 
				
			||||||
        breakRemoveOn={{
 | 
					        breakRemoveOn={{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user