tachybase_todo/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/createCalendarBlockUISchema.ts
Zeke Zhang 74051ff0a5
refactor(DataBlock): kanban and gantt and map and calendar (#3792)
* refactor: kanban

* refactor: gantt

* refactor: map

* refactor: calendar

* refactor: compat

* refactor: rename to createKanbanBlockUISchema

* refactor(kanban): use x-use-component-props instead of useProps

* refactor(Gantt): rename to createGanttBlockUISchema

* refactor: use x-use-component-props instead of useProps

* refactor: rename

* refactor(Map): use x-use-component-props instead of useProps

* refactor(Calendar): rename

* refactor(Calendar): should not get collection on getting association in UISchema

* refactor(Calendar): use x-use-component-props instead of useProps

* chore: add comment

* chore: fix unit test

* fix: add scopes to fix e2e

* fix(Calendar): add association property to CalendarBlockProvider decorator

* test: add e2e for Calenndar
2024-03-27 18:06:28 +08:00

99 lines
3.0 KiB
TypeScript

import { ISchema } from '@formily/react';
import { uid } from '@formily/shared';
import { generateNTemplate } from '../../locale';
export const createCalendarBlockUISchema = (options: {
dataSource: string;
fieldNames: object;
collectionName?: string;
association?: string;
}): ISchema => {
const { collectionName, dataSource, fieldNames, association } = options;
return {
type: 'void',
'x-acl-action': `${association || collectionName}:list`,
'x-decorator': 'CalendarBlockProvider',
'x-use-decorator-props': 'useCalendarBlockDecoratorProps',
'x-decorator-props': {
collection: collectionName,
dataSource,
association,
action: 'list',
fieldNames: {
id: 'id',
...fieldNames,
},
params: {
paginate: false,
},
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:calendar',
'x-component': 'CardItem',
properties: {
[uid()]: {
type: 'void',
'x-component': 'CalendarV2',
'x-use-component-props': 'useCalendarBlockProps',
properties: {
toolBar: {
type: 'void',
'x-component': 'CalendarV2.ActionBar',
'x-component-props': {
style: {
marginBottom: 24,
},
},
'x-initializer': 'calendar:configureActions',
},
event: {
type: 'void',
'x-component': 'CalendarV2.Event',
properties: {
drawer: {
type: 'void',
'x-component': 'Action.Drawer',
'x-component-props': {
className: 'nb-action-popup',
},
title: generateNTemplate('View record'),
properties: {
tabs: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer-props': {
gridInitializer: 'popup:common:addBlock',
},
properties: {
tab1: {
type: 'void',
title: generateNTemplate('Details'),
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
properties: {
grid: {
type: 'void',
'x-component': 'Grid',
'x-initializer-props': {
actionInitializers: 'details:configureActions',
},
'x-initializer': 'popup:common:addBlock',
},
},
},
},
},
},
},
},
},
},
},
},
};
};