mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:05:45 +00:00
refactor(SchemaSettings): unify naming style
This commit is contained in:
parent
c07ac36922
commit
8566735922
@ -745,6 +745,10 @@ export function SecondConFirm() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const actionSettings = new SchemaSettings({
|
export const actionSettings = new SchemaSettings({
|
||||||
name: 'ActionSettings',
|
name: 'ActionSettings',
|
||||||
items: actionSettingsItems,
|
items: actionSettingsItems,
|
||||||
|
@ -32,6 +32,9 @@ import { getTempFieldState } from '../form-v2/utils';
|
|||||||
import { useColorFields } from '../table-v2/Table.Column.Designer';
|
import { useColorFields } from '../table-v2/Table.Column.Designer';
|
||||||
import { useColumnSchema } from '../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
import { useColumnSchema } from '../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const formItemSettings = new SchemaSettings({
|
export const formItemSettings = new SchemaSettings({
|
||||||
name: 'FormItemSettings',
|
name: 'FormItemSettings',
|
||||||
items: [
|
items: [
|
||||||
|
@ -17,6 +17,9 @@ import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettings
|
|||||||
import { useDesignable } from '../../hooks';
|
import { useDesignable } from '../../hooks';
|
||||||
import { removeNullCondition } from '../filter';
|
import { removeNullCondition } from '../filter';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const formSettings = new SchemaSettings({
|
export const formSettings = new SchemaSettings({
|
||||||
name: 'FormSettings',
|
name: 'FormSettings',
|
||||||
items: [
|
items: [
|
||||||
@ -83,6 +86,9 @@ export const formSettings = new SchemaSettings({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const readPrettyFormSettings = new SchemaSettings({
|
export const readPrettyFormSettings = new SchemaSettings({
|
||||||
name: 'ReadPrettyFormSettings',
|
name: 'ReadPrettyFormSettings',
|
||||||
items: [
|
items: [
|
||||||
@ -122,6 +128,9 @@ export const readPrettyFormSettings = new SchemaSettings({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const formDetailsSettings = new SchemaSettings({
|
export const formDetailsSettings = new SchemaSettings({
|
||||||
name: 'FormDetailsSettings',
|
name: 'FormDetailsSettings',
|
||||||
items: [
|
items: [
|
||||||
|
@ -2,6 +2,9 @@ import { SchemaSettings } from '../../../application/schema-settings';
|
|||||||
import { useCollection_deprecated } from '../../../collection-manager';
|
import { useCollection_deprecated } from '../../../collection-manager';
|
||||||
import { SchemaSettingsTemplate } from '../../../schema-settings/SchemaSettings';
|
import { SchemaSettingsTemplate } from '../../../schema-settings/SchemaSettings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const formV1Settings = new SchemaSettings({
|
export const formV1Settings = new SchemaSettings({
|
||||||
name: 'FormV1Settings',
|
name: 'FormV1Settings',
|
||||||
items: [
|
items: [
|
||||||
|
@ -9,6 +9,9 @@ function useNotDisableHeader() {
|
|||||||
return !fieldSchema['x-component-props']?.disablePageHeader;
|
return !fieldSchema['x-component-props']?.disablePageHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const pageSettings = new SchemaSettings({
|
export const pageSettings = new SchemaSettings({
|
||||||
name: 'PageSettings',
|
name: 'PageSettings',
|
||||||
items: [
|
items: [
|
||||||
|
@ -5,6 +5,9 @@ import { useDesignable } from '../../hooks';
|
|||||||
import { useSchemaToolbar } from '../../../application/schema-toolbar';
|
import { useSchemaToolbar } from '../../../application/schema-toolbar';
|
||||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const pageTabSettings = new SchemaSettings({
|
export const pageTabSettings = new SchemaSettings({
|
||||||
name: 'PageTabSettings',
|
name: 'PageTabSettings',
|
||||||
items: [
|
items: [
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { Plugin } from '@nocobase/client';
|
import { Plugin } from '@nocobase/client';
|
||||||
import { IframeBlockProvider } from './IframeBlockProvider';
|
import { IframeBlockProvider } from './IframeBlockProvider';
|
||||||
import { iframeBlockSchemaSettings } from './schemaSettings';
|
import { iframeBlockSchemaSettings, iframeBlockSchemaSettings_deprecated } from './schemaSettings';
|
||||||
|
|
||||||
export class IframeBlockPlugin extends Plugin {
|
export class IframeBlockPlugin extends Plugin {
|
||||||
async load() {
|
async load() {
|
||||||
|
this.app.schemaSettingsManager.add(iframeBlockSchemaSettings_deprecated);
|
||||||
this.app.schemaSettingsManager.add(iframeBlockSchemaSettings);
|
this.app.schemaSettingsManager.add(iframeBlockSchemaSettings);
|
||||||
this.app.use(IframeBlockProvider);
|
this.app.use(IframeBlockProvider);
|
||||||
const blockInitializers = this.app.schemaInitializerManager.get('BlockInitializers');
|
const blockInitializers = this.app.schemaInitializerManager.get('BlockInitializers');
|
||||||
|
@ -3,7 +3,10 @@ import { uid } from '@formily/shared';
|
|||||||
import { SchemaSettings, useAPIClient, useDesignable } from '@nocobase/client';
|
import { SchemaSettings, useAPIClient, useDesignable } from '@nocobase/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
export const iframeBlockSchemaSettings = new SchemaSettings({
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
export const iframeBlockSchemaSettings_deprecated = new SchemaSettings({
|
||||||
name: 'iframeBlockSchemaSettings',
|
name: 'iframeBlockSchemaSettings',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@ -143,3 +146,144 @@ export const iframeBlockSchemaSettings = new SchemaSettings({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const iframeBlockSchemaSettings = new SchemaSettings({
|
||||||
|
name: 'blockSettings:iframe',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
name: 'EditIframe',
|
||||||
|
type: 'modal',
|
||||||
|
useComponentProps() {
|
||||||
|
const field = useField();
|
||||||
|
const fieldSchema = useFieldSchema();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { dn } = useDesignable();
|
||||||
|
const api = useAPIClient();
|
||||||
|
const { mode, url, htmlId, height = '60vh' } = fieldSchema['x-component-props'] || {};
|
||||||
|
|
||||||
|
const saveHtml = async (html: string) => {
|
||||||
|
const options = {
|
||||||
|
values: { html },
|
||||||
|
};
|
||||||
|
if (htmlId) {
|
||||||
|
// eslint-disable-next-line no-unsafe-optional-chaining
|
||||||
|
const { data } = await api.resource('iframeHtml').update?.({ ...options, filterByTk: htmlId });
|
||||||
|
return data?.data?.[0] || { id: htmlId };
|
||||||
|
} else {
|
||||||
|
// eslint-disable-next-line no-unsafe-optional-chaining
|
||||||
|
const { data } = await api.resource('iframeHtml').create?.(options);
|
||||||
|
return data?.data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitHandler = async ({ mode, url, html, height }) => {
|
||||||
|
const componentProps = fieldSchema['x-component-props'] || {};
|
||||||
|
componentProps['mode'] = mode;
|
||||||
|
componentProps['height'] = height;
|
||||||
|
componentProps['url'] = url;
|
||||||
|
if (mode === 'html') {
|
||||||
|
const data = await saveHtml(html);
|
||||||
|
componentProps['htmlId'] = data.id;
|
||||||
|
}
|
||||||
|
fieldSchema['x-component-props'] = componentProps;
|
||||||
|
field.componentProps = { ...componentProps };
|
||||||
|
field.data = { v: uid() };
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema: {
|
||||||
|
'x-uid': fieldSchema['x-uid'],
|
||||||
|
'x-component-props': componentProps,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: t('Edit iframe'),
|
||||||
|
asyncGetInitialValues: async () => {
|
||||||
|
const values = {
|
||||||
|
mode,
|
||||||
|
url,
|
||||||
|
height,
|
||||||
|
};
|
||||||
|
if (htmlId) {
|
||||||
|
// eslint-disable-next-line no-unsafe-optional-chaining
|
||||||
|
const { data } = await api.resource('iframeHtml').get?.({ filterByTk: htmlId });
|
||||||
|
values['html'] = data?.data?.html || '';
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
type: 'object',
|
||||||
|
title: t('Edit iframe'),
|
||||||
|
properties: {
|
||||||
|
mode: {
|
||||||
|
title: '{{t("Mode")}}',
|
||||||
|
'x-component': 'Radio.Group',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
required: true,
|
||||||
|
default: 'url',
|
||||||
|
enum: [
|
||||||
|
{ value: 'url', label: t('URL') },
|
||||||
|
{ value: 'html', label: t('html') },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
title: t('URL'),
|
||||||
|
type: 'string',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input',
|
||||||
|
required: true,
|
||||||
|
'x-reactions': {
|
||||||
|
dependencies: ['mode'],
|
||||||
|
fulfill: {
|
||||||
|
state: {
|
||||||
|
hidden: '{{$deps[0] === "html"}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
html: {
|
||||||
|
title: t('html'),
|
||||||
|
type: 'string',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input.TextArea',
|
||||||
|
required: true,
|
||||||
|
'x-reactions': {
|
||||||
|
dependencies: ['mode'],
|
||||||
|
fulfill: {
|
||||||
|
state: {
|
||||||
|
hidden: '{{$deps[0] === "url"}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
title: t('Height'),
|
||||||
|
type: 'string',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as ISchema,
|
||||||
|
onSubmit: submitHandler,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'divider',
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'delete',
|
||||||
|
type: 'remove',
|
||||||
|
useComponentProps() {
|
||||||
|
return {
|
||||||
|
removeParentsIfNoChildren: true,
|
||||||
|
breakRemoveOn: {
|
||||||
|
'x-component': 'Grid',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user