@nocobase/client 0.7.2-alpha.5 → 0.7.3-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/block-provider/FormBlockProvider.js +8 -3
- package/es/block-provider/TableSelectorProvider.js +41 -13
- package/es/block-provider/hooks/index.d.ts +6 -0
- package/es/block-provider/hooks/index.js +145 -63
- package/es/collection-manager/CollectionField.js +5 -3
- package/es/collection-manager/interfaces/input.js +103 -0
- package/es/collection-manager/interfaces/integer.js +63 -0
- package/es/collection-manager/interfaces/markdown.js +34 -0
- package/es/collection-manager/interfaces/number.js +55 -0
- package/es/collection-manager/interfaces/password.js +35 -1
- package/es/collection-manager/interfaces/percent.js +97 -0
- package/es/collection-manager/interfaces/richText.js +34 -0
- package/es/collection-manager/interfaces/textarea.js +34 -0
- package/es/file-manager/FileStorageShortcut.js +2 -2
- package/es/locale/en_US.d.ts +5 -0
- package/es/locale/en_US.js +6 -1
- package/es/locale/zh_CN.d.ts +23 -0
- package/es/locale/zh_CN.js +24 -1
- package/es/plugin-manager/PluginManager.js +8 -4
- package/es/schema-component/antd/action/Action.Modal.js +1 -1
- package/es/schema-component/antd/form-item/FormItem.js +156 -3
- package/es/schema-component/antd/grid/Grid.js +72 -6
- package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/es/schema-component/antd/input-number/InputNumber.js +25 -1
- package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/percent/Percent.js +2 -2
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
- package/es/schema-component/antd/table/Table.Array.js +2 -2
- package/es/schema-component/antd/table/Table.Void.js +11 -1
- package/es/schema-component/antd/table-v2/Table.js +1 -4
- package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
- package/es/schema-component/hooks/useDesignable.js +21 -21
- package/es/schema-component/hooks/useProps.js +1 -1
- package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
- package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.js +253 -69
- package/es/schema-initializer/items/index.d.ts +2 -0
- package/es/schema-initializer/items/index.js +46 -1
- package/es/schema-initializer/utils.js +6 -2
- package/es/system-settings/SystemSettingsShortcut.js +35 -12
- package/lib/block-provider/FormBlockProvider.js +7 -2
- package/lib/block-provider/TableSelectorProvider.js +41 -13
- package/lib/block-provider/hooks/index.d.ts +6 -0
- package/lib/block-provider/hooks/index.js +154 -65
- package/lib/collection-manager/CollectionField.js +5 -2
- package/lib/collection-manager/interfaces/input.js +104 -0
- package/lib/collection-manager/interfaces/integer.js +65 -0
- package/lib/collection-manager/interfaces/markdown.js +35 -0
- package/lib/collection-manager/interfaces/number.js +56 -0
- package/lib/collection-manager/interfaces/password.js +36 -1
- package/lib/collection-manager/interfaces/percent.js +99 -0
- package/lib/collection-manager/interfaces/richText.js +35 -0
- package/lib/collection-manager/interfaces/textarea.js +35 -0
- package/lib/file-manager/FileStorageShortcut.js +1 -1
- package/lib/locale/en_US.d.ts +5 -0
- package/lib/locale/en_US.js +6 -1
- package/lib/locale/zh_CN.d.ts +23 -0
- package/lib/locale/zh_CN.js +24 -1
- package/lib/plugin-manager/PluginManager.js +8 -3
- package/lib/schema-component/antd/action/Action.Modal.js +1 -1
- package/lib/schema-component/antd/form-item/FormItem.js +165 -5
- package/lib/schema-component/antd/grid/Grid.js +69 -3
- package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/lib/schema-component/antd/input-number/InputNumber.js +29 -2
- package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/percent/Percent.js +2 -2
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
- package/lib/schema-component/antd/table/Table.Array.js +2 -2
- package/lib/schema-component/antd/table/Table.Void.js +11 -1
- package/lib/schema-component/antd/table-v2/Table.js +1 -4
- package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
- package/lib/schema-component/hooks/useDesignable.js +21 -21
- package/lib/schema-component/hooks/useProps.js +1 -1
- package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
- package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +254 -66
- package/lib/schema-initializer/items/index.d.ts +2 -0
- package/lib/schema-initializer/items/index.js +52 -1
- package/lib/schema-initializer/utils.js +6 -2
- package/lib/system-settings/SystemSettingsShortcut.js +37 -13
- package/package.json +6 -4
|
@@ -23,7 +23,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
23
23
|
|
|
24
24
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
25
|
|
|
26
|
-
import { RecursionField, useFieldSchema } from '@formily/react';
|
|
26
|
+
import { RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
27
27
|
import { Select } from 'antd';
|
|
28
28
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
29
29
|
import { useTableSelectorProps as useTsp } from '../../../block-provider/TableSelectorProvider';
|
|
@@ -32,34 +32,48 @@ import { FormProvider, SchemaComponentOptions } from '../../core';
|
|
|
32
32
|
import { useCompile } from '../../hooks';
|
|
33
33
|
import { ActionContext, useActionContext } from '../action';
|
|
34
34
|
import { useFieldNames } from './useFieldNames';
|
|
35
|
+
import { differenceBy, unionBy } from 'lodash';
|
|
35
36
|
var RecordPickerContext = /*#__PURE__*/createContext(null);
|
|
36
37
|
|
|
37
38
|
var useTableSelectorProps = function useTableSelectorProps() {
|
|
39
|
+
var field = useField();
|
|
40
|
+
|
|
38
41
|
var _useContext = useContext(RecordPickerContext),
|
|
39
42
|
multiple = _useContext.multiple,
|
|
40
43
|
value = _useContext.value,
|
|
41
44
|
setSelectedRows = _useContext.setSelectedRows,
|
|
42
|
-
|
|
45
|
+
rcSelectRows = _useContext.selectedRows;
|
|
43
46
|
|
|
44
47
|
var _useTsp = useTsp(),
|
|
45
48
|
_onRowSelectionChange = _useTsp.onRowSelectionChange,
|
|
46
49
|
rowKey = _useTsp.rowKey,
|
|
47
|
-
others = _objectWithoutProperties(_useTsp, _excluded);
|
|
50
|
+
others = _objectWithoutProperties(_useTsp, _excluded); // console.log('useTableSelectorProps', field.value, value);
|
|
51
|
+
|
|
48
52
|
|
|
49
53
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
50
54
|
rowKey: rowKey,
|
|
51
55
|
rowSelection: {
|
|
52
56
|
type: multiple ? 'checkbox' : 'radio',
|
|
53
|
-
defaultSelectedRowKeys:
|
|
54
|
-
|
|
55
|
-
}),
|
|
56
|
-
selectedRowKeys: selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
|
|
57
|
+
// defaultSelectedRowKeys: rcSelectRows?.map((item) => item[rowKey||'id']),
|
|
58
|
+
selectedRowKeys: rcSelectRows === null || rcSelectRows === void 0 ? void 0 : rcSelectRows.map(function (item) {
|
|
57
59
|
return item[rowKey || 'id'];
|
|
58
60
|
})
|
|
59
61
|
},
|
|
60
62
|
onRowSelectionChange: function onRowSelectionChange(selectedRowKeys, selectedRows) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
if (multiple) {
|
|
64
|
+
var scopeRows = field.value || [];
|
|
65
|
+
var allSelectedRows = rcSelectRows || [];
|
|
66
|
+
var otherRows = differenceBy(allSelectedRows, scopeRows, rowKey || 'id');
|
|
67
|
+
var unionSelectedRows = unionBy(otherRows, selectedRows, rowKey || 'id');
|
|
68
|
+
var unionSelectedRowKeys = unionSelectedRows.map(function (item) {
|
|
69
|
+
return item[rowKey || 'id'];
|
|
70
|
+
});
|
|
71
|
+
setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(unionSelectedRows);
|
|
72
|
+
_onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(unionSelectedRowKeys, unionSelectedRows);
|
|
73
|
+
} else {
|
|
74
|
+
setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(selectedRows);
|
|
75
|
+
_onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(selectedRowKeys, selectedRows);
|
|
76
|
+
}
|
|
63
77
|
}
|
|
64
78
|
});
|
|
65
79
|
};
|
|
@@ -137,13 +151,13 @@ export var InputRecordPicker = function InputRecordPicker(props) {
|
|
|
137
151
|
setSelectedRows(opts);
|
|
138
152
|
}
|
|
139
153
|
}, [value]);
|
|
140
|
-
useEffect(function () {});
|
|
141
154
|
|
|
142
155
|
var getValue = function getValue() {
|
|
143
|
-
if (multiple == null) return null;
|
|
144
|
-
|
|
156
|
+
if (multiple == null) return null; // console.log('getValue', multiple, value, Array.isArray(value));
|
|
157
|
+
|
|
158
|
+
return Array.isArray(value) ? value === null || value === void 0 ? void 0 : value.map(function (v) {
|
|
145
159
|
return v[fieldNames.value];
|
|
146
|
-
}) :
|
|
160
|
+
}) : value === null || value === void 0 ? void 0 : value[fieldNames.value];
|
|
147
161
|
};
|
|
148
162
|
|
|
149
163
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _objectSpread(_objectSpread({}, others), {}, {
|
|
@@ -12,7 +12,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
12
12
|
|
|
13
13
|
import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
|
|
14
14
|
import { toArr } from '@formily/shared';
|
|
15
|
-
import React, { useRef, useState } from 'react';
|
|
15
|
+
import React, { Fragment, useRef, useState } from 'react';
|
|
16
16
|
import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
|
|
17
17
|
import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager';
|
|
18
18
|
import { RecordProvider, useRecord } from '../../../record-provider';
|
|
@@ -57,7 +57,9 @@ export var ReadPrettyRecordPicker = observer(function (props) {
|
|
|
57
57
|
|
|
58
58
|
var renderRecords = function renderRecords() {
|
|
59
59
|
return toArr(field.value).map(function (record, index, arr) {
|
|
60
|
-
return /*#__PURE__*/React.createElement(
|
|
60
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
61
|
+
key: "".concat(record.id, "_").concat(index)
|
|
62
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("a", {
|
|
61
63
|
onClick: function onClick(e) {
|
|
62
64
|
var _ellipsisWithTooltipR;
|
|
63
65
|
|
|
@@ -71,8 +71,8 @@ var useTableColumns = function useTableColumns() {
|
|
|
71
71
|
render: function render(v, record) {
|
|
72
72
|
var _field$value;
|
|
73
73
|
|
|
74
|
-
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record);
|
|
75
|
-
|
|
74
|
+
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
|
|
75
|
+
|
|
76
76
|
return /*#__PURE__*/React.createElement(RecordIndexProvider, {
|
|
77
77
|
index: index
|
|
78
78
|
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
@@ -13,7 +13,7 @@ import { useAttach } from '../../hooks';
|
|
|
13
13
|
import { TableArray } from './Table.Array';
|
|
14
14
|
|
|
15
15
|
var usePaginationProps = function usePaginationProps(props, service) {
|
|
16
|
-
var _props$request, _props$request$params;
|
|
16
|
+
var _props$request, _props$request$params, _service$data;
|
|
17
17
|
|
|
18
18
|
if (props.pagination === false) {
|
|
19
19
|
return false;
|
|
@@ -27,6 +27,16 @@ var usePaginationProps = function usePaginationProps(props, service) {
|
|
|
27
27
|
pagination.defaultPageSize = props === null || props === void 0 ? void 0 : (_props$request2 = props.request) === null || _props$request2 === void 0 ? void 0 : (_props$request2$param = _props$request2.params) === null || _props$request2$param === void 0 ? void 0 : _props$request2$param.pageSize;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
if (!pagination.total && (service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.meta)) {
|
|
31
|
+
var _service$data$meta = service.data.meta,
|
|
32
|
+
count = _service$data$meta.count,
|
|
33
|
+
page = _service$data$meta.page,
|
|
34
|
+
pageSize = _service$data$meta.pageSize;
|
|
35
|
+
pagination.total = count;
|
|
36
|
+
pagination.current = page;
|
|
37
|
+
pagination.pageSize = pageSize;
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
return _objectSpread(_objectSpread({
|
|
31
41
|
showSizeChanger: true
|
|
32
42
|
}, pagination), {}, {
|
|
@@ -48,8 +48,7 @@ var useTableColumns = function useTableColumns() {
|
|
|
48
48
|
|
|
49
49
|
var _useSchemaInitializer = useSchemaInitializer(schema['x-initializer']),
|
|
50
50
|
exists = _useSchemaInitializer.exists,
|
|
51
|
-
render = _useSchemaInitializer.render;
|
|
52
|
-
|
|
51
|
+
render = _useSchemaInitializer.render;
|
|
53
52
|
|
|
54
53
|
var columns = schema.reduceProperties(function (buf, s) {
|
|
55
54
|
if (isColumnComponent(s)) {
|
|
@@ -64,7 +63,6 @@ var useTableColumns = function useTableColumns() {
|
|
|
64
63
|
}
|
|
65
64
|
}, []);
|
|
66
65
|
var dataIndex = (collectionFields === null || collectionFields === void 0 ? void 0 : collectionFields.length) > 0 ? collectionFields[0].name : s.name;
|
|
67
|
-
console.log('useTableColumns', s.name, s, field.value);
|
|
68
66
|
return {
|
|
69
67
|
title: /*#__PURE__*/React.createElement(RecursionField, {
|
|
70
68
|
name: s.name,
|
|
@@ -80,7 +78,6 @@ var useTableColumns = function useTableColumns() {
|
|
|
80
78
|
|
|
81
79
|
var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
|
|
82
80
|
|
|
83
|
-
console.log('useTableColumns.index', index, record);
|
|
84
81
|
return /*#__PURE__*/React.createElement(RecordIndexProvider, {
|
|
85
82
|
index: index
|
|
86
83
|
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { usePrefixCls } from '@formily/antd/lib/__builtins__';
|
|
2
|
+
import { toArr } from '@formily/shared';
|
|
3
3
|
import cls from 'classnames';
|
|
4
|
+
import moment from 'moment';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
export var ReadPretty = function ReadPretty(props) {
|
|
6
|
-
var
|
|
7
|
+
var value = props.value,
|
|
8
|
+
_props$format = props.format,
|
|
9
|
+
format = _props$format === void 0 ? 'HH:mm:ss' : _props$format;
|
|
7
10
|
var prefixCls = usePrefixCls('description-text', props);
|
|
11
|
+
var values = toArr(value);
|
|
8
12
|
|
|
9
13
|
var getLabels = function getLabels() {
|
|
10
|
-
var labels =
|
|
11
|
-
|
|
14
|
+
var labels = values.map(function (v) {
|
|
15
|
+
return moment(v, 'HH:mm:ss').format(format);
|
|
16
|
+
});
|
|
17
|
+
return labels.join('~');
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -724,6 +724,27 @@ export var Designable = /*#__PURE__*/function () {
|
|
|
724
724
|
wrap = _options$wrap4 === void 0 ? defaultWrap : _options$wrap4,
|
|
725
725
|
breakRemoveOn = options.breakRemoveOn,
|
|
726
726
|
removeParentsIfNoChildren = options.removeParentsIfNoChildren;
|
|
727
|
+
var order = 0;
|
|
728
|
+
var newOrder = 0;
|
|
729
|
+
var start = false;
|
|
730
|
+
var properties = {};
|
|
731
|
+
this.current.parent.mapProperties(function (property, key) {
|
|
732
|
+
property['x-index'] = order;
|
|
733
|
+
|
|
734
|
+
if (key === _this4.current.name) {
|
|
735
|
+
++order;
|
|
736
|
+
newOrder = order;
|
|
737
|
+
start = true;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
++order;
|
|
741
|
+
|
|
742
|
+
if (start && key !== _this4.current.name) {
|
|
743
|
+
properties[key] = property;
|
|
744
|
+
|
|
745
|
+
_this4.current.parent.removeProperty(key);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
727
748
|
|
|
728
749
|
if (Schema.isSchemaInstance(schema)) {
|
|
729
750
|
if (this.parentsIn(schema)) {
|
|
@@ -747,27 +768,6 @@ export var Designable = /*#__PURE__*/function () {
|
|
|
747
768
|
schema = cloneDeep(schema);
|
|
748
769
|
}
|
|
749
770
|
|
|
750
|
-
var order = 0;
|
|
751
|
-
var newOrder = 0;
|
|
752
|
-
var start = false;
|
|
753
|
-
var properties = {};
|
|
754
|
-
this.current.parent.mapProperties(function (property, key) {
|
|
755
|
-
property['x-index'] = order;
|
|
756
|
-
|
|
757
|
-
if (key === _this4.current.name) {
|
|
758
|
-
++order;
|
|
759
|
-
newOrder = order;
|
|
760
|
-
start = true;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
++order;
|
|
764
|
-
|
|
765
|
-
if (start && key !== _this4.current.name) {
|
|
766
|
-
properties[key] = property;
|
|
767
|
-
|
|
768
|
-
_this4.current.parent.removeProperty(key);
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
771
|
this.prepareProperty(schema);
|
|
772
772
|
var wrapped = wrap(schema);
|
|
773
773
|
var s = this.current.parent.addProperty(wrapped.name || uid(), wrapped);
|
|
@@ -9,6 +9,6 @@ export var useProps = function useProps(props, options) {
|
|
|
9
9
|
var useProps = props.useProps,
|
|
10
10
|
props1 = _objectWithoutProperties(props, _excluded);
|
|
11
11
|
|
|
12
|
-
var props2 =
|
|
12
|
+
var props2 = typeof useProps === 'function' ? useProps() : {};
|
|
13
13
|
return merge(props1 || {}, props2, options);
|
|
14
14
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { union } from 'lodash';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { SchemaInitializer } from '../SchemaInitializer';
|
|
4
|
-
import { gridRowColWrap, useFormItemInitializerFields } from '../utils'; // 表单里配置字段
|
|
5
|
+
import { gridRowColWrap, useAssociatedFormItemInitializerFields, useFormItemInitializerFields } from '../utils'; // 表单里配置字段
|
|
5
6
|
|
|
6
7
|
export var FormItemInitializers = function FormItemInitializers(props) {
|
|
7
8
|
var _useTranslation = useTranslation(),
|
|
@@ -9,14 +10,24 @@ export var FormItemInitializers = function FormItemInitializers(props) {
|
|
|
9
10
|
|
|
10
11
|
var insertPosition = props.insertPosition,
|
|
11
12
|
component = props.component;
|
|
13
|
+
var associationFields = useAssociatedFormItemInitializerFields({
|
|
14
|
+
readPretty: true,
|
|
15
|
+
block: 'Form'
|
|
16
|
+
});
|
|
12
17
|
return /*#__PURE__*/React.createElement(SchemaInitializer.Button, {
|
|
13
18
|
wrap: gridRowColWrap,
|
|
14
19
|
icon: 'SettingOutlined',
|
|
15
|
-
items: [{
|
|
20
|
+
items: union([{
|
|
16
21
|
type: 'itemGroup',
|
|
17
22
|
title: t('Display fields'),
|
|
18
23
|
children: useFormItemInitializerFields()
|
|
24
|
+
}], associationFields.length > 0 ? [{
|
|
25
|
+
type: 'divider'
|
|
19
26
|
}, {
|
|
27
|
+
type: 'itemGroup',
|
|
28
|
+
title: t('Display association fields'),
|
|
29
|
+
children: associationFields
|
|
30
|
+
}] : [], [{
|
|
20
31
|
type: 'divider'
|
|
21
32
|
}, {
|
|
22
33
|
type: 'item',
|
|
@@ -32,7 +43,7 @@ export var FormItemInitializers = function FormItemInitializers(props) {
|
|
|
32
43
|
content: t('This is a demo text, **supports Markdown syntax**.')
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
|
-
}],
|
|
46
|
+
}]),
|
|
36
47
|
insertPosition: insertPosition,
|
|
37
48
|
component: component,
|
|
38
49
|
title: component ? null : t('Configure fields')
|
|
@@ -27,6 +27,14 @@ export var ReadPrettyFormActionInitializers = {
|
|
|
27
27
|
'x-component': 'Action',
|
|
28
28
|
'x-decorator': 'ACLActionProvider'
|
|
29
29
|
}
|
|
30
|
+
}, {
|
|
31
|
+
type: 'item',
|
|
32
|
+
title: '{{t("Print")}}',
|
|
33
|
+
component: 'PrintActionInitializer',
|
|
34
|
+
schema: {
|
|
35
|
+
'x-component': 'Action',
|
|
36
|
+
'x-decorator': 'ACLActionProvider'
|
|
37
|
+
}
|
|
30
38
|
}]
|
|
31
39
|
}, {
|
|
32
40
|
type: 'divider'
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
+
import { union } from 'lodash';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { SchemaInitializer } from '../SchemaInitializer';
|
|
4
|
-
import { gridRowColWrap, useFormItemInitializerFields } from '../utils';
|
|
5
|
+
import { gridRowColWrap, useAssociatedFormItemInitializerFields, useFormItemInitializerFields } from '../utils';
|
|
5
6
|
export var ReadPrettyFormItemInitializers = function ReadPrettyFormItemInitializers(props) {
|
|
6
7
|
var _useTranslation = useTranslation(),
|
|
7
8
|
t = _useTranslation.t;
|
|
8
9
|
|
|
9
10
|
var insertPosition = props.insertPosition,
|
|
10
11
|
component = props.component;
|
|
12
|
+
var associationFields = useAssociatedFormItemInitializerFields({
|
|
13
|
+
readPretty: true,
|
|
14
|
+
block: 'Form'
|
|
15
|
+
});
|
|
11
16
|
return /*#__PURE__*/React.createElement(SchemaInitializer.Button, {
|
|
12
17
|
wrap: gridRowColWrap,
|
|
13
18
|
icon: 'SettingOutlined',
|
|
14
|
-
items: [{
|
|
19
|
+
items: union([{
|
|
15
20
|
type: 'itemGroup',
|
|
16
21
|
title: t('Display fields'),
|
|
17
22
|
children: useFormItemInitializerFields()
|
|
23
|
+
}], associationFields.length > 0 ? [{
|
|
24
|
+
type: 'divider'
|
|
18
25
|
}, {
|
|
26
|
+
type: 'itemGroup',
|
|
27
|
+
title: t('Display association fields'),
|
|
28
|
+
children: associationFields
|
|
29
|
+
}] : [], [{
|
|
19
30
|
type: 'divider'
|
|
20
31
|
}, {
|
|
21
32
|
type: 'item',
|
|
@@ -31,7 +42,7 @@ export var ReadPrettyFormItemInitializers = function ReadPrettyFormItemInitializ
|
|
|
31
42
|
content: t('This is a demo text, **supports Markdown syntax**.')
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
|
-
}],
|
|
45
|
+
}]),
|
|
35
46
|
insertPosition: insertPosition,
|
|
36
47
|
component: component,
|
|
37
48
|
title: component ? null : t('Configure fields')
|
|
@@ -1,11 +1,40 @@
|
|
|
1
|
+
import { useFieldSchema } from '@formily/react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { SchemaInitializer, useCollection } from '../..';
|
|
4
|
+
import { SchemaInitializer, useCollection, useCollectionManager } from '../..';
|
|
4
5
|
import { gridRowColWrap } from '../utils';
|
|
5
6
|
|
|
7
|
+
var recursiveParent = function recursiveParent(schema) {
|
|
8
|
+
var _schema$xDecorator;
|
|
9
|
+
|
|
10
|
+
if (!schema) return null;
|
|
11
|
+
|
|
12
|
+
if ((_schema$xDecorator = schema['x-decorator']) === null || _schema$xDecorator === void 0 ? void 0 : _schema$xDecorator.endsWith('BlockProvider')) {
|
|
13
|
+
var _schema$xDecoratorP;
|
|
14
|
+
|
|
15
|
+
return (_schema$xDecoratorP = schema['x-decorator-props']) === null || _schema$xDecoratorP === void 0 ? void 0 : _schema$xDecoratorP['collection'];
|
|
16
|
+
} else {
|
|
17
|
+
return recursiveParent(schema.parent);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
var useRelationFields = function useRelationFields() {
|
|
7
|
-
var
|
|
8
|
-
|
|
22
|
+
var fieldSchema = useFieldSchema();
|
|
23
|
+
|
|
24
|
+
var _useCollectionManager = useCollectionManager(),
|
|
25
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
26
|
+
|
|
27
|
+
var fields = [];
|
|
28
|
+
|
|
29
|
+
if (fieldSchema['x-initializer']) {
|
|
30
|
+
fields = useCollection().fields;
|
|
31
|
+
} else {
|
|
32
|
+
var collection = recursiveParent(fieldSchema.parent);
|
|
33
|
+
|
|
34
|
+
if (collection) {
|
|
35
|
+
fields = getCollectionFields(collection);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
9
38
|
|
|
10
39
|
var relationFields = fields.filter(function (field) {
|
|
11
40
|
return ['linkTo', 'subTable', 'o2m', 'm2m', 'obo', 'oho', 'o2o', 'm2o'].includes(field.interface);
|
|
@@ -37,6 +37,17 @@ export var TableActionInitializers = {
|
|
|
37
37
|
skipScopeCheck: true
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
}, {
|
|
41
|
+
type: 'item',
|
|
42
|
+
title: "{{t('Refresh')}}",
|
|
43
|
+
component: 'RefreshActionInitializer',
|
|
44
|
+
schema: {
|
|
45
|
+
'x-align': 'right',
|
|
46
|
+
'x-decorator': 'ACLActionProvider',
|
|
47
|
+
'x-acl-action-props': {
|
|
48
|
+
skipScopeCheck: true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
40
51
|
}]
|
|
41
52
|
}]
|
|
42
53
|
};
|