6febdb041a
* feat: snapshort init * feat: snapshot update yarn.lock * feat: snapshot add to preset * feat: snapshot add field fix * feat: snapshot remove Table Column SnapshotField * feat: snapshot field label fix * feat: snapshot request error fix * feat: snapshot 二级关联数据打开 * feat: snapshot batch edit fix * feat: snapshot 2 level draw fix * feat: snapshot translate * feat: snapshot global historyCollection provider * feat: snapshot install initial * feat: snapshot refreshCH * feat: snapshot add transaction * feat: snapshot default collecitonField * feat: snapshot build fix * feat: snapshot useSnapshotFieldTargetCollectionKey * feat: snapshot batch update * feat: snapshot linkto support * feat: snapshot use getRepository * feat: snapshot recreate fix * feat: snapshot collectionKey to collectionName & rebuild collection * feat: snapshot remove SnapshotHistoryCollectionProvider & collectionName * feat: snapshot use historyCollections in inherit table * feat: snapshot fix TableSelectorBlock appends * feat: snapshot kanban fix * feat: snapshot snapshot association field fix * feat: snapshot add CollectionFieldProvider fallback * feat: snapshot AssociationSelect fix * feat: snapshot TableField fix
103 lines
2.7 KiB
TypeScript
103 lines
2.7 KiB
TypeScript
import { ISchema } from '@formily/react';
|
|
import { IField } from '@nocobase/client';
|
|
import { cloneDeep } from 'lodash';
|
|
import { interfacesProperties } from '@nocobase/client';
|
|
import { useSnapshotTranslation } from './locale';
|
|
import { useMemo } from 'react';
|
|
|
|
const { defaultProps, recordPickerSelector } = interfacesProperties;
|
|
|
|
export const useSnapshotInterface = () => {
|
|
const { t } = useSnapshotTranslation();
|
|
|
|
const recordPickerViewer = {
|
|
type: 'void',
|
|
title: t('View record'),
|
|
'x-component': 'RecordPicker.Viewer',
|
|
'x-component-props': {
|
|
className: 'nb-action-popup',
|
|
},
|
|
properties: {
|
|
tabs: {
|
|
type: 'void',
|
|
'x-component': 'Tabs',
|
|
'x-component-props': {},
|
|
// 'x-initializer': 'TabPaneInitializers',
|
|
properties: {
|
|
tab1: {
|
|
type: 'void',
|
|
title: t('Detail'),
|
|
'x-component': 'Tabs.TabPane',
|
|
'x-designer': 'Tabs.Designer',
|
|
'x-component-props': {},
|
|
properties: {
|
|
grid: {
|
|
type: 'void',
|
|
'x-component': 'Grid',
|
|
'x-initializer': 'SnapshotBlockInitializers',
|
|
properties: {},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const snapshot: IField = {
|
|
name: 'snapshot',
|
|
type: 'object',
|
|
group: 'advanced',
|
|
title: t('Snapshot'),
|
|
description: t('Snapshot to description'),
|
|
default: {
|
|
type: 'snapshot',
|
|
// name,
|
|
uiSchema: {
|
|
// title,
|
|
'x-component': 'SnapshotRecordPicker',
|
|
'x-component-props': {
|
|
// mode: 'tags',
|
|
multiple: true,
|
|
fieldNames: {
|
|
label: 'id',
|
|
value: 'id',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
schemaInitialize(schema: ISchema, { field, readPretty, action, block }) {
|
|
if (readPretty || action === 'update') {
|
|
schema['properties'] = {
|
|
viewer: cloneDeep(recordPickerViewer),
|
|
};
|
|
} else {
|
|
schema['properties'] = {
|
|
selector: cloneDeep(recordPickerSelector),
|
|
};
|
|
}
|
|
},
|
|
initialize: (values: any) => {},
|
|
properties: {
|
|
...defaultProps,
|
|
target: {
|
|
type: 'string',
|
|
title: t('Related collection'),
|
|
required: true,
|
|
'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'],
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Select',
|
|
'x-disabled': '{{ !createOnly }}',
|
|
},
|
|
'uiSchema.x-component-props.multiple': {
|
|
type: 'boolean',
|
|
'x-content': t('Allow linking to multiple records'),
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Checkbox',
|
|
},
|
|
},
|
|
};
|
|
|
|
return useMemo<IField>(() => snapshot, [t]);
|
|
};
|