@nocobase/client-v2 2.2.0-beta.9 → 3.0.0-alpha.1
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/APIClient.d.ts +1 -3
- package/es/BaseApplication.d.ts +1 -0
- package/es/acl/ACLProvider.d.ts +10 -0
- package/es/authRedirect.d.ts +5 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
- package/es/components/AttachmentUpload.d.ts +51 -0
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/ScanInput/useCodeScanner.d.ts +3 -2
- package/es/components/form/TypedVariableInput.d.ts +31 -5
- package/es/components/form/filter/CollectionFilter.d.ts +2 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
- package/es/components/index.d.ts +2 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +3 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- package/es/flow/components/FlowRoute.d.ts +2 -2
- package/es/flow/components/RunJSValueEditor.d.ts +1 -0
- package/es/flow/components/filter/FilterGroup.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
- package/es/flow/index.d.ts +1 -0
- package/es/flow/internal/registerDeviceTypeContext.d.ts +10 -0
- package/es/flow/models/base/ActionModelCore.d.ts +4 -2
- package/es/flow/models/base/BlockGridModel.d.ts +3 -0
- package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
- package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
- package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +17 -2
- package/es/flow/models/blocks/table/TableColumnModel.d.ts +1 -0
- package/es/flow/models/fields/DateTimeFieldModel/dateLimit.d.ts +15 -7
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +8 -1
- package/es/index.mjs +190 -141
- package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
- package/es/nocobase-buildin-plugin/index.d.ts +9 -0
- package/es/settings-app/SettingsApplication.d.ts +18 -0
- package/es/settings-app/SettingsBrand.d.ts +16 -0
- package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
- package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
- package/es/settings-app/SettingsGroupNav.d.ts +17 -0
- package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
- package/es/settings-app/SettingsRouterManager.d.ts +15 -0
- package/es/settings-app/SettingsSearch.d.ts +17 -0
- package/es/settings-app/SettingsShell.d.ts +10 -0
- package/es/settings-app/isSettingsApp.d.ts +18 -0
- package/es/settings-app/runtimePaths.d.ts +18 -0
- package/es/settings-app/settingsDocumentPath.d.ts +14 -0
- package/es/settings-app/settingsTheme.d.ts +87 -0
- package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
- package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
- package/es/settings-center/groups.d.ts +66 -0
- package/es/settings-center/useSettingsGroups.d.ts +36 -0
- package/es/settings-center/useSettingsSearch.d.ts +35 -0
- package/es/settings-center/utils.d.ts +24 -0
- package/es/theme/index.d.ts +1 -0
- package/es/theme/itemActive.d.ts +24 -0
- package/es/theme/type.d.ts +9 -0
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/lib/index.js +195 -146
- package/lib/locale/languageCodes.js +3 -1
- package/package.json +9 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +11 -6
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +137 -0
- package/src/__tests__/browserChecker.test.ts +185 -6
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/mockSettingsApplication.ts +29 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +79 -10
- package/src/__tests__/plugin-manager.test.tsx +7 -6
- package/src/__tests__/settings-application.test.ts +164 -0
- package/src/__tests__/settings-auth-routes.test.ts +71 -0
- package/src/__tests__/settings-center.test.tsx +38 -37
- package/src/__tests__/settings-layout-root.test.tsx +260 -0
- package/src/__tests__/settings-runtime-paths.test.ts +99 -0
- package/src/__tests__/settings-shell.test.tsx +200 -0
- package/src/acl/ACLProvider.tsx +21 -0
- package/src/authRedirect.ts +72 -3
- package/src/collection-field-interface/CollectionFieldInterface.ts +1 -0
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +1 -0
- package/src/collection-manager/field-validation.ts +1 -1
- package/src/components/AttachmentUpload.tsx +275 -0
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +4 -0
- package/src/components/form/ScanInput/CodeScanner.tsx +79 -35
- package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +101 -0
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +284 -11
- package/src/components/form/ScanInput/useCodeScanner.ts +332 -24
- package/src/components/form/TypedVariableInput.tsx +452 -101
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
- package/src/components/form/filter/CollectionFilter.tsx +4 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/filter/useFilterActionProps.ts +37 -6
- package/src/components/index.ts +2 -0
- package/src/flow/FlowPage.tsx +9 -1
- package/src/flow/__tests__/FlowPage.test.tsx +50 -3
- package/src/flow/__tests__/FlowRoute.test.tsx +128 -10
- package/src/flow/__tests__/PluginFlowEngine.test.ts +58 -0
- package/src/flow/actions/__tests__/actionLinkageRules.forkProps.test.ts +314 -0
- package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +102 -0
- package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +7 -3
- package/src/flow/actions/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +111 -16
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -57
- package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
- package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +77 -13
- package/src/flow/common/Markdown/style.ts +4 -0
- package/src/flow/components/BlockItemCard.tsx +2 -2
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +78 -32
- package/src/flow/components/RunJSValueEditor.tsx +9 -1
- package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +216 -0
- package/src/flow/components/filter/FilterGroup.tsx +33 -5
- package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
- package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
- package/src/flow/index.ts +3 -0
- package/src/flow/internal/registerDeviceTypeContext.ts +39 -0
- package/src/flow/models/base/ActionModelCore.tsx +11 -2
- package/src/flow/models/base/BlockGridModel.tsx +26 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +6 -2
- package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
- package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
- package/src/flow/models/base/PageModel/PageTabModel.tsx +249 -18
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
- package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +1075 -7
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +49 -0
- package/src/flow/models/base/__tests__/BlockGridModel.selectSceneActivation.test.ts +124 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.addAppends.test.ts +41 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +28 -3
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +27 -12
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +36 -0
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +66 -4
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +189 -36
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +350 -2
- package/src/flow/models/blocks/js-block/JSBlock.tsx +1 -1
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +4 -2
- package/src/flow/models/blocks/table/TableColumnModel.tsx +30 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.quickEditRefresh.test.ts +12 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +33 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/DateTimeFieldModel/__tests__/DateTimeNoTzFieldModel.dateLimit.test.tsx +149 -0
- package/src/flow/models/fields/DateTimeFieldModel/dateLimit.ts +149 -113
- package/src/flow/models/fields/JsonFieldModel.tsx +31 -8
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/JsonFieldModel.test.ts +82 -0
- package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +20 -10
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +24 -12
- package/src/flow/models/topbar/TopbarActionModel.tsx +52 -180
- package/src/flow/utils/dataScopeFormValueClear.ts +4 -3
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +14 -1
- package/src/locale/languageCodes.ts +3 -1
- package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
- package/src/nocobase-buildin-plugin/index.tsx +110 -70
- package/src/settings-app/SettingsApplication.ts +31 -0
- package/src/settings-app/SettingsBrand.tsx +108 -0
- package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
- package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
- package/src/settings-app/SettingsGroupNav.tsx +124 -0
- package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
- package/src/settings-app/SettingsRouterManager.ts +92 -0
- package/src/settings-app/SettingsSearch.tsx +238 -0
- package/src/settings-app/SettingsShell.tsx +167 -0
- package/src/settings-app/isSettingsApp.ts +21 -0
- package/src/settings-app/runtimePaths.ts +104 -0
- package/src/settings-app/settingsDocumentPath.ts +66 -0
- package/src/settings-app/settingsTheme.ts +301 -0
- package/src/settings-app/useSettingsThemeConfig.ts +100 -0
- package/src/settings-center/AdminSettingsLayout.tsx +122 -141
- package/src/settings-center/SystemSettingsPage.tsx +4 -170
- package/src/settings-center/groups.ts +108 -0
- package/src/settings-center/useSettingsGroups.ts +105 -0
- package/src/settings-center/useSettingsSearch.ts +173 -0
- package/src/settings-center/utils.tsx +50 -1
- package/src/theme/index.tsx +1 -0
- package/src/theme/itemActive.ts +31 -0
- package/src/theme/type.ts +10 -0
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { FlowModel, FlowModelRenderer, observable, tExpr } from '@nocobase/flow-engine';
|
|
10
|
+
import { FlowModel, FlowModelRenderer, observable, type ParamObject, tExpr } from '@nocobase/flow-engine';
|
|
11
11
|
import { Icon, type NocoBaseDesktopRoute } from '../../../../flow-compat';
|
|
12
|
+
import type { RouteRepository } from '../../../../RouteRepository';
|
|
12
13
|
import { useRequest } from 'ahooks';
|
|
14
|
+
import _ from 'lodash';
|
|
13
15
|
import React from 'react';
|
|
14
16
|
import { SkeletonFallback } from '../../../components/SkeletonFallback';
|
|
15
17
|
import { TextAreaWithContextSelector } from '../../../components/TextAreaWithContextSelector';
|
|
@@ -52,6 +54,43 @@ function normalizePersistedRoute(payload: unknown): Partial<NocoBaseDesktopRoute
|
|
|
52
54
|
return undefined;
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
type PersistedFlowModelAnchor = Record<string, unknown> & {
|
|
58
|
+
uid?: unknown;
|
|
59
|
+
stepParams?: unknown;
|
|
60
|
+
subModels?: unknown;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type LinkageRulesStepParams = ParamObject & {
|
|
64
|
+
value?: unknown;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
68
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isLinkageRulesStepParams(value: unknown): value is LinkageRulesStepParams {
|
|
72
|
+
return isRecord(value);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type RefreshableRouteRepository = Pick<RouteRepository, 'refreshAccessible'>;
|
|
76
|
+
|
|
77
|
+
const routeRefreshQueues = new WeakMap<RefreshableRouteRepository, Promise<unknown>>();
|
|
78
|
+
|
|
79
|
+
async function refreshRouteRepository(repository: RefreshableRouteRepository) {
|
|
80
|
+
const previous = routeRefreshQueues.get(repository) || Promise.resolve();
|
|
81
|
+
const current = previous.catch(() => undefined).then(() => repository.refreshAccessible());
|
|
82
|
+
|
|
83
|
+
routeRefreshQueues.set(repository, current);
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await current;
|
|
87
|
+
} finally {
|
|
88
|
+
if (routeRefreshQueues.get(repository) === current) {
|
|
89
|
+
routeRefreshQueues.delete(repository);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
55
94
|
export class BasePageTabModel extends FlowModel<{
|
|
56
95
|
subModels: {
|
|
57
96
|
grid: BlockGridModel;
|
|
@@ -139,13 +178,100 @@ BasePageTabModel.registerFlow({
|
|
|
139
178
|
ctx.model.setProps('title', translate(params.title, { ns: 'lm-desktop-routes' }));
|
|
140
179
|
ctx.model.setProps('icon', params.icon);
|
|
141
180
|
const pageModel = ctx.engine.getModel(ctx.model.parentId) as { updateDocumentTitle?: () => Promise<void> };
|
|
142
|
-
|
|
181
|
+
await pageModel?.updateDocumentTitle?.();
|
|
143
182
|
},
|
|
144
183
|
},
|
|
184
|
+
linkageRules: {
|
|
185
|
+
use: 'tabLinkageRules',
|
|
186
|
+
},
|
|
145
187
|
},
|
|
146
188
|
});
|
|
147
189
|
|
|
148
190
|
export class RootPageTabModel extends BasePageTabModel {
|
|
191
|
+
private persistedLinkageRulesHydrated = false;
|
|
192
|
+
private persistedLinkageRulesHydrating?: Promise<void>;
|
|
193
|
+
|
|
194
|
+
onInit(options) {
|
|
195
|
+
super.onInit(options);
|
|
196
|
+
if (this.shouldHydratePersistedLinkageRules()) {
|
|
197
|
+
this.hydratePersistedLinkageRules().catch((error) => {
|
|
198
|
+
console.warn('[RootPageTabModel] Failed to hydrate tab linkage rules', error);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private hasExplicitLinkageRulesStep() {
|
|
204
|
+
const pageTabSettings = this.stepParams?.pageTabSettings;
|
|
205
|
+
return isRecord(pageTabSettings) && Object.prototype.hasOwnProperty.call(pageTabSettings, 'linkageRules');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private shouldHydratePersistedLinkageRules() {
|
|
209
|
+
return !!this.context.flowSettingsEnabled || this.props.route?.options?.hasPersistedPageTabFlowModel === true;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private async fetchPersistedAnchor(): Promise<PersistedFlowModelAnchor | undefined> {
|
|
213
|
+
const response = await this.context.api.request({
|
|
214
|
+
url: 'flowModels:findOne',
|
|
215
|
+
params: { uid: this.uid },
|
|
216
|
+
});
|
|
217
|
+
const anchor = response?.data?.data;
|
|
218
|
+
return isRecord(anchor) ? anchor : undefined;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private async performPersistedLinkageRulesHydrate() {
|
|
222
|
+
if (this.hasExplicitLinkageRulesStep()) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const anchor = await this.fetchPersistedAnchor();
|
|
227
|
+
if (this.hasExplicitLinkageRulesStep()) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const stepParams = isRecord(anchor?.stepParams) ? anchor.stepParams : undefined;
|
|
232
|
+
const pageTabSettings = isRecord(stepParams?.pageTabSettings) ? stepParams.pageTabSettings : undefined;
|
|
233
|
+
const linkageRules = pageTabSettings?.linkageRules;
|
|
234
|
+
if (!isLinkageRulesStepParams(linkageRules)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.setStepParams('pageTabSettings', 'linkageRules', _.cloneDeep(linkageRules));
|
|
239
|
+
this.invalidateFlowCache('beforeRender', true);
|
|
240
|
+
await this.rerender();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private hydratePersistedLinkageRules(): Promise<void> {
|
|
244
|
+
if (this.persistedLinkageRulesHydrated) {
|
|
245
|
+
return Promise.resolve();
|
|
246
|
+
}
|
|
247
|
+
if (this.persistedLinkageRulesHydrating) {
|
|
248
|
+
return this.persistedLinkageRulesHydrating;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const hydration = this.performPersistedLinkageRulesHydrate();
|
|
252
|
+
this.persistedLinkageRulesHydrating = hydration;
|
|
253
|
+
hydration
|
|
254
|
+
.then(() => {
|
|
255
|
+
if (this.persistedLinkageRulesHydrating === hydration) {
|
|
256
|
+
this.persistedLinkageRulesHydrated = true;
|
|
257
|
+
this.persistedLinkageRulesHydrating = undefined;
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
.catch(() => {
|
|
261
|
+
if (this.persistedLinkageRulesHydrating === hydration) {
|
|
262
|
+
this.persistedLinkageRulesHydrating = undefined;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return hydration;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async openFlowSettings(options?: Parameters<FlowModel['openFlowSettings']>[0]) {
|
|
269
|
+
if (options?.flowKey === 'pageTabSettings' && options?.stepKey === 'linkageRules') {
|
|
270
|
+
await this.hydratePersistedLinkageRules();
|
|
271
|
+
}
|
|
272
|
+
return super.openFlowSettings(options);
|
|
273
|
+
}
|
|
274
|
+
|
|
149
275
|
renderChildren() {
|
|
150
276
|
return (
|
|
151
277
|
<PageTabChildrenRenderer
|
|
@@ -162,28 +288,50 @@ export class RootPageTabModel extends BasePageTabModel {
|
|
|
162
288
|
}
|
|
163
289
|
|
|
164
290
|
async saveStepParams() {
|
|
165
|
-
|
|
291
|
+
const hasExplicitLinkageRulesStep = this.hasExplicitLinkageRulesStep();
|
|
292
|
+
const linkageRules = hasExplicitLinkageRulesStep
|
|
293
|
+
? (_.cloneDeep(this.stepParams.pageTabSettings.linkageRules) as LinkageRulesStepParams)
|
|
294
|
+
: undefined;
|
|
295
|
+
|
|
296
|
+
await this.save();
|
|
297
|
+
if (hasExplicitLinkageRulesStep && linkageRules) {
|
|
298
|
+
await this.persistLinkageRulesToAnchor(linkageRules);
|
|
299
|
+
}
|
|
166
300
|
}
|
|
167
301
|
|
|
168
302
|
async save() {
|
|
169
303
|
const json = this.serialize();
|
|
170
304
|
const documentTitle = this.stepParams?.pageTabSettings?.tab?.documentTitle;
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
305
|
+
const route = this.props.route || {};
|
|
306
|
+
const persisted = route.id != null;
|
|
307
|
+
const currentRoute =
|
|
308
|
+
persisted && route.schemaUid ? this.context.routeRepository?.getRouteBySchemaUid?.(route.schemaUid) : undefined;
|
|
309
|
+
const data = {
|
|
310
|
+
...(persisted ? { schemaUid: route.schemaUid } : route),
|
|
311
|
+
title: this.getTabTitle(''),
|
|
312
|
+
icon: this.getTabIcon(),
|
|
313
|
+
options: {
|
|
314
|
+
...(currentRoute ? currentRoute.options : route.options),
|
|
315
|
+
flowRegistry: json.flowRegistry,
|
|
316
|
+
documentTitle,
|
|
176
317
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
318
|
+
};
|
|
319
|
+
const response = await this.context.api.request(
|
|
320
|
+
persisted
|
|
321
|
+
? {
|
|
322
|
+
method: 'post',
|
|
323
|
+
url: `desktopRoutes:update?filter[id]=${route.id}`,
|
|
324
|
+
data,
|
|
325
|
+
}
|
|
326
|
+
: {
|
|
327
|
+
method: 'post',
|
|
328
|
+
url: 'desktopRoutes:updateOrCreate',
|
|
329
|
+
params: {
|
|
330
|
+
filterKeys: ['schemaUid'],
|
|
331
|
+
},
|
|
332
|
+
data,
|
|
333
|
+
},
|
|
334
|
+
);
|
|
187
335
|
const persistedRoute = normalizePersistedRoute(response?.data?.data);
|
|
188
336
|
|
|
189
337
|
// 新建 tab 首次保存后需要立即拿到持久化 route id,拖拽排序会直接依赖它。
|
|
@@ -197,6 +345,89 @@ export class RootPageTabModel extends BasePageTabModel {
|
|
|
197
345
|
},
|
|
198
346
|
});
|
|
199
347
|
}
|
|
348
|
+
|
|
349
|
+
// 后续保存会从 RouteRepository 读取扩展 options,当前写入完成后必须先同步最新路由快照。
|
|
350
|
+
try {
|
|
351
|
+
if (this.context.routeRepository?.refreshAccessible) {
|
|
352
|
+
await refreshRouteRepository(this.context.routeRepository);
|
|
353
|
+
} else {
|
|
354
|
+
await this.context.refreshDesktopRoutes?.();
|
|
355
|
+
}
|
|
356
|
+
} catch (error) {
|
|
357
|
+
this.context.logger?.warn?.(
|
|
358
|
+
{ err: error },
|
|
359
|
+
'[client-v2] Failed to refresh desktop routes after saving a page tab',
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private buildAnchorPayload(latestAnchor: PersistedFlowModelAnchor | undefined, linkageRules: LinkageRulesStepParams) {
|
|
365
|
+
const hasPersistedAnchor = typeof latestAnchor?.uid === 'string' && latestAnchor.uid.length > 0;
|
|
366
|
+
const anchorRoot: PersistedFlowModelAnchor = hasPersistedAnchor
|
|
367
|
+
? _.cloneDeep(latestAnchor)
|
|
368
|
+
: { uid: this.uid, use: 'RouteModel' };
|
|
369
|
+
delete anchorRoot.subModels;
|
|
370
|
+
|
|
371
|
+
const latestStepParams = isRecord(anchorRoot.stepParams) ? anchorRoot.stepParams : {};
|
|
372
|
+
const latestPageTabSettings = isRecord(latestStepParams.pageTabSettings) ? latestStepParams.pageTabSettings : {};
|
|
373
|
+
|
|
374
|
+
return {
|
|
375
|
+
...anchorRoot,
|
|
376
|
+
stepParams: {
|
|
377
|
+
...latestStepParams,
|
|
378
|
+
pageTabSettings: {
|
|
379
|
+
...latestPageTabSettings,
|
|
380
|
+
linkageRules: _.cloneDeep(linkageRules),
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private async persistLinkageRulesToAnchor(linkageRules: LinkageRulesStepParams) {
|
|
387
|
+
const latestAnchor = await this.fetchPersistedAnchor();
|
|
388
|
+
const anchorPayload = this.buildAnchorPayload(latestAnchor, linkageRules);
|
|
389
|
+
await this.context.api.request({
|
|
390
|
+
method: 'post',
|
|
391
|
+
url: 'flowModels:save',
|
|
392
|
+
data: anchorPayload,
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const hasRules = Array.isArray(linkageRules.value) && linkageRules.value.length > 0;
|
|
396
|
+
await this.syncPersistedPageTabFlowModelMarker(hasRules);
|
|
397
|
+
this.persistedLinkageRulesHydrated = true;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private async syncPersistedPageTabFlowModelMarker(hasRules: boolean) {
|
|
401
|
+
const route = this.props.route;
|
|
402
|
+
if (route?.id == null) {
|
|
403
|
+
throw new Error('Cannot persist page tab FlowModel marker before the desktop route is saved.');
|
|
404
|
+
}
|
|
405
|
+
if (typeof this.context.routeRepository?.updateRoute !== 'function') {
|
|
406
|
+
throw new Error('Route repository is unavailable while persisting the page tab FlowModel marker.');
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const currentRoute = route.schemaUid
|
|
410
|
+
? this.context.routeRepository.getRouteBySchemaUid?.(route.schemaUid)
|
|
411
|
+
: undefined;
|
|
412
|
+
const nextOptions = {
|
|
413
|
+
...(currentRoute?.options || route.options || {}),
|
|
414
|
+
};
|
|
415
|
+
if (hasRules) {
|
|
416
|
+
nextOptions.hasPersistedPageTabFlowModel = true;
|
|
417
|
+
} else {
|
|
418
|
+
delete nextOptions.hasPersistedPageTabFlowModel;
|
|
419
|
+
}
|
|
420
|
+
const persistedOptions = Object.keys(nextOptions).length > 0 ? nextOptions : undefined;
|
|
421
|
+
|
|
422
|
+
await this.context.routeRepository.updateRoute(
|
|
423
|
+
route.id,
|
|
424
|
+
{ options: persistedOptions },
|
|
425
|
+
{ refreshAfterMutation: false },
|
|
426
|
+
);
|
|
427
|
+
this.setProps('route', {
|
|
428
|
+
...route,
|
|
429
|
+
options: persistedOptions,
|
|
430
|
+
});
|
|
200
431
|
}
|
|
201
432
|
|
|
202
433
|
async destroy() {
|