@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
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
createRecordResolveOnServerWithLocal,
|
|
23
23
|
} from '@nocobase/flow-engine';
|
|
24
24
|
import { Button, Form, Skeleton, Space } from 'antd';
|
|
25
|
-
import _ from 'lodash';
|
|
26
25
|
import React from 'react';
|
|
27
26
|
import { FieldModel } from '../../base/FieldModel';
|
|
28
27
|
import { FormComponent } from './FormBlockModel';
|
|
@@ -31,6 +30,37 @@ import { FormItemModel } from './FormItemModel';
|
|
|
31
30
|
export const QUICK_EDIT_POPOVER_MAX_HEIGHT = 'calc(100vh - 96px)';
|
|
32
31
|
export const QUICK_EDIT_FORM_MAX_HEIGHT = 'calc(100vh - 160px)';
|
|
33
32
|
export const QUICK_EDIT_MARKDOWN_HEIGHT = 'min(480px, calc(100vh - 320px))';
|
|
33
|
+
const QUICK_EDIT_MOBILE_DRAWER_HEIGHT = '50vh';
|
|
34
|
+
const QUICK_EDIT_MOBILE_FORM_MAX_HEIGHT = 'calc(50vh - var(--nb-mobile-page-header-height, 40px) - 132px)';
|
|
35
|
+
const QUICK_EDIT_MOBILE_CONTENT_PADDING = '8px var(--nb-mobile-page-tabs-content-padding, 12px) 0';
|
|
36
|
+
const QUICK_EDIT_MOBILE_ACTIONS_PADDING =
|
|
37
|
+
'8px var(--nb-mobile-page-tabs-content-padding, 12px) calc(80px + env(safe-area-inset-bottom, 0px))';
|
|
38
|
+
const QUICK_EDIT_MOBILE_MEDIA_QUERY = '(max-width: 768px)';
|
|
39
|
+
|
|
40
|
+
type QuickEditViewBeforeClosePayload = {
|
|
41
|
+
result?: unknown;
|
|
42
|
+
force?: boolean;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type QuickEditViewBeforeCloseHandler = (
|
|
47
|
+
payload: QuickEditViewBeforeClosePayload,
|
|
48
|
+
) => Promise<boolean | void> | boolean | void;
|
|
49
|
+
|
|
50
|
+
type QuickEditViewUpdateConfig = {
|
|
51
|
+
preventClose?: boolean;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type QuickEditViewContainer = {
|
|
56
|
+
close: (result?: unknown, force?: boolean) => Promise<boolean | void> | boolean | void;
|
|
57
|
+
update?: (newConfig: QuickEditViewUpdateConfig) => unknown;
|
|
58
|
+
beforeClose?: QuickEditViewBeforeCloseHandler;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type QuickEditViewContext = {
|
|
62
|
+
defineProperty?: (key: string, options: { value: unknown }) => void;
|
|
63
|
+
};
|
|
34
64
|
|
|
35
65
|
export function getQuickEditFieldProps(collectionField: CollectionField, fieldProps?: Record<string, any>) {
|
|
36
66
|
const nextProps = { ...collectionField.getComponentProps(), ...(fieldProps || {}) };
|
|
@@ -40,15 +70,92 @@ export function getQuickEditFieldProps(collectionField: CollectionField, fieldPr
|
|
|
40
70
|
return nextProps;
|
|
41
71
|
}
|
|
42
72
|
|
|
73
|
+
function getQuickEditMobileLayoutState(flowEngine: FlowEngine, sourceFieldModel?: FlowModel) {
|
|
74
|
+
const sourceMobileLayout = sourceFieldModel?.context?.isMobileLayout;
|
|
75
|
+
if (typeof sourceMobileLayout === 'boolean') {
|
|
76
|
+
return { isMobileLayout: sourceMobileLayout, inheritsMobileContext: sourceMobileLayout };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const engineMobileLayout = flowEngine.context?.isMobileLayout;
|
|
80
|
+
if (typeof engineMobileLayout === 'boolean') {
|
|
81
|
+
return { isMobileLayout: engineMobileLayout, inheritsMobileContext: engineMobileLayout };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
|
|
85
|
+
return { isMobileLayout: false, inheritsMobileContext: false };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
isMobileLayout: window.matchMedia(QUICK_EDIT_MOBILE_MEDIA_QUERY).matches,
|
|
90
|
+
inheritsMobileContext: false,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getQuickEditTitle(
|
|
95
|
+
flowEngine: FlowEngine,
|
|
96
|
+
dataSourceKey: string,
|
|
97
|
+
collectionName: string,
|
|
98
|
+
fieldPath: string,
|
|
99
|
+
sourceFieldModel?: FlowModel,
|
|
100
|
+
fieldProps?: Record<string, unknown>,
|
|
101
|
+
): React.ReactNode {
|
|
102
|
+
const sourceColumnTitle = sourceFieldModel?.parent?.props?.title;
|
|
103
|
+
if (sourceColumnTitle) {
|
|
104
|
+
return sourceColumnTitle;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const fieldPropsTitle = fieldProps?.title;
|
|
108
|
+
if (fieldPropsTitle) {
|
|
109
|
+
return fieldPropsTitle as React.ReactNode;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const collectionField = flowEngine.context.dataSourceManager.getCollectionField(
|
|
113
|
+
`${dataSourceKey}.${collectionName}.${fieldPath}`,
|
|
114
|
+
) as CollectionField | undefined;
|
|
115
|
+
return collectionField?.title || fieldPath;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function createQuickEditViewContainer(view: QuickEditViewContainer): QuickEditViewContainer {
|
|
119
|
+
let preventClose = false;
|
|
120
|
+
let nextBeforeClose = view.beforeClose;
|
|
121
|
+
const beforeClose: QuickEditViewBeforeCloseHandler = async (payload) => {
|
|
122
|
+
if (preventClose && !payload?.force) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const result = await nextBeforeClose?.(payload);
|
|
127
|
+
return result !== false;
|
|
128
|
+
};
|
|
129
|
+
view.beforeClose = beforeClose;
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
...view,
|
|
133
|
+
close(result, force) {
|
|
134
|
+
return view.close(result, force);
|
|
135
|
+
},
|
|
136
|
+
update(newConfig) {
|
|
137
|
+
if (Object.prototype.hasOwnProperty.call(newConfig, 'preventClose')) {
|
|
138
|
+
preventClose = !!newConfig.preventClose;
|
|
139
|
+
}
|
|
140
|
+
return view.update?.(newConfig);
|
|
141
|
+
},
|
|
142
|
+
get beforeClose() {
|
|
143
|
+
return view.beforeClose;
|
|
144
|
+
},
|
|
145
|
+
set beforeClose(value) {
|
|
146
|
+
nextBeforeClose = value;
|
|
147
|
+
view.beforeClose = beforeClose;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
43
152
|
export class QuickEditFormModel extends FlowModel {
|
|
44
153
|
fieldPath: string;
|
|
45
154
|
|
|
46
155
|
declare resource: SingleRecordResource;
|
|
47
156
|
declare collection: Collection;
|
|
48
157
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
viewContainer: any;
|
|
158
|
+
declare viewContainer: QuickEditViewContainer;
|
|
52
159
|
__onSubmitSuccess;
|
|
53
160
|
_fieldProps: any;
|
|
54
161
|
_onOk: any;
|
|
@@ -89,21 +196,75 @@ export class QuickEditFormModel extends FlowModel {
|
|
|
89
196
|
onOk,
|
|
90
197
|
sourceFieldModelUid,
|
|
91
198
|
} = options;
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
199
|
+
const sourceFieldModel = sourceFieldModelUid ? flowEngine.getModel<FlowModel>(sourceFieldModelUid) : undefined;
|
|
200
|
+
const model = flowEngine.createModel(
|
|
201
|
+
{
|
|
202
|
+
use: 'QuickEditFormModel',
|
|
203
|
+
stepParams: {
|
|
204
|
+
quickEditFormSettings: {
|
|
205
|
+
init: {
|
|
206
|
+
dataSourceKey,
|
|
207
|
+
collectionName,
|
|
208
|
+
fieldPath,
|
|
209
|
+
},
|
|
100
210
|
},
|
|
101
211
|
},
|
|
102
212
|
},
|
|
103
|
-
|
|
213
|
+
sourceFieldModel ? { delegate: sourceFieldModel.context } : undefined,
|
|
214
|
+
) as QuickEditFormModel;
|
|
104
215
|
|
|
105
|
-
|
|
106
|
-
|
|
216
|
+
const bodyStyles = {
|
|
217
|
+
maxHeight: QUICK_EDIT_POPOVER_MAX_HEIGHT,
|
|
218
|
+
overflowY: 'auto',
|
|
219
|
+
overscrollBehavior: 'contain',
|
|
220
|
+
};
|
|
221
|
+
const mobileBodyStyles = {
|
|
222
|
+
...bodyStyles,
|
|
223
|
+
maxHeight: QUICK_EDIT_MOBILE_DRAWER_HEIGHT,
|
|
224
|
+
};
|
|
225
|
+
const content = (view: QuickEditViewContainer, viewContext?: QuickEditViewContext) => {
|
|
226
|
+
if (mobileLayoutState.isMobileLayout) {
|
|
227
|
+
viewContext?.defineProperty?.('isMobileLayout', { value: true });
|
|
228
|
+
}
|
|
229
|
+
model.viewContainer = createQuickEditViewContainer(view);
|
|
230
|
+
model.__onSubmitSuccess = onSuccess;
|
|
231
|
+
model._fieldProps = fieldProps;
|
|
232
|
+
model._onOk = onOk;
|
|
233
|
+
return (
|
|
234
|
+
<FlowModelRenderer
|
|
235
|
+
fallback={<Skeleton.Input size="small" />}
|
|
236
|
+
model={model}
|
|
237
|
+
inputArgs={{ filterByTk, record, sourceFieldModelUid }}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
const mobileLayoutState = getQuickEditMobileLayoutState(flowEngine, sourceFieldModel);
|
|
242
|
+
if (mobileLayoutState.isMobileLayout) {
|
|
243
|
+
model.context.defineProperty('isMobileLayout', { value: true });
|
|
244
|
+
const viewer = sourceFieldModel?.context?.viewer || flowEngine.context.viewer;
|
|
245
|
+
const title = getQuickEditTitle(
|
|
246
|
+
flowEngine,
|
|
247
|
+
dataSourceKey,
|
|
248
|
+
collectionName,
|
|
249
|
+
fieldPath,
|
|
250
|
+
sourceFieldModel,
|
|
251
|
+
fieldProps,
|
|
252
|
+
);
|
|
253
|
+
await viewer.open({
|
|
254
|
+
type: 'drawer',
|
|
255
|
+
title,
|
|
256
|
+
closable: true,
|
|
257
|
+
placement: 'bottom',
|
|
258
|
+
inputArgs: {
|
|
259
|
+
isMobileLayout: true,
|
|
260
|
+
},
|
|
261
|
+
styles: {
|
|
262
|
+
body: mobileBodyStyles,
|
|
263
|
+
},
|
|
264
|
+
content,
|
|
265
|
+
});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
107
268
|
|
|
108
269
|
await flowEngine.context.viewer.open({
|
|
109
270
|
type: 'popover',
|
|
@@ -112,25 +273,10 @@ export class QuickEditFormModel extends FlowModel {
|
|
|
112
273
|
styles: {
|
|
113
274
|
body: {
|
|
114
275
|
width: 420,
|
|
115
|
-
|
|
116
|
-
overflowY: 'auto',
|
|
117
|
-
overscrollBehavior: 'contain',
|
|
276
|
+
...bodyStyles,
|
|
118
277
|
},
|
|
119
278
|
},
|
|
120
|
-
content
|
|
121
|
-
model.viewContainer = popover;
|
|
122
|
-
model.__onSubmitSuccess = onSuccess;
|
|
123
|
-
model._fieldProps = fieldProps;
|
|
124
|
-
model._onOk = onOk;
|
|
125
|
-
console.log('QuickEditFormModel.open3', Date.now() - model.now);
|
|
126
|
-
return (
|
|
127
|
-
<FlowModelRenderer
|
|
128
|
-
fallback={<Skeleton.Input size="small" />}
|
|
129
|
-
model={model}
|
|
130
|
-
inputArgs={{ filterByTk, record, sourceFieldModelUid }}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
},
|
|
279
|
+
content,
|
|
134
280
|
});
|
|
135
281
|
}
|
|
136
282
|
|
|
@@ -171,15 +317,15 @@ export class QuickEditFormModel extends FlowModel {
|
|
|
171
317
|
}
|
|
172
318
|
|
|
173
319
|
render() {
|
|
174
|
-
|
|
175
|
-
|
|
320
|
+
const isMobileLayout = this.context.isMobileLayout;
|
|
176
321
|
return (
|
|
177
322
|
<FormComponent model={this}>
|
|
178
323
|
<div
|
|
179
324
|
style={{
|
|
180
325
|
minHeight: 0,
|
|
181
326
|
overflowY: 'auto',
|
|
182
|
-
maxHeight: QUICK_EDIT_FORM_MAX_HEIGHT,
|
|
327
|
+
maxHeight: isMobileLayout ? QUICK_EDIT_MOBILE_FORM_MAX_HEIGHT : QUICK_EDIT_FORM_MAX_HEIGHT,
|
|
328
|
+
padding: isMobileLayout ? QUICK_EDIT_MOBILE_CONTENT_PADDING : undefined,
|
|
183
329
|
}}
|
|
184
330
|
>
|
|
185
331
|
{this.mapSubModels('fields', (field) => {
|
|
@@ -196,7 +342,14 @@ export class QuickEditFormModel extends FlowModel {
|
|
|
196
342
|
);
|
|
197
343
|
})}
|
|
198
344
|
</div>
|
|
199
|
-
<Space
|
|
345
|
+
<Space
|
|
346
|
+
style={{
|
|
347
|
+
display: 'flex',
|
|
348
|
+
justifyContent: 'flex-end',
|
|
349
|
+
flexShrink: 0,
|
|
350
|
+
padding: isMobileLayout ? QUICK_EDIT_MOBILE_ACTIONS_PADDING : undefined,
|
|
351
|
+
}}
|
|
352
|
+
>
|
|
200
353
|
<Button
|
|
201
354
|
onClick={() => {
|
|
202
355
|
this.viewContainer.close();
|
|
@@ -7,17 +7,365 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
11
|
-
import { FlowEngine, SingleRecordResource } from '@nocobase/flow-engine';
|
|
10
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
11
|
+
import { FlowEngine, FlowModel, SingleRecordResource } from '@nocobase/flow-engine';
|
|
12
12
|
import { QuickEditFormModel } from '../QuickEditFormModel';
|
|
13
13
|
|
|
14
14
|
describe('QuickEditFormModel - quick edit save triggers API (regression)', () => {
|
|
15
15
|
let engine: FlowEngine;
|
|
16
|
+
const originalMatchMediaDescriptor = Object.getOwnPropertyDescriptor(window, 'matchMedia');
|
|
16
17
|
|
|
17
18
|
beforeEach(() => {
|
|
18
19
|
engine = new FlowEngine();
|
|
19
20
|
});
|
|
20
21
|
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
if (originalMatchMediaDescriptor) {
|
|
24
|
+
Object.defineProperty(window, 'matchMedia', originalMatchMediaDescriptor);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
delete (window as unknown as { matchMedia?: Window['matchMedia'] }).matchMedia;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const mockMatchMedia = (matches: boolean) => {
|
|
31
|
+
const matchMediaMock = vi.fn((query: string) => {
|
|
32
|
+
return {
|
|
33
|
+
matches,
|
|
34
|
+
media: query,
|
|
35
|
+
onchange: null,
|
|
36
|
+
addListener: vi.fn(),
|
|
37
|
+
removeListener: vi.fn(),
|
|
38
|
+
addEventListener: vi.fn(),
|
|
39
|
+
removeEventListener: vi.fn(),
|
|
40
|
+
dispatchEvent: vi.fn(),
|
|
41
|
+
} as unknown as MediaQueryList;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
45
|
+
...(originalMatchMediaDescriptor || { configurable: true, writable: true }),
|
|
46
|
+
value: matchMediaMock,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const addUsersCollection = () => {
|
|
51
|
+
const ds = engine.context.dataSourceManager.getDataSource('main');
|
|
52
|
+
ds.addCollection({
|
|
53
|
+
name: 'users',
|
|
54
|
+
fields: [{ name: 'name', type: 'string', interface: 'input', uiSchema: { title: 'Name' } }],
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
it('uses source field context when opening quick edit', async () => {
|
|
59
|
+
engine.registerModels({ QuickEditFormModel });
|
|
60
|
+
engine.context.defineProperty('pageActive', { value: { value: false } });
|
|
61
|
+
engine.context.defineProperty('viewer', { value: { open: vi.fn(async () => undefined) } });
|
|
62
|
+
|
|
63
|
+
const page = engine.createModel<FlowModel>({ use: 'FlowModel', uid: 'page' });
|
|
64
|
+
page.context.defineProperty('pageActive', { value: { value: true } });
|
|
65
|
+
const source = engine.createModel<FlowModel>({ use: 'FlowModel', uid: 'source-field', parentId: page.uid });
|
|
66
|
+
|
|
67
|
+
await QuickEditFormModel.open({
|
|
68
|
+
flowEngine: engine,
|
|
69
|
+
target: document.createElement('div'),
|
|
70
|
+
dataSourceKey: 'main',
|
|
71
|
+
collectionName: 'users',
|
|
72
|
+
fieldPath: 'name',
|
|
73
|
+
record: {},
|
|
74
|
+
sourceFieldModelUid: source.uid,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
let quickEditModel: QuickEditFormModel | undefined;
|
|
78
|
+
engine.forEachModel((model) => {
|
|
79
|
+
if (model instanceof QuickEditFormModel) {
|
|
80
|
+
quickEditModel = model;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(quickEditModel?.context.pageActive.value).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('opens quick edit in a mobile drawer when the source field layout is mobile', async () => {
|
|
88
|
+
engine.registerModels({ QuickEditFormModel });
|
|
89
|
+
addUsersCollection();
|
|
90
|
+
const engineOpen = vi.fn(async () => undefined);
|
|
91
|
+
const sourceOpen = vi.fn(async () => undefined);
|
|
92
|
+
engine.context.defineProperty('isMobileLayout', { value: false });
|
|
93
|
+
engine.context.defineProperty('viewer', { value: { open: engineOpen } });
|
|
94
|
+
const source = engine.createModel<FlowModel>({ use: 'FlowModel', uid: 'source-field' });
|
|
95
|
+
source.context.defineProperty('isMobileLayout', { value: true });
|
|
96
|
+
source.context.defineProperty('viewer', { value: { open: sourceOpen } });
|
|
97
|
+
|
|
98
|
+
await QuickEditFormModel.open({
|
|
99
|
+
flowEngine: engine,
|
|
100
|
+
target: document.createElement('div'),
|
|
101
|
+
dataSourceKey: 'main',
|
|
102
|
+
collectionName: 'users',
|
|
103
|
+
fieldPath: 'name',
|
|
104
|
+
record: {},
|
|
105
|
+
sourceFieldModelUid: source.uid,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(engineOpen).not.toHaveBeenCalled();
|
|
109
|
+
expect(sourceOpen).toHaveBeenCalledTimes(1);
|
|
110
|
+
expect(sourceOpen).toHaveBeenCalledWith(
|
|
111
|
+
expect.objectContaining({
|
|
112
|
+
type: 'drawer',
|
|
113
|
+
title: 'Name',
|
|
114
|
+
closable: true,
|
|
115
|
+
placement: 'bottom',
|
|
116
|
+
styles: {
|
|
117
|
+
body: expect.objectContaining({
|
|
118
|
+
maxHeight: '50vh',
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
inputArgs: {
|
|
122
|
+
isMobileLayout: true,
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
let quickEditModel: QuickEditFormModel | undefined;
|
|
127
|
+
engine.forEachModel((model) => {
|
|
128
|
+
if (model instanceof QuickEditFormModel) {
|
|
129
|
+
quickEditModel = model;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
expect(quickEditModel?.context.isMobileLayout).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('uses the source table column title for the mobile drawer header', async () => {
|
|
136
|
+
engine.registerModels({ QuickEditFormModel });
|
|
137
|
+
addUsersCollection();
|
|
138
|
+
const sourceOpen = vi.fn(async () => undefined);
|
|
139
|
+
engine.context.defineProperty('viewer', { value: { open: vi.fn(async () => undefined) } });
|
|
140
|
+
const column = engine.createModel<FlowModel>({ use: 'FlowModel', uid: 'table-column' });
|
|
141
|
+
column.setProps({ title: 'Custom marital status' });
|
|
142
|
+
const source = engine.createModel<FlowModel>({ use: 'FlowModel', uid: 'source-field', parentId: column.uid });
|
|
143
|
+
source.context.defineProperty('isMobileLayout', { value: true });
|
|
144
|
+
source.context.defineProperty('viewer', { value: { open: sourceOpen } });
|
|
145
|
+
|
|
146
|
+
await QuickEditFormModel.open({
|
|
147
|
+
flowEngine: engine,
|
|
148
|
+
target: document.createElement('div'),
|
|
149
|
+
dataSourceKey: 'main',
|
|
150
|
+
collectionName: 'users',
|
|
151
|
+
fieldPath: 'name',
|
|
152
|
+
record: {},
|
|
153
|
+
sourceFieldModelUid: source.uid,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
expect(sourceOpen).toHaveBeenCalledWith(
|
|
157
|
+
expect.objectContaining({
|
|
158
|
+
type: 'drawer',
|
|
159
|
+
title: 'Custom marital status',
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('uses the mobile drawer fallback on narrow viewports', async () => {
|
|
165
|
+
engine.registerModels({ QuickEditFormModel });
|
|
166
|
+
addUsersCollection();
|
|
167
|
+
mockMatchMedia(true);
|
|
168
|
+
const viewContext = {
|
|
169
|
+
defineProperty: vi.fn(),
|
|
170
|
+
};
|
|
171
|
+
const open = vi.fn(
|
|
172
|
+
async (config: { content: (view: { close: () => void }, context: typeof viewContext) => unknown }) => {
|
|
173
|
+
config.content({ close: vi.fn() }, viewContext);
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
engine.context.defineProperty('viewer', { value: { open } });
|
|
177
|
+
|
|
178
|
+
await QuickEditFormModel.open({
|
|
179
|
+
flowEngine: engine,
|
|
180
|
+
target: document.createElement('div'),
|
|
181
|
+
dataSourceKey: 'main',
|
|
182
|
+
collectionName: 'users',
|
|
183
|
+
fieldPath: 'name',
|
|
184
|
+
record: {},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
expect(open).toHaveBeenCalledTimes(1);
|
|
188
|
+
expect(viewContext.defineProperty).toHaveBeenCalledWith('isMobileLayout', { value: true });
|
|
189
|
+
expect(window.matchMedia).toHaveBeenCalledWith('(max-width: 768px)');
|
|
190
|
+
expect(open).toHaveBeenCalledWith(
|
|
191
|
+
expect.objectContaining({
|
|
192
|
+
type: 'drawer',
|
|
193
|
+
title: 'Name',
|
|
194
|
+
closable: true,
|
|
195
|
+
placement: 'bottom',
|
|
196
|
+
styles: {
|
|
197
|
+
body: expect.objectContaining({
|
|
198
|
+
maxHeight: '50vh',
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
201
|
+
inputArgs: {
|
|
202
|
+
isMobileLayout: true,
|
|
203
|
+
},
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
let quickEditModel: QuickEditFormModel | undefined;
|
|
207
|
+
engine.forEachModel((model) => {
|
|
208
|
+
if (model instanceof QuickEditFormModel) {
|
|
209
|
+
quickEditModel = model;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
expect(quickEditModel?.context.isMobileLayout).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('uses the engine mobile layout context without relying on matchMedia', async () => {
|
|
216
|
+
engine.registerModels({ QuickEditFormModel });
|
|
217
|
+
addUsersCollection();
|
|
218
|
+
mockMatchMedia(false);
|
|
219
|
+
const open = vi.fn(async () => undefined);
|
|
220
|
+
engine.context.defineProperty('isMobileLayout', { value: true });
|
|
221
|
+
engine.context.defineProperty('viewer', { value: { open } });
|
|
222
|
+
|
|
223
|
+
await QuickEditFormModel.open({
|
|
224
|
+
flowEngine: engine,
|
|
225
|
+
target: document.createElement('div'),
|
|
226
|
+
dataSourceKey: 'main',
|
|
227
|
+
collectionName: 'users',
|
|
228
|
+
fieldPath: 'name',
|
|
229
|
+
record: {},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(window.matchMedia).not.toHaveBeenCalled();
|
|
233
|
+
expect(open).toHaveBeenCalledTimes(1);
|
|
234
|
+
expect(open).toHaveBeenCalledWith(
|
|
235
|
+
expect.objectContaining({
|
|
236
|
+
type: 'drawer',
|
|
237
|
+
title: 'Name',
|
|
238
|
+
placement: 'bottom',
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('keeps an explicit non-mobile layout context ahead of the narrow viewport fallback', async () => {
|
|
244
|
+
engine.registerModels({ QuickEditFormModel });
|
|
245
|
+
addUsersCollection();
|
|
246
|
+
mockMatchMedia(true);
|
|
247
|
+
const open = vi.fn(async () => undefined);
|
|
248
|
+
const target = document.createElement('div');
|
|
249
|
+
engine.context.defineProperty('isMobileLayout', { value: false });
|
|
250
|
+
engine.context.defineProperty('viewer', { value: { open } });
|
|
251
|
+
|
|
252
|
+
await QuickEditFormModel.open({
|
|
253
|
+
flowEngine: engine,
|
|
254
|
+
target,
|
|
255
|
+
dataSourceKey: 'main',
|
|
256
|
+
collectionName: 'users',
|
|
257
|
+
fieldPath: 'name',
|
|
258
|
+
record: {},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
expect(window.matchMedia).not.toHaveBeenCalled();
|
|
262
|
+
expect(open).toHaveBeenCalledTimes(1);
|
|
263
|
+
expect(open).toHaveBeenCalledWith(
|
|
264
|
+
expect.objectContaining({
|
|
265
|
+
type: 'popover',
|
|
266
|
+
target,
|
|
267
|
+
placement: 'rightTop',
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('keeps dynamic preventClose effective for mobile quick edit drawer containers', async () => {
|
|
273
|
+
engine.registerModels({ QuickEditFormModel });
|
|
274
|
+
addUsersCollection();
|
|
275
|
+
mockMatchMedia(true);
|
|
276
|
+
const originalBeforeClose = vi.fn(async () => true);
|
|
277
|
+
const drawerView = {
|
|
278
|
+
close: vi.fn(),
|
|
279
|
+
update: vi.fn(),
|
|
280
|
+
beforeClose: originalBeforeClose,
|
|
281
|
+
};
|
|
282
|
+
const open = vi.fn(async (config: { content: (view: typeof drawerView) => unknown }) => {
|
|
283
|
+
config.content(drawerView);
|
|
284
|
+
});
|
|
285
|
+
engine.context.defineProperty('viewer', { value: { open } });
|
|
286
|
+
|
|
287
|
+
await QuickEditFormModel.open({
|
|
288
|
+
flowEngine: engine,
|
|
289
|
+
target: document.createElement('div'),
|
|
290
|
+
dataSourceKey: 'main',
|
|
291
|
+
collectionName: 'users',
|
|
292
|
+
fieldPath: 'name',
|
|
293
|
+
record: {},
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
let quickEditModel: QuickEditFormModel | undefined;
|
|
297
|
+
engine.forEachModel((model) => {
|
|
298
|
+
if (model instanceof QuickEditFormModel) {
|
|
299
|
+
quickEditModel = model;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
quickEditModel?.viewContainer.update?.({ preventClose: true });
|
|
304
|
+
expect(drawerView.update).toHaveBeenCalledWith({ preventClose: true });
|
|
305
|
+
await expect(drawerView.beforeClose?.({ force: false })).resolves.toBe(false);
|
|
306
|
+
expect(originalBeforeClose).not.toHaveBeenCalled();
|
|
307
|
+
|
|
308
|
+
quickEditModel?.viewContainer.update?.({ preventClose: false });
|
|
309
|
+
expect(drawerView.update).toHaveBeenCalledWith({ preventClose: false });
|
|
310
|
+
await expect(drawerView.beforeClose?.({ force: false })).resolves.toBe(true);
|
|
311
|
+
expect(originalBeforeClose).toHaveBeenCalledTimes(1);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('keeps desktop quick edit in the existing right-top popover', async () => {
|
|
315
|
+
engine.registerModels({ QuickEditFormModel });
|
|
316
|
+
mockMatchMedia(false);
|
|
317
|
+
const open = vi.fn(async () => undefined);
|
|
318
|
+
const target = document.createElement('div');
|
|
319
|
+
engine.context.defineProperty('viewer', { value: { open } });
|
|
320
|
+
|
|
321
|
+
await QuickEditFormModel.open({
|
|
322
|
+
flowEngine: engine,
|
|
323
|
+
target,
|
|
324
|
+
dataSourceKey: 'main',
|
|
325
|
+
collectionName: 'users',
|
|
326
|
+
fieldPath: 'name',
|
|
327
|
+
record: {},
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
expect(open).toHaveBeenCalledTimes(1);
|
|
331
|
+
expect(open).toHaveBeenCalledWith(
|
|
332
|
+
expect.objectContaining({
|
|
333
|
+
type: 'popover',
|
|
334
|
+
target,
|
|
335
|
+
placement: 'rightTop',
|
|
336
|
+
styles: {
|
|
337
|
+
body: expect.objectContaining({
|
|
338
|
+
width: 420,
|
|
339
|
+
}),
|
|
340
|
+
},
|
|
341
|
+
}),
|
|
342
|
+
);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('keeps mobile quick edit content naturally sized with half-window scroll bounds', () => {
|
|
346
|
+
engine.registerModels({ QuickEditFormModel });
|
|
347
|
+
const model = engine.createModel<QuickEditFormModel>({
|
|
348
|
+
use: QuickEditFormModel,
|
|
349
|
+
uid: 'quick-edit-style',
|
|
350
|
+
});
|
|
351
|
+
model.context.defineProperty('isMobileLayout', { value: true });
|
|
352
|
+
|
|
353
|
+
const result = QuickEditFormModel.prototype.render.call(model) as any;
|
|
354
|
+
const formBody = result.props.children[0];
|
|
355
|
+
const actions = result.props.children[1];
|
|
356
|
+
|
|
357
|
+
expect(formBody.props.style).toMatchObject({
|
|
358
|
+
maxHeight: 'calc(50vh - var(--nb-mobile-page-header-height, 40px) - 132px)',
|
|
359
|
+
overflowY: 'auto',
|
|
360
|
+
padding: '8px var(--nb-mobile-page-tabs-content-padding, 12px) 0',
|
|
361
|
+
});
|
|
362
|
+
expect(formBody.props.style.minHeight).toBe(0);
|
|
363
|
+
expect(actions.props.style).toMatchObject({
|
|
364
|
+
justifyContent: 'flex-end',
|
|
365
|
+
padding: '8px var(--nb-mobile-page-tabs-content-padding, 12px) calc(80px + env(safe-area-inset-bottom, 0px))',
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
21
369
|
it('calls update with filterByTk and merges primary key from ctx.collection/record', async () => {
|
|
22
370
|
// 1) 准备数据源与集合(含主键字段)
|
|
23
371
|
const dsm = engine.context.dataSourceManager;
|
|
@@ -235,7 +235,7 @@ export class JSBlockModel extends BlockModel {
|
|
|
235
235
|
const cardProps = {
|
|
236
236
|
...rest,
|
|
237
237
|
height,
|
|
238
|
-
style,
|
|
238
|
+
...(style === undefined ? {} : { style }),
|
|
239
239
|
...(beforeContent === undefined ? {} : { beforeContent }),
|
|
240
240
|
...(afterContent === undefined ? {} : { afterContent }),
|
|
241
241
|
};
|
|
@@ -121,10 +121,11 @@ const Columns = observer<any>(({ record, model, index }) => {
|
|
|
121
121
|
fork.context.defineProperty('recordIndex', {
|
|
122
122
|
get: () => index,
|
|
123
123
|
});
|
|
124
|
+
const rendererKey = `${fork.uid}:${fork.forkId}`;
|
|
124
125
|
const renderer = (
|
|
125
126
|
<FlowModelRenderer
|
|
126
127
|
showFlowSettings={{ showBorder: false, toolbarPosition: 'above' }}
|
|
127
|
-
key={
|
|
128
|
+
key={rendererKey}
|
|
128
129
|
model={fork}
|
|
129
130
|
inputArgs={record}
|
|
130
131
|
fallback={<Skeleton.Button size="small" />}
|
|
@@ -244,7 +244,9 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
createResource(ctx, params) {
|
|
247
|
-
|
|
247
|
+
const resource = this.context.createResource(MultiRecordResource);
|
|
248
|
+
resource.addRequestHeader('X-With-ACL-Meta', 'true');
|
|
249
|
+
return resource;
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
/**
|
|
@@ -310,7 +312,7 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
310
312
|
transform: translateY(-50%);
|
|
311
313
|
}
|
|
312
314
|
&:hover {
|
|
313
|
-
|
|
315
|
+
box-shadow: inset 0 0 0 9999px rgba(24, 144, 255, 0.1);
|
|
314
316
|
}
|
|
315
317
|
&:hover .edit-icon {
|
|
316
318
|
display: inline-flex;
|