@nocobase/client-v2 2.4.0-alpha.2 → 2.4.0-alpha.20
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/README.md +4 -4
- package/es/RouteRepository.d.ts +6 -0
- package/es/components/form/ScanInput/useCodeScanner.d.ts +12 -2
- package/es/components/form/ScanInput/zxingWasmDecoder.d.ts +9 -0
- package/es/components/form/VariableInput.d.ts +1 -0
- package/es/flow/FlowModelRepository.d.ts +4 -1
- package/es/flow/FlowPage.d.ts +1 -1
- package/es/flow/admin-shell/admin-layout/MobileTopbarActionsContext.d.ts +10 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +2 -0
- package/es/flow/components/field-value-variable/FieldValueVariableInput.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +10 -1
- package/es/flow/internal/utils/quickEditDataScope.d.ts +48 -0
- package/es/flow/internal/utils/quickEditViewContainer.d.ts +27 -0
- package/es/flow/models/actions/LinkActionUtils.d.ts +1 -0
- package/es/flow/models/actions/getHasManyDeleteFilterByTk.d.ts +12 -0
- package/es/flow/models/base/PageModel/closeGuard.d.ts +8 -1
- package/es/flow/models/blocks/assign-form/assignFormValue.d.ts +29 -0
- package/es/flow/models/blocks/form/EditFormModel.d.ts +2 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +1 -0
- package/es/flow/models/blocks/table/sortUtils.d.ts +3 -0
- package/es/flow/models/topbar/UserCenterTopbarActionModel.d.ts +2 -0
- package/es/flow/useRouteContentRequest.d.ts +20 -0
- package/es/index.mjs +141 -104
- package/lib/index.js +178 -141
- package/package.json +9 -8
- package/src/BaseApplication.tsx +2 -0
- package/src/RouteRepository.ts +14 -0
- package/src/__tests__/RouteRepository.test.ts +51 -0
- package/src/__tests__/app.test.tsx +13 -0
- package/src/collection-manager/__tests__/field-configure.test.ts +52 -0
- package/src/collection-manager/field-configure.ts +2 -2
- package/src/components/form/ScanInput/CodeScanner.tsx +3 -1
- package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +7 -1
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +182 -8
- package/src/components/form/ScanInput/__tests__/zxingWasmDecoder.test.ts +78 -0
- package/src/components/form/ScanInput/useCodeScanner.ts +135 -20
- package/src/components/form/ScanInput/zxingWasmDecoder.ts +64 -0
- package/src/components/form/VariableInput.tsx +1 -0
- package/src/flow/FlowModelRepository.ts +47 -1
- package/src/flow/FlowPage.tsx +25 -10
- package/src/flow/__tests__/FlowModelRepository.test.ts +38 -1
- package/src/flow/__tests__/FlowPage.test.tsx +78 -46
- package/src/flow/actions/__tests__/validation.test.ts +48 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +8 -1
- package/src/flow/admin-shell/admin-layout/HelpLite.tsx +5 -1
- package/src/flow/admin-shell/admin-layout/MobileTopbarActionsContext.ts +13 -0
- package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +13 -2
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.mobile.test.tsx +259 -0
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +39 -0
- package/src/flow/components/FieldAssignValueInput.tsx +4 -0
- package/src/flow/components/field-value-variable/FieldValueVariableInput.tsx +21 -12
- package/src/flow/components/field-value-variable/__tests__/FieldValueVariableInput.test.tsx +9 -0
- package/src/flow/components/filter/VariableFilterItem.tsx +14 -4
- package/src/flow/components/filter/__tests__/VariableFilterItem.rightMetaTree.test.tsx +158 -0
- package/src/flow/flows/editMarkdownFlow.tsx +1 -1
- package/src/flow/internal/utils/__tests__/quickEditDataScope.test.ts +156 -0
- package/src/flow/internal/utils/__tests__/quickEditViewContainer.test.ts +52 -0
- package/src/flow/internal/utils/quickEditDataScope.tsx +177 -0
- package/src/flow/internal/utils/quickEditViewContainer.ts +46 -0
- package/src/flow/models/actions/BulkDeleteActionModel.tsx +13 -2
- package/src/flow/models/actions/DeleteActionModel.tsx +16 -2
- package/src/flow/models/actions/JSItemActionModel.tsx +19 -3
- package/src/flow/models/actions/LinkActionModel.tsx +11 -9
- package/src/flow/models/actions/LinkActionUtils.ts +4 -2
- package/src/flow/models/actions/__tests__/DeleteActionModel.test.ts +256 -0
- package/src/flow/models/actions/__tests__/JSItemActionModel.test.tsx +47 -1
- package/src/flow/models/actions/__tests__/LinkActionModel.test.ts +14 -0
- package/src/flow/models/actions/getHasManyDeleteFilterByTk.ts +40 -0
- package/src/flow/models/base/GridModel.tsx +0 -1
- package/src/flow/models/base/PageModel/PageTabModel.tsx +27 -12
- package/src/flow/models/base/PageModel/closeGuard.ts +9 -8
- package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +22 -1
- package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +40 -12
- package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.editor.test.tsx +140 -0
- package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.multipleSelect.test.tsx +216 -0
- package/src/flow/models/blocks/assign-form/__tests__/assignFormValue.test.ts +41 -0
- package/src/flow/models/blocks/assign-form/assignFormValue.ts +64 -0
- package/src/flow/models/blocks/details/DetailsItemModel.tsx +62 -1
- package/src/flow/models/blocks/details/__tests__/DetailsItemModel.spacing.test.tsx +77 -0
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormGridModel.toggleFormFieldsCollapse.test.ts +29 -0
- package/src/flow/models/blocks/filter-form/fields/FieldComponentProps.tsx +1 -1
- package/src/flow/models/blocks/filter-form/fields/__tests__/FieldComponentProps.options.test.tsx +61 -0
- package/src/flow/models/blocks/form/EditFormModel.tsx +23 -1
- package/src/flow/models/blocks/form/FormBlockModel.tsx +26 -5
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +45 -11
- package/src/flow/models/blocks/form/__tests__/EditFormModel.pagination.test.tsx +77 -0
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +145 -0
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +120 -0
- package/src/flow/models/blocks/form/__tests__/popupLinkage.test.tsx +175 -0
- package/src/flow/models/blocks/js-block/JSBlock.tsx +5 -1
- package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +23 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +4 -10
- package/src/flow/models/blocks/table/TableColumnModel.tsx +31 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +64 -0
- package/src/flow/models/blocks/table/__tests__/sortUtils.test.ts +11 -1
- package/src/flow/models/blocks/table/sortUtils.ts +10 -0
- package/src/flow/models/fields/AssociationFieldModel/CascadeSelectFieldModel.tsx +11 -2
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +4 -3
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +13 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +47 -17
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +6 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableColumnModel.largeField.test.tsx +178 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableField.disabled.test.tsx +90 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordSelectFieldModel.quickCreatePopup.test.tsx +183 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/associationSelect.search.test.ts +113 -0
- package/src/flow/models/fields/DisplayAssociationField/DisplaySubTableFieldModel.tsx +42 -7
- package/src/flow/models/fields/DisplayAssociationField/__tests__/DisplaySubTableFieldModel.test.tsx +351 -0
- package/src/flow/models/fields/InputFieldModel.tsx +1 -1
- package/src/flow/models/fields/SelectFieldModel.tsx +5 -0
- package/src/flow/models/fields/__tests__/InputFieldModel.test.tsx +16 -0
- package/src/flow/models/fields/__tests__/SelectFieldModel.test.tsx +29 -1
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +1 -0
- package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +20 -0
- package/src/flow/models/topbar/UserCenterTopbarActionModel.tsx +64 -30
- package/src/flow/useRouteContentRequest.tsx +46 -0
package/src/flow/models/blocks/assign-form/__tests__/assignFieldValuesFlow.multipleSelect.test.tsx
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
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 React from 'react';
|
|
11
|
+
import { App, ConfigProvider } from 'antd';
|
|
12
|
+
import { describe, expect, it } from 'vitest';
|
|
13
|
+
import { render, waitFor } from '@nocobase/test/client';
|
|
14
|
+
import {
|
|
15
|
+
FlowEngine,
|
|
16
|
+
FlowEngineProvider,
|
|
17
|
+
FlowRuntimeContext,
|
|
18
|
+
FlowSettingsContextProvider,
|
|
19
|
+
type FlowModel,
|
|
20
|
+
type IFlowModelRepository,
|
|
21
|
+
} from '@nocobase/flow-engine';
|
|
22
|
+
import { AssignFormGridModel } from '../AssignFormGridModel';
|
|
23
|
+
import { AssignFormItemModel } from '../AssignFormItemModel';
|
|
24
|
+
import { AssignFormModel } from '../AssignFormModel';
|
|
25
|
+
import { createAssignFieldValuesStep } from '../assignFieldValuesFlow';
|
|
26
|
+
import { InputFieldModel } from '../../../fields/InputFieldModel';
|
|
27
|
+
import { SelectFieldModel } from '../../../fields/SelectFieldModel';
|
|
28
|
+
import { VariableFieldFormModel } from '../../../fields/VariableFieldFormModel';
|
|
29
|
+
|
|
30
|
+
class MockFlowModelRepository implements IFlowModelRepository {
|
|
31
|
+
async findOne(): Promise<Record<string, any> | null> {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async save(model: FlowModel): Promise<Record<string, any>> {
|
|
36
|
+
return { uid: model.uid };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async destroy(): Promise<boolean> {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async move(): Promise<void> {}
|
|
44
|
+
|
|
45
|
+
async duplicate(): Promise<Record<string, any> | null> {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createEngine() {
|
|
51
|
+
const engine = new FlowEngine();
|
|
52
|
+
engine.setModelRepository(new MockFlowModelRepository());
|
|
53
|
+
engine.registerModels({
|
|
54
|
+
AssignFormModel,
|
|
55
|
+
AssignFormGridModel,
|
|
56
|
+
AssignFormItemModel,
|
|
57
|
+
InputFieldModel,
|
|
58
|
+
SelectFieldModel,
|
|
59
|
+
VariableFieldFormModel,
|
|
60
|
+
});
|
|
61
|
+
engine.context.defineProperty('location', { value: { search: '' } });
|
|
62
|
+
engine.context.defineProperty('themeToken', { value: { marginLG: 24 } });
|
|
63
|
+
return engine;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function addMultipleSelectCollection(engine: FlowEngine) {
|
|
67
|
+
const dsm = engine.context.dataSourceManager;
|
|
68
|
+
const main = dsm.getDataSource('main');
|
|
69
|
+
main.addCollection({
|
|
70
|
+
name: 'assign_multiple_select',
|
|
71
|
+
fields: [
|
|
72
|
+
{
|
|
73
|
+
name: 'tags',
|
|
74
|
+
type: 'array',
|
|
75
|
+
interface: 'multipleSelect',
|
|
76
|
+
uiSchema: {
|
|
77
|
+
type: 'array',
|
|
78
|
+
'x-component': 'Select',
|
|
79
|
+
'x-component-props': { mode: 'multiple' },
|
|
80
|
+
enum: [
|
|
81
|
+
{ value: 'a', label: 'A' },
|
|
82
|
+
{ value: 'b', label: 'B' },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
// Fields created before the interface default was persisted may miss `mode`.
|
|
88
|
+
name: 'legacyTags',
|
|
89
|
+
type: 'array',
|
|
90
|
+
interface: 'multipleSelect',
|
|
91
|
+
uiSchema: {
|
|
92
|
+
type: 'array',
|
|
93
|
+
'x-component': 'Select',
|
|
94
|
+
enum: [{ value: 'c', label: 'C' }],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'tagMode',
|
|
99
|
+
type: 'array',
|
|
100
|
+
interface: 'multipleSelect',
|
|
101
|
+
uiSchema: {
|
|
102
|
+
type: 'array',
|
|
103
|
+
'x-component': 'Select',
|
|
104
|
+
'x-component-props': { mode: 'tags' },
|
|
105
|
+
enum: [{ value: 't', label: 'T' }],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'single',
|
|
110
|
+
type: 'string',
|
|
111
|
+
interface: 'select',
|
|
112
|
+
uiSchema: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
'x-component': 'Select',
|
|
115
|
+
enum: [{ value: 'x', label: 'X' }],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{ name: 'nickname', type: 'string', interface: 'input' },
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
return dsm.getCollection('main', 'assign_multiple_select');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function renderAssignEditor(engine: FlowEngine, action: FlowModel) {
|
|
125
|
+
const step = createAssignFieldValuesStep({ settingsFlowKey: 'assignSettings' });
|
|
126
|
+
const Editor = step.uiSchema().editor?.['x-component'] as React.ComponentType;
|
|
127
|
+
const flowSettingsCtx = new FlowRuntimeContext(action as any, 'assignSettings', 'settings');
|
|
128
|
+
|
|
129
|
+
render(
|
|
130
|
+
<FlowEngineProvider engine={engine}>
|
|
131
|
+
<ConfigProvider>
|
|
132
|
+
<App>
|
|
133
|
+
<FlowSettingsContextProvider value={flowSettingsCtx}>
|
|
134
|
+
<Editor />
|
|
135
|
+
</FlowSettingsContextProvider>
|
|
136
|
+
</App>
|
|
137
|
+
</ConfigProvider>
|
|
138
|
+
</FlowEngineProvider>,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
describe('assignFieldValuesFlow multipleSelect', () => {
|
|
143
|
+
it('renders multipleSelect as multi select and normalizes historical scalar values', async () => {
|
|
144
|
+
const engine = createEngine();
|
|
145
|
+
const collection = addMultipleSelectCollection(engine);
|
|
146
|
+
|
|
147
|
+
const action = engine.createModel({ use: 'FlowModel', uid: 'act-assign-multiple-select' });
|
|
148
|
+
action.setStepParams('assignSettings', 'assignFieldValues', {
|
|
149
|
+
assignedValues: {
|
|
150
|
+
tags: 'a',
|
|
151
|
+
legacyTags: 'c',
|
|
152
|
+
tagMode: 't',
|
|
153
|
+
single: 'x',
|
|
154
|
+
nickname: 'hello',
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
action.context.defineProperty('blockModel', { value: { collection } });
|
|
158
|
+
|
|
159
|
+
const tempFields: any[] = [];
|
|
160
|
+
const originalCreateModel = engine.createModel.bind(engine);
|
|
161
|
+
(engine as any).createModel = (options: any) => {
|
|
162
|
+
const model = originalCreateModel(options);
|
|
163
|
+
if (options?.use === 'VariableFieldFormModel') {
|
|
164
|
+
tempFields.push(model);
|
|
165
|
+
}
|
|
166
|
+
return model;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
await renderAssignEditor(engine, action);
|
|
170
|
+
|
|
171
|
+
await waitFor(() => {
|
|
172
|
+
const form = engine.findModelByParentId<AssignFormModel>(action.uid, 'assignForm');
|
|
173
|
+
expect(form?.subModels.grid.subModels.items || []).toHaveLength(5);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const form = engine.findModelByParentId<AssignFormModel>(action.uid, 'assignForm');
|
|
177
|
+
await waitFor(() => {
|
|
178
|
+
expect(form?.getAssignedValues()).toEqual({
|
|
179
|
+
tags: ['a'],
|
|
180
|
+
legacyTags: ['c'],
|
|
181
|
+
tagMode: ['t'],
|
|
182
|
+
single: 'x',
|
|
183
|
+
nickname: 'hello',
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
await waitFor(() => {
|
|
188
|
+
// All three multipleSelect fields must render as antd multi select, including the
|
|
189
|
+
// field without schema `mode`; the normal select stays single.
|
|
190
|
+
expect(document.querySelectorAll('.ant-select-multiple')).toHaveLength(3);
|
|
191
|
+
expect(document.querySelectorAll('.ant-select-single').length).toBeGreaterThanOrEqual(1);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const findTempField = (fieldPath: string) =>
|
|
195
|
+
tempFields
|
|
196
|
+
.map((root) => root?.subModels?.fields?.[0])
|
|
197
|
+
.find((field) => field?.getStepParams?.('fieldSettings', 'init')?.fieldPath === fieldPath);
|
|
198
|
+
await waitFor(() => {
|
|
199
|
+
expect(findTempField('tags')?.props?.onChange).toBeTypeOf('function');
|
|
200
|
+
expect(findTempField('tags')?.props?.mode).toBe('multiple');
|
|
201
|
+
expect(findTempField('legacyTags')?.props?.mode).toBe('multiple');
|
|
202
|
+
// An explicit schema mode must be preserved by the fallback.
|
|
203
|
+
expect(findTempField('tagMode')?.props?.mode).toBe('tags');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
findTempField('tags').props.onChange(['a', 'b']);
|
|
207
|
+
await waitFor(() => {
|
|
208
|
+
expect(form?.getAssignedValues()).toMatchObject({ tags: ['a', 'b'], single: 'x' });
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
findTempField('tags').props.onChange('');
|
|
212
|
+
await waitFor(() => {
|
|
213
|
+
expect(form?.getAssignedValues()).toMatchObject({ tags: [] });
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { isArrayValueField, normalizeAssignFormValue } from '../assignFormValue';
|
|
12
|
+
|
|
13
|
+
describe('assignFormValue', () => {
|
|
14
|
+
it('detects array-valued fields', () => {
|
|
15
|
+
expect(isArrayValueField({ interface: 'multipleSelect' })).toBe(true);
|
|
16
|
+
expect(isArrayValueField({ interface: 'checkboxGroup' })).toBe(true);
|
|
17
|
+
expect(isArrayValueField({ uiSchema: { type: 'array' } })).toBe(true);
|
|
18
|
+
expect(isArrayValueField({ interface: 'select', uiSchema: { type: 'string' } })).toBe(false);
|
|
19
|
+
expect(isArrayValueField(undefined)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('wraps scalar constants for array fields', () => {
|
|
23
|
+
expect(normalizeAssignFormValue('a', true)).toEqual(['a']);
|
|
24
|
+
expect(normalizeAssignFormValue(0, true)).toEqual([0]);
|
|
25
|
+
expect(normalizeAssignFormValue(false, true)).toEqual([false]);
|
|
26
|
+
expect(normalizeAssignFormValue(['a', 'b'], true)).toEqual(['a', 'b']);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('keeps non-constant and empty values unchanged', () => {
|
|
30
|
+
expect(normalizeAssignFormValue('', true)).toEqual([]);
|
|
31
|
+
expect(normalizeAssignFormValue(null, true)).toBeNull();
|
|
32
|
+
expect(normalizeAssignFormValue(undefined, true)).toBeUndefined();
|
|
33
|
+
expect(normalizeAssignFormValue('{{ ctx.record.name }}', true)).toBe('{{ ctx.record.name }}');
|
|
34
|
+
expect(normalizeAssignFormValue({ code: 'return 1;' }, true)).toEqual({ code: 'return 1;' });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('does not touch non-array fields', () => {
|
|
38
|
+
expect(normalizeAssignFormValue('a', false)).toBe('a');
|
|
39
|
+
expect(normalizeAssignFormValue(['a'], false)).toEqual(['a']);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { isRunJSValue, isVariableExpression } from '@nocobase/flow-engine';
|
|
11
|
+
|
|
12
|
+
type ArrayValueCollectionField =
|
|
13
|
+
| {
|
|
14
|
+
interface?: string;
|
|
15
|
+
uiSchema?: {
|
|
16
|
+
type?: string;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
| null
|
|
20
|
+
| undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fields whose stored value is an array. Besides `multipleSelect`/`checkboxGroup`,
|
|
24
|
+
* some legacy fields declare `uiSchema.type === 'array'` explicitly.
|
|
25
|
+
*/
|
|
26
|
+
export function isArrayValueField(collectionField: ArrayValueCollectionField): boolean {
|
|
27
|
+
if (!collectionField) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (collectionField.interface === 'multipleSelect' || collectionField.interface === 'checkboxGroup') {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return collectionField.uiSchema?.type === 'array';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a constant assignment value for array-valued fields.
|
|
38
|
+
*
|
|
39
|
+
* Historical configurations may store a scalar (before the multi-select control
|
|
40
|
+
* was rendered correctly), so wrap it into an array instead of submitting a
|
|
41
|
+
* string to the server. Variable expressions, RunJS values, Null and empty
|
|
42
|
+
* values are kept as-is so the assignment mode is not changed.
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeAssignFormValue(value: unknown, arrayValueField: boolean): unknown {
|
|
45
|
+
if (!arrayValueField) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
if (isVariableExpression(value) || isRunJSValue(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (value === '') {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
if (value === null || typeof value === 'undefined') {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
61
|
+
return [value];
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { css, cx } from '@emotion/css';
|
|
10
11
|
import {
|
|
11
12
|
Collection,
|
|
12
13
|
DisplayItemModel,
|
|
@@ -14,6 +15,8 @@ import {
|
|
|
14
15
|
FieldModelRenderer,
|
|
15
16
|
FlowModelContext,
|
|
16
17
|
FormItem,
|
|
18
|
+
formItemStyle,
|
|
19
|
+
untracked,
|
|
17
20
|
} from '@nocobase/flow-engine';
|
|
18
21
|
import { get, castArray } from 'lodash';
|
|
19
22
|
import React from 'react';
|
|
@@ -22,6 +25,49 @@ import { DetailsGridModel } from './DetailsGridModel';
|
|
|
22
25
|
import { rebuildFieldSubModel } from '../../../internal/utils/rebuildFieldSubModel';
|
|
23
26
|
import { isToManyAssociationField } from '../../../internal/utils/modelUtils';
|
|
24
27
|
|
|
28
|
+
function mobileHorizontalItemStyle(marginBottom: number) {
|
|
29
|
+
return css`
|
|
30
|
+
&&.ant-form-item {
|
|
31
|
+
margin-bottom: ${formItemStyle.marginBottom}px;
|
|
32
|
+
|
|
33
|
+
@media (max-width: 575px) {
|
|
34
|
+
margin-bottom: ${marginBottom}px;
|
|
35
|
+
min-height: ${32 - marginBottom}px;
|
|
36
|
+
|
|
37
|
+
> .ant-form-item-row > .ant-form-item-label {
|
|
38
|
+
padding-bottom: 0;
|
|
39
|
+
line-height: max(20px, 1.4em);
|
|
40
|
+
|
|
41
|
+
> label {
|
|
42
|
+
height: auto;
|
|
43
|
+
line-height: max(20px, 1.4em);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
> .ant-form-item-row > .ant-form-item-control > .ant-form-item-control-input {
|
|
48
|
+
min-height: 20px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const mobileSpacingByBlock = new Map([
|
|
56
|
+
['DetailsBlockModel', mobileHorizontalItemStyle(3)],
|
|
57
|
+
['GridCardBlockModel', mobileHorizontalItemStyle(8)],
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const mobilePlainTextStyle = css`
|
|
61
|
+
@media (max-width: 575px) {
|
|
62
|
+
> .ant-form-item-row
|
|
63
|
+
> .ant-form-item-control
|
|
64
|
+
> .ant-form-item-control-input
|
|
65
|
+
> .ant-form-item-control-input-content {
|
|
66
|
+
line-height: max(20px, 1.4em);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
25
71
|
/**
|
|
26
72
|
* 从 record 中取值
|
|
27
73
|
* @param record 当前行数据
|
|
@@ -217,8 +263,23 @@ export class DetailsItemModel extends DisplayItemModel<{
|
|
|
217
263
|
idx,
|
|
218
264
|
}),
|
|
219
265
|
);
|
|
266
|
+
const spacing =
|
|
267
|
+
this.context.isMobileLayout && mergedProps.layout === 'horizontal'
|
|
268
|
+
? mobileSpacingByBlock.get(this.context.blockModel.use)
|
|
269
|
+
: undefined;
|
|
270
|
+
const isPlainText =
|
|
271
|
+
spacing &&
|
|
272
|
+
modelForRender?.use === 'DisplayTextFieldModel' &&
|
|
273
|
+
(mergedProps.displayStyle ??
|
|
274
|
+
fieldModel.getStepParams('displayFieldSettings', 'displayStyle')?.displayStyle ??
|
|
275
|
+
// FieldModelRenderer writes back fork props after rendering. Subscribing here would render the item again.
|
|
276
|
+
untracked(() => modelForRender.props.displayStyle)) !== 'tag';
|
|
220
277
|
return (
|
|
221
|
-
<FormItem
|
|
278
|
+
<FormItem
|
|
279
|
+
{...mergedProps}
|
|
280
|
+
itemMarginClassName={spacing && cx(spacing, isPlainText && mobilePlainTextStyle)}
|
|
281
|
+
value={value}
|
|
282
|
+
>
|
|
222
283
|
<FieldModelRenderer model={modelForRender} />
|
|
223
284
|
</FormItem>
|
|
224
285
|
);
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { FlowEngine, FlowModel, Tracker } from '@nocobase/flow-engine';
|
|
11
|
+
import { render } from '@testing-library/react';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { expect, it, vi } from 'vitest';
|
|
14
|
+
import { DetailsItemModel } from '../DetailsItemModel';
|
|
15
|
+
|
|
16
|
+
it.each([
|
|
17
|
+
['DetailsBlockModel', true, 'horizontal', 'DisplayTextFieldModel', 'text', '3px', '29px', true],
|
|
18
|
+
['GridCardBlockModel', true, 'horizontal', 'DisplayTextFieldModel', 'text', '8px', '24px', true],
|
|
19
|
+
['GridCardBlockModel', true, 'horizontal', 'DisplayTextFieldModel', 'tag', '8px', '24px', false],
|
|
20
|
+
['DetailsBlockModel', true, 'horizontal', 'DisplayHtmlFieldModel', 'text', '3px', '29px', false],
|
|
21
|
+
['CCTaskCardDetailsModel', true, 'horizontal', 'DisplayTextFieldModel', 'text', '', '', false],
|
|
22
|
+
['DetailsBlockModel', false, 'horizontal', 'DisplayTextFieldModel', 'text', '', '', false],
|
|
23
|
+
['GridCardBlockModel', true, 'vertical', 'DisplayTextFieldModel', 'text', '', '', false],
|
|
24
|
+
] as const)(
|
|
25
|
+
'selects phone styles for %s, mobile=%s, %s, %s (%s)',
|
|
26
|
+
(block, mobile, layout, field, displayStyle, margin, minHeight, plainText) => {
|
|
27
|
+
const engine = new FlowEngine();
|
|
28
|
+
engine.registerModels({ [field]: FlowModel });
|
|
29
|
+
const model = new DetailsItemModel({ uid: 'detail-field', flowEngine: engine });
|
|
30
|
+
model.context.defineProperty('blockModel', { value: { use: block, props: { layout } } });
|
|
31
|
+
model.context.defineProperty('isMobileLayout', { value: mobile });
|
|
32
|
+
model.setProps('label', 'Name');
|
|
33
|
+
model.setStepParams('fieldSettings', 'init', { fieldPath: 'name' });
|
|
34
|
+
model.setSubModel('field', { use: field, props: { displayStyle } });
|
|
35
|
+
|
|
36
|
+
const { container } = render(React.cloneElement(model.renderItem(), {}, <span>Value</span>));
|
|
37
|
+
const item = container.querySelector<HTMLElement>('.ant-form-item');
|
|
38
|
+
const value = item.querySelector('.ant-form-item-control-input-content');
|
|
39
|
+
const rules = Array.from(document.styleSheets).flatMap((sheet) => Array.from(sheet.cssRules));
|
|
40
|
+
const narrowRules = rules.flatMap((rule) =>
|
|
41
|
+
rule instanceof CSSMediaRule && rule.conditionText === '(max-width: 575px)' ? Array.from(rule.cssRules) : [],
|
|
42
|
+
);
|
|
43
|
+
const declarations = (element: Element, property: string) =>
|
|
44
|
+
narrowRules
|
|
45
|
+
.flatMap((rule) =>
|
|
46
|
+
rule instanceof CSSStyleRule && element.matches(rule.selectorText)
|
|
47
|
+
? [rule.style.getPropertyValue(property)]
|
|
48
|
+
: [],
|
|
49
|
+
)
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
|
|
52
|
+
expect(item.style.marginBottom).toBe(margin ? '' : '12px');
|
|
53
|
+
expect(declarations(item, 'margin-bottom')).toEqual(margin ? [margin] : []);
|
|
54
|
+
expect(declarations(item, 'min-height')).toEqual(minHeight ? [minHeight] : []);
|
|
55
|
+
expect(declarations(value, 'line-height')).toEqual(plainText ? ['max(20px, 1.4em)'] : []);
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
it('does not subscribe the grid card item to field renderer prop writes', () => {
|
|
60
|
+
const engine = new FlowEngine();
|
|
61
|
+
engine.registerModels({ DisplayTextFieldModel: FlowModel });
|
|
62
|
+
const item = new DetailsItemModel({ uid: 'card-field', flowEngine: engine });
|
|
63
|
+
item.context.defineProperty('blockModel', { value: { use: 'GridCardBlockModel', props: { layout: 'horizontal' } } });
|
|
64
|
+
item.context.defineProperty('isMobileLayout', { value: true });
|
|
65
|
+
item.context.defineProperty('fieldIndex', { value: 0 });
|
|
66
|
+
item.setStepParams('fieldSettings', 'init', { fieldPath: 'name' });
|
|
67
|
+
const field = item.setSubModel('field', { use: 'DisplayTextFieldModel' });
|
|
68
|
+
const invalidate = vi.fn();
|
|
69
|
+
const tracker = new Tracker(invalidate);
|
|
70
|
+
try {
|
|
71
|
+
tracker.track(() => item.renderItem());
|
|
72
|
+
field.getFork('0').setProps({ value: 'First row' });
|
|
73
|
+
expect(invalidate).not.toHaveBeenCalled();
|
|
74
|
+
} finally {
|
|
75
|
+
tracker.dispose();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
@@ -21,6 +21,35 @@ describe('FilterFormGridModel.toggleFormFieldsCollapse', () => {
|
|
|
21
21
|
engine.registerModels({ FilterFormGridModel });
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
it.each([false, true])('preserves collapsed fields in mobile layout with settings enabled: %s', (settingsEnabled) => {
|
|
25
|
+
engine.flowSettings[settingsEnabled ? 'enable' : 'disable']();
|
|
26
|
+
const rows = {
|
|
27
|
+
first: [['field-1']],
|
|
28
|
+
second: [['field-2']],
|
|
29
|
+
third: [['field-3']],
|
|
30
|
+
};
|
|
31
|
+
const model = engine.createModel<FilterFormGridModel>({
|
|
32
|
+
uid: 'mobile-filter-grid',
|
|
33
|
+
use: 'FilterFormGridModel',
|
|
34
|
+
props: { rows },
|
|
35
|
+
subModels: {
|
|
36
|
+
items: ['field-1', 'field-2', 'field-3'].map((uid) => ({ use: 'FlowModel', uid })),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
model.context.defineProperty('isMobileLayout', { value: true });
|
|
40
|
+
model.setStepParams(GRID_FLOW_KEY, GRID_STEP, { rows });
|
|
41
|
+
type VisibleLayoutReader = { getVisibleLayout(): { rows: Record<string, string[][]> } };
|
|
42
|
+
const renderedItems = () =>
|
|
43
|
+
Object.values((model as unknown as VisibleLayoutReader).getVisibleLayout().rows).flat(2);
|
|
44
|
+
|
|
45
|
+
expect(renderedItems()).toEqual(['field-1', 'field-2', 'field-3']);
|
|
46
|
+
model.toggleFormFieldsCollapse(true, 1);
|
|
47
|
+
expect(renderedItems()).toEqual(['field-1']);
|
|
48
|
+
model.toggleFormFieldsCollapse(false, 1);
|
|
49
|
+
expect(renderedItems()).toEqual(['field-1', 'field-2', 'field-3']);
|
|
50
|
+
expect(model.getStepParams(GRID_FLOW_KEY, GRID_STEP).rows).toEqual(rows);
|
|
51
|
+
});
|
|
52
|
+
|
|
24
53
|
it('uses rowOrder from the full layout when collapsing after reorder', () => {
|
|
25
54
|
const model = engine.createModel<FilterFormGridModel>({
|
|
26
55
|
uid: 'filter-grid-collapse-order',
|
|
@@ -351,7 +351,7 @@ export const FieldComponentProps: React.FC<{ fieldModel: string; source: string[
|
|
|
351
351
|
<FormItem label={t('Options')}>
|
|
352
352
|
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
|
353
353
|
{options.map((option: any, index: number) => (
|
|
354
|
-
<Space key={
|
|
354
|
+
<Space key={index} style={{ width: '100%' }} size={8} wrap align="start">
|
|
355
355
|
<Input
|
|
356
356
|
style={{ flex: 1, minWidth: 120 }}
|
|
357
357
|
placeholder={t('Option label')}
|
package/src/flow/models/blocks/filter-form/fields/__tests__/FieldComponentProps.options.test.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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 React from 'react';
|
|
11
|
+
import { describe, expect, it } from 'vitest';
|
|
12
|
+
import { createForm } from '@formily/core';
|
|
13
|
+
import { Field, FormProvider } from '@formily/react';
|
|
14
|
+
import { render, screen } from '@nocobase/test/client';
|
|
15
|
+
import userEvent from '@testing-library/user-event';
|
|
16
|
+
import { FlowEngine, FlowEngineProvider, FlowModel, FlowModelProvider } from '@nocobase/flow-engine';
|
|
17
|
+
import { FieldComponentProps } from '../FieldComponentProps';
|
|
18
|
+
|
|
19
|
+
class HostModel extends FlowModel {
|
|
20
|
+
render() {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe.each(['RadioGroupFieldModel', 'CheckboxGroupFieldModel', 'SelectFieldModel'])('%s options', (fieldModel) => {
|
|
26
|
+
it('keeps focus while editing option values and preserves remaining rows after removal', async () => {
|
|
27
|
+
const form = createForm();
|
|
28
|
+
const engine = new FlowEngine();
|
|
29
|
+
engine.registerModels({ HostModel });
|
|
30
|
+
const model = engine.createModel<HostModel>({ use: 'HostModel' });
|
|
31
|
+
render(
|
|
32
|
+
<FlowEngineProvider engine={engine}>
|
|
33
|
+
<FlowModelProvider model={model}>
|
|
34
|
+
<FormProvider form={form}>
|
|
35
|
+
<Field name="props" component={[FieldComponentProps, { fieldModel, source: [] }]} />
|
|
36
|
+
</FormProvider>
|
|
37
|
+
</FlowModelProvider>
|
|
38
|
+
</FlowEngineProvider>,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
await userEvent.click(screen.getByRole('button', { name: 'plus Add' }));
|
|
42
|
+
const valueInput = screen.getByPlaceholderText('Option value');
|
|
43
|
+
await userEvent.type(valueInput, 'abcdef');
|
|
44
|
+
expect(screen.getByPlaceholderText('Option value')).toHaveValue('abcdef');
|
|
45
|
+
expect(valueInput).toHaveFocus();
|
|
46
|
+
|
|
47
|
+
await userEvent.keyboard('{Backspace}{Backspace}xy');
|
|
48
|
+
expect(valueInput).toHaveValue('abcdxy');
|
|
49
|
+
expect(valueInput).toHaveFocus();
|
|
50
|
+
await userEvent.type(screen.getByPlaceholderText('Option label'), 'First');
|
|
51
|
+
await userEvent.click(screen.getByRole('button', { name: 'plus Add' }));
|
|
52
|
+
await userEvent.type(screen.getAllByPlaceholderText('Option label')[1], 'Second');
|
|
53
|
+
await userEvent.type(screen.getAllByPlaceholderText('Option value')[1], 'second');
|
|
54
|
+
await userEvent.click(screen.getAllByRole('button', { name: 'close' })[0]);
|
|
55
|
+
expect(screen.getByPlaceholderText('Option label')).toHaveValue('Second');
|
|
56
|
+
expect(screen.getByPlaceholderText('Option value')).toHaveValue('second');
|
|
57
|
+
await userEvent.type(screen.getByPlaceholderText('Option value'), '2');
|
|
58
|
+
expect(screen.getByPlaceholderText('Option value')).toHaveFocus();
|
|
59
|
+
expect(form.values.props.options).toEqual([{ label: 'Second', value: 'second2' }]);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
FlowModelRenderer,
|
|
17
17
|
MemoFlowModelRenderer,
|
|
18
18
|
MultiRecordResource,
|
|
19
|
+
observable,
|
|
19
20
|
SingleRecordResource,
|
|
20
21
|
} from '@nocobase/flow-engine';
|
|
21
22
|
import { Pagination, Space } from 'antd';
|
|
@@ -23,12 +24,14 @@ import { isEqual } from 'lodash';
|
|
|
23
24
|
import React from 'react';
|
|
24
25
|
import { BlockSceneEnum } from '../../base/BlockModel';
|
|
25
26
|
import { FormBlockContent, FormBlockModel } from './FormBlockModel';
|
|
27
|
+
import { confirmDiscardChanges } from '../../base/PageModel/closeGuard';
|
|
26
28
|
import { dispatchEventDeep } from '../../../utils';
|
|
27
29
|
|
|
28
30
|
export class EditFormModel extends FormBlockModel {
|
|
29
31
|
static scene = BlockSceneEnum.oam;
|
|
30
32
|
static blockCapabilityActionName = 'update';
|
|
31
33
|
|
|
34
|
+
private readonly confirmingPageChange = observable.ref(false);
|
|
32
35
|
private actionFlowSettings = { showBackground: false, showBorder: false, toolbarPosition: 'above' as const };
|
|
33
36
|
private actionExtraToolbarItems = [
|
|
34
37
|
{
|
|
@@ -71,9 +74,26 @@ export class EditFormModel extends FormBlockModel {
|
|
|
71
74
|
getAclActionName() {
|
|
72
75
|
return 'update';
|
|
73
76
|
}
|
|
77
|
+
|
|
78
|
+
private hasUnsavedChanges = () => {
|
|
79
|
+
const record = this.getCurrentRecord();
|
|
80
|
+
return Array.from(this.getUserModifiedFields()).some(
|
|
81
|
+
(field) => !isEqual(this.form.getFieldValue(field), record?.[field]),
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
74
85
|
handlePageChange = async (page: number) => {
|
|
75
86
|
if (this.resource instanceof MultiRecordResource) {
|
|
76
87
|
const multiResource = this.resource as MultiRecordResource;
|
|
88
|
+
if (page === multiResource.getPage() || this.confirmingPageChange.value) return;
|
|
89
|
+
if (this.hasUnsavedChanges()) {
|
|
90
|
+
this.confirmingPageChange.value = true;
|
|
91
|
+
try {
|
|
92
|
+
if (!(await confirmDiscardChanges(this.context))) return;
|
|
93
|
+
} finally {
|
|
94
|
+
this.confirmingPageChange.value = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
77
97
|
multiResource.setPage(page);
|
|
78
98
|
multiResource.loading = true;
|
|
79
99
|
await multiResource.refresh();
|
|
@@ -116,10 +136,12 @@ export class EditFormModel extends FormBlockModel {
|
|
|
116
136
|
}}
|
|
117
137
|
>
|
|
118
138
|
<Pagination
|
|
139
|
+
// Simple pagination keeps its own editable page number. Reset it while confirming the switch.
|
|
140
|
+
key={this.confirmingPageChange.value ? 'confirming' : 'editing'}
|
|
119
141
|
simple
|
|
120
142
|
pageSize={1}
|
|
121
143
|
showSizeChanger={false}
|
|
122
|
-
|
|
144
|
+
current={(this.resource as MultiRecordResource).getPage()}
|
|
123
145
|
total={(this.resource as MultiRecordResource).getTotalPage()}
|
|
124
146
|
onChange={this.handlePageChange}
|
|
125
147
|
style={{ display: 'inline-block' }}
|