mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 16:34:13 +00:00
refactor: associationFilterInitializer
This commit is contained in:
parent
da186662d5
commit
eff813a184
@ -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: {},
|
||||
};
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user