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",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"npmClientArgs": [
|
||||
"--ignore-engines"
|
||||
],
|
||||
"npmClientArgs": ["--ignore-engines"],
|
||||
"command": {
|
||||
"version": {
|
||||
"forcePublish": true,
|
||||
|
@ -13,7 +13,6 @@ import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin'
|
||||
import {
|
||||
CheckboxFieldInterface,
|
||||
CheckboxGroupFieldInterface,
|
||||
ChinaRegionFieldInterface,
|
||||
CollectionSelectFieldInterface,
|
||||
ColorFieldInterface,
|
||||
CreatedAtFieldInterface,
|
||||
@ -134,7 +133,6 @@ export class CollectionPlugin extends Plugin {
|
||||
this.dataSourceManager.addFieldInterfaces([
|
||||
CheckboxFieldInterface,
|
||||
CheckboxGroupFieldInterface,
|
||||
ChinaRegionFieldInterface,
|
||||
CollectionSelectFieldInterface,
|
||||
ColorFieldInterface,
|
||||
CreatedAtFieldInterface,
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
export * from './checkbox';
|
||||
export * from './checkboxGroup';
|
||||
export * from './chinaRegion';
|
||||
export * from './collection';
|
||||
export * from './color';
|
||||
export * from './createdAt';
|
||||
|
@ -29,7 +29,6 @@ export * from './appInfo';
|
||||
export * from './application';
|
||||
export * from './async-data-provider';
|
||||
export * from './block-provider';
|
||||
export * from './china-region';
|
||||
export * from './collection-manager';
|
||||
|
||||
export * from './common';
|
||||
|
@ -13,7 +13,7 @@ import { connect, mapProps, mapReadPretty, useField } from '@formily/react';
|
||||
import { toArr } from '@formily/shared';
|
||||
import { Cascader as AntdCascader, CascaderProps as AntdCascaderProps, Space } from 'antd';
|
||||
import { BaseOptionType } from 'antd/es/select';
|
||||
import { isBoolean, omit } from 'lodash';
|
||||
import { isBoolean, omit, isFunction } from 'lodash';
|
||||
import React from 'react';
|
||||
import { UseRequestResult, useRequest } from '../../../api-client';
|
||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||
@ -71,15 +71,17 @@ export const Cascader = withDynamicSchemaProps(
|
||||
...others
|
||||
} = props;
|
||||
const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
|
||||
const loadData = useLoadData(props);
|
||||
const { loading, run } = useDataSource(
|
||||
{
|
||||
onSuccess(data) {
|
||||
field.dataSource = data?.data || [];
|
||||
},
|
||||
},
|
||||
props,
|
||||
);
|
||||
const loadData = isFunction(useLoadData) ? useLoadData(props) : [];
|
||||
const { loading, run } = isFunction(useLoadData)
|
||||
? useDataSource(
|
||||
{
|
||||
onSuccess(data) {
|
||||
field.dataSource = data?.data || [];
|
||||
},
|
||||
},
|
||||
props,
|
||||
)
|
||||
: ({} as any);
|
||||
// 兼容值为 object[] 的情况
|
||||
const toValue = () => {
|
||||
return toArr(value).map((item) => {
|
||||
@ -106,7 +108,7 @@ export const Cascader = withDynamicSchemaProps(
|
||||
};
|
||||
const handelDropDownVisible = (value) => {
|
||||
if (value && !field.dataSource?.length) {
|
||||
run();
|
||||
run?.();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-field-china-region",
|
||||
"version": "1.3.52",
|
||||
"displayName": "Administrative divisions of China",
|
||||
"displayName.zh-CN": "中国行政区划",
|
||||
"displayName": "Collection field: administrative divisions of China",
|
||||
"displayName.zh-CN": "数据表字段:中国行政区划",
|
||||
"description": "Provides data and field type for administrative divisions of China.",
|
||||
"description.zh-CN": "提供中国行政区划数据和字段类型。",
|
||||
"main": "./dist/server/index.js",
|
||||
@ -24,6 +24,6 @@
|
||||
},
|
||||
"gitHead": "d0b4efe4be55f8c79a98a331d99d9f8cf99021a1",
|
||||
"keywords": [
|
||||
"Fields"
|
||||
"Collection fields"
|
||||
]
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
*/
|
||||
|
||||
import { uid } from '@formily/shared';
|
||||
import { defaultProps, operators } from './properties';
|
||||
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';
|
||||
import { defaultProps, operators, CollectionFieldInterface } from '@nocobase/client';
|
||||
|
||||
export class ChinaRegionFieldInterface extends CollectionFieldInterface {
|
||||
name = 'chinaRegion';
|
@ -9,6 +9,7 @@
|
||||
|
||||
import { Plugin } from '@nocobase/client';
|
||||
import { useChinaRegionDataSource, useChinaRegionLoadData } from './ChinaRegionProvider';
|
||||
import { ChinaRegionFieldInterface } from './chinaRegion';
|
||||
|
||||
export class PluginFieldChinaRegionClient extends Plugin {
|
||||
async load() {
|
||||
@ -16,6 +17,7 @@ export class PluginFieldChinaRegionClient extends Plugin {
|
||||
useChinaRegionDataSource,
|
||||
useChinaRegionLoadData,
|
||||
});
|
||||
this.app.dataSourceManager.addFieldInterfaces([ChinaRegionFieldInterface]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,6 @@
|
||||
"@nocobase/plugin-data-source-manager",
|
||||
"@nocobase/plugin-data-visualization",
|
||||
"@nocobase/plugin-error-handler",
|
||||
"@nocobase/plugin-field-china-region",
|
||||
"@nocobase/plugin-field-formula",
|
||||
"@nocobase/plugin-field-sequence",
|
||||
"@nocobase/plugin-file-manager",
|
||||
|
@ -23,7 +23,7 @@ export class PresetNocoBase extends Plugin {
|
||||
'verification',
|
||||
'users',
|
||||
'acl',
|
||||
'field-china-region',
|
||||
// 'field-china-region',
|
||||
'workflow',
|
||||
'workflow-action-trigger',
|
||||
'workflow-aggregate',
|
||||
@ -73,6 +73,7 @@ export class PresetNocoBase extends Plugin {
|
||||
'workflow-mailer',
|
||||
'field-m2m-array',
|
||||
'backup-restore',
|
||||
'field-china-region',
|
||||
];
|
||||
|
||||
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