@nocobase/client-v2 2.1.11 → 2.1.14
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/flow/actions/afterSuccess.d.ts +8 -1
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/models/blocks/form/submitHandler.d.ts +1 -1
- package/es/flow/models/blocks/js-block/JSBlock.d.ts +1 -0
- package/es/flow/models/blocks/table/TableActionsColumnModel.d.ts +1 -0
- package/es/flow/models/blocks/table/TableBlockModel.d.ts +1 -0
- package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +1 -1
- package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +2 -1
- package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +6 -4
- package/es/flow/resolveViewParamsToViewList.d.ts +1 -1
- package/es/index.mjs +137 -89
- package/lib/index.js +163 -115
- package/package.json +7 -7
- package/src/collection-manager/field-configure.ts +1 -1
- package/src/collection-manager/interfaces/id.ts +1 -1
- package/src/collection-manager/interfaces/m2m.tsx +2 -2
- package/src/collection-manager/interfaces/m2o.tsx +2 -2
- package/src/collection-manager/interfaces/nanoid.ts +1 -1
- package/src/collection-manager/interfaces/o2m.tsx +2 -2
- package/src/collection-manager/interfaces/obo.tsx +2 -2
- package/src/collection-manager/interfaces/oho.tsx +2 -2
- package/src/collection-manager/interfaces/properties/index.ts +2 -2
- package/src/collection-manager/interfaces/uuid.ts +1 -1
- package/src/flow/__tests__/getKey.test.ts +7 -0
- package/src/flow/__tests__/resolveViewParamsToViewList.test.ts +34 -0
- package/src/flow/actions/__tests__/afterSuccess.test.ts +73 -0
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +104 -0
- package/src/flow/actions/afterSuccess.tsx +142 -3
- package/src/flow/actions/dateTimeFormat.tsx +2 -2
- package/src/flow/actions/index.ts +1 -1
- package/src/flow/actions/openView.tsx +38 -4
- package/src/flow/admin-shell/BaseLayoutModel.tsx +25 -3
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +5 -2
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +13 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +82 -0
- package/src/flow/getViewDiffAndUpdateHidden.tsx +1 -0
- package/src/flow/models/base/ActionModelCore.tsx +6 -4
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +37 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.tsx +1 -1
- package/src/flow/models/blocks/form/FormActionModel.tsx +1 -1
- package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +54 -1
- package/src/flow/models/blocks/form/submitHandler.ts +17 -3
- package/src/flow/models/blocks/js-block/JSBlock.tsx +223 -2
- package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +150 -0
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +35 -12
- package/src/flow/models/blocks/table/TableBlockModel.tsx +25 -14
- package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
- package/src/flow/models/blocks/table/__tests__/TableActionsColumnModel.test.tsx +57 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.dragSort.test.ts +127 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +1 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
- package/src/flow/models/blocks/table/dragSort/dragSortHooks.tsx +28 -17
- package/src/flow/models/blocks/table/dragSort/dragSortSettings.ts +13 -6
- package/src/flow/models/blocks/table/dragSort/dragSortUtils.ts +15 -2
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
- package/src/flow/resolveViewParamsToViewList.tsx +11 -3
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
- package/src/settings-center/SystemSettingsPage.tsx +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
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 } from '@nocobase/flow-engine';
|
|
11
|
+
import { describe, expect, it } from 'vitest';
|
|
12
|
+
import '@nocobase/client';
|
|
13
|
+
import { initDragSortParams } from '../dragSort';
|
|
14
|
+
import { TableBlockModel } from '../TableBlockModel';
|
|
15
|
+
|
|
16
|
+
function createTableModel() {
|
|
17
|
+
const engine = new FlowEngine();
|
|
18
|
+
engine.registerModels({ TableBlockModel });
|
|
19
|
+
|
|
20
|
+
const ds = engine.dataSourceManager.getDataSource('main');
|
|
21
|
+
ds.addCollection({
|
|
22
|
+
name: 'posts',
|
|
23
|
+
filterTargetKey: 'id',
|
|
24
|
+
fields: [
|
|
25
|
+
{ name: 'id', type: 'integer', interface: 'number' },
|
|
26
|
+
{ name: 'title', type: 'string', interface: 'input' },
|
|
27
|
+
{ name: 'sort', type: 'sort', interface: 'sort' },
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return engine.createModel<TableBlockModel>({
|
|
32
|
+
uid: 'posts-table',
|
|
33
|
+
use: 'TableBlockModel',
|
|
34
|
+
stepParams: {
|
|
35
|
+
resourceSettings: {
|
|
36
|
+
init: {
|
|
37
|
+
dataSourceKey: 'main',
|
|
38
|
+
collectionName: 'posts',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('TableBlockModel drag sorting settings', () => {
|
|
46
|
+
it('does not keep a deleted drag sort field in resource sort', () => {
|
|
47
|
+
const model = createTableModel();
|
|
48
|
+
|
|
49
|
+
model.setProps('dragSort', true);
|
|
50
|
+
model.setProps('dragSortBy', 'sort');
|
|
51
|
+
model.setProps('globalSort', ['title']);
|
|
52
|
+
model.resource.setSort(['sort']);
|
|
53
|
+
model.collection.fields.delete('sort');
|
|
54
|
+
|
|
55
|
+
initDragSortParams(model);
|
|
56
|
+
|
|
57
|
+
expect(model.getDragSortFieldName()).toBeUndefined();
|
|
58
|
+
expect(model.resource.getSort()).toEqual(['title']);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('hides the drag handle when the configured sort field was deleted', () => {
|
|
62
|
+
const model = createTableModel();
|
|
63
|
+
|
|
64
|
+
model.setProps('enableRowSelection', false);
|
|
65
|
+
model.setProps('showIndex', false);
|
|
66
|
+
model.setProps('dragSort', true);
|
|
67
|
+
model.setProps('dragSortBy', 'sort');
|
|
68
|
+
model.collection.fields.delete('sort');
|
|
69
|
+
|
|
70
|
+
expect(model.getLeftAuxiliaryColumn()).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('allows clearing the configured drag sort field and restores default sorting', () => {
|
|
74
|
+
const model = createTableModel();
|
|
75
|
+
const dragSortByStep = model.getFlow('tableSettings')?.steps?.dragSortBy;
|
|
76
|
+
|
|
77
|
+
model.setProps('dragSort', true);
|
|
78
|
+
model.setProps('dragSortBy', 'sort');
|
|
79
|
+
model.setProps('globalSort', ['title']);
|
|
80
|
+
model.resource.setSort(['sort']);
|
|
81
|
+
|
|
82
|
+
const uiMode =
|
|
83
|
+
typeof dragSortByStep?.uiMode === 'function' ? dragSortByStep.uiMode({ model, t: (key: string) => key }) : null;
|
|
84
|
+
dragSortByStep?.handler({ model }, { dragSortBy: null });
|
|
85
|
+
|
|
86
|
+
expect(uiMode).toMatchObject({
|
|
87
|
+
type: 'select',
|
|
88
|
+
key: 'dragSortBy',
|
|
89
|
+
props: {
|
|
90
|
+
allowClear: true,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
expect(model.props.dragSortBy).toBeNull();
|
|
94
|
+
expect(model.resource.getSort()).toEqual(['title']);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('ignores a deleted drag sort field submitted by settings', () => {
|
|
98
|
+
const model = createTableModel();
|
|
99
|
+
const dragSortByStep = model.getFlow('tableSettings')?.steps?.dragSortBy;
|
|
100
|
+
|
|
101
|
+
model.setProps('dragSort', true);
|
|
102
|
+
model.setProps('dragSortBy', 'sort');
|
|
103
|
+
model.setProps('globalSort', ['title']);
|
|
104
|
+
model.resource.setSort(['sort']);
|
|
105
|
+
model.collection.fields.delete('sort');
|
|
106
|
+
|
|
107
|
+
dragSortByStep?.handler({ model }, { dragSortBy: 'sort' });
|
|
108
|
+
|
|
109
|
+
expect(model.props.dragSortBy).toBeNull();
|
|
110
|
+
expect(model.resource.getSort()).toEqual(['title']);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('restores default sorting when drag sorting is disabled', () => {
|
|
114
|
+
const model = createTableModel();
|
|
115
|
+
const dragSortStep = model.getFlow('tableSettings')?.steps?.dragSort;
|
|
116
|
+
|
|
117
|
+
model.setProps('dragSort', true);
|
|
118
|
+
model.setProps('dragSortBy', 'sort');
|
|
119
|
+
model.setProps('globalSort', ['title']);
|
|
120
|
+
model.resource.setSort(['sort']);
|
|
121
|
+
|
|
122
|
+
dragSortStep?.handler({ model }, { dragSort: false });
|
|
123
|
+
|
|
124
|
+
expect(model.props.dragSort).toBe(false);
|
|
125
|
+
expect(model.resource.getSort()).toEqual(['title']);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -327,6 +327,57 @@ describe('TableColumnModel sorter settings', () => {
|
|
|
327
327
|
);
|
|
328
328
|
});
|
|
329
329
|
|
|
330
|
+
it('keeps saved ordinary datetime format when table column initializes again', async () => {
|
|
331
|
+
const engine = new FlowEngine();
|
|
332
|
+
const model = new TableColumnModel({
|
|
333
|
+
uid: 'table-column-saved-datetime-format',
|
|
334
|
+
flowEngine: engine,
|
|
335
|
+
} as any);
|
|
336
|
+
const initStep = model.getFlow('tableColumnSettings')?.steps?.init as any;
|
|
337
|
+
const setProps = vi.fn();
|
|
338
|
+
|
|
339
|
+
await initStep.handler({
|
|
340
|
+
model: {
|
|
341
|
+
context: {
|
|
342
|
+
collectionField: {
|
|
343
|
+
title: 'Datetime',
|
|
344
|
+
name: 'datetime',
|
|
345
|
+
isAssociationField: () => false,
|
|
346
|
+
getComponentProps: () => ({
|
|
347
|
+
dateFormat: 'YYYY-MM-DD',
|
|
348
|
+
showTime: false,
|
|
349
|
+
}),
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
props: {},
|
|
353
|
+
subModels: {
|
|
354
|
+
field: {
|
|
355
|
+
getStepParams: (flowKey, stepKey) =>
|
|
356
|
+
flowKey === 'datetimeSettings' && stepKey === 'dateFormat'
|
|
357
|
+
? {
|
|
358
|
+
picker: 'date',
|
|
359
|
+
dateFormat: 'YYYY-MM-DD',
|
|
360
|
+
showTime: true,
|
|
361
|
+
timeFormat: 'HH:mm:ss',
|
|
362
|
+
}
|
|
363
|
+
: undefined,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
applySubModelsBeforeRenderFlows: vi.fn(),
|
|
367
|
+
setProps,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
expect(setProps).toHaveBeenCalledWith(
|
|
372
|
+
expect.objectContaining({
|
|
373
|
+
dateFormat: 'YYYY-MM-DD',
|
|
374
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
|
375
|
+
showTime: true,
|
|
376
|
+
timeFormat: 'HH:mm:ss',
|
|
377
|
+
}),
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
330
381
|
it('does not update field component setting when title field refresh fails', async () => {
|
|
331
382
|
const engine = new FlowEngine();
|
|
332
383
|
const model = new TableColumnModel({ uid: 'table-column-title-field-component-failed', flowEngine: engine } as any);
|
|
@@ -19,16 +19,23 @@ export function useDragSortBodyWrapper(
|
|
|
19
19
|
model: TableBlockModel,
|
|
20
20
|
dataSourceRef: React.MutableRefObject<any>,
|
|
21
21
|
getRowKeyFunc: (record: any) => string | number,
|
|
22
|
+
dragSortFieldName?: string,
|
|
22
23
|
) {
|
|
24
|
+
const expandedRowKeys = model.props.expandedRowKeys;
|
|
25
|
+
const defaultExpandAllRows = model.props.defaultExpandAllRows;
|
|
26
|
+
const resource = model.resource;
|
|
27
|
+
const filterTargetKey = model.collection.filterTargetKey;
|
|
28
|
+
const message = (model as { ctx?: { message?: { error?: (content: string) => void } } }).ctx?.message;
|
|
29
|
+
|
|
23
30
|
return useMemo(() => {
|
|
24
|
-
if (!
|
|
31
|
+
if (!dragSortFieldName) {
|
|
25
32
|
return (props) => <tbody {...props} />;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
const flattenTreeData = (data: any[]) => {
|
|
29
36
|
const result: any[] = [];
|
|
30
|
-
const expandedKeys = new Set((
|
|
31
|
-
const includeAll = !!
|
|
37
|
+
const expandedKeys = new Set((expandedRowKeys || []).map((key) => (key == null ? key : String(key))));
|
|
38
|
+
const includeAll = !!defaultExpandAllRows;
|
|
32
39
|
|
|
33
40
|
const walk = (nodes: any[]) => {
|
|
34
41
|
if (!nodes?.length) return;
|
|
@@ -73,22 +80,22 @@ export function useDragSortBodyWrapper(
|
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
if (from && to) {
|
|
76
|
-
|
|
83
|
+
resource
|
|
77
84
|
.runAction('move', {
|
|
78
85
|
method: 'post',
|
|
79
86
|
params: {
|
|
80
|
-
sourceId: getRowKey(from,
|
|
81
|
-
targetId: getRowKey(to,
|
|
82
|
-
sortField:
|
|
87
|
+
sourceId: getRowKey(from, filterTargetKey),
|
|
88
|
+
targetId: getRowKey(to, filterTargetKey),
|
|
89
|
+
sortField: dragSortFieldName,
|
|
83
90
|
},
|
|
84
91
|
})
|
|
85
92
|
.then(() => {
|
|
86
|
-
|
|
93
|
+
resource.refresh();
|
|
87
94
|
})
|
|
88
95
|
.catch((error) => {
|
|
89
96
|
console.error('Move failed:', error);
|
|
90
97
|
// Show a user-facing error message if the message system is available
|
|
91
|
-
|
|
98
|
+
message?.error?.(error?.message || 'Move failed');
|
|
92
99
|
});
|
|
93
100
|
}
|
|
94
101
|
};
|
|
@@ -104,13 +111,14 @@ export function useDragSortBodyWrapper(
|
|
|
104
111
|
);
|
|
105
112
|
};
|
|
106
113
|
}, [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
model.collection.filterTargetKey,
|
|
114
|
+
dataSourceRef,
|
|
115
|
+
defaultExpandAllRows,
|
|
116
|
+
dragSortFieldName,
|
|
117
|
+
expandedRowKeys,
|
|
118
|
+
filterTargetKey,
|
|
113
119
|
getRowKeyFunc,
|
|
120
|
+
message,
|
|
121
|
+
resource,
|
|
114
122
|
]);
|
|
115
123
|
}
|
|
116
124
|
|
|
@@ -124,7 +132,10 @@ export function useDragSortRowComponent(dragSort: boolean) {
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
export function initDragSortParams(model: TableBlockModel) {
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
const dragSortFieldName = model.getDragSortFieldName();
|
|
136
|
+
if (dragSortFieldName) {
|
|
137
|
+
model.resource.setSort([dragSortFieldName]);
|
|
138
|
+
} else if (model.props.dragSort && model.props.dragSortBy) {
|
|
139
|
+
model.resource.setSort(Array.isArray(model.props.globalSort) ? model.props.globalSort : []);
|
|
129
140
|
}
|
|
130
141
|
}
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
import { tExpr } from '@nocobase/flow-engine';
|
|
11
11
|
import type { TableBlockModel } from '../TableBlockModel';
|
|
12
|
-
import { convertFieldsToOptions, getSortFields } from './dragSortUtils';
|
|
12
|
+
import { convertFieldsToOptions, getSortFields, hasSortField } from './dragSortUtils';
|
|
13
|
+
|
|
14
|
+
function getFallbackSort(model: TableBlockModel): string[] {
|
|
15
|
+
return Array.isArray(model.props.globalSort) ? model.props.globalSort : [];
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
export const dragSortSettings = {
|
|
15
19
|
title: tExpr('Enable drag and drop sorting'),
|
|
@@ -17,9 +21,12 @@ export const dragSortSettings = {
|
|
|
17
21
|
defaultParams: {
|
|
18
22
|
dragSort: false,
|
|
19
23
|
},
|
|
20
|
-
|
|
24
|
+
handler(ctx, params) {
|
|
21
25
|
const model = ctx.model as TableBlockModel;
|
|
22
26
|
model.setProps('dragSort', params.dragSort);
|
|
27
|
+
if (!params.dragSort) {
|
|
28
|
+
model.resource.setSort(getFallbackSort(model));
|
|
29
|
+
}
|
|
23
30
|
|
|
24
31
|
// Note: automatic configuration of the drag sort field has been removed;
|
|
25
32
|
// users now configure `dragSortBy` explicitly via `dragSortBySettings`.
|
|
@@ -45,6 +52,7 @@ export const dragSortBySettings = {
|
|
|
45
52
|
key: 'dragSortBy',
|
|
46
53
|
props: {
|
|
47
54
|
options,
|
|
55
|
+
allowClear: true,
|
|
48
56
|
placeholder: ctx.t('Select field'),
|
|
49
57
|
},
|
|
50
58
|
};
|
|
@@ -54,9 +62,8 @@ export const dragSortBySettings = {
|
|
|
54
62
|
},
|
|
55
63
|
handler(ctx, params) {
|
|
56
64
|
const model = ctx.model as TableBlockModel;
|
|
57
|
-
model.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
65
|
+
const dragSortBy = hasSortField(model.collection, params.dragSortBy) ? params.dragSortBy : null;
|
|
66
|
+
model.setProps('dragSortBy', dragSortBy);
|
|
67
|
+
model.resource.setSort(dragSortBy ? [dragSortBy] : getFallbackSort(model));
|
|
61
68
|
},
|
|
62
69
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { Collection } from '@nocobase/flow-engine';
|
|
10
|
+
import type { Collection, CollectionField } from '@nocobase/flow-engine';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 从 collection 中获取所有 sort 类型的字段
|
|
@@ -24,6 +24,19 @@ export function getSortFields(collection: Collection | undefined) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export function getSortField(
|
|
28
|
+
collection: Collection | undefined,
|
|
29
|
+
fieldName?: string | null,
|
|
30
|
+
): CollectionField | undefined {
|
|
31
|
+
if (!collection || !fieldName) return undefined;
|
|
32
|
+
|
|
33
|
+
return getSortFields(collection).find((field) => field.name === fieldName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function hasSortField(collection: Collection | undefined, fieldName?: string | null): boolean {
|
|
37
|
+
return !!getSortField(collection, fieldName);
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* 获取 collection 中第一个可用的 sort 字段
|
|
29
42
|
* @param collection - 集合对象
|
|
@@ -39,7 +52,7 @@ export function getFirstSortField(collection: Collection | undefined) {
|
|
|
39
52
|
* @param fields - 字段数组
|
|
40
53
|
* @returns 选项数组
|
|
41
54
|
*/
|
|
42
|
-
export function convertFieldsToOptions(fields:
|
|
55
|
+
export function convertFieldsToOptions(fields: CollectionField[]) {
|
|
43
56
|
return fields.map((field) => ({
|
|
44
57
|
label: field?.uiSchema?.title || field?.name,
|
|
45
58
|
value: field?.name,
|
|
@@ -198,6 +198,48 @@ const useFieldPermissionMessage = (model, allowEdit) => {
|
|
|
198
198
|
return messageValue;
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
+
const recordSelectClassName = css`
|
|
202
|
+
min-width: 0;
|
|
203
|
+
|
|
204
|
+
.ant-select-selector {
|
|
205
|
+
min-width: 0;
|
|
206
|
+
overflow: hidden;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.ant-select-selection-search,
|
|
210
|
+
.ant-select-selection-item,
|
|
211
|
+
.ant-select-selection-placeholder,
|
|
212
|
+
.ant-select-selection-overflow,
|
|
213
|
+
.ant-select-selection-overflow-item {
|
|
214
|
+
min-width: 0;
|
|
215
|
+
max-width: 100%;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ant-select-selection-item,
|
|
219
|
+
.ant-select-selection-item-content {
|
|
220
|
+
overflow: hidden;
|
|
221
|
+
text-overflow: ellipsis;
|
|
222
|
+
white-space: nowrap;
|
|
223
|
+
}
|
|
224
|
+
`;
|
|
225
|
+
|
|
226
|
+
const recordSelectLabelClassName = css`
|
|
227
|
+
display: block;
|
|
228
|
+
min-width: 0;
|
|
229
|
+
max-width: 100%;
|
|
230
|
+
overflow: hidden;
|
|
231
|
+
text-overflow: ellipsis;
|
|
232
|
+
white-space: nowrap;
|
|
233
|
+
|
|
234
|
+
* {
|
|
235
|
+
min-width: 0;
|
|
236
|
+
max-width: 100%;
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
text-overflow: ellipsis;
|
|
239
|
+
white-space: nowrap !important;
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
|
|
201
243
|
const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
202
244
|
const {
|
|
203
245
|
fieldNames,
|
|
@@ -210,6 +252,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
|
210
252
|
onChange,
|
|
211
253
|
allowCreate = true,
|
|
212
254
|
allowEdit = true,
|
|
255
|
+
className,
|
|
213
256
|
...others
|
|
214
257
|
} = props;
|
|
215
258
|
const model: any = useFlowModel();
|
|
@@ -317,6 +360,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
|
317
360
|
<Select
|
|
318
361
|
style={{ width: '100%' }}
|
|
319
362
|
{...others}
|
|
363
|
+
className={[recordSelectClassName, className].filter(Boolean).join(' ')}
|
|
320
364
|
allowClear
|
|
321
365
|
showSearch
|
|
322
366
|
maxTagCount="responsive"
|
|
@@ -409,19 +453,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
|
409
453
|
}}
|
|
410
454
|
popupMatchSelectWidth
|
|
411
455
|
labelRender={(data) => {
|
|
412
|
-
return
|
|
413
|
-
<div
|
|
414
|
-
className={css`
|
|
415
|
-
div {
|
|
416
|
-
white-space: nowrap !important;
|
|
417
|
-
overflow: hidden;
|
|
418
|
-
text-overflow: ellipsis;
|
|
419
|
-
}
|
|
420
|
-
`}
|
|
421
|
-
>
|
|
422
|
-
{data.label}
|
|
423
|
-
</div>
|
|
424
|
-
);
|
|
456
|
+
return <div className={recordSelectLabelClassName}>{data.label}</div>;
|
|
425
457
|
}}
|
|
426
458
|
dropdownRender={(menu) => {
|
|
427
459
|
const isFullMatch = realOptions.some((v) => v[normalizedFieldNames.label] === others.searchText);
|
|
@@ -49,12 +49,12 @@ export function resolveViewParamsToViewList(
|
|
|
49
49
|
return viewItems;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export function updateViewListHidden(viewItems: ViewItem[]) {
|
|
52
|
+
export function updateViewListHidden(viewItems: ViewItem[], isMobileLayout = false) {
|
|
53
53
|
// Calculate hidden values based on view types and positions
|
|
54
54
|
let hasEmbedAfter = false;
|
|
55
55
|
for (let i = viewItems.length - 1; i >= 0; i--) {
|
|
56
56
|
const viewItem = viewItems[i];
|
|
57
|
-
const viewType = getViewType(viewItem);
|
|
57
|
+
const viewType = getViewType(viewItem, isMobileLayout);
|
|
58
58
|
|
|
59
59
|
if (viewType === 'embed' && !hasEmbedAfter) {
|
|
60
60
|
hasEmbedAfter = true;
|
|
@@ -65,15 +65,23 @@ export function updateViewListHidden(viewItems: ViewItem[]) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function getViewType(viewItem: ViewItem): string {
|
|
68
|
+
function getViewType(viewItem: ViewItem, isMobileLayout = false): string {
|
|
69
69
|
if (viewItem.model instanceof RouteModel) {
|
|
70
70
|
return 'embed';
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
if (isMobileLayout && viewItem.index > 0) {
|
|
74
|
+
return 'embed';
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
if (!viewItem.model) {
|
|
74
78
|
return 'drawer';
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
if (viewItem.params.openViewRouteState?.mode) {
|
|
82
|
+
return viewItem.params.openViewRouteState.mode;
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
const params = viewItem.model.getStepParams('popupSettings', 'openView');
|
|
78
86
|
return params?.mode || 'drawer';
|
|
79
87
|
}
|
|
@@ -207,6 +207,48 @@ describe('dateTimeFormat', () => {
|
|
|
207
207
|
expect(save).toHaveBeenCalled();
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
+
it('syncs ordinary table column props when date time format settings are saved', async () => {
|
|
211
|
+
const setProps = vi.fn();
|
|
212
|
+
const save = vi.fn();
|
|
213
|
+
const setParentProps = vi.fn();
|
|
214
|
+
const model = {
|
|
215
|
+
context: {
|
|
216
|
+
collectionField: {
|
|
217
|
+
type: 'datetime',
|
|
218
|
+
interface: 'datetime',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
setProps,
|
|
222
|
+
save,
|
|
223
|
+
parent: {
|
|
224
|
+
use: 'TableColumnModel',
|
|
225
|
+
setProps: setParentProps,
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
model.parent['subModels'] = {
|
|
229
|
+
field: model,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
await dateTimeFormat.beforeParamsSave(
|
|
233
|
+
{ model },
|
|
234
|
+
{
|
|
235
|
+
picker: 'date',
|
|
236
|
+
dateFormat: 'YYYY-MM-DD',
|
|
237
|
+
showTime: true,
|
|
238
|
+
timeFormat: 'HH:mm:ss',
|
|
239
|
+
},
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
expect(setParentProps).toHaveBeenCalledWith({
|
|
243
|
+
picker: 'date',
|
|
244
|
+
dateFormat: 'YYYY-MM-DD',
|
|
245
|
+
showTime: true,
|
|
246
|
+
timeFormat: 'HH:mm:ss',
|
|
247
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
|
248
|
+
});
|
|
249
|
+
expect(save).toHaveBeenCalled();
|
|
250
|
+
});
|
|
251
|
+
|
|
210
252
|
it('hides time format for association title date-only fields', () => {
|
|
211
253
|
const ctx = {
|
|
212
254
|
model: {
|
|
@@ -240,7 +240,7 @@ export const SystemSettingsPage = () => {
|
|
|
240
240
|
<Form.Item
|
|
241
241
|
name="raw_title"
|
|
242
242
|
label={t('System title')}
|
|
243
|
-
rules={[{ required: true, message: t('Please enter') + t('System title') }]}
|
|
243
|
+
rules={[{ required: true, message: t('Please enter') + ' ' + t('System title') }]}
|
|
244
244
|
>
|
|
245
245
|
<Input.TextArea autoSize={{ minRows: 2, maxRows: 4 }} />
|
|
246
246
|
</Form.Item>
|