@nocobase/client 0.7.2-alpha.6 → 0.7.4-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/application/Application.d.ts +1 -0
- package/es/application/Application.js +7 -1
- package/es/block-provider/FormBlockProvider.js +8 -3
- package/es/block-provider/TableFieldProvider.d.ts +1 -0
- package/es/block-provider/TableFieldProvider.js +5 -2
- package/es/block-provider/TableSelectorProvider.js +41 -13
- package/es/block-provider/hooks/index.d.ts +6 -0
- package/es/block-provider/hooks/index.js +159 -65
- package/es/collection-manager/CollectionField.js +4 -2
- package/es/collection-manager/Configuration/index.js +5 -1
- package/es/collection-manager/Configuration/schemas/collections.js +2 -1
- package/es/collection-manager/interfaces/input.js +103 -0
- package/es/collection-manager/interfaces/integer.js +63 -0
- package/es/collection-manager/interfaces/m2m.js +2 -0
- package/es/collection-manager/interfaces/m2o.js +1 -0
- package/es/collection-manager/interfaces/markdown.js +34 -0
- package/es/collection-manager/interfaces/number.js +55 -0
- package/es/collection-manager/interfaces/o2m.js +1 -0
- package/es/collection-manager/interfaces/o2o.js +3 -0
- package/es/collection-manager/interfaces/password.js +36 -1
- package/es/collection-manager/interfaces/percent.js +97 -0
- package/es/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/es/collection-manager/interfaces/properties/index.js +1 -0
- package/es/collection-manager/interfaces/properties/operators.js +4 -4
- package/es/collection-manager/interfaces/richText.js +34 -0
- package/es/collection-manager/interfaces/textarea.js +34 -0
- package/es/file-manager/FileStorageShortcut.js +2 -2
- package/es/locale/en_US.d.ts +8 -2
- package/es/locale/en_US.js +9 -3
- package/es/locale/zh_CN.d.ts +26 -2
- package/es/locale/zh_CN.js +27 -3
- package/es/plugin-manager/PluginManager.d.ts +1 -0
- package/es/plugin-manager/PluginManager.js +20 -6
- package/es/schema-component/antd/action/Action.Modal.js +1 -1
- package/es/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/es/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/es/schema-component/antd/date-picker/DatePicker.js +1 -1
- package/es/schema-component/antd/date-picker/ReadPretty.js +1 -1
- package/es/schema-component/antd/date-picker/util.d.ts +0 -10
- package/es/schema-component/antd/date-picker/util.js +1 -79
- package/es/schema-component/antd/form-item/FormItem.js +161 -10
- package/es/schema-component/antd/grid/Grid.js +72 -6
- package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/es/schema-component/antd/input-number/InputNumber.js +25 -1
- package/es/schema-component/antd/input-number/ReadPretty.js +2 -4
- package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/percent/Percent.js +2 -2
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +5 -3
- package/es/schema-component/antd/table/Table.Array.js +2 -2
- package/es/schema-component/antd/table/Table.Void.js +11 -1
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/es/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/es/schema-component/antd/table-v2/Table.js +163 -92
- package/es/schema-component/antd/table-v2/TableField.js +3 -0
- package/es/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/es/schema-component/antd/tabs/Tabs.js +7 -1
- package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
- package/es/schema-component/core/DesignableSwitch.js +7 -1
- package/es/schema-component/hooks/useDesignable.js +21 -21
- package/es/schema-component/hooks/useProps.js +1 -1
- package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
- package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
- package/es/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.js +255 -69
- package/es/schema-initializer/items/index.d.ts +2 -0
- package/es/schema-initializer/items/index.js +48 -2
- package/es/schema-initializer/utils.js +22 -2
- package/es/system-settings/SystemSettingsShortcut.js +35 -12
- package/lib/application/Application.d.ts +1 -0
- package/lib/application/Application.js +11 -2
- package/lib/block-provider/FormBlockProvider.js +7 -2
- package/lib/block-provider/TableFieldProvider.d.ts +1 -0
- package/lib/block-provider/TableFieldProvider.js +4 -1
- package/lib/block-provider/TableSelectorProvider.js +41 -13
- package/lib/block-provider/hooks/index.d.ts +6 -0
- package/lib/block-provider/hooks/index.js +168 -67
- package/lib/collection-manager/CollectionField.js +5 -2
- package/lib/collection-manager/Configuration/index.js +5 -0
- package/lib/collection-manager/Configuration/schemas/collections.js +2 -1
- package/lib/collection-manager/interfaces/input.js +104 -0
- package/lib/collection-manager/interfaces/integer.js +65 -0
- package/lib/collection-manager/interfaces/m2m.js +2 -0
- package/lib/collection-manager/interfaces/m2o.js +1 -0
- package/lib/collection-manager/interfaces/markdown.js +35 -0
- package/lib/collection-manager/interfaces/number.js +56 -0
- package/lib/collection-manager/interfaces/o2m.js +1 -0
- package/lib/collection-manager/interfaces/o2o.js +3 -0
- package/lib/collection-manager/interfaces/password.js +37 -1
- package/lib/collection-manager/interfaces/percent.js +99 -0
- package/lib/collection-manager/interfaces/properties/index.d.ts +1 -0
- package/lib/collection-manager/interfaces/properties/index.js +1 -0
- package/lib/collection-manager/interfaces/properties/operators.js +4 -4
- package/lib/collection-manager/interfaces/richText.js +35 -0
- package/lib/collection-manager/interfaces/textarea.js +35 -0
- package/lib/file-manager/FileStorageShortcut.js +1 -1
- package/lib/locale/en_US.d.ts +8 -2
- package/lib/locale/en_US.js +9 -3
- package/lib/locale/zh_CN.d.ts +26 -2
- package/lib/locale/zh_CN.js +27 -3
- package/lib/plugin-manager/PluginManager.d.ts +1 -0
- package/lib/plugin-manager/PluginManager.js +23 -5
- package/lib/schema-component/antd/action/Action.Modal.js +1 -1
- package/lib/schema-component/antd/calendar/Calendar.Designer.js +16 -10
- package/lib/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
- package/lib/schema-component/antd/date-picker/DatePicker.js +2 -2
- package/lib/schema-component/antd/date-picker/ReadPretty.js +6 -6
- package/lib/schema-component/antd/date-picker/util.d.ts +0 -10
- package/lib/schema-component/antd/date-picker/util.js +6 -89
- package/lib/schema-component/antd/form-item/FormItem.js +164 -12
- package/lib/schema-component/antd/grid/Grid.js +69 -3
- package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
- package/lib/schema-component/antd/input-number/InputNumber.js +28 -1
- package/lib/schema-component/antd/input-number/ReadPretty.js +2 -5
- package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/percent/Percent.js +2 -2
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
- package/lib/schema-component/antd/table/Table.Array.js +2 -2
- package/lib/schema-component/antd/table/Table.Void.js +11 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
- package/lib/schema-component/antd/table-v2/Table.d.ts +0 -11
- package/lib/schema-component/antd/table-v2/Table.js +172 -94
- package/lib/schema-component/antd/table-v2/TableField.js +3 -0
- package/lib/schema-component/antd/tabs/Tabs.Designer.js +23 -12
- package/lib/schema-component/antd/tabs/Tabs.js +8 -1
- package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
- package/lib/schema-component/core/DesignableSwitch.js +8 -1
- package/lib/schema-component/hooks/useDesignable.js +21 -21
- package/lib/schema-component/hooks/useProps.js +1 -1
- package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
- package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
- package/lib/schema-initializer/buttons/TabPaneInitializers.js +11 -3
- package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +257 -66
- package/lib/schema-initializer/items/index.d.ts +2 -0
- package/lib/schema-initializer/items/index.js +54 -2
- package/lib/schema-initializer/utils.js +22 -2
- package/lib/system-settings/SystemSettingsShortcut.js +37 -13
- package/package.json +7 -4
|
@@ -10,12 +10,13 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
10
10
|
|
|
11
11
|
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); }
|
|
12
12
|
|
|
13
|
-
import { Schema as SchemaCompiler } from '@formily/json-schema';
|
|
14
13
|
import { useField, useFieldSchema, useForm } from '@formily/react';
|
|
15
14
|
import { message, Modal } from 'antd';
|
|
15
|
+
import parse from 'json-templates';
|
|
16
16
|
import get from 'lodash/get';
|
|
17
17
|
import { useTranslation } from 'react-i18next';
|
|
18
18
|
import { useHistory } from 'react-router-dom';
|
|
19
|
+
import { useReactToPrint } from 'react-to-print';
|
|
19
20
|
import { useFormBlockContext } from '../..';
|
|
20
21
|
import { useAPIClient } from '../../api-client';
|
|
21
22
|
import { useCollection } from '../../collection-manager';
|
|
@@ -141,6 +142,8 @@ function getFormValues(filterByTk, field, form, fieldNames, getField, resource)
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
export var useCreateActionProps = function useCreateActionProps() {
|
|
145
|
+
var _currentUserContext$d;
|
|
146
|
+
|
|
144
147
|
var form = useForm();
|
|
145
148
|
|
|
146
149
|
var _useBlockRequestConte = useBlockRequestContext(),
|
|
@@ -166,12 +169,15 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
166
169
|
|
|
167
170
|
var compile = useCompile();
|
|
168
171
|
var filterByTk = useFilterByTk();
|
|
172
|
+
var currentRecord = useRecord();
|
|
173
|
+
var currentUserContext = useCurrentUserContext();
|
|
174
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d = currentUserContext.data) === null || _currentUserContext$d === void 0 ? void 0 : _currentUserContext$d.data;
|
|
169
175
|
return {
|
|
170
176
|
onClick: function onClick() {
|
|
171
177
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
172
178
|
var _actionSchema$xActio;
|
|
173
179
|
|
|
174
|
-
var fieldNames, _ref, assignedValues, onSuccess, overwriteValues, skipValidator, values, _parent$service, _parent$service$refre;
|
|
180
|
+
var fieldNames, _ref, _ref$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, assignedValues, values, _parent$service, _parent$service$refre;
|
|
175
181
|
|
|
176
182
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
177
183
|
while (1) {
|
|
@@ -180,39 +186,44 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
180
186
|
fieldNames = fields.map(function (field) {
|
|
181
187
|
return field.name;
|
|
182
188
|
});
|
|
183
|
-
_ref = (_actionSchema$xActio = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio !== void 0 ? _actionSchema$xActio : {}, assignedValues = _ref.assignedValues, onSuccess = _ref.onSuccess, overwriteValues = _ref.overwriteValues, skipValidator = _ref.skipValidator;
|
|
189
|
+
_ref = (_actionSchema$xActio = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio !== void 0 ? _actionSchema$xActio : {}, _ref$assignedValues = _ref.assignedValues, originalAssignedValues = _ref$assignedValues === void 0 ? {} : _ref$assignedValues, onSuccess = _ref.onSuccess, overwriteValues = _ref.overwriteValues, skipValidator = _ref.skipValidator;
|
|
190
|
+
assignedValues = parse(originalAssignedValues)({
|
|
191
|
+
currentTime: new Date(),
|
|
192
|
+
currentRecord: currentRecord,
|
|
193
|
+
currentUser: currentUser
|
|
194
|
+
});
|
|
184
195
|
|
|
185
196
|
if (skipValidator) {
|
|
186
|
-
_context2.next =
|
|
197
|
+
_context2.next = 6;
|
|
187
198
|
break;
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
_context2.next =
|
|
201
|
+
_context2.next = 6;
|
|
191
202
|
return form.submit();
|
|
192
203
|
|
|
193
|
-
case
|
|
204
|
+
case 6:
|
|
194
205
|
values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
|
|
195
206
|
actionField.data = field.data || {};
|
|
196
207
|
actionField.data.loading = true;
|
|
197
|
-
_context2.prev =
|
|
198
|
-
_context2.next =
|
|
208
|
+
_context2.prev = 9;
|
|
209
|
+
_context2.next = 12;
|
|
199
210
|
return resource.create({
|
|
200
211
|
values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues)
|
|
201
212
|
});
|
|
202
213
|
|
|
203
|
-
case
|
|
214
|
+
case 12:
|
|
204
215
|
actionField.data.loading = false;
|
|
205
216
|
__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);
|
|
206
217
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
207
218
|
|
|
208
219
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
209
|
-
_context2.next =
|
|
220
|
+
_context2.next = 17;
|
|
210
221
|
break;
|
|
211
222
|
}
|
|
212
223
|
|
|
213
224
|
return _context2.abrupt("return");
|
|
214
225
|
|
|
215
|
-
case
|
|
226
|
+
case 17:
|
|
216
227
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
217
228
|
Modal.success({
|
|
218
229
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
@@ -253,25 +264,27 @@ export var useCreateActionProps = function useCreateActionProps() {
|
|
|
253
264
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
254
265
|
}
|
|
255
266
|
|
|
256
|
-
_context2.next =
|
|
267
|
+
_context2.next = 23;
|
|
257
268
|
break;
|
|
258
269
|
|
|
259
|
-
case
|
|
260
|
-
_context2.prev =
|
|
261
|
-
_context2.t0 = _context2["catch"](
|
|
270
|
+
case 20:
|
|
271
|
+
_context2.prev = 20;
|
|
272
|
+
_context2.t0 = _context2["catch"](9);
|
|
262
273
|
actionField.data.loading = false;
|
|
263
274
|
|
|
264
|
-
case
|
|
275
|
+
case 23:
|
|
265
276
|
case "end":
|
|
266
277
|
return _context2.stop();
|
|
267
278
|
}
|
|
268
279
|
}
|
|
269
|
-
}, _callee2, null, [[
|
|
280
|
+
}, _callee2, null, [[9, 20]]);
|
|
270
281
|
}))();
|
|
271
282
|
}
|
|
272
283
|
};
|
|
273
284
|
};
|
|
274
285
|
export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProps() {
|
|
286
|
+
var _currentUserContext$d2;
|
|
287
|
+
|
|
275
288
|
var _useBlockRequestConte2 = useBlockRequestContext(),
|
|
276
289
|
resource = _useBlockRequestConte2.resource,
|
|
277
290
|
__parent = _useBlockRequestConte2.__parent,
|
|
@@ -280,7 +293,8 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
280
293
|
var filterByTk = useFilterByTk();
|
|
281
294
|
var actionSchema = useFieldSchema();
|
|
282
295
|
var currentRecord = useRecord();
|
|
283
|
-
var
|
|
296
|
+
var currentUserContext = useCurrentUserContext();
|
|
297
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d2 = currentUserContext.data) === null || _currentUserContext$d2 === void 0 ? void 0 : _currentUserContext$d2.data;
|
|
284
298
|
var history = useHistory();
|
|
285
299
|
var compile = useCompile();
|
|
286
300
|
var form = useForm();
|
|
@@ -289,30 +303,35 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
289
303
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
290
304
|
var _actionSchema$xActio2, _service$refresh;
|
|
291
305
|
|
|
292
|
-
var _ref2, assignedValues, onSuccess, skipValidator, _parent$service2, _parent$service2$refr;
|
|
306
|
+
var _ref2, _ref2$assignedValues, originalAssignedValues, onSuccess, skipValidator, assignedValues, _parent$service2, _parent$service2$refr;
|
|
293
307
|
|
|
294
308
|
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
295
309
|
while (1) {
|
|
296
310
|
switch (_context4.prev = _context4.next) {
|
|
297
311
|
case 0:
|
|
298
|
-
_ref2 = (_actionSchema$xActio2 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio2 !== void 0 ? _actionSchema$xActio2 : {}, assignedValues = _ref2.assignedValues, onSuccess = _ref2.onSuccess, skipValidator = _ref2.skipValidator;
|
|
312
|
+
_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, skipValidator = _ref2.skipValidator;
|
|
313
|
+
assignedValues = parse(originalAssignedValues)({
|
|
314
|
+
currentTime: new Date(),
|
|
315
|
+
currentRecord: currentRecord,
|
|
316
|
+
currentUser: currentUser
|
|
317
|
+
});
|
|
299
318
|
|
|
300
319
|
if (!(skipValidator === false)) {
|
|
301
|
-
_context4.next =
|
|
320
|
+
_context4.next = 5;
|
|
302
321
|
break;
|
|
303
322
|
}
|
|
304
323
|
|
|
305
|
-
_context4.next =
|
|
324
|
+
_context4.next = 5;
|
|
306
325
|
return form.submit();
|
|
307
326
|
|
|
308
|
-
case
|
|
309
|
-
_context4.next =
|
|
327
|
+
case 5:
|
|
328
|
+
_context4.next = 7;
|
|
310
329
|
return resource.update({
|
|
311
330
|
filterByTk: filterByTk,
|
|
312
331
|
values: _objectSpread({}, assignedValues)
|
|
313
332
|
});
|
|
314
333
|
|
|
315
|
-
case
|
|
334
|
+
case 7:
|
|
316
335
|
service === null || service === void 0 ? void 0 : (_service$refresh = service.refresh) === null || _service$refresh === void 0 ? void 0 : _service$refresh.call(service);
|
|
317
336
|
|
|
318
337
|
if (!(resource instanceof TableFieldResource)) {
|
|
@@ -320,13 +339,13 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
320
339
|
}
|
|
321
340
|
|
|
322
341
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
323
|
-
_context4.next =
|
|
342
|
+
_context4.next = 11;
|
|
324
343
|
break;
|
|
325
344
|
}
|
|
326
345
|
|
|
327
346
|
return _context4.abrupt("return");
|
|
328
347
|
|
|
329
|
-
case
|
|
348
|
+
case 11:
|
|
330
349
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
331
350
|
Modal.success({
|
|
332
351
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
@@ -363,7 +382,7 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
363
382
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
364
383
|
}
|
|
365
384
|
|
|
366
|
-
case
|
|
385
|
+
case 12:
|
|
367
386
|
case "end":
|
|
368
387
|
return _context4.stop();
|
|
369
388
|
}
|
|
@@ -374,7 +393,7 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
|
|
|
374
393
|
};
|
|
375
394
|
};
|
|
376
395
|
export var useCustomizeRequestActionProps = function useCustomizeRequestActionProps() {
|
|
377
|
-
var _currentUserContext$
|
|
396
|
+
var _currentUserContext$d3;
|
|
378
397
|
|
|
379
398
|
var apiClient = useAPIClient();
|
|
380
399
|
var history = useHistory();
|
|
@@ -395,7 +414,7 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
395
414
|
|
|
396
415
|
var currentRecord = useRecord();
|
|
397
416
|
var currentUserContext = useCurrentUserContext();
|
|
398
|
-
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$
|
|
417
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d3 = currentUserContext.data) === null || _currentUserContext$d3 === void 0 ? void 0 : _currentUserContext$d3.data;
|
|
399
418
|
var actionField = useField();
|
|
400
419
|
|
|
401
420
|
var _useActionContext2 = useActionContext(),
|
|
@@ -452,15 +471,15 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
452
471
|
currentUser: currentUser
|
|
453
472
|
}),
|
|
454
473
|
method: requestSettings['method'],
|
|
455
|
-
headers:
|
|
474
|
+
headers: parse(headers)({
|
|
456
475
|
currentRecord: currentRecord,
|
|
457
476
|
currentUser: currentUser
|
|
458
477
|
}),
|
|
459
|
-
params:
|
|
478
|
+
params: parse(params)({
|
|
460
479
|
currentRecord: currentRecord,
|
|
461
480
|
currentUser: currentUser
|
|
462
481
|
}),
|
|
463
|
-
data:
|
|
482
|
+
data: parse(data)({
|
|
464
483
|
currentRecord: currentRecord,
|
|
465
484
|
currentUser: currentUser
|
|
466
485
|
})
|
|
@@ -544,6 +563,8 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
|
|
|
544
563
|
};
|
|
545
564
|
};
|
|
546
565
|
export var useUpdateActionProps = function useUpdateActionProps() {
|
|
566
|
+
var _currentUserContext$d4;
|
|
567
|
+
|
|
547
568
|
var form = useForm();
|
|
548
569
|
var filterByTk = useFilterByTk();
|
|
549
570
|
|
|
@@ -557,7 +578,6 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
557
578
|
|
|
558
579
|
var actionSchema = useFieldSchema();
|
|
559
580
|
var history = useHistory();
|
|
560
|
-
var record = useRecord();
|
|
561
581
|
|
|
562
582
|
var _useCollection3 = useCollection(),
|
|
563
583
|
fields = _useCollection3.fields,
|
|
@@ -569,43 +589,51 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
569
589
|
var _useFormBlockContext = useFormBlockContext(),
|
|
570
590
|
updateAssociationValues = _useFormBlockContext.updateAssociationValues;
|
|
571
591
|
|
|
592
|
+
var currentRecord = useRecord();
|
|
593
|
+
var currentUserContext = useCurrentUserContext();
|
|
594
|
+
var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d4 = currentUserContext.data) === null || _currentUserContext$d4 === void 0 ? void 0 : _currentUserContext$d4.data;
|
|
572
595
|
return {
|
|
573
596
|
onClick: function onClick() {
|
|
574
597
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
|
|
575
598
|
var _actionSchema$xActio4;
|
|
576
599
|
|
|
577
|
-
var _ref4, assignedValues, onSuccess, overwriteValues, skipValidator, fieldNames, values, _parent$service4, _parent$service4$refr, _parent$__parent, _parent$__parent$serv, _parent$__parent$serv2;
|
|
600
|
+
var _ref4, _ref4$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, assignedValues, fieldNames, values, _parent$service4, _parent$service4$refr, _parent$__parent, _parent$__parent$serv, _parent$__parent$serv2;
|
|
578
601
|
|
|
579
602
|
return regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
580
603
|
while (1) {
|
|
581
604
|
switch (_context8.prev = _context8.next) {
|
|
582
605
|
case 0:
|
|
583
|
-
_ref4 = (_actionSchema$xActio4 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio4 !== void 0 ? _actionSchema$xActio4 : {}, assignedValues = _ref4.assignedValues, onSuccess = _ref4.onSuccess, overwriteValues = _ref4.overwriteValues, skipValidator = _ref4.skipValidator;
|
|
606
|
+
_ref4 = (_actionSchema$xActio4 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio4 !== void 0 ? _actionSchema$xActio4 : {}, _ref4$assignedValues = _ref4.assignedValues, originalAssignedValues = _ref4$assignedValues === void 0 ? {} : _ref4$assignedValues, onSuccess = _ref4.onSuccess, overwriteValues = _ref4.overwriteValues, skipValidator = _ref4.skipValidator;
|
|
607
|
+
assignedValues = parse(originalAssignedValues)({
|
|
608
|
+
currentTime: new Date(),
|
|
609
|
+
currentRecord: currentRecord,
|
|
610
|
+
currentUser: currentUser
|
|
611
|
+
});
|
|
584
612
|
|
|
585
613
|
if (skipValidator) {
|
|
586
|
-
_context8.next =
|
|
614
|
+
_context8.next = 5;
|
|
587
615
|
break;
|
|
588
616
|
}
|
|
589
617
|
|
|
590
|
-
_context8.next =
|
|
618
|
+
_context8.next = 5;
|
|
591
619
|
return form.submit();
|
|
592
620
|
|
|
593
|
-
case
|
|
621
|
+
case 5:
|
|
594
622
|
fieldNames = fields.map(function (field) {
|
|
595
623
|
return field.name;
|
|
596
624
|
});
|
|
597
625
|
values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
|
|
598
626
|
actionField.data = field.data || {};
|
|
599
627
|
actionField.data.loading = true;
|
|
600
|
-
_context8.prev =
|
|
601
|
-
_context8.next =
|
|
628
|
+
_context8.prev = 9;
|
|
629
|
+
_context8.next = 12;
|
|
602
630
|
return resource.update({
|
|
603
631
|
filterByTk: filterByTk,
|
|
604
632
|
values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues),
|
|
605
633
|
updateAssociationValues: updateAssociationValues
|
|
606
634
|
});
|
|
607
635
|
|
|
608
|
-
case
|
|
636
|
+
case 12:
|
|
609
637
|
actionField.data.loading = false;
|
|
610
638
|
|
|
611
639
|
if (!(resource instanceof TableFieldResource)) {
|
|
@@ -616,13 +644,13 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
616
644
|
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
617
645
|
|
|
618
646
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
|
|
619
|
-
_context8.next =
|
|
647
|
+
_context8.next = 18;
|
|
620
648
|
break;
|
|
621
649
|
}
|
|
622
650
|
|
|
623
651
|
return _context8.abrupt("return");
|
|
624
652
|
|
|
625
|
-
case
|
|
653
|
+
case 18:
|
|
626
654
|
if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
|
|
627
655
|
Modal.success({
|
|
628
656
|
title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
|
|
@@ -663,20 +691,20 @@ export var useUpdateActionProps = function useUpdateActionProps() {
|
|
|
663
691
|
message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
|
|
664
692
|
}
|
|
665
693
|
|
|
666
|
-
_context8.next =
|
|
694
|
+
_context8.next = 24;
|
|
667
695
|
break;
|
|
668
696
|
|
|
669
|
-
case
|
|
670
|
-
_context8.prev =
|
|
671
|
-
_context8.t0 = _context8["catch"](
|
|
697
|
+
case 21:
|
|
698
|
+
_context8.prev = 21;
|
|
699
|
+
_context8.t0 = _context8["catch"](9);
|
|
672
700
|
actionField.data.loading = false;
|
|
673
701
|
|
|
674
|
-
case
|
|
702
|
+
case 24:
|
|
675
703
|
case "end":
|
|
676
704
|
return _context8.stop();
|
|
677
705
|
}
|
|
678
706
|
}
|
|
679
|
-
}, _callee8, null, [[
|
|
707
|
+
}, _callee8, null, [[9, 21]]);
|
|
680
708
|
}))();
|
|
681
709
|
}
|
|
682
710
|
};
|
|
@@ -686,13 +714,20 @@ export var useDestroyActionProps = function useDestroyActionProps() {
|
|
|
686
714
|
|
|
687
715
|
var _useBlockRequestConte5 = useBlockRequestContext(),
|
|
688
716
|
resource = _useBlockRequestConte5.resource,
|
|
689
|
-
service = _useBlockRequestConte5.service
|
|
717
|
+
service = _useBlockRequestConte5.service,
|
|
718
|
+
block = _useBlockRequestConte5.block,
|
|
719
|
+
__parent = _useBlockRequestConte5.__parent;
|
|
720
|
+
|
|
721
|
+
var _useActionContext4 = useActionContext(),
|
|
722
|
+
setVisible = _useActionContext4.setVisible;
|
|
690
723
|
|
|
691
724
|
return {
|
|
692
725
|
onClick: function onClick() {
|
|
693
726
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
|
|
694
727
|
var _service$refresh3;
|
|
695
728
|
|
|
729
|
+
var _parent$service5, _parent$service5$refr;
|
|
730
|
+
|
|
696
731
|
return regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
697
732
|
while (1) {
|
|
698
733
|
switch (_context9.prev = _context9.next) {
|
|
@@ -705,7 +740,12 @@ export var useDestroyActionProps = function useDestroyActionProps() {
|
|
|
705
740
|
case 2:
|
|
706
741
|
service === null || service === void 0 ? void 0 : (_service$refresh3 = service.refresh) === null || _service$refresh3 === void 0 ? void 0 : _service$refresh3.call(service);
|
|
707
742
|
|
|
708
|
-
|
|
743
|
+
if (block !== 'TableField') {
|
|
744
|
+
__parent === null || __parent === void 0 ? void 0 : (_parent$service5 = __parent.service) === null || _parent$service5 === void 0 ? void 0 : (_parent$service5$refr = _parent$service5.refresh) === null || _parent$service5$refr === void 0 ? void 0 : _parent$service5$refr.call(_parent$service5);
|
|
745
|
+
setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
case 4:
|
|
709
749
|
case "end":
|
|
710
750
|
return _context9.stop();
|
|
711
751
|
}
|
|
@@ -715,6 +755,35 @@ export var useDestroyActionProps = function useDestroyActionProps() {
|
|
|
715
755
|
}
|
|
716
756
|
};
|
|
717
757
|
};
|
|
758
|
+
export var useDetailPrintActionProps = function useDetailPrintActionProps() {
|
|
759
|
+
var _useFormBlockContext2 = useFormBlockContext(),
|
|
760
|
+
formBlockRef = _useFormBlockContext2.formBlockRef;
|
|
761
|
+
|
|
762
|
+
var printHandler = useReactToPrint({
|
|
763
|
+
content: function content() {
|
|
764
|
+
return formBlockRef.current;
|
|
765
|
+
},
|
|
766
|
+
pageStyle: "@media print {\n * {\n margin: 0;\n }\n div.ant-formily-layout>div:first-child {\n overflow: hidden; height: 0;\n }\n\n }"
|
|
767
|
+
});
|
|
768
|
+
return {
|
|
769
|
+
onClick: function onClick() {
|
|
770
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
|
|
771
|
+
return regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
772
|
+
while (1) {
|
|
773
|
+
switch (_context10.prev = _context10.next) {
|
|
774
|
+
case 0:
|
|
775
|
+
printHandler();
|
|
776
|
+
|
|
777
|
+
case 1:
|
|
778
|
+
case "end":
|
|
779
|
+
return _context10.stop();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}, _callee10);
|
|
783
|
+
}))();
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
};
|
|
718
787
|
export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
|
|
719
788
|
var _useBlockRequestConte6 = useBlockRequestContext(),
|
|
720
789
|
field = _useBlockRequestConte6.field;
|
|
@@ -725,22 +794,22 @@ export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
|
|
|
725
794
|
|
|
726
795
|
return {
|
|
727
796
|
onClick: function onClick() {
|
|
728
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
797
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
|
|
729
798
|
var _field$data, _field$data$selectedR, _field$data2, _service$refresh4;
|
|
730
799
|
|
|
731
|
-
return regeneratorRuntime.wrap(function
|
|
800
|
+
return regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
732
801
|
while (1) {
|
|
733
|
-
switch (
|
|
802
|
+
switch (_context11.prev = _context11.next) {
|
|
734
803
|
case 0:
|
|
735
804
|
if (field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : (_field$data$selectedR = _field$data.selectedRowKeys) === null || _field$data$selectedR === void 0 ? void 0 : _field$data$selectedR.length) {
|
|
736
|
-
|
|
805
|
+
_context11.next = 2;
|
|
737
806
|
break;
|
|
738
807
|
}
|
|
739
808
|
|
|
740
|
-
return
|
|
809
|
+
return _context11.abrupt("return");
|
|
741
810
|
|
|
742
811
|
case 2:
|
|
743
|
-
|
|
812
|
+
_context11.next = 4;
|
|
744
813
|
return resource.destroy({
|
|
745
814
|
filterByTk: (_field$data2 = field.data) === null || _field$data2 === void 0 ? void 0 : _field$data2.selectedRowKeys
|
|
746
815
|
});
|
|
@@ -751,10 +820,35 @@ export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
|
|
|
751
820
|
|
|
752
821
|
case 6:
|
|
753
822
|
case "end":
|
|
754
|
-
return
|
|
823
|
+
return _context11.stop();
|
|
755
824
|
}
|
|
756
825
|
}
|
|
757
|
-
},
|
|
826
|
+
}, _callee11);
|
|
827
|
+
}))();
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
export var useRefreshActionProps = function useRefreshActionProps() {
|
|
832
|
+
var _useBlockRequestConte8 = useBlockRequestContext(),
|
|
833
|
+
service = _useBlockRequestConte8.service;
|
|
834
|
+
|
|
835
|
+
return {
|
|
836
|
+
onClick: function onClick() {
|
|
837
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
|
|
838
|
+
var _service$refresh5;
|
|
839
|
+
|
|
840
|
+
return regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
841
|
+
while (1) {
|
|
842
|
+
switch (_context12.prev = _context12.next) {
|
|
843
|
+
case 0:
|
|
844
|
+
service === null || service === void 0 ? void 0 : (_service$refresh5 = service.refresh) === null || _service$refresh5 === void 0 ? void 0 : _service$refresh5.call(service);
|
|
845
|
+
|
|
846
|
+
case 1:
|
|
847
|
+
case "end":
|
|
848
|
+
return _context12.stop();
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}, _callee12);
|
|
758
852
|
}))();
|
|
759
853
|
}
|
|
760
854
|
};
|
|
@@ -771,13 +865,13 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
|
|
|
771
865
|
total: count,
|
|
772
866
|
pageSize: 1,
|
|
773
867
|
onChange: function onChange(page) {
|
|
774
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
868
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
|
|
775
869
|
var _ctx$service3, _ctx$service3$params;
|
|
776
870
|
|
|
777
871
|
var params;
|
|
778
|
-
return regeneratorRuntime.wrap(function
|
|
872
|
+
return regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
779
873
|
while (1) {
|
|
780
|
-
switch (
|
|
874
|
+
switch (_context13.prev = _context13.next) {
|
|
781
875
|
case 0:
|
|
782
876
|
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];
|
|
783
877
|
ctx.service.run(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -786,10 +880,10 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
|
|
|
786
880
|
|
|
787
881
|
case 2:
|
|
788
882
|
case "end":
|
|
789
|
-
return
|
|
883
|
+
return _context13.stop();
|
|
790
884
|
}
|
|
791
885
|
}
|
|
792
|
-
},
|
|
886
|
+
}, _callee13);
|
|
793
887
|
}))();
|
|
794
888
|
},
|
|
795
889
|
style: {
|
|
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import { connect, useField, useFieldSchema } from '@formily/react';
|
|
8
8
|
import { merge } from '@formily/shared';
|
|
9
|
+
import { concat } from 'lodash';
|
|
9
10
|
import React, { useEffect } from 'react';
|
|
10
11
|
import { useCompile, useComponent, useFormBlockContext } from '..';
|
|
11
12
|
import { CollectionFieldProvider } from './CollectionFieldProvider';
|
|
@@ -51,8 +52,9 @@ var InternalField = function InternalField(props) {
|
|
|
51
52
|
setFieldProps('description', uiSchema.description);
|
|
52
53
|
setFieldProps('initialValue', uiSchema.default);
|
|
53
54
|
|
|
54
|
-
if (!field.validator && uiSchema['x-validator']) {
|
|
55
|
-
|
|
55
|
+
if (!field.validator && (uiSchema['x-validator'] || fieldSchema['x-validator'])) {
|
|
56
|
+
var concatSchema = concat([], uiSchema['x-validator'] || [], fieldSchema['x-validator'] || []);
|
|
57
|
+
field.validator = concatSchema;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
if (fieldSchema['x-disabled'] === true) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { registerValidateFormats } from '@formily/core';
|
|
1
2
|
export * from './AddFieldAction';
|
|
2
3
|
export * from './ConfigurationTable';
|
|
3
|
-
export * from './EditFieldAction';
|
|
4
|
+
export * from './EditFieldAction';
|
|
5
|
+
registerValidateFormats({
|
|
6
|
+
uid: /^[A-Za-z0-9][A-Za-z0-9_-]*$/
|
|
7
|
+
});
|