@nocobase/client-v2 2.1.0-alpha.40 → 2.1.0-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Application.d.ts +7 -0
- package/es/BaseApplication.d.ts +13 -0
- package/es/RouterManager.d.ts +1 -0
- package/es/authRedirect.d.ts +12 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +51 -15
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +82 -3
- package/es/collection-manager/field-configure.d.ts +80 -0
- package/es/collection-manager/field-validation.d.ts +43 -0
- package/es/collection-manager/filter-operators/index.d.ts +46 -0
- package/es/collection-manager/filter-operators/operators.d.ts +30 -0
- package/es/collection-manager/interfaces/checkbox.d.ts +1 -41
- package/es/collection-manager/interfaces/checkboxGroup.d.ts +12 -44
- package/es/collection-manager/interfaces/collection.d.ts +12 -51
- package/es/collection-manager/interfaces/color.d.ts +1 -16
- package/es/collection-manager/interfaces/createdAt.d.ts +1 -44
- package/es/collection-manager/interfaces/createdBy.d.ts +0 -4
- package/es/collection-manager/interfaces/dateOnly.d.ts +7 -44
- package/es/collection-manager/interfaces/datetime.d.ts +1 -44
- package/es/collection-manager/interfaces/datetimeNoTz.d.ts +1 -44
- package/es/collection-manager/interfaces/email.d.ts +1 -29
- package/es/collection-manager/interfaces/id.d.ts +1 -16
- package/es/collection-manager/interfaces/index.d.ts +2 -3
- package/es/collection-manager/interfaces/input.d.ts +1 -102
- package/es/collection-manager/interfaces/integer.d.ts +1 -95
- package/es/collection-manager/interfaces/json.d.ts +16 -7
- package/es/collection-manager/interfaces/m2m.d.ts +11 -19
- package/es/collection-manager/interfaces/m2o.d.ts +11 -19
- package/es/collection-manager/interfaces/markdown.d.ts +1 -63
- package/es/collection-manager/interfaces/multipleSelect.d.ts +12 -44
- package/es/collection-manager/interfaces/nanoid.d.ts +1 -34
- package/es/collection-manager/interfaces/number.d.ts +1 -87
- package/es/collection-manager/interfaces/o2m.d.ts +12 -24
- package/es/collection-manager/interfaces/obo.d.ts +207 -0
- package/es/collection-manager/interfaces/oho.d.ts +207 -0
- package/es/collection-manager/interfaces/password.d.ts +1 -56
- package/es/collection-manager/interfaces/percent.d.ts +1 -84
- package/es/collection-manager/interfaces/phone.d.ts +1 -25
- package/es/collection-manager/interfaces/properties/index.d.ts +0 -28
- package/es/collection-manager/interfaces/radioGroup.d.ts +1 -29
- package/es/collection-manager/interfaces/richText.d.ts +1 -63
- package/es/collection-manager/interfaces/select.d.ts +12 -44
- package/es/collection-manager/interfaces/snowflake-id.d.ts +1 -34
- package/es/collection-manager/interfaces/tableoid.d.ts +1 -10
- package/es/collection-manager/interfaces/textarea.d.ts +1 -51
- package/es/collection-manager/interfaces/time.d.ts +1 -16
- package/es/collection-manager/interfaces/types.d.ts +3 -12
- package/es/collection-manager/interfaces/unixTimestamp.d.ts +1 -44
- package/es/collection-manager/interfaces/updatedAt.d.ts +1 -44
- package/es/collection-manager/interfaces/updatedBy.d.ts +0 -4
- package/es/collection-manager/interfaces/url.d.ts +1 -20
- package/es/collection-manager/interfaces/uuid.d.ts +1 -34
- package/es/collection-manager/template-fields.d.ts +53 -0
- package/es/components/KeepAlive.d.ts +22 -0
- package/es/components/RouterBridge.d.ts +9 -0
- package/es/components/form/DialogFormLayout.d.ts +5 -29
- package/es/components/form/TypedVariableInput.d.ts +75 -0
- package/es/components/form/VariableInput.d.ts +53 -2
- package/es/components/form/filter/CollectionFilter.d.ts +49 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +49 -0
- package/es/components/form/filter/DateFilterDynamicComponent.d.ts +57 -0
- package/es/components/form/filter/FilterValueInput.d.ts +29 -0
- package/es/components/form/filter/index.d.ts +11 -0
- package/es/components/form/filter/useFilterActionProps.d.ts +96 -0
- package/es/components/form/index.d.ts +2 -0
- package/es/data-source/ExtendCollectionsProvider.d.ts +50 -0
- package/es/data-source/index.d.ts +9 -0
- package/es/flow/FlowPage.d.ts +2 -1
- package/es/flow/admin-shell/AdminLayoutRouteCoordinator.d.ts +8 -40
- package/es/flow/admin-shell/BaseLayoutModel.d.ts +89 -0
- package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +74 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.d.ts +12 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutModel.d.ts +7 -92
- package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +11 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +3 -0
- package/es/flow/admin-shell/admin-layout/useApplications.d.ts +3 -2
- package/es/flow/admin-shell/useAdminLayoutRoutePage.d.ts +2 -2
- package/es/flow/admin-shell/useLayoutRoutePage.d.ts +23 -0
- package/es/flow/components/ConditionBuilder.d.ts +1 -0
- package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
- package/es/flow/components/FieldAssignValueInput.d.ts +1 -0
- package/es/flow/components/FlowRoute.d.ts +10 -1
- package/es/flow/components/fieldAssignOptions.d.ts +10 -0
- package/es/flow/components/filter/LinkageFilterItem.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +1 -0
- package/es/flow/components/filter/index.d.ts +2 -0
- package/es/flow/components/filter/metaTreeAssociationDepth.d.ts +13 -0
- package/es/flow/components/filter/useFilterOptions.d.ts +66 -0
- package/es/flow/index.d.ts +4 -0
- package/es/flow/models/base/AssociationFieldGroupModel.d.ts +2 -33
- package/es/flow/models/base/PageModel/PageModel.d.ts +3 -1
- package/es/flow/models/blocks/assign-form/assignFieldValuesFlow.d.ts +92 -0
- package/es/flow/models/blocks/assign-form/index.d.ts +1 -0
- package/es/flow/models/blocks/form/FormActionGroupModel.d.ts +1 -0
- package/es/flow/models/blocks/form/FormActionModel.d.ts +9 -2
- package/es/flow/models/blocks/table/TableBlockModel.d.ts +10 -0
- package/es/flow/models/blocks/table/TableColumnModel.d.ts +2 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.d.ts +1 -1
- package/es/flow-compat/passwordUtils.d.ts +1 -1
- package/es/index.d.ts +6 -0
- package/es/index.mjs +552 -459
- package/es/layout-manager/LayoutContentRoute.d.ts +14 -0
- package/es/layout-manager/LayoutManager.d.ts +22 -0
- package/es/layout-manager/LayoutRoute.d.ts +14 -0
- package/es/layout-manager/index.d.ts +13 -0
- package/es/layout-manager/types.d.ts +20 -0
- package/es/layout-manager/utils.d.ts +14 -0
- package/es/nocobase-buildin-plugin/index.d.ts +3 -10
- package/es/settings-center/index.d.ts +1 -1
- package/es/settings-center/plugin-manager/BulkEnableButton.d.ts +15 -0
- package/es/settings-center/plugin-manager/PluginCard.d.ts +15 -0
- package/es/settings-center/plugin-manager/PluginDetail.d.ts +16 -0
- package/es/settings-center/{PluginManagerPage.d.ts → plugin-manager/index.d.ts} +1 -7
- package/es/settings-center/plugin-manager/types.d.ts +34 -0
- package/lib/index.js +552 -459
- package/package.json +8 -7
- package/src/Application.tsx +51 -12
- package/src/BaseApplication.tsx +32 -0
- package/src/PluginSettingsManager.ts +1 -1
- package/src/RouterManager.tsx +17 -1
- package/src/__tests__/PluginSettingsManager.test.ts +41 -2
- package/src/__tests__/app.test.tsx +17 -1
- package/src/__tests__/globalDeps.test.ts +1 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +50 -2
- package/src/__tests__/plugin-manager.test.tsx +177 -0
- package/src/__tests__/settings-center.test.tsx +24 -2
- package/src/authRedirect.ts +43 -0
- package/src/collection-field-interface/CollectionFieldInterface.ts +71 -77
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +201 -4
- package/src/collection-manager/field-configure.ts +548 -0
- package/src/collection-manager/field-validation.ts +195 -0
- package/src/collection-manager/filter-operators/index.ts +176 -0
- package/src/collection-manager/{interfaces/properties → filter-operators}/operators.ts +24 -13
- package/src/collection-manager/interfaces/checkbox.ts +2 -9
- package/src/collection-manager/interfaces/checkboxGroup.ts +2 -10
- package/src/collection-manager/interfaces/collection.ts +2 -15
- package/src/collection-manager/interfaces/color.ts +2 -2
- package/src/collection-manager/interfaces/createdAt.ts +2 -2
- package/src/collection-manager/interfaces/createdBy.ts +1 -12
- package/src/collection-manager/interfaces/dateOnly.ts +8 -2
- package/src/collection-manager/interfaces/datetime.ts +2 -2
- package/src/collection-manager/interfaces/datetimeNoTz.ts +2 -2
- package/src/collection-manager/interfaces/email.ts +2 -9
- package/src/collection-manager/interfaces/id.ts +1 -2
- package/src/collection-manager/interfaces/index.ts +2 -3
- package/src/collection-manager/interfaces/input.ts +2 -133
- package/src/collection-manager/interfaces/integer.ts +2 -71
- package/src/collection-manager/interfaces/json.tsx +17 -11
- package/src/collection-manager/interfaces/m2m.tsx +0 -21
- package/src/collection-manager/interfaces/m2o.tsx +0 -22
- package/src/collection-manager/interfaces/markdown.ts +2 -51
- package/src/collection-manager/interfaces/multipleSelect.ts +2 -14
- package/src/collection-manager/interfaces/nanoid.ts +2 -2
- package/src/collection-manager/interfaces/number.ts +2 -85
- package/src/collection-manager/interfaces/o2m.tsx +1 -22
- package/src/collection-manager/interfaces/obo.tsx +145 -0
- package/src/collection-manager/interfaces/oho.tsx +145 -0
- package/src/collection-manager/interfaces/password.ts +2 -44
- package/src/collection-manager/interfaces/percent.ts +2 -74
- package/src/collection-manager/interfaces/phone.ts +2 -2
- package/src/collection-manager/interfaces/properties/index.ts +0 -133
- package/src/collection-manager/interfaces/radioGroup.ts +2 -2
- package/src/collection-manager/interfaces/richText.ts +2 -51
- package/src/collection-manager/interfaces/select.ts +2 -14
- package/src/collection-manager/interfaces/snowflake-id.ts +2 -2
- package/src/collection-manager/interfaces/tableoid.ts +1 -2
- package/src/collection-manager/interfaces/textarea.ts +2 -51
- package/src/collection-manager/interfaces/time.ts +2 -2
- package/src/collection-manager/interfaces/types.ts +4 -12
- package/src/collection-manager/interfaces/unixTimestamp.tsx +2 -2
- package/src/collection-manager/interfaces/updatedAt.ts +2 -2
- package/src/collection-manager/interfaces/updatedBy.ts +1 -12
- package/src/collection-manager/interfaces/url.ts +2 -4
- package/src/collection-manager/interfaces/uuid.ts +2 -2
- package/src/collection-manager/template-fields.ts +109 -0
- package/src/components/KeepAlive.tsx +131 -0
- package/src/components/README.md +138 -6
- package/src/components/README.zh-CN.md +138 -7
- package/src/components/RouterBridge.tsx +28 -4
- package/src/components/__tests__/KeepAlive.test.tsx +63 -0
- package/src/components/__tests__/RouterBridge.test.tsx +27 -0
- package/src/components/form/DialogFormLayout.tsx +5 -29
- package/src/components/form/TypedVariableInput.tsx +441 -0
- package/src/components/form/VariableInput.tsx +101 -28
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +152 -0
- package/src/components/form/__tests__/VariableInput.test.ts +85 -0
- package/src/components/form/filter/CollectionFilter.tsx +111 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +184 -0
- package/src/components/form/filter/DateFilterDynamicComponent.tsx +283 -0
- package/src/components/form/filter/FilterValueInput.tsx +198 -0
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +247 -0
- package/src/components/form/filter/__tests__/DateFilterDynamicComponent.test.tsx +148 -0
- package/src/components/form/filter/__tests__/FilterValueInput.test.tsx +243 -0
- package/src/components/form/filter/__tests__/compileFilterGroup.test.ts +146 -0
- package/src/components/form/filter/index.ts +13 -0
- package/src/components/form/filter/useFilterActionProps.ts +203 -0
- package/src/components/form/index.tsx +2 -0
- package/src/data-source/ExtendCollectionsProvider.tsx +144 -0
- package/src/data-source/__tests__/ExtendCollectionsProvider.test.tsx +264 -0
- package/src/data-source/index.ts +10 -0
- package/src/flow/FlowPage.tsx +35 -7
- package/src/flow/__tests__/FlowPage.test.tsx +79 -0
- package/src/flow/__tests__/FlowRoute.test.tsx +537 -3
- package/src/flow/actions/__tests__/linkageRules.hiddenSync.restore.test.ts +100 -0
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +191 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +23 -1
- package/src/flow/actions/__tests__/openView.subModelKey.test.tsx +33 -0
- package/src/flow/actions/aclCheck.tsx +4 -0
- package/src/flow/actions/aclCheckRefresh.tsx +4 -0
- package/src/flow/actions/dataScope.tsx +8 -1
- package/src/flow/actions/dateTimeFormat.tsx +12 -8
- package/src/flow/actions/linkageRules.tsx +127 -2
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -3
- package/src/flow/actions/openView.tsx +28 -4
- package/src/flow/actions/setTargetDataScope.tsx +1 -1
- package/src/flow/admin-shell/AdminLayoutRouteCoordinator.ts +11 -329
- package/src/flow/admin-shell/BaseLayoutModel.tsx +455 -0
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +502 -0
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +547 -3
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +35 -7
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +160 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +15 -13
- package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +28 -201
- package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +11 -2
- package/src/flow/admin-shell/admin-layout/AppListRender.tsx +139 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +76 -27
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +149 -27
- package/src/flow/admin-shell/admin-layout/index.ts +3 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +11 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +2 -4
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +34 -1
- package/src/flow/admin-shell/useAdminLayoutRoutePage.ts +10 -26
- package/src/flow/admin-shell/useLayoutRoutePage.ts +61 -0
- package/src/flow/common/Markdown/Edit.tsx +32 -4
- package/src/flow/components/AdminLayout.tsx +4 -154
- package/src/flow/components/ConditionBuilder.tsx +12 -2
- package/src/flow/components/FieldAssignRulesEditor.tsx +37 -46
- package/src/flow/components/FieldAssignValueInput.tsx +8 -4
- package/src/flow/components/FlowRoute.tsx +105 -15
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +112 -1
- package/src/flow/components/__tests__/fieldAssignOptions.test.ts +71 -1
- package/src/flow/components/code-editor/__tests__/runjsCompletions.test.ts +272 -27
- package/src/flow/components/code-editor/runjsCompletions.ts +490 -9
- package/src/flow/components/fieldAssignOptions.ts +23 -6
- package/src/flow/components/filter/LinkageFilterItem.tsx +22 -9
- package/src/flow/components/filter/VariableFilterItem.tsx +27 -9
- package/src/flow/components/filter/__tests__/fieldsToOptions.test.ts +48 -0
- package/src/flow/components/filter/__tests__/metaTreeAssociationDepth.test.ts +60 -0
- package/src/flow/components/filter/fieldsToOptions.ts +9 -4
- package/src/flow/components/filter/index.ts +3 -0
- package/src/flow/components/filter/metaTreeAssociationDepth.ts +69 -0
- package/src/flow/components/filter/useFilterOptions.ts +102 -0
- package/src/flow/index.ts +4 -0
- package/src/flow/models/actions/FilterActionModel.tsx +15 -3
- package/src/flow/models/actions/UpdateRecordActionModel.tsx +14 -95
- package/src/flow/models/actions/UpdateRecordActionUtils.ts +4 -7
- package/src/flow/models/actions/__tests__/AssignFormRefill.test.ts +116 -1
- package/src/flow/models/base/ActionModel.tsx +8 -1
- package/src/flow/models/base/AssociationFieldGroupModel.tsx +20 -3
- package/src/flow/models/base/GridModel.tsx +1 -1
- package/src/flow/models/base/PageModel/ChildPageModel.tsx +5 -1
- package/src/flow/models/base/PageModel/PageModel.tsx +51 -18
- package/src/flow/models/base/PageModel/RootPageModel.tsx +6 -13
- package/src/flow/models/base/PageModel/__tests__/ChildPageModel.test.ts +12 -0
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +102 -1
- package/src/flow/models/base/RouteModel.tsx +1 -1
- package/src/flow/models/base/__tests__/AssociationFieldGroupModel.test.ts +86 -0
- package/src/flow/models/base/__tests__/GridModel.render.test.tsx +53 -0
- package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +12 -3
- package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +77 -6
- package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.editor.test.tsx +216 -0
- package/src/flow/models/blocks/assign-form/assignFieldValuesFlow.tsx +308 -0
- package/src/flow/models/blocks/assign-form/index.ts +1 -0
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +1 -1
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +6 -1
- package/src/flow/models/blocks/filter-manager/flow-actions/connectFields.tsx +48 -6
- package/src/flow/models/blocks/form/FormActionGroupModel.tsx +14 -0
- package/src/flow/models/blocks/form/FormActionModel.tsx +30 -3
- package/src/flow/models/blocks/form/FormAssociationItemModel.tsx +9 -0
- package/src/flow/models/blocks/form/FormItemModel.tsx +17 -1
- package/src/flow/models/blocks/form/__tests__/FormActionGroupModel.test.ts +46 -0
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +17 -0
- package/src/flow/models/blocks/form/__tests__/FormItemModel.defineChildren.test.ts +27 -2
- package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +71 -0
- package/src/flow/models/blocks/form/submitHandler.ts +8 -1
- package/src/flow/models/blocks/form/submitValues.ts +4 -1
- package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +29 -0
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +5 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +118 -16
- package/src/flow/models/blocks/table/TableColumnModel.tsx +15 -5
- package/src/flow/models/blocks/table/TableCustomColumnModel.tsx +2 -2
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +114 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +18 -0
- package/src/flow/models/fields/AssociationFieldModel/SubFormFieldModel.tsx +7 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +6 -7
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +1 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +6 -5
- package/src/flow/models/fields/ClickableFieldModel.tsx +9 -1
- package/src/flow/models/fields/CollectionSelectorFieldModel.tsx +8 -2
- package/src/flow/models/fields/DisplayEnumFieldModel.tsx +8 -2
- package/src/flow/models/fields/DisplayTimeFieldModel.tsx +1 -1
- package/src/flow/models/fields/TimeFieldModel.tsx +1 -1
- package/src/flow/models/fields/__tests__/TimeFieldModel.test.tsx +61 -0
- package/src/flow/models/fields/mobile-components/MobileDatePicker.tsx +19 -3
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +5 -3
- package/src/flow/models/fields/mobile-components/__tests__/MobileDatePicker.test.tsx +94 -0
- package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +70 -0
- package/src/flow/models/topbar/TopbarActionModel.tsx +1 -1
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +91 -0
- package/src/index.ts +6 -0
- package/src/layout-manager/LayoutContentRoute.tsx +90 -0
- package/src/layout-manager/LayoutManager.tsx +185 -0
- package/src/layout-manager/LayoutRoute.tsx +138 -0
- package/src/layout-manager/__tests__/LayoutManager.test.tsx +335 -0
- package/src/layout-manager/__tests__/LayoutRoute.test.tsx +473 -0
- package/src/layout-manager/index.ts +14 -0
- package/src/layout-manager/types.ts +22 -0
- package/src/layout-manager/utils.ts +37 -0
- package/src/nocobase-buildin-plugin/index.tsx +69 -67
- package/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +1 -0
- package/src/settings-center/index.ts +1 -1
- package/src/settings-center/plugin-manager/BulkEnableButton.tsx +111 -0
- package/src/settings-center/plugin-manager/PluginCard.tsx +270 -0
- package/src/settings-center/plugin-manager/PluginDetail.tsx +195 -0
- package/src/settings-center/plugin-manager/index.tsx +254 -0
- package/src/settings-center/plugin-manager/types.ts +35 -0
- package/src/settings-center/utils.tsx +8 -1
- package/src/theme/__tests__/globalStyles.test.ts +24 -0
- package/src/theme/globalStyles.ts +10 -0
- package/src/utils/globalDeps.ts +2 -0
- package/es/collection-manager/interfaces/linkTo.d.ts +0 -90
- package/es/collection-manager/interfaces/o2o.d.ts +0 -621
- package/es/collection-manager/interfaces/properties/operators.d.ts +0 -294
- package/es/collection-manager/interfaces/subTable.d.ts +0 -172
- package/src/collection-manager/interfaces/linkTo.ts +0 -120
- package/src/collection-manager/interfaces/o2o.tsx +0 -561
- package/src/collection-manager/interfaces/subTable.ts +0 -218
- package/src/settings-center/PluginManagerPage.tsx +0 -162
|
@@ -27,6 +27,7 @@ import _ from 'lodash';
|
|
|
27
27
|
import { NumberPicker } from '@formily/antd-v5';
|
|
28
28
|
import { enumToOptions, normalizeSelectRenderValue, UiSchemaEnumItem } from '../../internal/utils/enumOptionsUtils';
|
|
29
29
|
import { resolveOperatorComponent } from '../../internal/utils/operatorSchemaHelper';
|
|
30
|
+
import { limitAssociationMetaTree } from './metaTreeAssociationDepth';
|
|
30
31
|
|
|
31
32
|
const { DateFilterDynamicComponent: DateFilterDynamicComponentLazy } = lazy(
|
|
32
33
|
() => import('../../models/blocks/filter-form/fields/date-time/components/DateFilterDynamicComponent'),
|
|
@@ -85,6 +86,14 @@ export interface VariableFilterItemProps {
|
|
|
85
86
|
*/
|
|
86
87
|
rightMetaTree?: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
|
|
87
88
|
ignoreFieldNames?: string[];
|
|
89
|
+
maxAssociationFieldDepth?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function limitMetaTreeIfNeeded(nodes: MetaTreeNode[], maxAssociationFieldDepth?: number) {
|
|
93
|
+
if (typeof maxAssociationFieldDepth !== 'number') {
|
|
94
|
+
return nodes;
|
|
95
|
+
}
|
|
96
|
+
return limitAssociationMetaTree(nodes, { maxAssociationDepth: maxAssociationFieldDepth });
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
function createStaticInputRenderer(
|
|
@@ -260,7 +269,7 @@ function normalizeRightValueInput(input: unknown) {
|
|
|
260
269
|
* 上下文筛选项组件
|
|
261
270
|
*/
|
|
262
271
|
export const VariableFilterItem: React.FC<VariableFilterItemProps> = observer(
|
|
263
|
-
({ value, model, rightAsVariable, rightMetaTree, ignoreFieldNames }) => {
|
|
272
|
+
({ value, model, rightAsVariable, rightMetaTree, ignoreFieldNames, maxAssociationFieldDepth }) => {
|
|
264
273
|
// 使用 View 上下文,确保可访问 ctx.view 的异步子树
|
|
265
274
|
const ctx = useFlowViewContext();
|
|
266
275
|
const t = model.translate;
|
|
@@ -539,13 +548,22 @@ export const VariableFilterItem: React.FC<VariableFilterItemProps> = observer(
|
|
|
539
548
|
const nodes: MetaTreeNode[] = Array.isArray(raw)
|
|
540
549
|
? (raw as MetaTreeNode[])
|
|
541
550
|
: await (raw as () => Promise<MetaTreeNode[]>)();
|
|
542
|
-
return
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
551
|
+
return limitMetaTreeIfNeeded(
|
|
552
|
+
[
|
|
553
|
+
{
|
|
554
|
+
title: t('Constant'),
|
|
555
|
+
name: 'constant',
|
|
556
|
+
type: 'string',
|
|
557
|
+
paths: ['constant'],
|
|
558
|
+
render: staticInputRenderer,
|
|
559
|
+
},
|
|
560
|
+
{ title: t('Null'), name: 'null', type: 'object', paths: ['null'], render: NullComponent },
|
|
561
|
+
...nodes,
|
|
562
|
+
],
|
|
563
|
+
maxAssociationFieldDepth,
|
|
564
|
+
);
|
|
547
565
|
};
|
|
548
|
-
}, [rightMetaTree, ctx, staticInputRenderer, NullComponent, t]);
|
|
566
|
+
}, [rightMetaTree, ctx, staticInputRenderer, NullComponent, t, maxAssociationFieldDepth]);
|
|
549
567
|
|
|
550
568
|
// 当启用右侧变量输入时,构造 VariableInput 的 converters:
|
|
551
569
|
// - 变量模式:返回 null 让 VariableInput 渲染 VariableTag
|
|
@@ -629,9 +647,9 @@ export const VariableFilterItem: React.FC<VariableFilterItemProps> = observer(
|
|
|
629
647
|
for (const n of nodes) {
|
|
630
648
|
out.push(await enhanceNode(n));
|
|
631
649
|
}
|
|
632
|
-
return out;
|
|
650
|
+
return limitMetaTreeIfNeeded(out, maxAssociationFieldDepth);
|
|
633
651
|
};
|
|
634
|
-
}, [getFieldInterface, model]);
|
|
652
|
+
}, [getFieldInterface, model, maxAssociationFieldDepth]);
|
|
635
653
|
|
|
636
654
|
return (
|
|
637
655
|
<Space wrap style={{ width: '100%' }}>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from 'vitest';
|
|
11
|
+
|
|
12
|
+
import { fieldsToOptions } from '../fieldsToOptions';
|
|
13
|
+
|
|
14
|
+
describe('fieldsToOptions', () => {
|
|
15
|
+
it('skips nested fields when target collection is unavailable', () => {
|
|
16
|
+
const field = {
|
|
17
|
+
name: 'space',
|
|
18
|
+
type: 'belongsTo',
|
|
19
|
+
target: 'spaces',
|
|
20
|
+
title: 'Space',
|
|
21
|
+
interface: 'm2o',
|
|
22
|
+
filterable: true,
|
|
23
|
+
uiSchema: {},
|
|
24
|
+
getInterfaceOptions: () => ({
|
|
25
|
+
filterable: {
|
|
26
|
+
nested: true,
|
|
27
|
+
operators: [{ value: '$eq', label: 'is' }],
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
getFields: () => {
|
|
31
|
+
throw new Error('Target collection spaces not found for field space');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
expect(() => fieldsToOptions([field], 1, [], (key: string) => key)).not.toThrow();
|
|
36
|
+
expect(fieldsToOptions([field], 1, [], (key: string) => key)).toEqual([
|
|
37
|
+
{
|
|
38
|
+
name: 'space',
|
|
39
|
+
type: 'belongsTo',
|
|
40
|
+
target: 'spaces',
|
|
41
|
+
title: 'Space',
|
|
42
|
+
schema: {},
|
|
43
|
+
operators: [{ value: '$eq', label: 'is' }],
|
|
44
|
+
children: [],
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from 'vitest';
|
|
11
|
+
import type { MetaTreeNode } from '@nocobase/flow-engine';
|
|
12
|
+
import { limitAssociationMetaTree } from '../metaTreeAssociationDepth';
|
|
13
|
+
|
|
14
|
+
describe('limitAssociationMetaTree', () => {
|
|
15
|
+
it('keeps relation / relation / normal field and removes deeper relation fields', async () => {
|
|
16
|
+
const tree: MetaTreeNode[] = [
|
|
17
|
+
{
|
|
18
|
+
name: 'user',
|
|
19
|
+
title: 'User',
|
|
20
|
+
type: 'object',
|
|
21
|
+
interface: 'm2o',
|
|
22
|
+
options: { target: 'users' },
|
|
23
|
+
paths: ['collection', 'user'],
|
|
24
|
+
children: async () => [
|
|
25
|
+
{
|
|
26
|
+
name: 'department',
|
|
27
|
+
title: 'Department',
|
|
28
|
+
type: 'object',
|
|
29
|
+
interface: 'm2o',
|
|
30
|
+
options: { target: 'departments' },
|
|
31
|
+
paths: ['collection', 'user', 'department'],
|
|
32
|
+
children: async () => [
|
|
33
|
+
{
|
|
34
|
+
name: 'name',
|
|
35
|
+
title: 'Name',
|
|
36
|
+
type: 'string',
|
|
37
|
+
interface: 'input',
|
|
38
|
+
paths: ['collection', 'user', 'department', 'name'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'company',
|
|
42
|
+
title: 'Company',
|
|
43
|
+
type: 'object',
|
|
44
|
+
interface: 'm2o',
|
|
45
|
+
options: { target: 'companies' },
|
|
46
|
+
paths: ['collection', 'user', 'department', 'company'],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const limited = limitAssociationMetaTree(tree);
|
|
55
|
+
const userChildren = await (limited[0].children as () => Promise<MetaTreeNode[]>)();
|
|
56
|
+
const departmentChildren = await (userChildren[0].children as () => Promise<MetaTreeNode[]>)();
|
|
57
|
+
|
|
58
|
+
expect(departmentChildren.map((node) => node.name)).toEqual(['name']);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -59,10 +59,15 @@ const field2option = (field: CollectionField, depth, nonfilterable, t) => {
|
|
|
59
59
|
option['children'] = children;
|
|
60
60
|
}
|
|
61
61
|
if (nested) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
let targetFields: CollectionField[] = [];
|
|
63
|
+
try {
|
|
64
|
+
targetFields = field.getFields().filter((f) => {
|
|
65
|
+
// 过滤掉附件字段,因为会报错:Target collection attachments not found for field xxx
|
|
66
|
+
return f.target !== 'attachments' && f.interface !== 'formula';
|
|
67
|
+
});
|
|
68
|
+
} catch {
|
|
69
|
+
targetFields = [];
|
|
70
|
+
}
|
|
66
71
|
const options = fieldsToOptions(targetFields, depth + 1, nonfilterable, t).filter(Boolean);
|
|
67
72
|
option['children'] = option['children'] || [];
|
|
68
73
|
option['children'].push(...options);
|
|
@@ -15,3 +15,6 @@ export { VariableFilterItem } from './VariableFilterItem';
|
|
|
15
15
|
export type { VariableFilterItemProps, VariableFilterItemValue } from './VariableFilterItem';
|
|
16
16
|
export { LinkageFilterItem } from './LinkageFilterItem';
|
|
17
17
|
export type { LinkageFilterItemProps, LinkageFilterItemValue } from './LinkageFilterItem';
|
|
18
|
+
export { useFilterOptions } from './useFilterOptions';
|
|
19
|
+
export type { FilterOption, UseFilterOptionsArgs } from './useFilterOptions';
|
|
20
|
+
// Higher-level filter compositions (`CollectionFilterItem`, `useFilterActionProps`, `createCollectionFilterItem`) live under `src/components/form/filter/`. They compose these flow primitives on top of a `Collection` binding — the dependency direction is form/filter → flow/components/filter, never the reverse.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MetaTreeNode } from '@nocobase/flow-engine';
|
|
11
|
+
|
|
12
|
+
const ASSOCIATION_FIELD_INTERFACES = new Set(['m2o', 'o2o', 'oho', 'obo', 'o2m', 'm2m', 'linkTo']);
|
|
13
|
+
|
|
14
|
+
function isAssociationMetaNode(node: MetaTreeNode) {
|
|
15
|
+
const options = (node as any)?.options || {};
|
|
16
|
+
return Boolean(
|
|
17
|
+
options.target ||
|
|
18
|
+
options.targetCollection ||
|
|
19
|
+
options.foreignKey ||
|
|
20
|
+
options.through ||
|
|
21
|
+
ASSOCIATION_FIELD_INTERFACES.has(String(node?.interface || '')),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function limitNodeAssociationDepth(node: MetaTreeNode, associationDepth: number, maxAssociationDepth: number) {
|
|
26
|
+
const isAssociation = isAssociationMetaNode(node);
|
|
27
|
+
const nextAssociationDepth = associationDepth + (isAssociation ? 1 : 0);
|
|
28
|
+
|
|
29
|
+
if (isAssociation && nextAssociationDepth > maxAssociationDepth) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const wrapChildren = (children: MetaTreeNode[] | (() => Promise<MetaTreeNode[]>)) => {
|
|
34
|
+
if (Array.isArray(children)) {
|
|
35
|
+
return limitAssociationMetaTree(children, {
|
|
36
|
+
associationDepth: nextAssociationDepth,
|
|
37
|
+
maxAssociationDepth,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return async () => {
|
|
42
|
+
const loaded = await children();
|
|
43
|
+
return limitAssociationMetaTree(Array.isArray(loaded) ? loaded : [], {
|
|
44
|
+
associationDepth: nextAssociationDepth,
|
|
45
|
+
maxAssociationDepth,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
...node,
|
|
52
|
+
children: node.children ? wrapChildren(node.children as any) : undefined,
|
|
53
|
+
} as MetaTreeNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function limitAssociationMetaTree(
|
|
57
|
+
nodes: MetaTreeNode[] | undefined,
|
|
58
|
+
options: {
|
|
59
|
+
associationDepth?: number;
|
|
60
|
+
maxAssociationDepth?: number;
|
|
61
|
+
} = {},
|
|
62
|
+
): MetaTreeNode[] {
|
|
63
|
+
const { associationDepth = 0, maxAssociationDepth = 2 } = options;
|
|
64
|
+
if (!Array.isArray(nodes)) return [];
|
|
65
|
+
|
|
66
|
+
return nodes
|
|
67
|
+
.map((node) => limitNodeAssociationDepth(node, associationDepth, maxAssociationDepth))
|
|
68
|
+
.filter(Boolean) as MetaTreeNode[];
|
|
69
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { Collection } from '@nocobase/flow-engine';
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
import { fieldsToOptions } from './fieldsToOptions';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* One operator entry on a `FilterOption`. Mirrors v1's interface-defined operator shape so the v2 filter value renderer can pick up the same per-operator value-side schema (e.g. datetime operators wanting the smart date picker, array/enum operators wanting a tag-mode Select).
|
|
16
|
+
*/
|
|
17
|
+
export type FilterOperator = {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Per-operator override for the value-side renderer. Wins over the field's own `uiSchema` when set. The `x-component` string is looked up against the v2 filter component registry.
|
|
22
|
+
*/
|
|
23
|
+
schema?: { 'x-component'?: string; 'x-component-props'?: Record<string, any> } & Record<string, any>;
|
|
24
|
+
/** Operator takes no right-hand value (e.g. `$empty`, `$notEmpty`). */
|
|
25
|
+
noValue?: boolean;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Single field-tree node returned by `useFilterOptions`. */
|
|
30
|
+
export type FilterOption = {
|
|
31
|
+
name: string;
|
|
32
|
+
type?: string;
|
|
33
|
+
target?: string;
|
|
34
|
+
title: string;
|
|
35
|
+
schema?: Record<string, any>;
|
|
36
|
+
operators?: FilterOperator[];
|
|
37
|
+
children?: FilterOption[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export interface UseFilterOptionsArgs {
|
|
41
|
+
/**
|
|
42
|
+
* **Preferred way to restrict fields**, alongside `nonfilterableFieldNames`.
|
|
43
|
+
*
|
|
44
|
+
* Whitelist of root-level field names to expose. Empty/undefined means "all filterable fields". The whitelist applies only at depth 1 — nested fields under an allowed association field are always included, matching the legacy v1 `Filter.Action` behaviour.
|
|
45
|
+
*/
|
|
46
|
+
filterableFieldNames?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* **Preferred way to restrict fields**, alongside `filterableFieldNames`.
|
|
49
|
+
*
|
|
50
|
+
* Blacklist of root-level field names to drop. Mirrors v1's `nonfilterable: [...]` schema prop on `Filter.Action`. Applies at depth 1 only, same as the whitelist. When both `filterableFieldNames` and `nonfilterableFieldNames` are provided, both apply: the final field set is `(whitelist or all) minus blacklist`.
|
|
51
|
+
*/
|
|
52
|
+
nonfilterableFieldNames?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Bypass the `filterableFieldNames` whitelist (mirrors v1 `noIgnore`).
|
|
55
|
+
*
|
|
56
|
+
* Legacy escape hatch from v1 schemas — prefer adjusting `filterableFieldNames` / `nonfilterableFieldNames` instead. Kept only for parity with existing v1 schemas that already set `noIgnore`.
|
|
57
|
+
*/
|
|
58
|
+
noIgnore?: boolean;
|
|
59
|
+
/** Translator used for field/operator labels. Defaults to identity. */
|
|
60
|
+
t?: (key: string) => string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const identity = (s: string) => s;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* v2 equivalent of v1's `useFilterOptions`/`useFilterFieldOptions`. Walks a `Collection`'s fields and returns the nested option tree consumed by antd `Cascader` in `CollectionFilterItem` (and any other v2 filter surface that wants the same field picker).
|
|
67
|
+
*
|
|
68
|
+
* Mirrors v1 in two ways that matter:
|
|
69
|
+
* - association fields (belongsTo / hasMany / m2m / etc.) are kept and recursed into via `fieldsToOptions`'s `nested` branch — so picking `user.username` is a first-class action, just like the legacy cascader.
|
|
70
|
+
* - the whitelist applies at depth 1 only, so capping the root field list (e.g. to `['lockedTs', 'unlockTs', 'user']`) doesn't accidentally hide the nested `user.username` / `user.nickname` leaves.
|
|
71
|
+
*/
|
|
72
|
+
export function useFilterOptions(collection: Collection | undefined, args: UseFilterOptionsArgs = {}): FilterOption[] {
|
|
73
|
+
const { filterableFieldNames, nonfilterableFieldNames, noIgnore = false, t = identity } = args;
|
|
74
|
+
|
|
75
|
+
const fields = useMemo(() => collection?.getFields() || [], [collection]);
|
|
76
|
+
|
|
77
|
+
const ignoreFieldsNames = useMemo(() => {
|
|
78
|
+
// Whitelist contribution: every field not in `filterableFieldNames`.
|
|
79
|
+
// Skipped when `noIgnore` is set, or when no whitelist was provided.
|
|
80
|
+
const whitelistIgnored =
|
|
81
|
+
noIgnore || !filterableFieldNames?.length
|
|
82
|
+
? []
|
|
83
|
+
: fields.map((f) => f.name).filter((n) => !filterableFieldNames.includes(n));
|
|
84
|
+
// Blacklist contribution: explicit names. Always applied, even with
|
|
85
|
+
// `noIgnore` (the blacklist's whole job is to subtract specific fields).
|
|
86
|
+
const blacklistIgnored = nonfilterableFieldNames ?? [];
|
|
87
|
+
if (!blacklistIgnored.length) return whitelistIgnored;
|
|
88
|
+
// Union the two so the final ignore set is `whitelist-derived ∪ blacklist`.
|
|
89
|
+
return Array.from(new Set([...whitelistIgnored, ...blacklistIgnored]));
|
|
90
|
+
}, [fields, filterableFieldNames, nonfilterableFieldNames, noIgnore]);
|
|
91
|
+
|
|
92
|
+
return useMemo(
|
|
93
|
+
() =>
|
|
94
|
+
fieldsToOptions(
|
|
95
|
+
fields.filter((field) => field.target !== 'attachments' && field.interface !== 'formula'),
|
|
96
|
+
1,
|
|
97
|
+
ignoreFieldsNames,
|
|
98
|
+
t,
|
|
99
|
+
).filter(Boolean) as FilterOption[],
|
|
100
|
+
[fields, ignoreFieldsNames, t],
|
|
101
|
+
);
|
|
102
|
+
}
|
package/src/flow/index.ts
CHANGED
|
@@ -100,7 +100,11 @@ export * from './utils';
|
|
|
100
100
|
export * from './actions';
|
|
101
101
|
export * from './system-settings';
|
|
102
102
|
export * from './admin-shell/admin-layout';
|
|
103
|
+
export * from './admin-shell/BaseLayoutModel';
|
|
104
|
+
export * from './admin-shell/BaseLayoutRouteCoordinator';
|
|
103
105
|
export * from './admin-shell/AdminLayoutRouteCoordinator';
|
|
106
|
+
export * from './admin-shell/useLayoutRoutePage';
|
|
107
|
+
export * from './admin-shell/useAdminLayoutRoutePage';
|
|
104
108
|
export * from '../settings-center';
|
|
105
109
|
export { openViewFlow } from './flows/openViewFlow';
|
|
106
110
|
export { editMarkdownFlow } from './flows/editMarkdownFlow';
|
|
@@ -75,7 +75,12 @@ export class FilterActionModel extends ActionModel {
|
|
|
75
75
|
value={this.props.filterValue || this.props.defaultFilterValue}
|
|
76
76
|
ctx={this.context}
|
|
77
77
|
FilterItem={(props) => (
|
|
78
|
-
<VariableFilterItem
|
|
78
|
+
<VariableFilterItem
|
|
79
|
+
{...props}
|
|
80
|
+
model={this}
|
|
81
|
+
ignoreFieldNames={this.getIgnoreFieldNames()}
|
|
82
|
+
maxAssociationFieldDepth={2}
|
|
83
|
+
/>
|
|
79
84
|
)}
|
|
80
85
|
/>
|
|
81
86
|
<div style={{ height: 150 }}></div>
|
|
@@ -94,7 +99,12 @@ export class FilterActionModel extends ActionModel {
|
|
|
94
99
|
value={this.props.filterValue || this.props.defaultFilterValue}
|
|
95
100
|
ctx={this.context}
|
|
96
101
|
FilterItem={(props) => (
|
|
97
|
-
<VariableFilterItem
|
|
102
|
+
<VariableFilterItem
|
|
103
|
+
{...props}
|
|
104
|
+
model={this}
|
|
105
|
+
ignoreFieldNames={this.getIgnoreFieldNames()}
|
|
106
|
+
maxAssociationFieldDepth={2}
|
|
107
|
+
/>
|
|
98
108
|
)}
|
|
99
109
|
/>
|
|
100
110
|
}
|
|
@@ -187,7 +197,9 @@ FilterActionModel.registerFlow({
|
|
|
187
197
|
return (
|
|
188
198
|
<FilterGroup
|
|
189
199
|
value={props.value || {}}
|
|
190
|
-
FilterItem={(props) =>
|
|
200
|
+
FilterItem={(props) => (
|
|
201
|
+
<VariableFilterItem {...props} model={modelInstance} maxAssociationFieldDepth={2} />
|
|
202
|
+
)}
|
|
191
203
|
/>
|
|
192
204
|
);
|
|
193
205
|
},
|
|
@@ -7,75 +7,22 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { tExpr,
|
|
10
|
+
import { tExpr, useFlowSettingsContext } from '@nocobase/flow-engine';
|
|
11
11
|
import { Alert, ButtonProps } from 'antd';
|
|
12
|
-
import React
|
|
12
|
+
import React from 'react';
|
|
13
13
|
import { AxiosRequestConfig } from 'axios';
|
|
14
14
|
import { ActionModel, ActionSceneEnum } from '../base/ActionModel';
|
|
15
|
-
import { CollectionActionModel } from '../base/CollectionActionModel';
|
|
16
|
-
import { RecordActionModel } from '../base/RecordActionModel';
|
|
17
15
|
import { AssignFormModel } from '../blocks/assign-form/AssignFormModel';
|
|
16
|
+
import {
|
|
17
|
+
createAssignFieldValuesStep,
|
|
18
|
+
createAssignFormSubModelOptions,
|
|
19
|
+
getAssignFieldValuesDefaultParams,
|
|
20
|
+
} from '../blocks/assign-form/assignFieldValuesFlow';
|
|
18
21
|
import { applyUpdateRecordAction } from './UpdateRecordActionUtils';
|
|
19
22
|
// import { RemoteFlowModelRenderer } from '../../FlowPage';
|
|
20
23
|
|
|
21
24
|
const SETTINGS_FLOW_KEY = 'assignSettings';
|
|
22
25
|
|
|
23
|
-
// 配置态编辑器:渲染 assignForm 子模型
|
|
24
|
-
function AssignFieldsEditor() {
|
|
25
|
-
const { model, blockModel } = useFlowSettingsContext();
|
|
26
|
-
const action: any = model;
|
|
27
|
-
const engine = useFlowEngine();
|
|
28
|
-
const initializedRef = useRef(false);
|
|
29
|
-
const [formModel, setFormModel] = React.useState<AssignFormModel | null>(null);
|
|
30
|
-
|
|
31
|
-
// 初始化回填
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
let cancelled = false;
|
|
34
|
-
(async () => {
|
|
35
|
-
const loaded = (await engine.loadOrCreateModel(
|
|
36
|
-
{
|
|
37
|
-
parentId: action.uid,
|
|
38
|
-
subKey: 'assignForm',
|
|
39
|
-
use: 'AssignFormModel',
|
|
40
|
-
},
|
|
41
|
-
{ skipSave: !model.context.flowSettingsEnabled },
|
|
42
|
-
)) as AssignFormModel;
|
|
43
|
-
if (cancelled) return;
|
|
44
|
-
setFormModel(loaded);
|
|
45
|
-
action.assignFormUid = (loaded as any)?.uid || action.assignFormUid;
|
|
46
|
-
})();
|
|
47
|
-
return () => {
|
|
48
|
-
cancelled = true;
|
|
49
|
-
};
|
|
50
|
-
}, [action, engine]);
|
|
51
|
-
|
|
52
|
-
// 初始化回填(在子模型加载完成后)
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (initializedRef.current) return;
|
|
55
|
-
if (!formModel) return;
|
|
56
|
-
const prev = action.getStepParams?.(SETTINGS_FLOW_KEY, 'assignFieldValues') || {};
|
|
57
|
-
// 注入资源上下文:与所在表格区块一致
|
|
58
|
-
const coll = blockModel?.collection || action?.context?.collection;
|
|
59
|
-
const dsKey = coll?.dataSourceKey;
|
|
60
|
-
const collName = coll?.name;
|
|
61
|
-
if (dsKey && collName) {
|
|
62
|
-
formModel.setStepParams('resourceSettings', 'init', {
|
|
63
|
-
dataSourceKey: dsKey,
|
|
64
|
-
collectionName: collName,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
formModel.setInitialAssignedValues(prev?.assignedValues || {});
|
|
68
|
-
// 批量配置态:移除 ctx.record(Action 为区块级,不具备单条记录上下文)
|
|
69
|
-
const isBulk = action instanceof CollectionActionModel && !(action instanceof RecordActionModel);
|
|
70
|
-
if (isBulk && (formModel as any)?.context?.defineProperty) {
|
|
71
|
-
formModel.context.defineProperty('record', { get: () => undefined, cache: false });
|
|
72
|
-
}
|
|
73
|
-
initializedRef.current = true;
|
|
74
|
-
}, [action, blockModel?.collection, formModel]);
|
|
75
|
-
|
|
76
|
-
return formModel ? <FlowModelRenderer model={formModel} showFlowSettings={false} /> : null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
26
|
function Info() {
|
|
80
27
|
const ctx = useFlowSettingsContext();
|
|
81
28
|
return (
|
|
@@ -124,16 +71,9 @@ UpdateRecordActionModel.define({
|
|
|
124
71
|
sort: 50,
|
|
125
72
|
// 使用函数型 createModelOptions,从父级上下文提取资源信息,直接注入到子模型的 resourceSettings.init
|
|
126
73
|
createModelOptions: (ctx) => {
|
|
127
|
-
const dsKey = ctx.collection.dataSourceKey;
|
|
128
|
-
const collName = ctx.collection.name;
|
|
129
|
-
const init = dsKey && collName ? { dataSourceKey: dsKey, collectionName: collName } : undefined;
|
|
130
74
|
return {
|
|
131
75
|
subModels: {
|
|
132
|
-
assignForm:
|
|
133
|
-
async: true,
|
|
134
|
-
use: 'AssignFormModel',
|
|
135
|
-
stepParams: { resourceSettings: { init } },
|
|
136
|
-
},
|
|
76
|
+
assignForm: createAssignFormSubModelOptions(ctx),
|
|
137
77
|
},
|
|
138
78
|
};
|
|
139
79
|
},
|
|
@@ -155,32 +95,12 @@ UpdateRecordActionModel.registerFlow({
|
|
|
155
95
|
content: tExpr('Are you sure you want to perform the Update record action?'),
|
|
156
96
|
},
|
|
157
97
|
},
|
|
158
|
-
assignFieldValues: {
|
|
98
|
+
assignFieldValues: createAssignFieldValuesStep({
|
|
99
|
+
settingsFlowKey: SETTINGS_FLOW_KEY,
|
|
159
100
|
title: tExpr('Field values'),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
'x-decorator': 'FormItem',
|
|
164
|
-
'x-component': () => <Info />,
|
|
165
|
-
},
|
|
166
|
-
editor: {
|
|
167
|
-
'x-decorator': 'FormItem',
|
|
168
|
-
'x-component': () => <AssignFieldsEditor />,
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
async beforeParamsSave(ctx) {
|
|
173
|
-
const m = ctx.model as UpdateRecordActionModel;
|
|
174
|
-
// 跨视图栈按 uid 定位到设置面板中的真实 AssignForm 实例
|
|
175
|
-
const form: AssignFormModel = m?.assignFormUid && ctx.engine.getModel?.(m.assignFormUid, true);
|
|
176
|
-
if (!form) return;
|
|
177
|
-
await form?.form?.validateFields?.();
|
|
178
|
-
const assignedValues = form?.getAssignedValues?.() || {};
|
|
179
|
-
const grid = form?.subModels?.grid;
|
|
180
|
-
const items = grid?.subModels?.items || [];
|
|
181
|
-
ctx.model.setStepParams(SETTINGS_FLOW_KEY, 'assignFieldValues', { assignedValues });
|
|
182
|
-
},
|
|
183
|
-
},
|
|
101
|
+
tipComponent: Info,
|
|
102
|
+
validateBeforeSave: true,
|
|
103
|
+
}),
|
|
184
104
|
},
|
|
185
105
|
});
|
|
186
106
|
|
|
@@ -190,8 +110,7 @@ UpdateRecordActionModel.registerFlow({
|
|
|
190
110
|
steps: {
|
|
191
111
|
apply: {
|
|
192
112
|
async defaultParams(ctx) {
|
|
193
|
-
|
|
194
|
-
return { assignedValues: step?.assignedValues || {} };
|
|
113
|
+
return getAssignFieldValuesDefaultParams(ctx, SETTINGS_FLOW_KEY);
|
|
195
114
|
},
|
|
196
115
|
async handler(ctx, params) {
|
|
197
116
|
await applyUpdateRecordAction(ctx, params, { settingsFlowKey: SETTINGS_FLOW_KEY });
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { MultiRecordResource, SingleRecordResource
|
|
10
|
+
import { MultiRecordResource, SingleRecordResource } from '@nocobase/flow-engine';
|
|
11
11
|
import { dispatchEventDeep } from '../../utils';
|
|
12
|
+
import { resolveAssignFieldValues } from '../blocks/assign-form/assignFieldValuesFlow';
|
|
12
13
|
|
|
13
14
|
export async function refreshLinkageRulesAfterUpdate(ctx: any) {
|
|
14
15
|
const blockModel = ctx?.blockModel || ctx?.model?.context?.blockModel || ctx?.model;
|
|
@@ -59,12 +60,8 @@ export async function applyUpdateRecordAction(
|
|
|
59
60
|
const confirmParams = savedConfirm && typeof savedConfirm === 'object' ? savedConfirm : { enable: false };
|
|
60
61
|
await ctx.runAction('confirm', confirmParams);
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
assignedValues = await resolveRunJSObjectValues(ctx, params?.assignedValues);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error('[UpdateRecordAction] RunJS execution failed', error);
|
|
67
|
-
ctx.message.error(ctx.t('RunJS execution failed'));
|
|
63
|
+
const assignedValues = await resolveAssignFieldValues(ctx, params?.assignedValues, 'UpdateRecordAction');
|
|
64
|
+
if (!assignedValues) {
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
|