@nocobase/client-v2 2.1.0-beta.44 → 2.1.0-beta.45
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/BaseApplication.d.ts +9 -0
- package/es/authRedirect.d.ts +12 -0
- package/es/collection-manager/filter-operators/index.d.ts +1 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +5 -1
- package/es/components/form/filter/FilterValueInput.d.ts +5 -0
- package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +11 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/useApplications.d.ts +3 -2
- package/es/flow/components/ConditionBuilder.d.ts +1 -0
- package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
- package/es/flow/components/FieldAssignValueInput.d.ts +1 -0
- package/es/flow/components/fieldAssignOptions.d.ts +10 -0
- package/es/flow/components/filter/LinkageFilterItem.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +1 -0
- package/es/flow/components/filter/metaTreeAssociationDepth.d.ts +13 -0
- package/es/flow/internal/utils/operatorSchemaHelper.d.ts +26 -3
- package/es/flow/models/base/AssociationFieldGroupModel.d.ts +2 -33
- package/es/flow/models/blocks/filter-manager/utils.d.ts +23 -1
- package/es/flow/models/blocks/table/TableColumnModel.d.ts +2 -0
- package/es/index.mjs +178 -100
- package/lib/index.js +187 -109
- package/package.json +7 -7
- package/src/BaseApplication.tsx +13 -0
- package/src/__tests__/browserChecker.test.ts +103 -0
- package/src/__tests__/dataSourceRuntime.test.tsx +22 -1
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +5 -0
- package/src/authRedirect.ts +43 -0
- package/src/collection-field-interface/CollectionFieldInterface.ts +14 -7
- package/src/collection-manager/filter-operators/index.ts +29 -2
- package/src/components/form/filter/CollectionFilterItem.tsx +10 -2
- package/src/components/form/filter/FilterValueInput.tsx +27 -2
- package/src/components/form/filter/__tests__/FilterValueInput.test.tsx +39 -0
- package/src/flow/__tests__/FlowRoute.test.tsx +8 -1
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +369 -2
- package/src/flow/actions/dataScope.tsx +8 -1
- package/src/flow/actions/linkageRules.tsx +56 -1
- package/src/flow/actions/setTargetDataScope.tsx +1 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +31 -3
- package/src/flow/admin-shell/admin-layout/AppListRender.tsx +139 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +8 -1
- package/src/flow/admin-shell/admin-layout/index.ts +1 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +11 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +2 -4
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +34 -1
- package/src/flow/common/Markdown/Edit.tsx +32 -4
- package/src/flow/components/ConditionBuilder.tsx +12 -2
- package/src/flow/components/DefaultValue.tsx +14 -8
- package/src/flow/components/FieldAssignRulesEditor.tsx +37 -46
- package/src/flow/components/FieldAssignValueInput.tsx +14 -14
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +112 -1
- package/src/flow/components/__tests__/fieldAssignOptions.test.ts +71 -1
- package/src/flow/components/fieldAssignOptions.ts +23 -6
- package/src/flow/components/filter/LinkageFilterItem.tsx +26 -12
- package/src/flow/components/filter/VariableFilterItem.tsx +32 -13
- package/src/flow/components/filter/__tests__/fieldsToOptions.test.ts +48 -0
- package/src/flow/components/filter/__tests__/metaTreeAssociationDepth.test.ts +60 -0
- package/src/flow/components/filter/fieldsToOptions.ts +9 -4
- package/src/flow/components/filter/metaTreeAssociationDepth.ts +69 -0
- package/src/flow/internal/utils/operatorSchemaHelper.ts +112 -5
- package/src/flow/models/actions/FilterActionModel.tsx +15 -3
- package/src/flow/models/base/AssociationFieldGroupModel.tsx +20 -3
- package/src/flow/models/base/__tests__/AssociationFieldGroupModel.test.ts +86 -0
- package/src/flow/models/blocks/assign-form/AssignFormGridModel.tsx +11 -0
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +14 -12
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +6 -1
- package/src/flow/models/blocks/filter-manager/__tests__/getDefaultOperator.test.ts +35 -1
- package/src/flow/models/blocks/filter-manager/flow-actions/__tests__/customizeFilterRender.test.tsx +148 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/__tests__/defaultOperator.test.tsx +85 -0
- package/src/flow/models/blocks/filter-manager/flow-actions/connectFields.tsx +48 -6
- package/src/flow/models/blocks/filter-manager/flow-actions/customizeFilterRender.tsx +14 -44
- package/src/flow/models/blocks/filter-manager/flow-actions/defaultOperator.tsx +3 -5
- package/src/flow/models/blocks/filter-manager/flow-actions/operatorComponentProps.tsx +2 -12
- package/src/flow/models/blocks/filter-manager/utils.ts +143 -4
- package/src/flow/models/blocks/form/FormAssociationItemModel.tsx +9 -0
- package/src/flow/models/blocks/form/FormItemModel.tsx +9 -0
- package/src/flow/models/blocks/form/__tests__/FormItemModel.defineChildren.test.ts +27 -2
- package/src/flow/models/blocks/table/TableColumnModel.tsx +15 -5
- package/src/flow/models/blocks/table/TableCustomColumnModel.tsx +2 -2
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +18 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +6 -7
|
@@ -12,7 +12,7 @@ import { FlowEngine, type FlowModelContext, type SubModelItem } from '@nocobase/
|
|
|
12
12
|
// Import from the aggregate to preserve the model initialization order used by adjacent tests.
|
|
13
13
|
import { FormItemModel, FormJSFieldItemModel, InputFieldModel, JSEditableFieldModel } from '../../../..';
|
|
14
14
|
|
|
15
|
-
function createFormMenuContext(prefixFieldPath = 'roles') {
|
|
15
|
+
function createFormMenuContext(prefixFieldPath = 'roles', collectionName = 'roles') {
|
|
16
16
|
const engine = new FlowEngine();
|
|
17
17
|
engine.registerModels({
|
|
18
18
|
FormItemModel,
|
|
@@ -36,15 +36,29 @@ function createFormMenuContext(prefixFieldPath = 'roles') {
|
|
|
36
36
|
fields: [
|
|
37
37
|
{ name: 'id', type: 'integer', interface: 'number', title: 'ID' },
|
|
38
38
|
{ name: 'name', type: 'string', interface: 'input', title: 'Name' },
|
|
39
|
+
{ name: 'department', type: 'belongsTo', interface: 'm2o', target: 'departments', title: 'Department' },
|
|
39
40
|
],
|
|
40
41
|
});
|
|
42
|
+
dataSource.addCollection({
|
|
43
|
+
name: 'departments',
|
|
44
|
+
filterTargetKey: 'id',
|
|
45
|
+
fields: [
|
|
46
|
+
{ name: 'name', type: 'string', interface: 'input', title: 'Name' },
|
|
47
|
+
{ name: 'company', type: 'belongsTo', interface: 'm2o', target: 'companies', title: 'Company' },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
dataSource.addCollection({
|
|
51
|
+
name: 'companies',
|
|
52
|
+
filterTargetKey: 'id',
|
|
53
|
+
fields: [{ name: 'name', type: 'string', interface: 'input', title: 'Name' }],
|
|
54
|
+
});
|
|
41
55
|
|
|
42
56
|
const blockModel = engine.createModel({ use: 'FlowModel', uid: 'users-form-block' });
|
|
43
57
|
(blockModel as any).collection = dataSource.getCollection('users');
|
|
44
58
|
|
|
45
59
|
const gridModel = engine.createModel({ use: 'FlowModel', uid: 'users-form-grid' });
|
|
46
60
|
gridModel.context.defineProperty('blockModel', { value: blockModel });
|
|
47
|
-
gridModel.context.defineProperty('collection', { value: dataSource.getCollection(
|
|
61
|
+
gridModel.context.defineProperty('collection', { value: dataSource.getCollection(collectionName) });
|
|
48
62
|
gridModel.context.defineProperty('prefixFieldPath', { value: prefixFieldPath });
|
|
49
63
|
|
|
50
64
|
return gridModel.context as FlowModelContext;
|
|
@@ -105,4 +119,15 @@ describe('FormItemModel defineChildren', () => {
|
|
|
105
119
|
|
|
106
120
|
expect((jsNameItem?.toggleable as (model: any) => boolean)(createModelLike(normalCreateOptions))).toBe(true);
|
|
107
121
|
});
|
|
122
|
+
|
|
123
|
+
it('hides association fields after two association levels in form add-field menus', async () => {
|
|
124
|
+
const ctx = createFormMenuContext('roles.department', 'departments');
|
|
125
|
+
const formItems = FormItemModel.defineChildren(ctx) as SubModelItem[];
|
|
126
|
+
const jsItems = (await FormJSFieldItemModel.defineChildren(ctx)) as SubModelItem[];
|
|
127
|
+
|
|
128
|
+
expect(formItems.map((item) => item.key)).toContain('roles.department.name');
|
|
129
|
+
expect(formItems.map((item) => item.key)).not.toContain('roles.department.company');
|
|
130
|
+
expect(jsItems.map((item) => item.key)).toContain('roles.department.name');
|
|
131
|
+
expect(jsItems.map((item) => item.key)).not.toContain('roles.department.company');
|
|
132
|
+
});
|
|
108
133
|
});
|
|
@@ -47,7 +47,7 @@ export function FieldDeletePlaceholder(props: any) {
|
|
|
47
47
|
const dataSourcePrefix = `${t(dataSource.displayName || dataSource.key)} > `;
|
|
48
48
|
const collectionPrefix = collection ? `${t(collection.title) || collection.name || collection.tableName} > ` : '';
|
|
49
49
|
return `${dataSourcePrefix}${collectionPrefix}${name}`;
|
|
50
|
-
}, []);
|
|
50
|
+
}, [collection, dataSource.displayName, dataSource.key, name, t]);
|
|
51
51
|
const content = t(`The {{type}} "{{name}}" may have been deleted. Please remove this {{blockType}}.`, {
|
|
52
52
|
type: t('Field'),
|
|
53
53
|
name: nameValue,
|
|
@@ -71,7 +71,7 @@ function FieldWithoutPermissionPlaceholder() {
|
|
|
71
71
|
const dataSourcePrefix = `${t(dataSource.displayName || dataSource.key)} > `;
|
|
72
72
|
const collectionPrefix = collection ? `${t(collection.title) || collection.name || collection.tableName} > ` : '';
|
|
73
73
|
return `${dataSourcePrefix}${collectionPrefix}${name}`;
|
|
74
|
-
}, []);
|
|
74
|
+
}, [collection, dataSource.displayName, dataSource.key, name, t]);
|
|
75
75
|
const { actionName } = model.forbidden;
|
|
76
76
|
const messageValue = useMemo(() => {
|
|
77
77
|
return t(
|
|
@@ -81,7 +81,7 @@ function FieldWithoutPermissionPlaceholder() {
|
|
|
81
81
|
actionName: t(capitalize(actionName)),
|
|
82
82
|
},
|
|
83
83
|
).replaceAll('>', '>');
|
|
84
|
-
}, [nameValue, t]);
|
|
84
|
+
}, [actionName, nameValue, t]);
|
|
85
85
|
return (
|
|
86
86
|
<Tooltip title={messageValue}>
|
|
87
87
|
<LockOutlined style={{ opacity: '0.3' }} />
|
|
@@ -89,6 +89,15 @@ function FieldWithoutPermissionPlaceholder() {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
export const TABLE_COLUMN_MIN_WIDTH = 10;
|
|
93
|
+
|
|
94
|
+
export function normalizeTableColumnWidth(width: number | null | undefined) {
|
|
95
|
+
if (typeof width === 'number' && width < TABLE_COLUMN_MIN_WIDTH) {
|
|
96
|
+
return TABLE_COLUMN_MIN_WIDTH;
|
|
97
|
+
}
|
|
98
|
+
return width;
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
export const CustomWidth = ({ setOpen, t, handleChange, defaultValue }) => {
|
|
93
102
|
const [customWidth, setCustomWidth] = useState(defaultValue);
|
|
94
103
|
return (
|
|
@@ -104,13 +113,14 @@ export const CustomWidth = ({ setOpen, t, handleChange, defaultValue }) => {
|
|
|
104
113
|
<Space.Compact block>
|
|
105
114
|
<InputNumber
|
|
106
115
|
placeholder={t('Custom column width')}
|
|
116
|
+
min={TABLE_COLUMN_MIN_WIDTH}
|
|
107
117
|
value={customWidth}
|
|
108
118
|
onChange={(val) => {
|
|
109
119
|
setCustomWidth(val);
|
|
110
120
|
}}
|
|
111
121
|
style={{ width: '100%', minWidth: 200 }}
|
|
112
122
|
/>
|
|
113
|
-
<Button type="primary" onClick={() => handleChange(customWidth)}>
|
|
123
|
+
<Button type="primary" onClick={() => handleChange(normalizeTableColumnWidth(customWidth))}>
|
|
114
124
|
OK
|
|
115
125
|
</Button>
|
|
116
126
|
</Space.Compact>
|
|
@@ -442,7 +452,7 @@ TableColumnModel.registerFlow({
|
|
|
442
452
|
width: 150,
|
|
443
453
|
},
|
|
444
454
|
handler(ctx, params) {
|
|
445
|
-
ctx.model.setProps('width', params.width);
|
|
455
|
+
ctx.model.setProps('width', normalizeTableColumnWidth(params.width));
|
|
446
456
|
},
|
|
447
457
|
},
|
|
448
458
|
aclCheck: {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { tExpr, FlowModel, ModelRenderMode } from '@nocobase/flow-engine';
|
|
11
11
|
import { Divider } from 'antd';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { CustomWidth } from './TableColumnModel';
|
|
13
|
+
import { CustomWidth, normalizeTableColumnWidth } from './TableColumnModel';
|
|
14
14
|
export class TableCustomColumnModel extends FlowModel {
|
|
15
15
|
static renderMode: ModelRenderMode = ModelRenderMode.RenderFunction;
|
|
16
16
|
}
|
|
@@ -100,7 +100,7 @@ TableCustomColumnModel.registerFlow({
|
|
|
100
100
|
width: 150,
|
|
101
101
|
},
|
|
102
102
|
handler(ctx, params) {
|
|
103
|
-
ctx.model.setProps('width', params.width);
|
|
103
|
+
ctx.model.setProps('width', normalizeTableColumnWidth(params.width));
|
|
104
104
|
},
|
|
105
105
|
},
|
|
106
106
|
fixed: {
|
|
@@ -12,6 +12,24 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
12
12
|
import { TableColumnModel } from '../TableColumnModel';
|
|
13
13
|
|
|
14
14
|
describe('TableColumnModel sorter settings', () => {
|
|
15
|
+
it('clamps custom column width to the minimum value', () => {
|
|
16
|
+
const engine = new FlowEngine();
|
|
17
|
+
const model = new TableColumnModel({ uid: 'table-column-min-width', flowEngine: engine } as any);
|
|
18
|
+
const widthStep = model.getFlow('tableColumnSettings')?.steps?.width as any;
|
|
19
|
+
const setProps = vi.fn();
|
|
20
|
+
|
|
21
|
+
widthStep.handler(
|
|
22
|
+
{
|
|
23
|
+
model: {
|
|
24
|
+
setProps,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{ width: 0 },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(setProps).toHaveBeenCalledWith('width', 10);
|
|
31
|
+
});
|
|
32
|
+
|
|
15
33
|
it('hides quick edit setting for relation path columns added from association groups', async () => {
|
|
16
34
|
const engine = new FlowEngine();
|
|
17
35
|
const model = new TableColumnModel({ uid: 'table-column-relation-path-quick-edit', flowEngine: engine } as any);
|
package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx
CHANGED
|
@@ -33,7 +33,7 @@ import React, { useRef, useMemo, useEffect } from 'react';
|
|
|
33
33
|
import { SubTableFieldModel } from '.';
|
|
34
34
|
import { FieldModel } from '../../../base/FieldModel';
|
|
35
35
|
import { DetailsItemModel } from '../../../blocks/details/DetailsItemModel';
|
|
36
|
-
import { FieldDeletePlaceholder, CustomWidth } from '../../../blocks/table/TableColumnModel';
|
|
36
|
+
import { FieldDeletePlaceholder, CustomWidth, normalizeTableColumnWidth } from '../../../blocks/table/TableColumnModel';
|
|
37
37
|
import { buildDynamicNamePath } from '../../../blocks/form/dynamicNamePath';
|
|
38
38
|
import { getSubTableRowIdentity } from './rowIdentity';
|
|
39
39
|
import { getFieldBindingUse, rebuildFieldSubModel } from '../../../../internal/utils/rebuildFieldSubModel';
|
|
@@ -67,7 +67,7 @@ export function FieldWithoutPermissionPlaceholder({ targetModel }) {
|
|
|
67
67
|
const dataSourcePrefix = `${t(dataSource.displayName || dataSource.key)} > `;
|
|
68
68
|
const collectionPrefix = collection ? `${t(collection.title) || collection.name || collection.tableName} > ` : '';
|
|
69
69
|
return `${dataSourcePrefix}${collectionPrefix}${name}`;
|
|
70
|
-
}, []);
|
|
70
|
+
}, [collection, dataSource.displayName, dataSource.key, name, t]);
|
|
71
71
|
const { actionName } = fieldModel.forbidden || {};
|
|
72
72
|
const messageValue = useMemo(() => {
|
|
73
73
|
return t(
|
|
@@ -77,7 +77,7 @@ export function FieldWithoutPermissionPlaceholder({ targetModel }) {
|
|
|
77
77
|
actionName: t(capitalize(actionName)),
|
|
78
78
|
},
|
|
79
79
|
).replaceAll('>', '>');
|
|
80
|
-
}, [nameValue, t]);
|
|
80
|
+
}, [actionName, nameValue, t]);
|
|
81
81
|
return (
|
|
82
82
|
<Tooltip title={messageValue}>
|
|
83
83
|
<LockOutlined style={{ opacity: '0.3' }} />
|
|
@@ -100,10 +100,9 @@ const LargeFieldEdit = observer(({ model, params: { fieldPath, index }, defaultV
|
|
|
100
100
|
const handleChange = useMemo(
|
|
101
101
|
() =>
|
|
102
102
|
debounce((val) => {
|
|
103
|
-
if (props.onChange) props.onChange(val);
|
|
104
103
|
if (onChange) onChange(val);
|
|
105
104
|
}, 200),
|
|
106
|
-
[
|
|
105
|
+
[onChange],
|
|
107
106
|
);
|
|
108
107
|
|
|
109
108
|
return <FieldModelRenderer model={model} {...rest} onChange={handleChange} />;
|
|
@@ -149,7 +148,7 @@ const LargeFieldEdit = observer(({ model, params: { fieldPath, index }, defaultV
|
|
|
149
148
|
</Space>
|
|
150
149
|
);
|
|
151
150
|
}
|
|
152
|
-
}, [collectionField.interface, defaultValue, fieldModel]);
|
|
151
|
+
}, [collectionField.interface, defaultValue, disabled, fieldModel]);
|
|
153
152
|
return (
|
|
154
153
|
<div
|
|
155
154
|
ref={ref}
|
|
@@ -830,7 +829,7 @@ SubTableColumnModel.registerFlow({
|
|
|
830
829
|
width: 200,
|
|
831
830
|
},
|
|
832
831
|
handler(ctx, params) {
|
|
833
|
-
ctx.model.setProps('width', params.width);
|
|
832
|
+
ctx.model.setProps('width', normalizeTableColumnWidth(params.width));
|
|
834
833
|
},
|
|
835
834
|
},
|
|
836
835
|
aclCheck: {
|