mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
feat: china region field plugin remove from built-in plugins (#5693)
* refactor: optimize China region field plugin remove from built-in plugins * refactor: migration * fix: remove field-china-region --------- Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
2959dd5d01
commit
6d8469b371
@ -2,9 +2,7 @@
|
|||||||
"version": "1.3.52",
|
"version": "1.3.52",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"npmClientArgs": [
|
"npmClientArgs": ["--ignore-engines"],
|
||||||
"--ignore-engines"
|
|
||||||
],
|
|
||||||
"command": {
|
"command": {
|
||||||
"version": {
|
"version": {
|
||||||
"forcePublish": true,
|
"forcePublish": true,
|
||||||
|
@ -13,7 +13,6 @@ import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin'
|
|||||||
import {
|
import {
|
||||||
CheckboxFieldInterface,
|
CheckboxFieldInterface,
|
||||||
CheckboxGroupFieldInterface,
|
CheckboxGroupFieldInterface,
|
||||||
ChinaRegionFieldInterface,
|
|
||||||
CollectionSelectFieldInterface,
|
CollectionSelectFieldInterface,
|
||||||
ColorFieldInterface,
|
ColorFieldInterface,
|
||||||
CreatedAtFieldInterface,
|
CreatedAtFieldInterface,
|
||||||
@ -134,7 +133,6 @@ export class CollectionPlugin extends Plugin {
|
|||||||
this.dataSourceManager.addFieldInterfaces([
|
this.dataSourceManager.addFieldInterfaces([
|
||||||
CheckboxFieldInterface,
|
CheckboxFieldInterface,
|
||||||
CheckboxGroupFieldInterface,
|
CheckboxGroupFieldInterface,
|
||||||
ChinaRegionFieldInterface,
|
|
||||||
CollectionSelectFieldInterface,
|
CollectionSelectFieldInterface,
|
||||||
ColorFieldInterface,
|
ColorFieldInterface,
|
||||||
CreatedAtFieldInterface,
|
CreatedAtFieldInterface,
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
export * from './checkbox';
|
export * from './checkbox';
|
||||||
export * from './checkboxGroup';
|
export * from './checkboxGroup';
|
||||||
export * from './chinaRegion';
|
|
||||||
export * from './collection';
|
export * from './collection';
|
||||||
export * from './color';
|
export * from './color';
|
||||||
export * from './createdAt';
|
export * from './createdAt';
|
||||||
|
@ -29,7 +29,6 @@ export * from './appInfo';
|
|||||||
export * from './application';
|
export * from './application';
|
||||||
export * from './async-data-provider';
|
export * from './async-data-provider';
|
||||||
export * from './block-provider';
|
export * from './block-provider';
|
||||||
export * from './china-region';
|
|
||||||
export * from './collection-manager';
|
export * from './collection-manager';
|
||||||
|
|
||||||
export * from './common';
|
export * from './common';
|
||||||
|
@ -13,7 +13,7 @@ import { connect, mapProps, mapReadPretty, useField } from '@formily/react';
|
|||||||
import { toArr } from '@formily/shared';
|
import { toArr } from '@formily/shared';
|
||||||
import { Cascader as AntdCascader, CascaderProps as AntdCascaderProps, Space } from 'antd';
|
import { Cascader as AntdCascader, CascaderProps as AntdCascaderProps, Space } from 'antd';
|
||||||
import { BaseOptionType } from 'antd/es/select';
|
import { BaseOptionType } from 'antd/es/select';
|
||||||
import { isBoolean, omit } from 'lodash';
|
import { isBoolean, omit, isFunction } from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { UseRequestResult, useRequest } from '../../../api-client';
|
import { UseRequestResult, useRequest } from '../../../api-client';
|
||||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||||
@ -71,15 +71,17 @@ export const Cascader = withDynamicSchemaProps(
|
|||||||
...others
|
...others
|
||||||
} = props;
|
} = props;
|
||||||
const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
|
const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
|
||||||
const loadData = useLoadData(props);
|
const loadData = isFunction(useLoadData) ? useLoadData(props) : [];
|
||||||
const { loading, run } = useDataSource(
|
const { loading, run } = isFunction(useLoadData)
|
||||||
{
|
? useDataSource(
|
||||||
onSuccess(data) {
|
{
|
||||||
field.dataSource = data?.data || [];
|
onSuccess(data) {
|
||||||
},
|
field.dataSource = data?.data || [];
|
||||||
},
|
},
|
||||||
props,
|
},
|
||||||
);
|
props,
|
||||||
|
)
|
||||||
|
: ({} as any);
|
||||||
// 兼容值为 object[] 的情况
|
// 兼容值为 object[] 的情况
|
||||||
const toValue = () => {
|
const toValue = () => {
|
||||||
return toArr(value).map((item) => {
|
return toArr(value).map((item) => {
|
||||||
@ -106,7 +108,7 @@ export const Cascader = withDynamicSchemaProps(
|
|||||||
};
|
};
|
||||||
const handelDropDownVisible = (value) => {
|
const handelDropDownVisible = (value) => {
|
||||||
if (value && !field.dataSource?.length) {
|
if (value && !field.dataSource?.length) {
|
||||||
run();
|
run?.();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@nocobase/plugin-field-china-region",
|
"name": "@nocobase/plugin-field-china-region",
|
||||||
"version": "1.3.52",
|
"version": "1.3.52",
|
||||||
"displayName": "Administrative divisions of China",
|
"displayName": "Collection field: administrative divisions of China",
|
||||||
"displayName.zh-CN": "中国行政区划",
|
"displayName.zh-CN": "数据表字段:中国行政区划",
|
||||||
"description": "Provides data and field type for administrative divisions of China.",
|
"description": "Provides data and field type for administrative divisions of China.",
|
||||||
"description.zh-CN": "提供中国行政区划数据和字段类型。",
|
"description.zh-CN": "提供中国行政区划数据和字段类型。",
|
||||||
"main": "./dist/server/index.js",
|
"main": "./dist/server/index.js",
|
||||||
@ -24,6 +24,6 @@
|
|||||||
},
|
},
|
||||||
"gitHead": "d0b4efe4be55f8c79a98a331d99d9f8cf99021a1",
|
"gitHead": "d0b4efe4be55f8c79a98a331d99d9f8cf99021a1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Fields"
|
"Collection fields"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import { defaultProps, operators } from './properties';
|
import { defaultProps, operators, CollectionFieldInterface } from '@nocobase/client';
|
||||||
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';
|
|
||||||
|
|
||||||
export class ChinaRegionFieldInterface extends CollectionFieldInterface {
|
export class ChinaRegionFieldInterface extends CollectionFieldInterface {
|
||||||
name = 'chinaRegion';
|
name = 'chinaRegion';
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import { Plugin } from '@nocobase/client';
|
import { Plugin } from '@nocobase/client';
|
||||||
import { useChinaRegionDataSource, useChinaRegionLoadData } from './ChinaRegionProvider';
|
import { useChinaRegionDataSource, useChinaRegionLoadData } from './ChinaRegionProvider';
|
||||||
|
import { ChinaRegionFieldInterface } from './chinaRegion';
|
||||||
|
|
||||||
export class PluginFieldChinaRegionClient extends Plugin {
|
export class PluginFieldChinaRegionClient extends Plugin {
|
||||||
async load() {
|
async load() {
|
||||||
@ -16,6 +17,7 @@ export class PluginFieldChinaRegionClient extends Plugin {
|
|||||||
useChinaRegionDataSource,
|
useChinaRegionDataSource,
|
||||||
useChinaRegionLoadData,
|
useChinaRegionLoadData,
|
||||||
});
|
});
|
||||||
|
this.app.dataSourceManager.addFieldInterfaces([ChinaRegionFieldInterface]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,6 @@
|
|||||||
"@nocobase/plugin-data-source-manager",
|
"@nocobase/plugin-data-source-manager",
|
||||||
"@nocobase/plugin-data-visualization",
|
"@nocobase/plugin-data-visualization",
|
||||||
"@nocobase/plugin-error-handler",
|
"@nocobase/plugin-error-handler",
|
||||||
"@nocobase/plugin-field-china-region",
|
|
||||||
"@nocobase/plugin-field-formula",
|
"@nocobase/plugin-field-formula",
|
||||||
"@nocobase/plugin-field-sequence",
|
"@nocobase/plugin-field-sequence",
|
||||||
"@nocobase/plugin-file-manager",
|
"@nocobase/plugin-file-manager",
|
||||||
|
@ -23,7 +23,7 @@ export class PresetNocoBase extends Plugin {
|
|||||||
'verification',
|
'verification',
|
||||||
'users',
|
'users',
|
||||||
'acl',
|
'acl',
|
||||||
'field-china-region',
|
// 'field-china-region',
|
||||||
'workflow',
|
'workflow',
|
||||||
'workflow-action-trigger',
|
'workflow-action-trigger',
|
||||||
'workflow-aggregate',
|
'workflow-aggregate',
|
||||||
@ -73,6 +73,7 @@ export class PresetNocoBase extends Plugin {
|
|||||||
'workflow-mailer',
|
'workflow-mailer',
|
||||||
'field-m2m-array',
|
'field-m2m-array',
|
||||||
'backup-restore',
|
'backup-restore',
|
||||||
|
'field-china-region',
|
||||||
];
|
];
|
||||||
|
|
||||||
splitNames(name: string) {
|
splitNames(name: string) {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
import { Migration } from '@nocobase/server';
|
||||||
|
|
||||||
|
export default class extends Migration {
|
||||||
|
on = 'beforeLoad'; // 'beforeLoad' or 'afterLoad'
|
||||||
|
// appVersion = '<1.3.52';
|
||||||
|
|
||||||
|
async up() {
|
||||||
|
await this.pm.repository.update({
|
||||||
|
values: {
|
||||||
|
builtIn: false,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
name: 'field-china-region',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user