@nocobase/client-v2 2.2.0-beta.8 → 2.3.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 +3 -0
- package/es/RouteRepository.d.ts +8 -0
- package/es/RouterManager.d.ts +15 -0
- package/es/authRedirect.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -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 +2 -1
- 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 +1 -0
- package/es/entry-actions/EntryActionManager.d.ts +24 -0
- package/es/entry-actions/index.d.ts +9 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +2 -0
- package/es/flow/admin-shell/BaseLayoutModel.d.ts +6 -0
- package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +7 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +2 -1
- package/es/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.d.ts +24 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/useApplications.d.ts +7 -2
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- 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/models/base/ActionModelCore.d.ts +2 -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/routeTransientInputArgs.d.ts +14 -0
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.mjs +279 -158
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/markdownSanitize.d.ts +11 -0
- package/lib/index.js +280 -159
- package/lib/locale/languageCodes.js +2 -1
- package/package.json +8 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +13 -6
- package/src/RouteRepository.ts +25 -0
- package/src/RouterManager.tsx +142 -1
- package/src/__tests__/RouteRepository.test.ts +23 -0
- package/src/__tests__/RouterManager.test.ts +125 -0
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +17 -0
- package/src/__tests__/browserChecker.test.ts +61 -0
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +28 -0
- package/src/authRedirect.ts +38 -0
- 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/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 +23 -6
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +180 -3
- package/src/components/form/ScanInput/useCodeScanner.ts +170 -5
- 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 +1 -0
- package/src/entry-actions/EntryActionManager.ts +76 -0
- package/src/entry-actions/index.ts +10 -0
- package/src/flow/FlowPage.tsx +38 -3
- package/src/flow/__tests__/FlowPage.test.tsx +201 -27
- package/src/flow/__tests__/FlowRoute.test.tsx +549 -4
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +62 -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/__tests__/openView.defineProps.route.test.tsx +80 -20
- package/src/flow/actions/dataScopeFilter.ts +10 -1
- package/src/flow/actions/dateTimeFormat.tsx +2 -2
- package/src/flow/actions/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +86 -11
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/actions/openView.tsx +21 -1
- package/src/flow/admin-shell/BaseLayoutModel.tsx +124 -0
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +184 -42
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +1016 -119
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +41 -5
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +177 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +20 -0
- package/src/flow/admin-shell/admin-layout/AppListRender.tsx +13 -2
- package/src/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.tsx +289 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +436 -2
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +48 -0
- package/src/flow/admin-shell/admin-layout/index.ts +1 -0
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +81 -12
- package/src/flow/common/Markdown/Display.tsx +14 -3
- package/src/flow/common/Markdown/Edit.tsx +19 -7
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +134 -18
- 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 +1 -0
- package/src/flow/internal/components/Markdown/util.ts +2 -1
- package/src/flow/models/base/ActionModel.tsx +10 -8
- package/src/flow/models/base/ActionModelCore.tsx +5 -0
- 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 +184 -3
- 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 +572 -1
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +1 -0
- 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 +34 -0
- 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/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +1 -1
- package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
- package/src/flow/models/fields/TextareaFieldModel.tsx +42 -19
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +32 -1
- 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 +78 -3
- package/src/flow/routeTransientInputArgs.ts +27 -0
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +6 -0
- package/src/locale/languageCodes.ts +2 -1
- package/src/nocobase-buildin-plugin/index.tsx +19 -1
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
- package/src/utils/markdownSanitize.ts +88 -0
package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts
CHANGED
|
@@ -33,6 +33,42 @@ class DummyCollectionBlockModel extends CollectionBlockModel {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
describe('FilterFormItemModel defineChildren association fields', () => {
|
|
36
|
+
it('hides default operator setting for association filter fields', () => {
|
|
37
|
+
const engine = new FlowEngine();
|
|
38
|
+
engine.registerModels({
|
|
39
|
+
FilterFormItemModel,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const filterItem = engine.createModel<FilterFormItemModel>({
|
|
43
|
+
uid: 'association-filter-item-settings',
|
|
44
|
+
use: 'FilterFormItemModel',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const defaultOperatorStep = filterItem.getFlow('filterFormItemSettings')?.steps?.defaultOperator as {
|
|
48
|
+
hideInSettings?: (ctx: {
|
|
49
|
+
collectionField?: unknown;
|
|
50
|
+
model?: {
|
|
51
|
+
subModels?: {
|
|
52
|
+
field?: {
|
|
53
|
+
context?: {
|
|
54
|
+
collectionField?: unknown;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}) => boolean;
|
|
60
|
+
};
|
|
61
|
+
expect(defaultOperatorStep?.hideInSettings?.({ collectionField: { isAssociationField: () => true } })).toBe(true);
|
|
62
|
+
expect(
|
|
63
|
+
defaultOperatorStep?.hideInSettings?.({
|
|
64
|
+
model: { subModels: { field: { context: { collectionField: { target: 'departments' } } } } },
|
|
65
|
+
}),
|
|
66
|
+
).toBe(true);
|
|
67
|
+
expect(defaultOperatorStep?.hideInSettings?.({ collectionField: { interface: 'input', type: 'string' } })).toBe(
|
|
68
|
+
false,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
36
72
|
it('groups association target fields and supports recursive paths', async () => {
|
|
37
73
|
const engine = new FlowEngine();
|
|
38
74
|
engine.registerModels({
|
|
@@ -301,6 +301,40 @@ describe('filter-form defaultValues wiring', () => {
|
|
|
301
301
|
expect(values.username_user).toBe('Manual');
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
+
it('does not reapply a filter form default value after user clears the field', async () => {
|
|
305
|
+
const { model, values } = createFilterFormDefaultValuesModel([
|
|
306
|
+
{
|
|
307
|
+
key: 'username-default',
|
|
308
|
+
enable: true,
|
|
309
|
+
targetPath: 'username',
|
|
310
|
+
mode: 'default',
|
|
311
|
+
value: 'admin',
|
|
312
|
+
},
|
|
313
|
+
]);
|
|
314
|
+
|
|
315
|
+
await FilterFormBlockModel.prototype.applyFormDefaultValues.call(model as any);
|
|
316
|
+
expect(values.username_user).toBe('admin');
|
|
317
|
+
|
|
318
|
+
values.username_user = undefined;
|
|
319
|
+
(model as any).handleFilterFormValuesChange({ username_user: undefined }, { username_user: undefined });
|
|
320
|
+
|
|
321
|
+
await waitFor(() => {
|
|
322
|
+
expect(model.dispatchEvent).toHaveBeenCalledWith(
|
|
323
|
+
'formValuesChange',
|
|
324
|
+
{
|
|
325
|
+
changedValues: {
|
|
326
|
+
username_user: undefined,
|
|
327
|
+
},
|
|
328
|
+
allValues: {
|
|
329
|
+
username_user: undefined,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
{ debounce: true },
|
|
333
|
+
);
|
|
334
|
+
});
|
|
335
|
+
expect(values.username_user).toBeUndefined();
|
|
336
|
+
});
|
|
337
|
+
|
|
304
338
|
it('applies fixed values even when the target filter field already has a value', async () => {
|
|
305
339
|
const { model, values } = createFilterFormDefaultValuesModel(
|
|
306
340
|
[
|
|
@@ -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();
|