@nocobase/client 0.9.2-alpha.3 → 0.9.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/acl/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
- package/es/api-client/hooks/useRequest.d.ts +1 -14
- package/es/api-client/hooks/useRequest.js +48 -53
- package/es/block-provider/DetailsBlockProvider.js +13 -1
- package/es/block-provider/FormBlockProvider.js +30 -13
- package/es/block-provider/hooks/index.d.ts +11 -1
- package/es/block-provider/hooks/index.js +527 -301
- package/es/collection-manager/Configuration/CollectionFields.js +1 -2
- package/es/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
- package/es/collection-manager/action-hooks.d.ts +4 -43
- package/es/collection-manager/action-hooks.js +18 -7
- package/es/collection-manager/interfaces/createdBy.js +1 -1
- package/es/collection-manager/interfaces/linkTo.js +5 -40
- package/es/collection-manager/interfaces/m2m.js +6 -39
- package/es/collection-manager/interfaces/m2o.js +6 -39
- package/es/collection-manager/interfaces/o2m.js +6 -69
- package/es/collection-manager/interfaces/o2o.js +31 -122
- package/es/collection-manager/interfaces/types.d.ts +2 -0
- package/es/collection-manager/interfaces/updatedBy.js +1 -1
- package/es/collection-manager/sub-table.d.ts +1 -14
- package/es/collection-manager/templates/tree.js +2 -2
- package/es/filter-provider/FilterProvider.js +3 -1
- package/es/locale/en_US.d.ts +4 -1
- package/es/locale/en_US.js +6 -3
- package/es/locale/ja_JP.d.ts +4 -1
- package/es/locale/ja_JP.js +4 -1
- package/es/locale/pt_BR.d.ts +1 -1
- package/es/locale/pt_BR.js +1 -1
- package/es/locale/zh_CN.d.ts +5 -1
- package/es/locale/zh_CN.js +5 -1
- package/es/schema-component/antd/action/Action.Designer.js +4 -5
- package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
- package/es/schema-component/antd/association-field/AssociationFieldProvider.js +19 -0
- package/es/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
- package/es/schema-component/antd/association-field/AssociationSelect.js +118 -0
- package/es/schema-component/antd/association-field/Editable.d.ts +2 -0
- package/es/schema-component/antd/association-field/Editable.js +88 -0
- package/es/schema-component/antd/association-field/FileManager.d.ts +4 -0
- package/es/schema-component/antd/association-field/FileManager.js +243 -0
- package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -0
- package/es/schema-component/antd/association-field/InternalNester.js +28 -0
- package/es/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
- package/es/schema-component/antd/association-field/InternalPicker.js +267 -0
- package/es/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
- package/es/schema-component/antd/association-field/InternalSubTable.js +28 -0
- package/es/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
- package/es/schema-component/antd/association-field/InternalViewer.js +115 -0
- package/es/schema-component/antd/association-field/Nester.d.ts +1 -0
- package/es/schema-component/antd/association-field/Nester.js +80 -0
- package/es/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
- package/es/schema-component/antd/association-field/ReadPretty.js +38 -0
- package/es/schema-component/antd/association-field/SubTable.d.ts +1 -0
- package/es/schema-component/antd/association-field/SubTable.js +25 -0
- package/es/schema-component/antd/association-field/context.d.ts +7 -0
- package/es/schema-component/antd/association-field/context.js +2 -0
- package/es/schema-component/antd/association-field/hooks.d.ts +8 -0
- package/es/schema-component/antd/association-field/hooks.js +96 -0
- package/es/schema-component/antd/association-field/index.d.ts +1 -0
- package/es/schema-component/antd/association-field/index.js +14 -0
- package/es/schema-component/antd/association-field/schema.d.ts +142 -0
- package/es/schema-component/antd/association-field/schema.js +141 -0
- package/es/schema-component/antd/association-field/util.d.ts +8 -0
- package/es/schema-component/antd/association-field/util.js +84 -0
- package/es/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
- package/es/schema-component/antd/association-select/AssociationSelect.js +11 -2
- package/es/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
- package/es/schema-component/antd/expand-action/Expand.Action.Design.js +112 -0
- package/es/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
- package/es/schema-component/antd/expand-action/Expand.Action.js +40 -0
- package/es/schema-component/antd/expand-action/index.d.ts +1 -0
- package/es/schema-component/antd/expand-action/index.js +5 -0
- package/es/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
- package/es/schema-component/antd/filter/FilterItem.js +1 -1
- package/es/schema-component/antd/filter/useOperators.d.ts +1 -1
- package/es/schema-component/antd/form-item/FormItem.d.ts +2 -1
- package/es/schema-component/antd/form-item/FormItem.js +206 -58
- package/es/schema-component/antd/form-item/SchemaSettingOptions.js +36 -58
- package/es/schema-component/antd/form-v2/utils.js +6 -4
- package/es/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
- package/es/schema-component/antd/gantt/components/other/tooltip.js +1 -1
- package/es/schema-component/antd/index.d.ts +3 -1
- package/es/schema-component/antd/index.js +3 -1
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +40 -17
- package/es/schema-component/antd/remote-select/RemoteSelect.js +16 -18
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
- package/es/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
- package/es/schema-component/antd/table-v2/Table.Index.js +6 -0
- package/es/schema-component/antd/table-v2/Table.js +9 -5
- package/es/schema-component/antd/table-v2/index.js +3 -1
- package/es/schema-component/antd/table-v2/utils.js +1 -1
- package/es/schema-component/antd/variable/Input.js +15 -16
- package/es/schema-component/antd/variable/TextArea.js +2 -5
- package/es/schema-component/antd/variable/Variable.d.ts +2 -0
- package/es/schema-component/antd/variable/Variable.js +5 -2
- package/es/schema-component/common/dnd-context/index.js +3 -2
- package/es/schema-component/common/sortable-item/SortableItem.js +4 -1
- package/es/schema-component/common/utils/uitls.js +1 -1
- package/es/schema-component/hooks/index.d.ts +1 -0
- package/es/schema-component/hooks/index.js +2 -1
- package/es/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
- package/es/schema-component/hooks/useFieldModeOptions.js +105 -0
- package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -1
- package/es/schema-initializer/components/CreateRecordAction.js +4 -3
- package/es/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
- package/es/schema-initializer/items/ExpandActionInitializer.js +9 -34
- package/es/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
- package/es/schema-initializer/items/SelectActionInitializer.js +65 -0
- package/es/schema-initializer/items/index.d.ts +1 -0
- package/es/schema-initializer/items/index.js +2 -1
- package/es/schema-initializer/utils.js +57 -43
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
- package/es/schema-settings/LinkageRules/Variables.d.ts +1 -1
- package/es/schema-settings/LinkageRules/Variables.js +7 -4
- package/es/schema-settings/SchemaSettings.js +3 -3
- package/es/schema-settings/VariableInput/VariableInput.d.ts +3 -2
- package/es/schema-settings/VariableInput/VariableInput.js +3 -1
- package/lib/acl/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
- package/lib/api-client/hooks/useRequest.d.ts +1 -14
- package/lib/api-client/hooks/useRequest.js +48 -53
- package/lib/block-provider/DetailsBlockProvider.js +13 -1
- package/lib/block-provider/FormBlockProvider.js +31 -15
- package/lib/block-provider/hooks/index.d.ts +11 -1
- package/lib/block-provider/hooks/index.js +537 -308
- package/lib/collection-manager/Configuration/CollectionFields.js +1 -2
- package/lib/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
- package/lib/collection-manager/action-hooks.d.ts +4 -43
- package/lib/collection-manager/action-hooks.js +18 -7
- package/lib/collection-manager/interfaces/createdBy.js +1 -1
- package/lib/collection-manager/interfaces/linkTo.js +4 -39
- package/lib/collection-manager/interfaces/m2m.js +5 -38
- package/lib/collection-manager/interfaces/m2o.js +5 -38
- package/lib/collection-manager/interfaces/o2m.js +8 -71
- package/lib/collection-manager/interfaces/o2o.js +36 -127
- package/lib/collection-manager/interfaces/types.d.ts +2 -0
- package/lib/collection-manager/interfaces/updatedBy.js +1 -1
- package/lib/collection-manager/sub-table.d.ts +1 -14
- package/lib/collection-manager/templates/tree.js +2 -2
- package/lib/filter-provider/FilterProvider.js +3 -1
- package/lib/locale/en_US.d.ts +4 -1
- package/lib/locale/en_US.js +6 -3
- package/lib/locale/ja_JP.d.ts +4 -1
- package/lib/locale/ja_JP.js +4 -1
- package/lib/locale/pt_BR.d.ts +1 -1
- package/lib/locale/pt_BR.js +1 -1
- package/lib/locale/zh_CN.d.ts +5 -1
- package/lib/locale/zh_CN.js +5 -1
- package/lib/schema-component/antd/action/Action.Designer.js +4 -5
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +28 -0
- package/lib/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
- package/lib/schema-component/antd/association-field/AssociationSelect.js +129 -0
- package/lib/schema-component/antd/association-field/Editable.d.ts +2 -0
- package/lib/schema-component/antd/association-field/Editable.js +97 -0
- package/lib/schema-component/antd/association-field/FileManager.d.ts +4 -0
- package/lib/schema-component/antd/association-field/FileManager.js +253 -0
- package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -0
- package/lib/schema-component/antd/association-field/InternalNester.js +39 -0
- package/lib/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
- package/lib/schema-component/antd/association-field/InternalPicker.js +277 -0
- package/lib/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
- package/lib/schema-component/antd/association-field/InternalSubTable.js +39 -0
- package/lib/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
- package/lib/schema-component/antd/association-field/InternalViewer.js +126 -0
- package/lib/schema-component/antd/association-field/Nester.d.ts +1 -0
- package/lib/schema-component/antd/association-field/Nester.js +89 -0
- package/lib/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
- package/lib/schema-component/antd/association-field/ReadPretty.js +47 -0
- package/lib/schema-component/antd/association-field/SubTable.d.ts +1 -0
- package/lib/schema-component/antd/association-field/SubTable.js +33 -0
- package/lib/schema-component/antd/association-field/context.d.ts +7 -0
- package/lib/schema-component/antd/association-field/context.js +9 -0
- package/lib/schema-component/antd/association-field/hooks.d.ts +8 -0
- package/lib/schema-component/antd/association-field/hooks.js +107 -0
- package/lib/schema-component/antd/association-field/index.d.ts +1 -0
- package/lib/schema-component/antd/association-field/index.js +21 -0
- package/lib/schema-component/antd/association-field/schema.d.ts +142 -0
- package/lib/schema-component/antd/association-field/schema.js +148 -0
- package/lib/schema-component/antd/association-field/util.d.ts +8 -0
- package/lib/schema-component/antd/association-field/util.js +98 -0
- package/lib/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
- package/lib/schema-component/antd/association-select/AssociationSelect.js +10 -1
- package/lib/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.Design.js +120 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.js +48 -0
- package/lib/schema-component/antd/expand-action/index.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/index.js +12 -0
- package/lib/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
- package/lib/schema-component/antd/filter/FilterItem.js +1 -1
- package/lib/schema-component/antd/filter/useOperators.d.ts +1 -1
- package/lib/schema-component/antd/form-item/FormItem.d.ts +2 -1
- package/lib/schema-component/antd/form-item/FormItem.js +204 -55
- package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +34 -56
- package/lib/schema-component/antd/form-v2/utils.js +6 -5
- package/lib/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
- package/lib/schema-component/antd/gantt/components/other/tooltip.js +1 -1
- package/lib/schema-component/antd/index.d.ts +3 -1
- package/lib/schema-component/antd/index.js +33 -11
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +42 -18
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +15 -17
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
- package/lib/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
- package/lib/schema-component/antd/table-v2/Table.Index.js +14 -0
- package/lib/schema-component/antd/table-v2/Table.js +9 -5
- package/lib/schema-component/antd/table-v2/index.js +3 -1
- package/lib/schema-component/antd/table-v2/utils.js +1 -1
- package/lib/schema-component/antd/variable/Input.js +15 -16
- package/lib/schema-component/antd/variable/TextArea.js +2 -5
- package/lib/schema-component/antd/variable/Variable.d.ts +2 -0
- package/lib/schema-component/antd/variable/Variable.js +6 -2
- package/lib/schema-component/common/dnd-context/index.js +3 -2
- package/lib/schema-component/common/sortable-item/SortableItem.js +4 -1
- package/lib/schema-component/common/utils/uitls.js +1 -1
- package/lib/schema-component/hooks/index.d.ts +1 -0
- package/lib/schema-component/hooks/index.js +11 -0
- package/lib/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
- package/lib/schema-component/hooks/useFieldModeOptions.js +112 -0
- package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -1
- package/lib/schema-initializer/components/CreateRecordAction.js +4 -3
- package/lib/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
- package/lib/schema-initializer/items/ExpandActionInitializer.js +11 -37
- package/lib/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
- package/lib/schema-initializer/items/SelectActionInitializer.js +73 -0
- package/lib/schema-initializer/items/index.d.ts +1 -0
- package/lib/schema-initializer/items/index.js +11 -0
- package/lib/schema-initializer/utils.js +56 -42
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
- package/lib/schema-settings/LinkageRules/Variables.d.ts +1 -1
- package/lib/schema-settings/LinkageRules/Variables.js +7 -4
- package/lib/schema-settings/SchemaSettings.js +4 -4
- package/lib/schema-settings/VariableInput/VariableInput.d.ts +3 -2
- package/lib/schema-settings/VariableInput/VariableInput.js +3 -1
- package/package.json +5 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
1
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -13,13 +14,13 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
13
14
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
15
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
16
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
|
-
import { SchemaExpressionScopeContext, useField, useFieldSchema, useForm } from '@formily/react';
|
|
17
|
+
import { Schema, SchemaExpressionScopeContext, useField, useFieldSchema, useForm } from '@formily/react';
|
|
18
|
+
import { parse } from '@nocobase/utils/client';
|
|
17
19
|
import { Modal, message } from 'antd';
|
|
18
|
-
import parse from 'json-templates';
|
|
19
20
|
import { cloneDeep } from 'lodash';
|
|
20
21
|
import get from 'lodash/get';
|
|
21
22
|
import omit from 'lodash/omit';
|
|
22
|
-
import { useContext } from 'react';
|
|
23
|
+
import { useContext, useEffect } from 'react';
|
|
23
24
|
import { useTranslation } from 'react-i18next';
|
|
24
25
|
import { useHistory } from 'react-router-dom';
|
|
25
26
|
import { useReactToPrint } from 'react-to-print';
|
|
@@ -173,7 +174,7 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
173
174
|
onClick: function onClick() {
|
|
174
175
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
175
176
|
var _actionSchema$xActio, _fieldSchema$xCompon;
|
|
176
|
-
var fieldNames, _ref, _ref$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, addChild, assignedValues, values, _treeParentField$name, _treeParentField$fore, treeParentField, _parent$service, _parent$service$refre;
|
|
177
|
+
var fieldNames, _ref, _ref$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, addChild, assignedValues, values, _treeParentField$name, _treeParentField$fore, treeParentField, _parent$service, _parent$service$refre, data;
|
|
177
178
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
178
179
|
while (1) switch (_context2.prev = _context2.next) {
|
|
179
180
|
case 0:
|
|
@@ -208,15 +209,17 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
208
209
|
values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues)
|
|
209
210
|
});
|
|
210
211
|
case 14:
|
|
212
|
+
data = _context2.sent;
|
|
211
213
|
actionField.data.loading = false;
|
|
214
|
+
actionField.data.data = data;
|
|
212
215
|
__parent === null || __parent === void 0 ? void 0 : (_parent$service = __parent.service) === null || _parent$service === void 0 ? void 0 : (_parent$service$refre = _parent$service.refresh) === null || _parent$service$refre === void 0 ? void 0 : _parent$service$refre.call(_parent$service);
|
|
213
216
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
214
217
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
215
|
-
_context2.next =
|
|
218
|
+
_context2.next = 21;
|
|
216
219
|
break;
|
|
217
220
|
}
|
|
218
221
|
return _context2.abrupt("return");
|
|
219
|
-
case
|
|
222
|
+
case 21:
|
|
220
223
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
221
224
|
Modal.success({
|
|
222
225
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
@@ -250,17 +253,102 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
250
253
|
} else {
|
|
251
254
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
252
255
|
}
|
|
253
|
-
_context2.next =
|
|
256
|
+
_context2.next = 27;
|
|
254
257
|
break;
|
|
255
|
-
case
|
|
256
|
-
_context2.prev =
|
|
258
|
+
case 24:
|
|
259
|
+
_context2.prev = 24;
|
|
257
260
|
_context2.t0 = _context2["catch"](11);
|
|
258
261
|
actionField.data.loading = false;
|
|
259
|
-
case
|
|
262
|
+
case 27:
|
|
260
263
|
case "end":
|
|
261
264
|
return _context2.stop();
|
|
262
265
|
}
|
|
263
|
-
}, _callee2, null, [[11,
|
|
266
|
+
}, _callee2, null, [[11, 24]]);
|
|
267
|
+
}))();
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
export var useAssociationCreateActionProps = function useAssociationCreateActionProps() {
|
|
272
|
+
var _currentUserContext$d2;
|
|
273
|
+
var form = useForm();
|
|
274
|
+
var _useBlockRequestConte2 = useBlockRequestContext(),
|
|
275
|
+
field = _useBlockRequestConte2.field,
|
|
276
|
+
resource = _useBlockRequestConte2.resource;
|
|
277
|
+
var _useActionContext2 = useActionContext(),
|
|
278
|
+
setVisible = _useActionContext2.setVisible,
|
|
279
|
+
fieldSchema = _useActionContext2.fieldSchema;
|
|
280
|
+
var actionSchema = useFieldSchema();
|
|
281
|
+
var actionField = useField();
|
|
282
|
+
var _useCollection2 = useCollection(),
|
|
283
|
+
fields = _useCollection2.fields,
|
|
284
|
+
getField = _useCollection2.getField,
|
|
285
|
+
getTreeParentField = _useCollection2.getTreeParentField;
|
|
286
|
+
var compile = useCompile();
|
|
287
|
+
var filterByTk = useFilterByTk();
|
|
288
|
+
var currentRecord = useRecord();
|
|
289
|
+
var currentUserContext = useCurrentUserContext();
|
|
290
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d2 = currentUserContext.data) === null || _currentUserContext$d2 === void 0 ? void 0 : _currentUserContext$d2.data;
|
|
291
|
+
return {
|
|
292
|
+
onClick: function onClick() {
|
|
293
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
294
|
+
var _actionSchema$xActio2, _fieldSchema$xCompon2;
|
|
295
|
+
var fieldNames, _ref2, _ref2$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, addChild, assignedValues, values, _treeParentField$name2, _treeParentField$fore2, treeParentField, data;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
297
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
fieldNames = fields.map(function (field) {
|
|
300
|
+
return field.name;
|
|
301
|
+
});
|
|
302
|
+
_ref2 = (_actionSchema$xActio2 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio2 !== void 0 ? _actionSchema$xActio2 : {}, _ref2$assignedValues = _ref2.assignedValues, originalAssignedValues = _ref2$assignedValues === void 0 ? {} : _ref2$assignedValues, onSuccess = _ref2.onSuccess, overwriteValues = _ref2.overwriteValues, skipValidator = _ref2.skipValidator;
|
|
303
|
+
addChild = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.addChild;
|
|
304
|
+
assignedValues = parse(originalAssignedValues)({
|
|
305
|
+
currentTime: new Date(),
|
|
306
|
+
currentRecord: currentRecord,
|
|
307
|
+
currentUser: currentUser
|
|
308
|
+
});
|
|
309
|
+
if (skipValidator) {
|
|
310
|
+
_context3.next = 7;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
_context3.next = 7;
|
|
314
|
+
return form.submit();
|
|
315
|
+
case 7:
|
|
316
|
+
values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
|
|
317
|
+
if (addChild) {
|
|
318
|
+
treeParentField = getTreeParentField();
|
|
319
|
+
values[(_treeParentField$name2 = treeParentField === null || treeParentField === void 0 ? void 0 : treeParentField.name) !== null && _treeParentField$name2 !== void 0 ? _treeParentField$name2 : 'parent'] = currentRecord;
|
|
320
|
+
values[(_treeParentField$fore2 = treeParentField === null || treeParentField === void 0 ? void 0 : treeParentField.foreignKey) !== null && _treeParentField$fore2 !== void 0 ? _treeParentField$fore2 : 'parentId'] = currentRecord.id;
|
|
321
|
+
}
|
|
322
|
+
actionField.data = field.data || {};
|
|
323
|
+
actionField.data.loading = true;
|
|
324
|
+
_context3.prev = 11;
|
|
325
|
+
_context3.next = 14;
|
|
326
|
+
return resource.create({
|
|
327
|
+
values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues)
|
|
328
|
+
});
|
|
329
|
+
case 14:
|
|
330
|
+
data = _context3.sent;
|
|
331
|
+
actionField.data.loading = false;
|
|
332
|
+
actionField.data.data = data;
|
|
333
|
+
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
334
|
+
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
335
|
+
_context3.next = 20;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
return _context3.abrupt("return");
|
|
339
|
+
case 20:
|
|
340
|
+
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
341
|
+
_context3.next = 26;
|
|
342
|
+
break;
|
|
343
|
+
case 23:
|
|
344
|
+
_context3.prev = 23;
|
|
345
|
+
_context3.t0 = _context3["catch"](11);
|
|
346
|
+
actionField.data.loading = false;
|
|
347
|
+
case 26:
|
|
348
|
+
case "end":
|
|
349
|
+
return _context3.stop();
|
|
350
|
+
}
|
|
351
|
+
}, _callee3, null, [[11, 23]]);
|
|
264
352
|
}))();
|
|
265
353
|
}
|
|
266
354
|
};
|
|
@@ -292,37 +380,37 @@ export var useFilterBlockActionProps = function useFilterBlockActionProps() {
|
|
|
292
380
|
var fieldSchema = useFieldSchema();
|
|
293
381
|
var _useFilterBlock = useFilterBlock(),
|
|
294
382
|
getDataBlocks = _useFilterBlock.getDataBlocks;
|
|
295
|
-
var
|
|
296
|
-
name =
|
|
383
|
+
var _useCollection3 = useCollection(),
|
|
384
|
+
name = _useCollection3.name;
|
|
297
385
|
var _useCollectionManager = useCollectionManager(),
|
|
298
386
|
getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
|
|
299
387
|
actionField.data = actionField.data || {};
|
|
300
388
|
return {
|
|
301
389
|
onClick: function onClick() {
|
|
302
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
390
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
303
391
|
var _findFilterTargets, _findFilterTargets$ta, targets, uid;
|
|
304
|
-
return _regeneratorRuntime().wrap(function
|
|
305
|
-
while (1) switch (
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
393
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
306
394
|
case 0:
|
|
307
395
|
_findFilterTargets = findFilterTargets(fieldSchema), _findFilterTargets$ta = _findFilterTargets.targets, targets = _findFilterTargets$ta === void 0 ? [] : _findFilterTargets$ta, uid = _findFilterTargets.uid;
|
|
308
396
|
actionField.data.loading = true;
|
|
309
|
-
|
|
310
|
-
|
|
397
|
+
_context5.prev = 2;
|
|
398
|
+
_context5.next = 5;
|
|
311
399
|
return Promise.all(getDataBlocks().map( /*#__PURE__*/function () {
|
|
312
|
-
var
|
|
400
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(block) {
|
|
313
401
|
var _block$service$params, _block$service$params2, _block$service$params3;
|
|
314
402
|
var target, param, storedFilter, mergedFilter;
|
|
315
|
-
return _regeneratorRuntime().wrap(function
|
|
316
|
-
while (1) switch (
|
|
403
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
404
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
317
405
|
case 0:
|
|
318
406
|
target = targets.find(function (target) {
|
|
319
407
|
return target.uid === block.uid;
|
|
320
408
|
});
|
|
321
409
|
if (target) {
|
|
322
|
-
|
|
410
|
+
_context4.next = 3;
|
|
323
411
|
break;
|
|
324
412
|
}
|
|
325
|
-
return
|
|
413
|
+
return _context4.abrupt("return");
|
|
326
414
|
case 3:
|
|
327
415
|
param = ((_block$service$params = block.service.params) === null || _block$service$params === void 0 ? void 0 : _block$service$params[0]) || {}; // 保留原有的 filter
|
|
328
416
|
storedFilter = ((_block$service$params2 = block.service.params) === null || _block$service$params2 === void 0 ? void 0 : (_block$service$params3 = _block$service$params2[1]) === null || _block$service$params3 === void 0 ? void 0 : _block$service$params3.filters) || {};
|
|
@@ -330,7 +418,7 @@ export var useFilterBlockActionProps = function useFilterBlockActionProps() {
|
|
|
330
418
|
mergedFilter = mergeFilter([].concat(_toConsumableArray(Object.values(storedFilter).map(function (filter) {
|
|
331
419
|
return removeNullCondition(filter);
|
|
332
420
|
})), [block.defaultFilter]));
|
|
333
|
-
return
|
|
421
|
+
return _context4.abrupt("return", block.doFilter(_objectSpread(_objectSpread({}, param), {}, {
|
|
334
422
|
page: 1,
|
|
335
423
|
filter: mergedFilter
|
|
336
424
|
}), {
|
|
@@ -338,28 +426,28 @@ export var useFilterBlockActionProps = function useFilterBlockActionProps() {
|
|
|
338
426
|
}));
|
|
339
427
|
case 8:
|
|
340
428
|
case "end":
|
|
341
|
-
return
|
|
429
|
+
return _context4.stop();
|
|
342
430
|
}
|
|
343
|
-
},
|
|
431
|
+
}, _callee4);
|
|
344
432
|
}));
|
|
345
433
|
return function (_x) {
|
|
346
|
-
return
|
|
434
|
+
return _ref3.apply(this, arguments);
|
|
347
435
|
};
|
|
348
436
|
}()));
|
|
349
437
|
case 5:
|
|
350
438
|
actionField.data.loading = false;
|
|
351
|
-
|
|
439
|
+
_context5.next = 12;
|
|
352
440
|
break;
|
|
353
441
|
case 8:
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
console.error(
|
|
442
|
+
_context5.prev = 8;
|
|
443
|
+
_context5.t0 = _context5["catch"](2);
|
|
444
|
+
console.error(_context5.t0);
|
|
357
445
|
actionField.data.loading = false;
|
|
358
446
|
case 12:
|
|
359
447
|
case "end":
|
|
360
|
-
return
|
|
448
|
+
return _context5.stop();
|
|
361
449
|
}
|
|
362
|
-
},
|
|
450
|
+
}, _callee5, null, [[2, 8]]);
|
|
363
451
|
}))();
|
|
364
452
|
}
|
|
365
453
|
};
|
|
@@ -373,37 +461,37 @@ export var useResetBlockActionProps = function useResetBlockActionProps() {
|
|
|
373
461
|
actionField.data = actionField.data || {};
|
|
374
462
|
return {
|
|
375
463
|
onClick: function onClick() {
|
|
376
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
464
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
377
465
|
var _findFilterTargets2, targets, uid;
|
|
378
|
-
return _regeneratorRuntime().wrap(function
|
|
379
|
-
while (1) switch (
|
|
466
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
467
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
380
468
|
case 0:
|
|
381
469
|
_findFilterTargets2 = findFilterTargets(fieldSchema), targets = _findFilterTargets2.targets, uid = _findFilterTargets2.uid;
|
|
382
470
|
form.reset();
|
|
383
471
|
actionField.data.loading = true;
|
|
384
|
-
|
|
385
|
-
|
|
472
|
+
_context7.prev = 3;
|
|
473
|
+
_context7.next = 6;
|
|
386
474
|
return Promise.all(getDataBlocks().map( /*#__PURE__*/function () {
|
|
387
|
-
var
|
|
475
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(block) {
|
|
388
476
|
var _block$service$params4, _block$service$params5, _block$service$params6;
|
|
389
477
|
var target, param, storedFilter, mergedFilter;
|
|
390
|
-
return _regeneratorRuntime().wrap(function
|
|
391
|
-
while (1) switch (
|
|
478
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
479
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
392
480
|
case 0:
|
|
393
481
|
target = targets.find(function (target) {
|
|
394
482
|
return target.uid === block.uid;
|
|
395
483
|
});
|
|
396
484
|
if (target) {
|
|
397
|
-
|
|
485
|
+
_context6.next = 3;
|
|
398
486
|
break;
|
|
399
487
|
}
|
|
400
|
-
return
|
|
488
|
+
return _context6.abrupt("return");
|
|
401
489
|
case 3:
|
|
402
490
|
param = ((_block$service$params4 = block.service.params) === null || _block$service$params4 === void 0 ? void 0 : _block$service$params4[0]) || {}; // 保留原有的 filter
|
|
403
491
|
storedFilter = ((_block$service$params5 = block.service.params) === null || _block$service$params5 === void 0 ? void 0 : (_block$service$params6 = _block$service$params5[1]) === null || _block$service$params6 === void 0 ? void 0 : _block$service$params6.filters) || {};
|
|
404
492
|
delete storedFilter[uid];
|
|
405
493
|
mergedFilter = mergeFilter([].concat(_toConsumableArray(Object.values(storedFilter)), [block.defaultFilter]));
|
|
406
|
-
return
|
|
494
|
+
return _context6.abrupt("return", block.doFilter(_objectSpread(_objectSpread({}, param), {}, {
|
|
407
495
|
page: 1,
|
|
408
496
|
filter: mergedFilter
|
|
409
497
|
}), {
|
|
@@ -411,67 +499,67 @@ export var useResetBlockActionProps = function useResetBlockActionProps() {
|
|
|
411
499
|
}));
|
|
412
500
|
case 8:
|
|
413
501
|
case "end":
|
|
414
|
-
return
|
|
502
|
+
return _context6.stop();
|
|
415
503
|
}
|
|
416
|
-
},
|
|
504
|
+
}, _callee6);
|
|
417
505
|
}));
|
|
418
506
|
return function (_x2) {
|
|
419
|
-
return
|
|
507
|
+
return _ref4.apply(this, arguments);
|
|
420
508
|
};
|
|
421
509
|
}()));
|
|
422
510
|
case 6:
|
|
423
511
|
actionField.data.loading = false;
|
|
424
|
-
|
|
512
|
+
_context7.next = 12;
|
|
425
513
|
break;
|
|
426
514
|
case 9:
|
|
427
|
-
|
|
428
|
-
|
|
515
|
+
_context7.prev = 9;
|
|
516
|
+
_context7.t0 = _context7["catch"](3);
|
|
429
517
|
actionField.data.loading = false;
|
|
430
518
|
case 12:
|
|
431
519
|
case "end":
|
|
432
|
-
return
|
|
520
|
+
return _context7.stop();
|
|
433
521
|
}
|
|
434
|
-
},
|
|
522
|
+
}, _callee7, null, [[3, 9]]);
|
|
435
523
|
}))();
|
|
436
524
|
}
|
|
437
525
|
};
|
|
438
526
|
};
|
|
439
527
|
export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProps() {
|
|
440
|
-
var _currentUserContext$
|
|
441
|
-
var
|
|
442
|
-
resource =
|
|
443
|
-
__parent =
|
|
444
|
-
service =
|
|
528
|
+
var _currentUserContext$d3;
|
|
529
|
+
var _useBlockRequestConte3 = useBlockRequestContext(),
|
|
530
|
+
resource = _useBlockRequestConte3.resource,
|
|
531
|
+
__parent = _useBlockRequestConte3.__parent,
|
|
532
|
+
service = _useBlockRequestConte3.service;
|
|
445
533
|
var filterByTk = useFilterByTk();
|
|
446
534
|
var actionSchema = useFieldSchema();
|
|
447
535
|
var currentRecord = useRecord();
|
|
448
536
|
var currentUserContext = useCurrentUserContext();
|
|
449
|
-
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$
|
|
537
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d3 = currentUserContext.data) === null || _currentUserContext$d3 === void 0 ? void 0 : _currentUserContext$d3.data;
|
|
450
538
|
var history = useHistory();
|
|
451
539
|
var compile = useCompile();
|
|
452
540
|
var form = useForm();
|
|
453
541
|
return {
|
|
454
542
|
onClick: function onClick() {
|
|
455
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
456
|
-
var _actionSchema$
|
|
457
|
-
var
|
|
458
|
-
return _regeneratorRuntime().wrap(function
|
|
459
|
-
while (1) switch (
|
|
543
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
544
|
+
var _actionSchema$xActio3, _service$refresh;
|
|
545
|
+
var _ref5, _ref5$assignedValues, originalAssignedValues, onSuccess, skipValidator, assignedValues, _parent$service2, _parent$service2$refr;
|
|
546
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
547
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
460
548
|
case 0:
|
|
461
|
-
|
|
549
|
+
_ref5 = (_actionSchema$xActio3 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio3 !== void 0 ? _actionSchema$xActio3 : {}, _ref5$assignedValues = _ref5.assignedValues, originalAssignedValues = _ref5$assignedValues === void 0 ? {} : _ref5$assignedValues, onSuccess = _ref5.onSuccess, skipValidator = _ref5.skipValidator;
|
|
462
550
|
assignedValues = parse(originalAssignedValues)({
|
|
463
551
|
currentTime: new Date(),
|
|
464
552
|
currentRecord: currentRecord,
|
|
465
553
|
currentUser: currentUser
|
|
466
554
|
});
|
|
467
555
|
if (!(skipValidator === false)) {
|
|
468
|
-
|
|
556
|
+
_context9.next = 5;
|
|
469
557
|
break;
|
|
470
558
|
}
|
|
471
|
-
|
|
559
|
+
_context9.next = 5;
|
|
472
560
|
return form.submit();
|
|
473
561
|
case 5:
|
|
474
|
-
|
|
562
|
+
_context9.next = 7;
|
|
475
563
|
return resource.update({
|
|
476
564
|
filterByTk: filterByTk,
|
|
477
565
|
values: _objectSpread({}, assignedValues)
|
|
@@ -482,18 +570,18 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
482
570
|
__parent === null || __parent === void 0 ? void 0 : (_parent$service2 = __parent.service) === null || _parent$service2 === void 0 ? void 0 : (_parent$service2$refr = _parent$service2.refresh) === null || _parent$service2$refr === void 0 ? void 0 : _parent$service2$refr.call(_parent$service2);
|
|
483
571
|
}
|
|
484
572
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
485
|
-
|
|
573
|
+
_context9.next = 11;
|
|
486
574
|
break;
|
|
487
575
|
}
|
|
488
|
-
return
|
|
576
|
+
return _context9.abrupt("return");
|
|
489
577
|
case 11:
|
|
490
578
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
491
579
|
Modal.success({
|
|
492
580
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
493
581
|
onOk: function () {
|
|
494
|
-
var _onOk2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
495
|
-
return _regeneratorRuntime().wrap(function
|
|
496
|
-
while (1) switch (
|
|
582
|
+
var _onOk2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
583
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
584
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
497
585
|
case 0:
|
|
498
586
|
if ((onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirecting) && (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirectTo)) {
|
|
499
587
|
if (isURL(onSuccess.redirectTo)) {
|
|
@@ -504,9 +592,9 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
504
592
|
}
|
|
505
593
|
case 1:
|
|
506
594
|
case "end":
|
|
507
|
-
return
|
|
595
|
+
return _context8.stop();
|
|
508
596
|
}
|
|
509
|
-
},
|
|
597
|
+
}, _callee8);
|
|
510
598
|
}));
|
|
511
599
|
function onOk() {
|
|
512
600
|
return _onOk2.apply(this, arguments);
|
|
@@ -519,27 +607,27 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
519
607
|
}
|
|
520
608
|
case 12:
|
|
521
609
|
case "end":
|
|
522
|
-
return
|
|
610
|
+
return _context9.stop();
|
|
523
611
|
}
|
|
524
|
-
},
|
|
612
|
+
}, _callee9);
|
|
525
613
|
}))();
|
|
526
614
|
}
|
|
527
615
|
};
|
|
528
616
|
};
|
|
529
617
|
export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateActionProps() {
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
field =
|
|
533
|
-
resource =
|
|
534
|
-
__parent =
|
|
535
|
-
service =
|
|
618
|
+
var _ref6, _tableBlockContext$fi, _tableBlockContext$fi2, _tableBlockContext$fi3, _currentUserContext$d4;
|
|
619
|
+
var _useBlockRequestConte4 = useBlockRequestContext(),
|
|
620
|
+
field = _useBlockRequestConte4.field,
|
|
621
|
+
resource = _useBlockRequestConte4.resource,
|
|
622
|
+
__parent = _useBlockRequestConte4.__parent,
|
|
623
|
+
service = _useBlockRequestConte4.service;
|
|
536
624
|
var expressionScope = useContext(SchemaExpressionScopeContext);
|
|
537
625
|
var actionSchema = useFieldSchema();
|
|
538
626
|
var tableBlockContext = useTableBlockContext();
|
|
539
627
|
var rowKey = tableBlockContext.rowKey;
|
|
540
|
-
var selectedRecordKeys = (
|
|
628
|
+
var selectedRecordKeys = (_ref6 = (_tableBlockContext$fi = (_tableBlockContext$fi2 = tableBlockContext.field) === null || _tableBlockContext$fi2 === void 0 ? void 0 : (_tableBlockContext$fi3 = _tableBlockContext$fi2.data) === null || _tableBlockContext$fi3 === void 0 ? void 0 : _tableBlockContext$fi3.selectedRowKeys) !== null && _tableBlockContext$fi !== void 0 ? _tableBlockContext$fi : expressionScope === null || expressionScope === void 0 ? void 0 : expressionScope.selectedRecordKeys) !== null && _ref6 !== void 0 ? _ref6 : {};
|
|
541
629
|
var currentUserContext = useCurrentUserContext();
|
|
542
|
-
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$
|
|
630
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d4 = currentUserContext.data) === null || _currentUserContext$d4 === void 0 ? void 0 : _currentUserContext$d4.data;
|
|
543
631
|
var history = useHistory();
|
|
544
632
|
var compile = useCompile();
|
|
545
633
|
var _useTranslation2 = useTranslation(),
|
|
@@ -547,13 +635,13 @@ export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateAc
|
|
|
547
635
|
var actionField = useField();
|
|
548
636
|
return {
|
|
549
637
|
onClick: function onClick() {
|
|
550
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
551
|
-
var _actionSchema$
|
|
552
|
-
var
|
|
553
|
-
return _regeneratorRuntime().wrap(function
|
|
554
|
-
while (1) switch (
|
|
638
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
639
|
+
var _actionSchema$xActio4;
|
|
640
|
+
var _ref7, _ref7$assignedValues, originalAssignedValues, onSuccess, updateMode, assignedValues;
|
|
641
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
642
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
555
643
|
case 0:
|
|
556
|
-
|
|
644
|
+
_ref7 = (_actionSchema$xActio4 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio4 !== void 0 ? _actionSchema$xActio4 : {}, _ref7$assignedValues = _ref7.assignedValues, originalAssignedValues = _ref7$assignedValues === void 0 ? {} : _ref7$assignedValues, onSuccess = _ref7.onSuccess, updateMode = _ref7.updateMode;
|
|
557
645
|
actionField.data = field.data || {};
|
|
558
646
|
actionField.data.loading = true;
|
|
559
647
|
assignedValues = parse(originalAssignedValues)({
|
|
@@ -564,29 +652,29 @@ export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateAc
|
|
|
564
652
|
title: t('Bulk update'),
|
|
565
653
|
content: updateMode === 'selected' ? t('Update selected data?') : t('Update all data?'),
|
|
566
654
|
onOk: function onOk() {
|
|
567
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
655
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
568
656
|
var _service$params$, _service$params, _service$refresh2;
|
|
569
|
-
var
|
|
570
|
-
return _regeneratorRuntime().wrap(function
|
|
571
|
-
while (1) switch (
|
|
657
|
+
var _ref8, filter, updateData, _parent$service3, _parent$service3$refr;
|
|
658
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
659
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
572
660
|
case 0:
|
|
573
|
-
|
|
661
|
+
_ref8 = (_service$params$ = (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params[0]) !== null && _service$params$ !== void 0 ? _service$params$ : {}, filter = _ref8.filter;
|
|
574
662
|
updateData = {
|
|
575
663
|
values: _objectSpread({}, assignedValues),
|
|
576
664
|
filter: filter,
|
|
577
665
|
forceUpdate: false
|
|
578
666
|
};
|
|
579
667
|
if (!(updateMode === 'selected')) {
|
|
580
|
-
|
|
668
|
+
_context11.next = 8;
|
|
581
669
|
break;
|
|
582
670
|
}
|
|
583
671
|
if (selectedRecordKeys === null || selectedRecordKeys === void 0 ? void 0 : selectedRecordKeys.length) {
|
|
584
|
-
|
|
672
|
+
_context11.next = 7;
|
|
585
673
|
break;
|
|
586
674
|
}
|
|
587
675
|
message.error(t('Please select the records to be updated'));
|
|
588
676
|
actionField.data.loading = false;
|
|
589
|
-
return
|
|
677
|
+
return _context11.abrupt("return");
|
|
590
678
|
case 7:
|
|
591
679
|
updateData.filter = {
|
|
592
680
|
$and: [_defineProperty({}, rowKey || 'id', {
|
|
@@ -597,37 +685,37 @@ export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateAc
|
|
|
597
685
|
if (!updateData.filter) {
|
|
598
686
|
updateData.forceUpdate = true;
|
|
599
687
|
}
|
|
600
|
-
|
|
601
|
-
|
|
688
|
+
_context11.prev = 9;
|
|
689
|
+
_context11.next = 12;
|
|
602
690
|
return resource.update(updateData);
|
|
603
691
|
case 12:
|
|
604
|
-
|
|
692
|
+
_context11.next = 16;
|
|
605
693
|
break;
|
|
606
694
|
case 14:
|
|
607
|
-
|
|
608
|
-
|
|
695
|
+
_context11.prev = 14;
|
|
696
|
+
_context11.t0 = _context11["catch"](9);
|
|
609
697
|
case 16:
|
|
610
|
-
|
|
698
|
+
_context11.prev = 16;
|
|
611
699
|
actionField.data.loading = false;
|
|
612
|
-
return
|
|
700
|
+
return _context11.finish(16);
|
|
613
701
|
case 19:
|
|
614
702
|
service === null || service === void 0 ? void 0 : (_service$refresh2 = service.refresh) === null || _service$refresh2 === void 0 ? void 0 : _service$refresh2.call(service);
|
|
615
703
|
if (!(resource instanceof TableFieldResource)) {
|
|
616
704
|
__parent === null || __parent === void 0 ? void 0 : (_parent$service3 = __parent.service) === null || _parent$service3 === void 0 ? void 0 : (_parent$service3$refr = _parent$service3.refresh) === null || _parent$service3$refr === void 0 ? void 0 : _parent$service3$refr.call(_parent$service3);
|
|
617
705
|
}
|
|
618
706
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
619
|
-
|
|
707
|
+
_context11.next = 23;
|
|
620
708
|
break;
|
|
621
709
|
}
|
|
622
|
-
return
|
|
710
|
+
return _context11.abrupt("return");
|
|
623
711
|
case 23:
|
|
624
712
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
625
713
|
Modal.success({
|
|
626
714
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
627
715
|
onOk: function () {
|
|
628
|
-
var _onOk3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
629
|
-
return _regeneratorRuntime().wrap(function
|
|
630
|
-
while (1) switch (
|
|
716
|
+
var _onOk3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
717
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
718
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
631
719
|
case 0:
|
|
632
720
|
if ((onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirecting) && (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirectTo)) {
|
|
633
721
|
if (isURL(onSuccess.redirectTo)) {
|
|
@@ -638,9 +726,9 @@ export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateAc
|
|
|
638
726
|
}
|
|
639
727
|
case 1:
|
|
640
728
|
case "end":
|
|
641
|
-
return
|
|
729
|
+
return _context10.stop();
|
|
642
730
|
}
|
|
643
|
-
},
|
|
731
|
+
}, _callee10);
|
|
644
732
|
}));
|
|
645
733
|
function onOk() {
|
|
646
734
|
return _onOk3.apply(this, arguments);
|
|
@@ -653,43 +741,43 @@ export var useCustomizeBulkUpdateActionProps = function useCustomizeBulkUpdateAc
|
|
|
653
741
|
}
|
|
654
742
|
case 24:
|
|
655
743
|
case "end":
|
|
656
|
-
return
|
|
744
|
+
return _context11.stop();
|
|
657
745
|
}
|
|
658
|
-
},
|
|
746
|
+
}, _callee11, null, [[9, 14, 16, 19]]);
|
|
659
747
|
}))();
|
|
660
748
|
},
|
|
661
749
|
onCancel: function onCancel() {
|
|
662
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
663
|
-
return _regeneratorRuntime().wrap(function
|
|
664
|
-
while (1) switch (
|
|
750
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
751
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
752
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
665
753
|
case 0:
|
|
666
754
|
actionField.data.loading = false;
|
|
667
755
|
case 1:
|
|
668
756
|
case "end":
|
|
669
|
-
return
|
|
757
|
+
return _context12.stop();
|
|
670
758
|
}
|
|
671
|
-
},
|
|
759
|
+
}, _callee12);
|
|
672
760
|
}))();
|
|
673
761
|
}
|
|
674
762
|
});
|
|
675
763
|
case 5:
|
|
676
764
|
case "end":
|
|
677
|
-
return
|
|
765
|
+
return _context13.stop();
|
|
678
766
|
}
|
|
679
|
-
},
|
|
767
|
+
}, _callee13);
|
|
680
768
|
}))();
|
|
681
769
|
}
|
|
682
770
|
};
|
|
683
771
|
};
|
|
684
772
|
export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditActionProps() {
|
|
685
|
-
var
|
|
773
|
+
var _ref10, _tableBlockContext$fi4, _tableBlockContext$fi5, _tableBlockContext$fi6;
|
|
686
774
|
var form = useForm();
|
|
687
775
|
var _useTranslation3 = useTranslation(),
|
|
688
776
|
t = _useTranslation3.t;
|
|
689
|
-
var
|
|
690
|
-
field =
|
|
691
|
-
resource =
|
|
692
|
-
__parent =
|
|
777
|
+
var _useBlockRequestConte5 = useBlockRequestContext(),
|
|
778
|
+
field = _useBlockRequestConte5.field,
|
|
779
|
+
resource = _useBlockRequestConte5.resource,
|
|
780
|
+
__parent = _useBlockRequestConte5.__parent;
|
|
693
781
|
var expressionScope = useContext(SchemaExpressionScopeContext);
|
|
694
782
|
var actionContext = useActionContext();
|
|
695
783
|
var history = useHistory();
|
|
@@ -697,24 +785,24 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
697
785
|
var actionField = useField();
|
|
698
786
|
var tableBlockContext = useTableBlockContext();
|
|
699
787
|
var rowKey = tableBlockContext.rowKey;
|
|
700
|
-
var selectedRecordKeys = (
|
|
788
|
+
var selectedRecordKeys = (_ref10 = (_tableBlockContext$fi4 = (_tableBlockContext$fi5 = tableBlockContext.field) === null || _tableBlockContext$fi5 === void 0 ? void 0 : (_tableBlockContext$fi6 = _tableBlockContext$fi5.data) === null || _tableBlockContext$fi6 === void 0 ? void 0 : _tableBlockContext$fi6.selectedRowKeys) !== null && _tableBlockContext$fi4 !== void 0 ? _tableBlockContext$fi4 : expressionScope === null || expressionScope === void 0 ? void 0 : expressionScope.selectedRecordKeys) !== null && _ref10 !== void 0 ? _ref10 : {};
|
|
701
789
|
var setVisible = actionContext.setVisible,
|
|
702
790
|
actionSchema = actionContext.fieldSchema;
|
|
703
791
|
return {
|
|
704
792
|
onClick: function onClick() {
|
|
705
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
706
|
-
var _actionSchema$
|
|
707
|
-
var
|
|
708
|
-
return _regeneratorRuntime().wrap(function
|
|
709
|
-
while (1) switch (
|
|
793
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
794
|
+
var _actionSchema$xActio5, _parent$service$para, _parent$service$para2;
|
|
795
|
+
var _ref11, onSuccess, skipValidator, updateMode, _ref12, filter, values, key, value, _parent$service4, _parent$service4$refr, updateData, _parent$__parent, _parent$__parent$serv, _parent$__parent$serv2;
|
|
796
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
797
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
710
798
|
case 0:
|
|
711
|
-
|
|
712
|
-
|
|
799
|
+
_ref11 = (_actionSchema$xActio5 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio5 !== void 0 ? _actionSchema$xActio5 : {}, onSuccess = _ref11.onSuccess, skipValidator = _ref11.skipValidator, updateMode = _ref11.updateMode;
|
|
800
|
+
_ref12 = (_parent$service$para = (_parent$service$para2 = __parent.service.params) === null || _parent$service$para2 === void 0 ? void 0 : _parent$service$para2[0]) !== null && _parent$service$para !== void 0 ? _parent$service$para : {}, filter = _ref12.filter;
|
|
713
801
|
if (skipValidator) {
|
|
714
|
-
|
|
802
|
+
_context15.next = 5;
|
|
715
803
|
break;
|
|
716
804
|
}
|
|
717
|
-
|
|
805
|
+
_context15.next = 5;
|
|
718
806
|
return form.submit();
|
|
719
807
|
case 5:
|
|
720
808
|
values = cloneDeep(form.values);
|
|
@@ -732,22 +820,22 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
732
820
|
}
|
|
733
821
|
}
|
|
734
822
|
}
|
|
735
|
-
|
|
823
|
+
_context15.prev = 9;
|
|
736
824
|
updateData = {
|
|
737
825
|
values: values,
|
|
738
826
|
filter: filter,
|
|
739
827
|
forceUpdate: false
|
|
740
828
|
};
|
|
741
829
|
if (!(updateMode === 'selected')) {
|
|
742
|
-
|
|
830
|
+
_context15.next = 16;
|
|
743
831
|
break;
|
|
744
832
|
}
|
|
745
833
|
if (selectedRecordKeys === null || selectedRecordKeys === void 0 ? void 0 : selectedRecordKeys.length) {
|
|
746
|
-
|
|
834
|
+
_context15.next = 15;
|
|
747
835
|
break;
|
|
748
836
|
}
|
|
749
837
|
message.error(t('Please select the records to be updated'));
|
|
750
|
-
return
|
|
838
|
+
return _context15.abrupt("return");
|
|
751
839
|
case 15:
|
|
752
840
|
updateData.filter = {
|
|
753
841
|
$and: [_defineProperty({}, rowKey || 'id', {
|
|
@@ -758,7 +846,7 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
758
846
|
if (!updateData.filter) {
|
|
759
847
|
updateData.forceUpdate = true;
|
|
760
848
|
}
|
|
761
|
-
|
|
849
|
+
_context15.next = 19;
|
|
762
850
|
return resource.update(updateData);
|
|
763
851
|
case 19:
|
|
764
852
|
actionField.data.loading = false;
|
|
@@ -768,20 +856,20 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
768
856
|
__parent === null || __parent === void 0 ? void 0 : (_parent$service4 = __parent.service) === null || _parent$service4 === void 0 ? void 0 : (_parent$service4$refr = _parent$service4.refresh) === null || _parent$service4$refr === void 0 ? void 0 : _parent$service4$refr.call(_parent$service4);
|
|
769
857
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
770
858
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
771
|
-
|
|
859
|
+
_context15.next = 25;
|
|
772
860
|
break;
|
|
773
861
|
}
|
|
774
|
-
return
|
|
862
|
+
return _context15.abrupt("return");
|
|
775
863
|
case 25:
|
|
776
864
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
777
865
|
Modal.success({
|
|
778
866
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
779
867
|
onOk: function () {
|
|
780
|
-
var _onOk4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
781
|
-
return _regeneratorRuntime().wrap(function
|
|
782
|
-
while (1) switch (
|
|
868
|
+
var _onOk4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
869
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
870
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
783
871
|
case 0:
|
|
784
|
-
|
|
872
|
+
_context14.next = 2;
|
|
785
873
|
return form.reset();
|
|
786
874
|
case 2:
|
|
787
875
|
if ((onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirecting) && (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirectTo)) {
|
|
@@ -793,9 +881,9 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
793
881
|
}
|
|
794
882
|
case 3:
|
|
795
883
|
case "end":
|
|
796
|
-
return
|
|
884
|
+
return _context14.stop();
|
|
797
885
|
}
|
|
798
|
-
},
|
|
886
|
+
}, _callee14);
|
|
799
887
|
}));
|
|
800
888
|
function onOk() {
|
|
801
889
|
return _onOk4.apply(this, arguments);
|
|
@@ -807,61 +895,61 @@ export var useCustomizeBulkEditActionProps = function useCustomizeBulkEditAction
|
|
|
807
895
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
808
896
|
}
|
|
809
897
|
case 26:
|
|
810
|
-
|
|
898
|
+
_context15.prev = 26;
|
|
811
899
|
actionField.data.loading = false;
|
|
812
|
-
return
|
|
900
|
+
return _context15.finish(26);
|
|
813
901
|
case 29:
|
|
814
902
|
case "end":
|
|
815
|
-
return
|
|
903
|
+
return _context15.stop();
|
|
816
904
|
}
|
|
817
|
-
},
|
|
905
|
+
}, _callee15, null, [[9,, 26, 29]]);
|
|
818
906
|
}))();
|
|
819
907
|
}
|
|
820
908
|
};
|
|
821
909
|
};
|
|
822
910
|
export var useCustomizeRequestActionProps = function useCustomizeRequestActionProps() {
|
|
823
|
-
var _currentUserContext$
|
|
911
|
+
var _currentUserContext$d5;
|
|
824
912
|
var apiClient = useAPIClient();
|
|
825
913
|
var history = useHistory();
|
|
826
914
|
var filterByTk = useFilterByTk();
|
|
827
915
|
var actionSchema = useFieldSchema();
|
|
828
916
|
var compile = useCompile();
|
|
829
917
|
var form = useForm();
|
|
830
|
-
var
|
|
831
|
-
fields =
|
|
832
|
-
getField =
|
|
833
|
-
var
|
|
834
|
-
field =
|
|
835
|
-
resource =
|
|
836
|
-
__parent =
|
|
837
|
-
service =
|
|
918
|
+
var _useCollection4 = useCollection(),
|
|
919
|
+
fields = _useCollection4.fields,
|
|
920
|
+
getField = _useCollection4.getField;
|
|
921
|
+
var _useBlockRequestConte6 = useBlockRequestContext(),
|
|
922
|
+
field = _useBlockRequestConte6.field,
|
|
923
|
+
resource = _useBlockRequestConte6.resource,
|
|
924
|
+
__parent = _useBlockRequestConte6.__parent,
|
|
925
|
+
service = _useBlockRequestConte6.service;
|
|
838
926
|
var currentRecord = useRecord();
|
|
839
927
|
var currentUserContext = useCurrentUserContext();
|
|
840
|
-
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$
|
|
928
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d5 = currentUserContext.data) === null || _currentUserContext$d5 === void 0 ? void 0 : _currentUserContext$d5.data;
|
|
841
929
|
var actionField = useField();
|
|
842
|
-
var
|
|
843
|
-
setVisible =
|
|
930
|
+
var _useActionContext3 = useActionContext(),
|
|
931
|
+
setVisible = _useActionContext3.setVisible;
|
|
844
932
|
return {
|
|
845
933
|
onClick: function onClick() {
|
|
846
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
847
|
-
var _actionSchema$
|
|
848
|
-
var
|
|
849
|
-
return _regeneratorRuntime().wrap(function
|
|
850
|
-
while (1) switch (
|
|
934
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
935
|
+
var _actionSchema$xActio6;
|
|
936
|
+
var _ref14, skipValidator, onSuccess, requestSettings, xAction, headers, params, data, methods, fieldNames, values, requestBody, _service$refresh3, _parent$service5, _parent$service5$refr;
|
|
937
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
938
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
851
939
|
case 0:
|
|
852
|
-
|
|
940
|
+
_ref14 = (_actionSchema$xActio6 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio6 !== void 0 ? _actionSchema$xActio6 : {}, skipValidator = _ref14.skipValidator, onSuccess = _ref14.onSuccess, requestSettings = _ref14.requestSettings;
|
|
853
941
|
xAction = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action'];
|
|
854
942
|
if (requestSettings['url']) {
|
|
855
|
-
|
|
943
|
+
_context17.next = 4;
|
|
856
944
|
break;
|
|
857
945
|
}
|
|
858
|
-
return
|
|
946
|
+
return _context17.abrupt("return");
|
|
859
947
|
case 4:
|
|
860
948
|
if (!(skipValidator !== true && xAction === 'customize:form:request')) {
|
|
861
|
-
|
|
949
|
+
_context17.next = 7;
|
|
862
950
|
break;
|
|
863
951
|
}
|
|
864
|
-
|
|
952
|
+
_context17.next = 7;
|
|
865
953
|
return form.submit();
|
|
866
954
|
case 7:
|
|
867
955
|
headers = requestSettings['headers'] ? JSON.parse(requestSettings['headers']) : {};
|
|
@@ -896,8 +984,8 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
896
984
|
};
|
|
897
985
|
actionField.data = field.data || {};
|
|
898
986
|
actionField.data.loading = true;
|
|
899
|
-
|
|
900
|
-
|
|
987
|
+
_context17.prev = 15;
|
|
988
|
+
_context17.next = 18;
|
|
901
989
|
return apiClient.request(_objectSpread({}, requestBody));
|
|
902
990
|
case 18:
|
|
903
991
|
actionField.data.loading = false;
|
|
@@ -909,18 +997,18 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
909
997
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
910
998
|
}
|
|
911
999
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
912
|
-
|
|
1000
|
+
_context17.next = 24;
|
|
913
1001
|
break;
|
|
914
1002
|
}
|
|
915
|
-
return
|
|
1003
|
+
return _context17.abrupt("return");
|
|
916
1004
|
case 24:
|
|
917
1005
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
918
1006
|
Modal.success({
|
|
919
1007
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
920
1008
|
onOk: function () {
|
|
921
|
-
var _onOk5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
922
|
-
return _regeneratorRuntime().wrap(function
|
|
923
|
-
while (1) switch (
|
|
1009
|
+
var _onOk5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1010
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1011
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
924
1012
|
case 0:
|
|
925
1013
|
if ((onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirecting) && (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirectTo)) {
|
|
926
1014
|
if (isURL(onSuccess.redirectTo)) {
|
|
@@ -931,9 +1019,9 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
931
1019
|
}
|
|
932
1020
|
case 1:
|
|
933
1021
|
case "end":
|
|
934
|
-
return
|
|
1022
|
+
return _context16.stop();
|
|
935
1023
|
}
|
|
936
|
-
},
|
|
1024
|
+
}, _callee16);
|
|
937
1025
|
}));
|
|
938
1026
|
function onOk() {
|
|
939
1027
|
return _onOk5.apply(this, arguments);
|
|
@@ -945,59 +1033,59 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
945
1033
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
946
1034
|
}
|
|
947
1035
|
case 25:
|
|
948
|
-
|
|
1036
|
+
_context17.prev = 25;
|
|
949
1037
|
actionField.data.loading = false;
|
|
950
|
-
return
|
|
1038
|
+
return _context17.finish(25);
|
|
951
1039
|
case 28:
|
|
952
1040
|
case "end":
|
|
953
|
-
return
|
|
1041
|
+
return _context17.stop();
|
|
954
1042
|
}
|
|
955
|
-
},
|
|
1043
|
+
}, _callee17, null, [[15,, 25, 28]]);
|
|
956
1044
|
}))();
|
|
957
1045
|
}
|
|
958
1046
|
};
|
|
959
1047
|
};
|
|
960
1048
|
export var useUpdateActionProps = function useUpdateActionProps() {
|
|
961
|
-
var _currentUserContext$
|
|
1049
|
+
var _currentUserContext$d6;
|
|
962
1050
|
var form = useForm();
|
|
963
1051
|
var filterByTk = useFilterByTk();
|
|
964
|
-
var
|
|
965
|
-
field =
|
|
966
|
-
resource =
|
|
967
|
-
__parent =
|
|
968
|
-
var
|
|
969
|
-
setVisible =
|
|
1052
|
+
var _useBlockRequestConte7 = useBlockRequestContext(),
|
|
1053
|
+
field = _useBlockRequestConte7.field,
|
|
1054
|
+
resource = _useBlockRequestConte7.resource,
|
|
1055
|
+
__parent = _useBlockRequestConte7.__parent;
|
|
1056
|
+
var _useActionContext4 = useActionContext(),
|
|
1057
|
+
setVisible = _useActionContext4.setVisible;
|
|
970
1058
|
var actionSchema = useFieldSchema();
|
|
971
1059
|
var history = useHistory();
|
|
972
|
-
var
|
|
973
|
-
fields =
|
|
974
|
-
getField =
|
|
1060
|
+
var _useCollection5 = useCollection(),
|
|
1061
|
+
fields = _useCollection5.fields,
|
|
1062
|
+
getField = _useCollection5.getField;
|
|
975
1063
|
var compile = useCompile();
|
|
976
1064
|
var actionField = useField();
|
|
977
1065
|
var _useFormBlockContext = useFormBlockContext(),
|
|
978
1066
|
updateAssociationValues = _useFormBlockContext.updateAssociationValues;
|
|
979
1067
|
var currentRecord = useRecord();
|
|
980
1068
|
var currentUserContext = useCurrentUserContext();
|
|
981
|
-
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$
|
|
1069
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d6 = currentUserContext.data) === null || _currentUserContext$d6 === void 0 ? void 0 : _currentUserContext$d6.data;
|
|
982
1070
|
return {
|
|
983
1071
|
onClick: function onClick() {
|
|
984
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
985
|
-
var _actionSchema$
|
|
986
|
-
var
|
|
987
|
-
return _regeneratorRuntime().wrap(function
|
|
988
|
-
while (1) switch (
|
|
1072
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1073
|
+
var _actionSchema$xActio7;
|
|
1074
|
+
var _ref15, _ref15$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, assignedValues, fieldNames, values, _parent$service6, _parent$service6$refr;
|
|
1075
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1076
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
989
1077
|
case 0:
|
|
990
|
-
|
|
1078
|
+
_ref15 = (_actionSchema$xActio7 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio7 !== void 0 ? _actionSchema$xActio7 : {}, _ref15$assignedValues = _ref15.assignedValues, originalAssignedValues = _ref15$assignedValues === void 0 ? {} : _ref15$assignedValues, onSuccess = _ref15.onSuccess, overwriteValues = _ref15.overwriteValues, skipValidator = _ref15.skipValidator;
|
|
991
1079
|
assignedValues = parse(originalAssignedValues)({
|
|
992
1080
|
currentTime: new Date(),
|
|
993
1081
|
currentRecord: currentRecord,
|
|
994
1082
|
currentUser: currentUser
|
|
995
1083
|
});
|
|
996
1084
|
if (skipValidator) {
|
|
997
|
-
|
|
1085
|
+
_context19.next = 5;
|
|
998
1086
|
break;
|
|
999
1087
|
}
|
|
1000
|
-
|
|
1088
|
+
_context19.next = 5;
|
|
1001
1089
|
return form.submit();
|
|
1002
1090
|
case 5:
|
|
1003
1091
|
fieldNames = fields.map(function (field) {
|
|
@@ -1006,8 +1094,8 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
1006
1094
|
values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
|
|
1007
1095
|
actionField.data = field.data || {};
|
|
1008
1096
|
actionField.data.loading = true;
|
|
1009
|
-
|
|
1010
|
-
|
|
1097
|
+
_context19.prev = 9;
|
|
1098
|
+
_context19.next = 12;
|
|
1011
1099
|
return resource.update({
|
|
1012
1100
|
filterByTk: filterByTk,
|
|
1013
1101
|
values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues),
|
|
@@ -1015,26 +1103,23 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
1015
1103
|
});
|
|
1016
1104
|
case 12:
|
|
1017
1105
|
actionField.data.loading = false;
|
|
1018
|
-
if (!(resource instanceof TableFieldResource)) {
|
|
1019
|
-
__parent === null || __parent === void 0 ? void 0 : (_parent$__parent2 = __parent.__parent) === null || _parent$__parent2 === void 0 ? void 0 : (_parent$__parent2$ser = _parent$__parent2.service) === null || _parent$__parent2$ser === void 0 ? void 0 : (_parent$__parent2$ser2 = _parent$__parent2$ser.refresh) === null || _parent$__parent2$ser2 === void 0 ? void 0 : _parent$__parent2$ser2.call(_parent$__parent2$ser);
|
|
1020
|
-
}
|
|
1021
1106
|
__parent === null || __parent === void 0 ? void 0 : (_parent$service6 = __parent.service) === null || _parent$service6 === void 0 ? void 0 : (_parent$service6$refr = _parent$service6.refresh) === null || _parent$service6$refr === void 0 ? void 0 : _parent$service6$refr.call(_parent$service6);
|
|
1022
1107
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
1023
1108
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
1024
|
-
|
|
1109
|
+
_context19.next = 17;
|
|
1025
1110
|
break;
|
|
1026
1111
|
}
|
|
1027
|
-
return
|
|
1028
|
-
case
|
|
1112
|
+
return _context19.abrupt("return");
|
|
1113
|
+
case 17:
|
|
1029
1114
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
1030
1115
|
Modal.success({
|
|
1031
1116
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
1032
1117
|
onOk: function () {
|
|
1033
|
-
var _onOk6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1034
|
-
return _regeneratorRuntime().wrap(function
|
|
1035
|
-
while (1) switch (
|
|
1118
|
+
var _onOk6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1119
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1120
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1036
1121
|
case 0:
|
|
1037
|
-
|
|
1122
|
+
_context18.next = 2;
|
|
1038
1123
|
return form.reset();
|
|
1039
1124
|
case 2:
|
|
1040
1125
|
if ((onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirecting) && (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.redirectTo)) {
|
|
@@ -1046,9 +1131,9 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
1046
1131
|
}
|
|
1047
1132
|
case 3:
|
|
1048
1133
|
case "end":
|
|
1049
|
-
return
|
|
1134
|
+
return _context18.stop();
|
|
1050
1135
|
}
|
|
1051
|
-
},
|
|
1136
|
+
}, _callee18);
|
|
1052
1137
|
}));
|
|
1053
1138
|
function onOk() {
|
|
1054
1139
|
return _onOk6.apply(this, arguments);
|
|
@@ -1059,44 +1144,44 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
1059
1144
|
} else {
|
|
1060
1145
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
1061
1146
|
}
|
|
1062
|
-
|
|
1147
|
+
_context19.next = 23;
|
|
1063
1148
|
break;
|
|
1064
|
-
case
|
|
1065
|
-
|
|
1066
|
-
|
|
1149
|
+
case 20:
|
|
1150
|
+
_context19.prev = 20;
|
|
1151
|
+
_context19.t0 = _context19["catch"](9);
|
|
1067
1152
|
actionField.data.loading = false;
|
|
1068
|
-
case
|
|
1153
|
+
case 23:
|
|
1069
1154
|
case "end":
|
|
1070
|
-
return
|
|
1155
|
+
return _context19.stop();
|
|
1071
1156
|
}
|
|
1072
|
-
},
|
|
1157
|
+
}, _callee19, null, [[9, 20]]);
|
|
1073
1158
|
}))();
|
|
1074
1159
|
}
|
|
1075
1160
|
};
|
|
1076
1161
|
};
|
|
1077
1162
|
export var useDestroyActionProps = function useDestroyActionProps() {
|
|
1078
1163
|
var filterByTk = useFilterByTk();
|
|
1079
|
-
var
|
|
1080
|
-
resource =
|
|
1081
|
-
service =
|
|
1082
|
-
block =
|
|
1083
|
-
__parent =
|
|
1084
|
-
var
|
|
1085
|
-
setVisible =
|
|
1164
|
+
var _useBlockRequestConte8 = useBlockRequestContext(),
|
|
1165
|
+
resource = _useBlockRequestConte8.resource,
|
|
1166
|
+
service = _useBlockRequestConte8.service,
|
|
1167
|
+
block = _useBlockRequestConte8.block,
|
|
1168
|
+
__parent = _useBlockRequestConte8.__parent;
|
|
1169
|
+
var _useActionContext5 = useActionContext(),
|
|
1170
|
+
setVisible = _useActionContext5.setVisible;
|
|
1086
1171
|
return {
|
|
1087
1172
|
onClick: function onClick() {
|
|
1088
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1173
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1089
1174
|
var _service$data;
|
|
1090
|
-
var
|
|
1091
|
-
return _regeneratorRuntime().wrap(function
|
|
1092
|
-
while (1) switch (
|
|
1175
|
+
var _ref16, _ref16$count, count, _ref16$page, page, _ref16$pageSize, pageSize, _service$params2, _service$refresh4, _parent$service7, _parent$service7$refr;
|
|
1176
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1177
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1093
1178
|
case 0:
|
|
1094
|
-
|
|
1179
|
+
_context20.next = 2;
|
|
1095
1180
|
return resource.destroy({
|
|
1096
1181
|
filterByTk: filterByTk
|
|
1097
1182
|
});
|
|
1098
1183
|
case 2:
|
|
1099
|
-
|
|
1184
|
+
_ref16 = (service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.meta) || {}, _ref16$count = _ref16.count, count = _ref16$count === void 0 ? 0 : _ref16$count, _ref16$page = _ref16.page, page = _ref16$page === void 0 ? 0 : _ref16$page, _ref16$pageSize = _ref16.pageSize, pageSize = _ref16$pageSize === void 0 ? 0 : _ref16$pageSize;
|
|
1100
1185
|
if (count % pageSize === 1) {
|
|
1101
1186
|
service.run(_objectSpread(_objectSpread({}, service === null || service === void 0 ? void 0 : (_service$params2 = service.params) === null || _service$params2 === void 0 ? void 0 : _service$params2[0]), {}, {
|
|
1102
1187
|
page: page - 1
|
|
@@ -1110,9 +1195,32 @@ export var useDestroyActionProps = function useDestroyActionProps() {
|
|
|
1110
1195
|
}
|
|
1111
1196
|
case 5:
|
|
1112
1197
|
case "end":
|
|
1113
|
-
return
|
|
1198
|
+
return _context20.stop();
|
|
1114
1199
|
}
|
|
1115
|
-
},
|
|
1200
|
+
}, _callee20);
|
|
1201
|
+
}))();
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
};
|
|
1205
|
+
export var useRemoveActionProps = function useRemoveActionProps(associationName) {
|
|
1206
|
+
var filterByTk = useFilterByTk();
|
|
1207
|
+
var api = useAPIClient();
|
|
1208
|
+
var resource = api.resource(associationName, filterByTk);
|
|
1209
|
+
return {
|
|
1210
|
+
onClick: function onClick(value) {
|
|
1211
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1212
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1213
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1214
|
+
case 0:
|
|
1215
|
+
_context21.next = 2;
|
|
1216
|
+
return resource.remove({
|
|
1217
|
+
values: [value.id]
|
|
1218
|
+
});
|
|
1219
|
+
case 2:
|
|
1220
|
+
case "end":
|
|
1221
|
+
return _context21.stop();
|
|
1222
|
+
}
|
|
1223
|
+
}, _callee21);
|
|
1116
1224
|
}))();
|
|
1117
1225
|
}
|
|
1118
1226
|
};
|
|
@@ -1128,40 +1236,40 @@ export var useDetailPrintActionProps = function useDetailPrintActionProps() {
|
|
|
1128
1236
|
});
|
|
1129
1237
|
return {
|
|
1130
1238
|
onClick: function onClick() {
|
|
1131
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1132
|
-
return _regeneratorRuntime().wrap(function
|
|
1133
|
-
while (1) switch (
|
|
1239
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1240
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1241
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1134
1242
|
case 0:
|
|
1135
1243
|
printHandler();
|
|
1136
1244
|
case 1:
|
|
1137
1245
|
case "end":
|
|
1138
|
-
return
|
|
1246
|
+
return _context22.stop();
|
|
1139
1247
|
}
|
|
1140
|
-
},
|
|
1248
|
+
}, _callee22);
|
|
1141
1249
|
}))();
|
|
1142
1250
|
}
|
|
1143
1251
|
};
|
|
1144
1252
|
};
|
|
1145
1253
|
export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
|
|
1146
|
-
var _useBlockRequestConte8 = useBlockRequestContext(),
|
|
1147
|
-
field = _useBlockRequestConte8.field;
|
|
1148
1254
|
var _useBlockRequestConte9 = useBlockRequestContext(),
|
|
1149
|
-
|
|
1150
|
-
|
|
1255
|
+
field = _useBlockRequestConte9.field;
|
|
1256
|
+
var _useBlockRequestConte10 = useBlockRequestContext(),
|
|
1257
|
+
resource = _useBlockRequestConte10.resource,
|
|
1258
|
+
service = _useBlockRequestConte10.service;
|
|
1151
1259
|
return {
|
|
1152
1260
|
onClick: function onClick() {
|
|
1153
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1261
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1154
1262
|
var _field$data2, _field$data2$selected, _field$data3, _service$refresh5;
|
|
1155
|
-
return _regeneratorRuntime().wrap(function
|
|
1156
|
-
while (1) switch (
|
|
1263
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1264
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1157
1265
|
case 0:
|
|
1158
1266
|
if (field === null || field === void 0 ? void 0 : (_field$data2 = field.data) === null || _field$data2 === void 0 ? void 0 : (_field$data2$selected = _field$data2.selectedRowKeys) === null || _field$data2$selected === void 0 ? void 0 : _field$data2$selected.length) {
|
|
1159
|
-
|
|
1267
|
+
_context23.next = 2;
|
|
1160
1268
|
break;
|
|
1161
1269
|
}
|
|
1162
|
-
return
|
|
1270
|
+
return _context23.abrupt("return");
|
|
1163
1271
|
case 2:
|
|
1164
|
-
|
|
1272
|
+
_context23.next = 4;
|
|
1165
1273
|
return resource.destroy({
|
|
1166
1274
|
filterByTk: (_field$data3 = field.data) === null || _field$data3 === void 0 ? void 0 : _field$data3.selectedRowKeys
|
|
1167
1275
|
});
|
|
@@ -1170,29 +1278,29 @@ export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
|
|
|
1170
1278
|
service === null || service === void 0 ? void 0 : (_service$refresh5 = service.refresh) === null || _service$refresh5 === void 0 ? void 0 : _service$refresh5.call(service);
|
|
1171
1279
|
case 6:
|
|
1172
1280
|
case "end":
|
|
1173
|
-
return
|
|
1281
|
+
return _context23.stop();
|
|
1174
1282
|
}
|
|
1175
|
-
},
|
|
1283
|
+
}, _callee23);
|
|
1176
1284
|
}))();
|
|
1177
1285
|
}
|
|
1178
1286
|
};
|
|
1179
1287
|
};
|
|
1180
1288
|
export var useRefreshActionProps = function useRefreshActionProps() {
|
|
1181
|
-
var
|
|
1182
|
-
service =
|
|
1289
|
+
var _useBlockRequestConte11 = useBlockRequestContext(),
|
|
1290
|
+
service = _useBlockRequestConte11.service;
|
|
1183
1291
|
return {
|
|
1184
1292
|
onClick: function onClick() {
|
|
1185
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1293
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1186
1294
|
var _service$refresh6;
|
|
1187
|
-
return _regeneratorRuntime().wrap(function
|
|
1188
|
-
while (1) switch (
|
|
1295
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1296
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1189
1297
|
case 0:
|
|
1190
1298
|
service === null || service === void 0 ? void 0 : (_service$refresh6 = service.refresh) === null || _service$refresh6 === void 0 ? void 0 : _service$refresh6.call(service);
|
|
1191
1299
|
case 1:
|
|
1192
1300
|
case "end":
|
|
1193
|
-
return
|
|
1301
|
+
return _context24.stop();
|
|
1194
1302
|
}
|
|
1195
|
-
},
|
|
1303
|
+
}, _callee24);
|
|
1196
1304
|
}))();
|
|
1197
1305
|
}
|
|
1198
1306
|
};
|
|
@@ -1208,11 +1316,11 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
|
|
|
1208
1316
|
total: count,
|
|
1209
1317
|
pageSize: 1,
|
|
1210
1318
|
onChange: function onChange(page) {
|
|
1211
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1319
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1212
1320
|
var _ctx$service3, _ctx$service3$params;
|
|
1213
1321
|
var params;
|
|
1214
|
-
return _regeneratorRuntime().wrap(function
|
|
1215
|
-
while (1) switch (
|
|
1322
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1323
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1216
1324
|
case 0:
|
|
1217
1325
|
params = (_ctx$service3 = ctx.service) === null || _ctx$service3 === void 0 ? void 0 : (_ctx$service3$params = _ctx$service3.params) === null || _ctx$service3$params === void 0 ? void 0 : _ctx$service3$params[0];
|
|
1218
1326
|
ctx.service.run(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -1220,9 +1328,9 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
|
|
|
1220
1328
|
}));
|
|
1221
1329
|
case 2:
|
|
1222
1330
|
case "end":
|
|
1223
|
-
return
|
|
1331
|
+
return _context25.stop();
|
|
1224
1332
|
}
|
|
1225
|
-
},
|
|
1333
|
+
}, _callee25);
|
|
1226
1334
|
}))();
|
|
1227
1335
|
},
|
|
1228
1336
|
style: {
|
|
@@ -1232,14 +1340,14 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
|
|
|
1232
1340
|
};
|
|
1233
1341
|
};
|
|
1234
1342
|
export var useAssociationFilterProps = function useAssociationFilterProps() {
|
|
1235
|
-
var _fieldSchema$
|
|
1343
|
+
var _fieldSchema$xCompon3, _fieldSchema$xCompon4, _field$componentProps, _field$componentProps2;
|
|
1236
1344
|
var collectionField = AssociationFilter.useAssociationField();
|
|
1237
|
-
var
|
|
1238
|
-
service =
|
|
1239
|
-
blockProps =
|
|
1345
|
+
var _useBlockRequestConte12 = useBlockRequestContext(),
|
|
1346
|
+
service = _useBlockRequestConte12.service,
|
|
1347
|
+
blockProps = _useBlockRequestConte12.props;
|
|
1240
1348
|
var fieldSchema = useFieldSchema();
|
|
1241
1349
|
var valueKey = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetKey) || 'id';
|
|
1242
|
-
var labelKey = ((_fieldSchema$
|
|
1350
|
+
var labelKey = ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.fieldNames) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.label) || valueKey;
|
|
1243
1351
|
var field = useField();
|
|
1244
1352
|
var collectionFieldName = collectionField.name;
|
|
1245
1353
|
var _useRequest = useRequest({
|
|
@@ -1289,9 +1397,9 @@ export var useAssociationFilterProps = function useAssociationFilterProps() {
|
|
|
1289
1397
|
};
|
|
1290
1398
|
};
|
|
1291
1399
|
export var useOptionalFieldList = function useOptionalFieldList() {
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
currentFields =
|
|
1400
|
+
var _useCollection6 = useCollection(),
|
|
1401
|
+
_useCollection6$curre = _useCollection6.currentFields,
|
|
1402
|
+
currentFields = _useCollection6$curre === void 0 ? [] : _useCollection6$curre;
|
|
1295
1403
|
return currentFields.filter(function (field) {
|
|
1296
1404
|
return isOptionalField(field) && field.uiSchema.enum;
|
|
1297
1405
|
});
|
|
@@ -1301,16 +1409,42 @@ var isOptionalField = function isOptionalField(field) {
|
|
|
1301
1409
|
return optionalInterfaces.includes(field.interface);
|
|
1302
1410
|
};
|
|
1303
1411
|
export var useAssociationFilterBlockProps = function useAssociationFilterBlockProps() {
|
|
1412
|
+
var _fieldSchema$xCompon5, _fieldSchema$xCompon6, _field$componentProps3, _field$componentProps4;
|
|
1304
1413
|
var collectionField = AssociationFilter.useAssociationField();
|
|
1305
1414
|
var fieldSchema = useFieldSchema();
|
|
1306
1415
|
var optionalFieldList = useOptionalFieldList();
|
|
1307
1416
|
var _useFilterBlock3 = useFilterBlock(),
|
|
1308
1417
|
getDataBlocks = _useFilterBlock3.getDataBlocks;
|
|
1309
1418
|
var collectionFieldName = collectionField.name;
|
|
1419
|
+
var field = useField();
|
|
1310
1420
|
var list, onSelected, handleSearchInput, params, run, data, valueKey, labelKey, filterKey;
|
|
1421
|
+
valueKey = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetKey) || 'id';
|
|
1422
|
+
labelKey = ((_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : (_fieldSchema$xCompon6 = _fieldSchema$xCompon5.fieldNames) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6.label) || valueKey;
|
|
1423
|
+
var _useRequest2 = useRequest({
|
|
1424
|
+
resource: collectionField === null || collectionField === void 0 ? void 0 : collectionField.target,
|
|
1425
|
+
action: 'list',
|
|
1426
|
+
params: _objectSpread({
|
|
1427
|
+
fields: [labelKey, valueKey],
|
|
1428
|
+
pageSize: 200,
|
|
1429
|
+
page: 1
|
|
1430
|
+
}, (_field$componentProps4 = field.componentProps) === null || _field$componentProps4 === void 0 ? void 0 : _field$componentProps4.params)
|
|
1431
|
+
}, {
|
|
1432
|
+
// 由于 选项字段不需要触发当前请求,所以当前请求更改为手动触发
|
|
1433
|
+
manual: true,
|
|
1434
|
+
debounceWait: 300
|
|
1435
|
+
});
|
|
1436
|
+
data = _useRequest2.data;
|
|
1437
|
+
params = _useRequest2.params;
|
|
1438
|
+
run = _useRequest2.run;
|
|
1439
|
+
useEffect(function () {
|
|
1440
|
+
// 由于 选项字段不需要触发当前请求,所以请求单独在 关系字段的时候触发
|
|
1441
|
+
if (!isOptionalField(fieldSchema)) {
|
|
1442
|
+
run();
|
|
1443
|
+
}
|
|
1444
|
+
}, [labelKey, valueKey, JSON.stringify(((_field$componentProps3 = field.componentProps) === null || _field$componentProps3 === void 0 ? void 0 : _field$componentProps3.params) || {}), isOptionalField(fieldSchema)]);
|
|
1311
1445
|
if (isOptionalField(fieldSchema)) {
|
|
1312
1446
|
var _field$uiSchema;
|
|
1313
|
-
var
|
|
1447
|
+
var _field = optionalFieldList.find(function (field) {
|
|
1314
1448
|
return field.name === fieldSchema.name;
|
|
1315
1449
|
});
|
|
1316
1450
|
var operatorMap = {
|
|
@@ -1319,13 +1453,13 @@ export var useAssociationFilterBlockProps = function useAssociationFilterBlockPr
|
|
|
1319
1453
|
checkbox: '$in',
|
|
1320
1454
|
checkboxGroup: '$anyOf'
|
|
1321
1455
|
};
|
|
1322
|
-
var _list = (
|
|
1456
|
+
var _list = (_field === null || _field === void 0 ? void 0 : (_field$uiSchema = _field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.enum) || [];
|
|
1323
1457
|
valueKey = 'value';
|
|
1324
1458
|
labelKey = 'label';
|
|
1325
1459
|
list = _list;
|
|
1326
1460
|
params = {};
|
|
1327
1461
|
run = function run() {};
|
|
1328
|
-
filterKey = "".concat(
|
|
1462
|
+
filterKey = "".concat(_field.name, ".").concat(operatorMap[_field.interface]);
|
|
1329
1463
|
handleSearchInput = function handleSearchInput(e) {
|
|
1330
1464
|
// TODO: 列表没有刷新,在这个 hook 中使用 useState 会产生 re-render 次数过多的错误
|
|
1331
1465
|
var value = e.target.value;
|
|
@@ -1338,24 +1472,7 @@ export var useAssociationFilterBlockProps = function useAssociationFilterBlockPr
|
|
|
1338
1472
|
});
|
|
1339
1473
|
};
|
|
1340
1474
|
} else {
|
|
1341
|
-
var
|
|
1342
|
-
valueKey = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetKey) || 'id';
|
|
1343
|
-
labelKey = ((_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : (_fieldSchema$xCompon5 = _fieldSchema$xCompon4.fieldNames) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : _fieldSchema$xCompon5.label) || valueKey;
|
|
1344
|
-
var _useRequest2 = useRequest({
|
|
1345
|
-
resource: collectionField.target,
|
|
1346
|
-
action: 'list',
|
|
1347
|
-
params: {
|
|
1348
|
-
fields: [labelKey, valueKey],
|
|
1349
|
-
pageSize: 200,
|
|
1350
|
-
page: 1
|
|
1351
|
-
}
|
|
1352
|
-
}, {
|
|
1353
|
-
refreshDeps: [labelKey, valueKey],
|
|
1354
|
-
debounceWait: 300
|
|
1355
|
-
});
|
|
1356
|
-
data = _useRequest2.data;
|
|
1357
|
-
params = _useRequest2.params;
|
|
1358
|
-
run = _useRequest2.run;
|
|
1475
|
+
var _data;
|
|
1359
1476
|
filterKey = "".concat(collectionFieldName, ".").concat(valueKey, ".$in");
|
|
1360
1477
|
list = ((_data = data) === null || _data === void 0 ? void 0 : _data.data) || [];
|
|
1361
1478
|
handleSearchInput = function handleSearchInput(e) {
|
|
@@ -1403,4 +1520,113 @@ export var useAssociationFilterBlockProps = function useAssociationFilterBlockPr
|
|
|
1403
1520
|
valueKey: valueKey,
|
|
1404
1521
|
labelKey: labelKey
|
|
1405
1522
|
};
|
|
1523
|
+
};
|
|
1524
|
+
export var useAssociationNames = function useAssociationNames(collection) {
|
|
1525
|
+
var _useCollectionManager2 = useCollectionManager(),
|
|
1526
|
+
getCollectionFields = _useCollectionManager2.getCollectionFields,
|
|
1527
|
+
getCollectionJoinField = _useCollectionManager2.getCollectionJoinField;
|
|
1528
|
+
var collectionFields = getCollectionFields(collection);
|
|
1529
|
+
var associationFields = new Set();
|
|
1530
|
+
var _iterator = _createForOfIteratorHelper(collectionFields),
|
|
1531
|
+
_step;
|
|
1532
|
+
try {
|
|
1533
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1534
|
+
var collectionField = _step.value;
|
|
1535
|
+
if (collectionField.target) {
|
|
1536
|
+
associationFields.add(collectionField.name);
|
|
1537
|
+
var fields = getCollectionFields(collectionField.target);
|
|
1538
|
+
var _iterator2 = _createForOfIteratorHelper(fields),
|
|
1539
|
+
_step2;
|
|
1540
|
+
try {
|
|
1541
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1542
|
+
var field = _step2.value;
|
|
1543
|
+
if (field.target) {
|
|
1544
|
+
associationFields.add("".concat(collectionField.name, ".").concat(field.name));
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
} catch (err) {
|
|
1548
|
+
_iterator2.e(err);
|
|
1549
|
+
} finally {
|
|
1550
|
+
_iterator2.f();
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
} catch (err) {
|
|
1555
|
+
_iterator.e(err);
|
|
1556
|
+
} finally {
|
|
1557
|
+
_iterator.f();
|
|
1558
|
+
}
|
|
1559
|
+
var fieldSchema = useFieldSchema();
|
|
1560
|
+
var associationValues = [];
|
|
1561
|
+
var formSchema = fieldSchema.reduceProperties(function (buf, schema) {
|
|
1562
|
+
if (['FormV2', 'Details'].includes(schema['x-component'])) {
|
|
1563
|
+
return schema;
|
|
1564
|
+
}
|
|
1565
|
+
return buf;
|
|
1566
|
+
}, new Schema({}));
|
|
1567
|
+
var getAssociationAppends = function getAssociationAppends(schema) {
|
|
1568
|
+
var arr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1569
|
+
return schema.reduceProperties(function (buf, s) {
|
|
1570
|
+
var collectionfield = s['x-collection-field'] && getCollectionJoinField(s['x-collection-field']);
|
|
1571
|
+
if (collectionfield && ['createdBy', 'updatedBy', 'o2m', 'obo', 'oho', 'm2o', 'm2m'].includes(collectionfield.interface)) {
|
|
1572
|
+
var _s$xComponentProps;
|
|
1573
|
+
if (['Nester', 'SubTable'].includes((_s$xComponentProps = s['x-component-props']) === null || _s$xComponentProps === void 0 ? void 0 : _s$xComponentProps.mode)) {
|
|
1574
|
+
associationValues.push(s.name);
|
|
1575
|
+
}
|
|
1576
|
+
buf.push(s.name);
|
|
1577
|
+
if (s['x-component-props'].mode === 'Nester' || s['x-component'] === 'TableField') {
|
|
1578
|
+
return getAssociationAppends(s, buf);
|
|
1579
|
+
}
|
|
1580
|
+
return buf;
|
|
1581
|
+
} else {
|
|
1582
|
+
if (s['x-component'] === 'Grid' || s['x-component'] === 'TableV2') {
|
|
1583
|
+
var _buf$concat;
|
|
1584
|
+
var kk = buf === null || buf === void 0 ? void 0 : (_buf$concat = buf.concat) === null || _buf$concat === void 0 ? void 0 : _buf$concat.call(buf);
|
|
1585
|
+
return getNesterAppends(s, kk || []);
|
|
1586
|
+
} else {
|
|
1587
|
+
var _s$xComponent;
|
|
1588
|
+
return !((_s$xComponent = s['x-component']) === null || _s$xComponent === void 0 ? void 0 : _s$xComponent.includes('Action.')) && getAssociationAppends(s, buf);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}, arr);
|
|
1592
|
+
};
|
|
1593
|
+
function flattenNestedList(nestedList) {
|
|
1594
|
+
var flattenedList = [];
|
|
1595
|
+
function flattenHelper(list, prefix) {
|
|
1596
|
+
for (var i = 0; i < list.length; i++) {
|
|
1597
|
+
if (Array.isArray(list[i])) {
|
|
1598
|
+
"".concat(prefix) !== "".concat(list[i][0]) && flattenHelper(list[i], "".concat(prefix, ".").concat(list[i][0]));
|
|
1599
|
+
} else {
|
|
1600
|
+
var str = prefix.replaceAll("".concat(list[i]), '').replace('..', '.').trim();
|
|
1601
|
+
!list.includes(str) && flattenedList.push("".concat(str).concat(list[i]));
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
for (var i = 0; i < nestedList.length; i++) {
|
|
1606
|
+
flattenHelper(nestedList[i], nestedList[i][0]);
|
|
1607
|
+
}
|
|
1608
|
+
return flattenedList.filter(function (obj) {
|
|
1609
|
+
return !obj.startsWith('.');
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
var getNesterAppends = function getNesterAppends(gridSchema, data) {
|
|
1613
|
+
gridSchema.reduceProperties(function (buf, s) {
|
|
1614
|
+
buf.push(getAssociationAppends(s));
|
|
1615
|
+
return buf;
|
|
1616
|
+
}, data);
|
|
1617
|
+
return data.filter(function (g) {
|
|
1618
|
+
return g.length;
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
var data = getAssociationAppends(formSchema);
|
|
1622
|
+
var associations = data.filter(function (g) {
|
|
1623
|
+
return g.length;
|
|
1624
|
+
});
|
|
1625
|
+
var appends = flattenNestedList(associations);
|
|
1626
|
+
return {
|
|
1627
|
+
appends: appends,
|
|
1628
|
+
updateAssociationValues: appends.filter(function (v) {
|
|
1629
|
+
return associationValues.includes(v);
|
|
1630
|
+
})
|
|
1631
|
+
};
|
|
1406
1632
|
};
|