From eff813a184d176235df8302f743aa6694ce8c7a6 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Thu, 7 Mar 2024 18:59:22 +0800 Subject: [PATCH] refactor: associationFilterInitializer --- .../ActionBarAssociationFilterAction.tsx | 2 +- .../AssociationFilter.Initializer.tsx | 60 +------------------ .../association-filter/AssociationFilter.tsx | 3 +- 3 files changed, 4 insertions(+), 61 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/association-filter/ActionBarAssociationFilterAction.tsx b/packages/core/client/src/schema-component/antd/association-filter/ActionBarAssociationFilterAction.tsx index ba2aeb8028..29443a4772 100644 --- a/packages/core/client/src/schema-component/antd/association-filter/ActionBarAssociationFilterAction.tsx +++ b/packages/core/client/src/schema-component/antd/association-filter/ActionBarAssociationFilterAction.tsx @@ -37,7 +37,7 @@ export const ActionBarAssociationFilterAction = (props) => { const schema = { type: 'void', 'x-action': 'associateFilter', - 'x-initializer': 'fieldInitializers:associationFilter', + 'x-initializer': 'AssociationFilter.Initializer', 'x-component': 'AssociationFilter', properties: {}, }; diff --git a/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.Initializer.tsx b/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.Initializer.tsx index 1e87acb62b..b99d7f45ee 100644 --- a/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.Initializer.tsx +++ b/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.Initializer.tsx @@ -1,11 +1,11 @@ -import { CompatibleSchemaInitializer } from '../../../application/schema-initializer/CompatibleSchemaInitializer'; +import { SchemaInitializer } from '../../../application/schema-initializer/SchemaInitializer'; import { SchemaInitializerItemType } from '../../../application/schema-initializer/types'; import { useAssociatedFields } from '../../../filter-provider/utils'; /** * @deprecated */ -export const associationFilterInitializer_deprecated = new CompatibleSchemaInitializer({ +export const associationFilterInitializer = new SchemaInitializer({ name: 'AssociationFilter.Initializer', style: { marginTop: 16, @@ -57,59 +57,3 @@ export const associationFilterInitializer_deprecated = new CompatibleSchemaIniti }, ], }); - -export const associationFilterInitializer = new CompatibleSchemaInitializer( - { - name: 'fieldInitializers:associationFilter', - style: { - marginTop: 16, - }, - icon: 'SettingOutlined', - title: '{{t("Configure fields")}}', - items: [ - { - name: 'associationFields', - type: 'itemGroup', - title: '{{t("Association fields")}}', - useChildren() { - const associatedFields = useAssociatedFields(); - const useProps = '{{useAssociationFilterProps}}'; - const children: SchemaInitializerItemType[] = associatedFields.map((field) => ({ - type: 'item', - name: field.key, - title: field.uiSchema?.title, - Component: 'AssociationFilterDesignerDisplayField', - schema: { - name: field.name, - title: field.uiSchema?.title, - type: 'void', - // 'x-designer': 'AssociationFilter.Item.Designer', - 'x-toolbar': 'CollapseItemSchemaToolbar', - 'x-settings': 'fieldSettings:FilterCollapseItem', - 'x-component': 'AssociationFilter.Item', - 'x-component-props': { - fieldNames: { - label: field.targetKey || 'id', - }, - useProps, - }, - properties: {}, - }, - })); - - return children; - }, - }, - { - name: 'divider', - type: 'divider', - }, - { - name: 'delete', - title: '{{t("Delete")}}', - Component: 'AssociationFilterDesignerDelete', - }, - ], - }, - associationFilterInitializer_deprecated, -); diff --git a/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.tsx b/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.tsx index 12b2924035..ce5551cc46 100644 --- a/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.tsx +++ b/packages/core/client/src/schema-component/antd/association-filter/AssociationFilter.tsx @@ -17,7 +17,7 @@ import { filterCollapseItemInitializer, filterCollapseItemInitializer_deprecated, } from '../../../modules/blocks/filter-blocks/collapse/filterCollapseItemInitializer'; -import { associationFilterInitializer, associationFilterInitializer_deprecated } from './AssociationFilter.Initializer'; +import { associationFilterInitializer } from './AssociationFilter.Initializer'; export const AssociationFilter = (props) => { const { token } = useToken(); @@ -107,7 +107,6 @@ export class AssociationFilterPlugin extends Plugin { this.app.schemaInitializerManager.add(associationFilterFilterBlockInitializer); this.app.schemaInitializerManager.add(filterCollapseItemInitializer_deprecated); this.app.schemaInitializerManager.add(filterCollapseItemInitializer); - this.app.schemaInitializerManager.add(associationFilterInitializer_deprecated); this.app.schemaInitializerManager.add(associationFilterInitializer); } }