@tachybase/client 0.23.48 → 1.0.6
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/api-client/APIClient.d.ts +5 -2
- package/es/api-client/APIClient.mjs +93 -49
- package/es/api-client/hooks/useRequest.d.ts +2 -0
- package/es/application/Application.d.ts +6 -0
- package/es/application/Application.mjs +19 -0
- package/es/application/CustomRouterContextProvider.d.ts +54 -0
- package/es/application/CustomRouterContextProvider.mjs +209 -0
- package/es/application/RouterManager.d.ts +8 -3
- package/es/application/RouterManager.mjs +48 -15
- package/es/application/hooks/index.d.ts +1 -0
- package/es/application/hooks/index.mjs +1 -0
- package/es/application/hooks/useGlobalVariable.d.ts +1 -0
- package/es/application/hooks/useGlobalVariable.mjs +18 -0
- package/es/application/schema-initializer/context/index.d.ts +1 -1
- package/es/application/schema-settings/hooks/index.d.ts +1 -1
- package/es/application/schema-settings/hooks/index.mjs +6 -8
- package/es/block-provider/hooks/index.d.ts +2 -0
- package/es/block-provider/hooks/index.mjs +29 -22
- package/es/built-in/context-menu/ContextMenu.provider.mjs +6 -6
- package/es/built-in/context-menu/ContextMenuItemsProps.d.ts +4 -4
- package/es/built-in/context-menu/ContextMenuItemsProps.mjs +6 -6
- package/es/built-in/context-menu/index.mjs +1 -1
- package/es/built-in/context-menu/useContextMenu.d.ts +2 -2
- package/es/built-in/index.mjs +8 -0
- package/es/built-in/locale/LocalePlugin.mjs +5 -1
- package/es/built-in/page-style/PageStyle.provider.mjs +2 -2
- package/es/built-in/system-settings/SystemSettingsProvider.d.ts +2 -3
- package/es/built-in/system-settings/SystemSettingsProvider.mjs +4 -3
- package/es/built-in/system-settings/SystemSettingsShortcut.mjs +11 -8
- package/es/collection-manager/Configuration/AddCollectionAction.mjs +12 -2
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.d.ts +2 -0
- package/es/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.mjs +255 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.d.ts +89 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.mjs +96 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.mjs +47 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.d.ts +3 -0
- package/es/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.mjs +44 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.mjs +380 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.d.ts +8 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.mjs +4 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxImportAction.mjs +187 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.d.ts +1 -0
- package/es/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.mjs +30 -0
- package/es/collection-manager/collectionPlugin.mjs +3 -1
- package/es/collection-manager/templates/import.mjs +1 -1
- package/es/collection-manager/templates/sql.d.ts +1 -1
- package/es/collection-manager/templates/view.d.ts +1 -1
- package/es/collection-manager/templates/xlsx.d.ts +11 -0
- package/es/collection-manager/templates/xlsx.mjs +19 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterface.mjs +18 -0
- package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.d.ts +8 -1
- package/es/data-source/collection-field-interface/CollectionFieldInterfaceManager.mjs +20 -0
- package/es/data-source/commonsSettingsItem/fieldComponent.mjs +3 -1
- package/es/data-source/data-source/DataSource.d.ts +1 -1
- package/es/filter-provider/utils.mjs +6 -0
- package/es/i18n/i18n.mjs +7 -12
- package/es/modules/actions/delete/deleteActionSettings.mjs +10 -0
- package/es/modules/blocks/data-blocks/form/FilterItemCustomSettings.mjs +1 -1
- package/es/modules/blocks/data-blocks/form/fieldSettingsFormItem.mjs +9 -4
- package/es/modules/blocks/data-blocks/table/hooks/useTableBlockProps.mjs +6 -4
- package/es/modules/blocks/data-blocks/table/tableBlockSettings.mjs +4 -0
- package/es/modules/blocks/data-blocks/table/tableColumnSettings.mjs +44 -0
- package/es/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.mjs +4 -0
- package/es/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.mjs +9 -0
- package/es/modules/fields/component/Radio/radioComponentFieldSettings.mjs +0 -4
- package/es/modules/fields/component/SubTable/secondLevelSelect.d.ts +11 -0
- package/es/modules/fields/component/SubTable/secondLevelSelect.mjs +102 -0
- package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.d.ts +79 -41
- package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.mjs +103 -100
- package/es/powered-by/index.mjs +4 -7
- package/es/schema-component/antd/action/Action.Designer.mjs +43 -5
- package/es/schema-component/antd/action/Action.Modal.mjs +19 -31
- package/es/schema-component/antd/action/Action.Modal.style.d.ts +4 -0
- package/es/schema-component/antd/action/Action.Modal.style.mjs +35 -0
- package/es/schema-component/antd/action/Action.mjs +1 -3
- package/es/schema-component/antd/action/utils.d.ts +1 -1
- package/es/schema-component/antd/action/utils.mjs +70 -70
- package/es/schema-component/antd/association-field/SubTabs/InternalCollapse.mjs +2 -1
- package/es/schema-component/antd/checkbox/Checkbox.mjs +9 -2
- package/es/schema-component/antd/index.d.ts +1 -0
- package/es/schema-component/antd/index.mjs +1 -0
- package/es/schema-component/antd/media-card/MediaCard.d.ts +11 -0
- package/es/schema-component/antd/media-card/MediaCard.mjs +35 -0
- package/es/schema-component/antd/media-card/index.d.ts +1 -0
- package/es/schema-component/antd/media-card/index.mjs +1 -0
- package/es/schema-component/antd/media-card/style.d.ts +3 -0
- package/es/schema-component/antd/media-card/style.mjs +25 -0
- package/es/schema-component/antd/page/Page.d.ts +1 -5
- package/es/schema-component/antd/page/Page.mjs +235 -144
- package/es/schema-component/antd/page/Page.style.d.ts +5 -0
- package/es/schema-component/antd/page/Page.style.mjs +45 -0
- package/es/schema-component/antd/page/PageDesigner.d.ts +3 -0
- package/es/schema-component/antd/page/PageDesigner.mjs +28 -0
- package/es/schema-component/antd/page/PageTabDesigner.d.ts +0 -3
- package/es/schema-component/antd/page/PageTabDesigner.mjs +3 -50
- package/es/schema-component/antd/page/style.d.ts +1 -1
- package/es/schema-component/antd/page/style.mjs +3 -13
- package/es/schema-component/antd/password/Password.d.ts +1 -1
- package/es/schema-component/antd/password/utils.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.d.ts +1 -1
- package/es/schema-component/antd/scroll-area/ScrollArea.mjs +2 -1
- package/es/schema-component/antd/variable/TextArea.mjs +1 -1
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.d.ts +13 -0
- package/es/schema-component/antd/variable/TextAreaWithGlobalScope.mjs +59 -0
- package/es/schema-component/antd/variable/index.d.ts +1 -0
- package/es/schema-component/antd/variable/index.mjs +3 -0
- package/es/schema-component/common/dnd-context/index.mjs +1 -7
- package/es/schema-component/common/sortable-item/DragHandlePageTab.d.ts +1 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.mjs +71 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.style.d.ts +3 -0
- package/es/schema-component/common/sortable-item/DragHandlePageTab.style.mjs +25 -0
- package/es/schema-items/GeneralSettings.mjs +5 -0
- package/es/schema-settings/EditCustomDefaultValue.mjs +1 -1
- package/es/schema-settings/SchemaSettings.mjs +1 -1
- package/es/schema-settings/SchemaSettingsDefaultValue.mjs +2 -0
- package/es/schema-settings/utils/createModalSettingsItem.d.ts +26 -0
- package/es/schema-settings/utils/createModalSettingsItem.mjs +46 -0
- package/es/schema-settings/utils/createSelectSettingsItem.d.ts +25 -0
- package/es/schema-settings/utils/createSelectSettingsItem.mjs +40 -0
- package/es/schema-settings/utils/createSwitchSettingsItem.d.ts +21 -0
- package/es/schema-settings/utils/createSwitchSettingsItem.mjs +38 -0
- package/es/schema-settings/utils/createTextSettingsItem.d.ts +9 -0
- package/es/schema-settings/utils/createTextSettingsItem.mjs +21 -0
- package/es/schema-settings/utils/index.d.ts +4 -0
- package/es/schema-settings/utils/index.mjs +4 -0
- package/es/schema-settings/utils/util.d.ts +12 -0
- package/es/schema-settings/utils/util.mjs +24 -0
- package/es/user/CurrentUserProvider.mjs +6 -3
- package/lib/api-client/APIClient.js +93 -49
- package/lib/application/Application.js +19 -0
- package/lib/application/CustomRouterContextProvider.js +276 -0
- package/lib/application/RouterManager.js +49 -15
- package/lib/application/hooks/index.js +9 -0
- package/lib/application/hooks/useGlobalVariable.js +52 -0
- package/lib/application/schema-initializer/hooks/index.js +2 -2
- package/lib/application/schema-settings/hooks/index.js +6 -8
- package/lib/block-provider/hooks/index.js +80 -59
- package/lib/built-in/context-menu/ContextMenu.provider.js +6 -6
- package/lib/built-in/context-menu/ContextMenuItemsProps.js +6 -6
- package/lib/built-in/context-menu/index.js +1 -1
- package/lib/built-in/index.js +8 -0
- package/lib/built-in/locale/LocalePlugin.js +5 -1
- package/lib/built-in/page-style/PageStyle.provider.js +2 -2
- package/lib/built-in/system-settings/SystemSettingsProvider.js +4 -3
- package/lib/built-in/system-settings/SystemSettingsShortcut.js +11 -8
- package/lib/collection-manager/Configuration/AddCollectionAction.js +12 -2
- package/lib/collection-manager/Configuration/ImportXlsx/ImportXlsxMetaAction.js +304 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxCollectionSchema.js +130 -0
- package/lib/collection-manager/Configuration/ImportXlsx/XlsxEditFieldAction.js +81 -0
- package/lib/collection-manager/Configuration/ImportXlsx/setUpdateXlsxCollectionField.js +78 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFieldsConfigure.js +414 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxFormValueContextProvider.js +53 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxImportAction.js +235 -0
- package/lib/collection-manager/Configuration/ImportXlsx/xlsxPreviewTable.js +64 -0
- package/lib/collection-manager/collectionPlugin.js +3 -1
- package/lib/collection-manager/templates/import.js +1 -1
- package/lib/collection-manager/templates/xlsx.js +53 -0
- package/lib/data-source/collection-field-interface/CollectionFieldInterface.js +18 -0
- package/lib/data-source/collection-field-interface/CollectionFieldInterfaceManager.js +20 -0
- package/lib/data-source/commonsSettingsItem/fieldComponent.js +3 -1
- package/lib/filter-provider/utils.js +6 -0
- package/lib/i18n/i18n.js +7 -12
- package/lib/locale/en_US.js +1 -0
- package/lib/locale/zh-CN.js +14 -2
- package/lib/modules/actions/delete/deleteActionSettings.js +10 -0
- package/lib/modules/blocks/data-blocks/form/FilterItemCustomSettings.js +1 -1
- package/lib/modules/blocks/data-blocks/form/fieldSettingsFormItem.js +9 -4
- package/lib/modules/blocks/data-blocks/table/hooks/useTableBlockProps.js +6 -4
- package/lib/modules/blocks/data-blocks/table/tableBlockSettings.js +4 -0
- package/lib/modules/blocks/data-blocks/table/tableColumnSettings.js +44 -0
- package/lib/modules/blocks/filter-blocks/collapse/filterCollapseItemFieldSettings.js +4 -0
- package/lib/modules/blocks/filter-blocks/form/filterFormItemFieldSettings.js +9 -0
- package/lib/modules/fields/component/Radio/radioComponentFieldSettings.js +0 -4
- package/lib/modules/fields/component/SubTable/secondLevelSelect.js +136 -0
- package/lib/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.js +104 -103
- package/lib/powered-by/index.js +4 -7
- package/lib/schema-component/antd/action/Action.Designer.js +43 -5
- package/lib/schema-component/antd/action/Action.Modal.js +19 -31
- package/lib/schema-component/antd/action/Action.Modal.style.js +69 -0
- package/lib/schema-component/antd/action/Action.js +1 -3
- package/lib/schema-component/antd/action/utils.js +70 -70
- package/lib/schema-component/antd/association-field/SubTabs/InternalCollapse.js +2 -1
- package/lib/schema-component/antd/checkbox/Checkbox.js +9 -2
- package/lib/schema-component/antd/index.js +18 -4
- package/lib/schema-component/antd/media-card/MediaCard.js +69 -0
- package/lib/schema-component/antd/media-card/index.js +65 -0
- package/lib/schema-component/antd/media-card/style.js +59 -0
- package/lib/schema-component/antd/page/Page.js +235 -144
- package/lib/schema-component/antd/page/Page.style.js +79 -0
- package/lib/schema-component/antd/page/PageDesigner.js +62 -0
- package/lib/schema-component/antd/page/PageTabDesigner.js +2 -50
- package/lib/schema-component/antd/page/style.js +3 -13
- package/lib/schema-component/antd/scroll-area/ScrollArea.js +2 -1
- package/lib/schema-component/antd/variable/TextArea.js +1 -1
- package/lib/schema-component/antd/variable/TextAreaWithGlobalScope.js +94 -0
- package/lib/schema-component/antd/variable/index.js +13 -1
- package/lib/schema-component/common/dnd-context/index.js +1 -7
- package/lib/schema-component/common/sortable-item/DragHandlePageTab.js +105 -0
- package/lib/schema-component/common/sortable-item/DragHandlePageTab.style.js +59 -0
- package/lib/schema-items/GeneralSettings.js +5 -0
- package/lib/schema-settings/EditCustomDefaultValue.js +1 -1
- package/lib/schema-settings/SchemaSettings.js +1 -1
- package/lib/schema-settings/SchemaSettingsDefaultValue.js +2 -0
- package/lib/schema-settings/utils/createModalSettingsItem.js +94 -0
- package/lib/schema-settings/utils/createSelectSettingsItem.js +88 -0
- package/lib/schema-settings/utils/createSwitchSettingsItem.js +86 -0
- package/lib/schema-settings/utils/createTextSettingsItem.js +55 -0
- package/lib/schema-settings/utils/index.js +92 -0
- package/lib/schema-settings/utils/util.js +74 -0
- package/lib/user/CurrentUserProvider.js +6 -3
- package/package.json +7 -7
|
@@ -46,6 +46,7 @@ const external_ResourceActionProvider_js_namespaceObject = require("../ResourceA
|
|
|
46
46
|
const external_components_index_js_namespaceObject = require("./components/index.js");
|
|
47
47
|
const TemplateSummary_js_namespaceObject = require("./components/TemplateSummary.js");
|
|
48
48
|
const external_ImportCollectionMetaAction_js_namespaceObject = require("./ImportCollectionMetaAction.js");
|
|
49
|
+
const ImportXlsxMetaAction_js_namespaceObject = require("./ImportXlsx/ImportXlsxMetaAction.js");
|
|
49
50
|
const getSchema = (schema, category, compile)=>{
|
|
50
51
|
if (!schema) return;
|
|
51
52
|
const properties = (0, external_lodash_namespaceObject.cloneDeep)(schema.configurableProperties);
|
|
@@ -165,6 +166,7 @@ const AddCollectionAction = (props)=>{
|
|
|
165
166
|
const compile = (0, external_schema_component_index_js_namespaceObject.useCompile)();
|
|
166
167
|
const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
|
|
167
168
|
const importRef = (0, external_react_namespaceObject.useRef)(null);
|
|
169
|
+
const importxlsxRef = (0, external_react_namespaceObject.useRef)(null);
|
|
168
170
|
const items = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
169
171
|
const result = [];
|
|
170
172
|
collectionTemplates.forEach((item)=>{
|
|
@@ -189,10 +191,14 @@ const AddCollectionAction = (props)=>{
|
|
|
189
191
|
onClick: (info)=>{
|
|
190
192
|
if ('import' === info.key) {
|
|
191
193
|
var _importRef_current;
|
|
192
|
-
console.log('import', importRef.current);
|
|
193
194
|
null === (_importRef_current = importRef.current) || void 0 === _importRef_current || _importRef_current.showModal();
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
197
|
+
if ('importXlsx' === info.key) {
|
|
198
|
+
var _importxlsxRef_current;
|
|
199
|
+
null === (_importxlsxRef_current = importxlsxRef.current) || void 0 === _importxlsxRef_current || _importxlsxRef_current.showModal();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
196
202
|
const schema = getSchema(getTemplate(info.key), category, compile);
|
|
197
203
|
setSchema(schema);
|
|
198
204
|
setVisible(true);
|
|
@@ -201,7 +207,8 @@ const AddCollectionAction = (props)=>{
|
|
|
201
207
|
}), [
|
|
202
208
|
category,
|
|
203
209
|
items,
|
|
204
|
-
importRef
|
|
210
|
+
importRef,
|
|
211
|
+
importxlsxRef
|
|
205
212
|
]);
|
|
206
213
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_record_provider_index_js_namespaceObject.RecordProvider, {
|
|
207
214
|
record: record,
|
|
@@ -248,6 +255,9 @@ const AddCollectionAction = (props)=>{
|
|
|
248
255
|
}),
|
|
249
256
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ImportCollectionMetaAction_js_namespaceObject.ImportCollectionMetaAction, {
|
|
250
257
|
ref: importRef
|
|
258
|
+
}),
|
|
259
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ImportXlsxMetaAction_js_namespaceObject.ImportXlsxMetaAction, {
|
|
260
|
+
ref: importxlsxRef
|
|
251
261
|
})
|
|
252
262
|
]
|
|
253
263
|
});
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = function(module) {
|
|
5
|
+
var getter = module && module.__esModule ? function() {
|
|
6
|
+
return module['default'];
|
|
7
|
+
} : function() {
|
|
8
|
+
return module;
|
|
9
|
+
};
|
|
10
|
+
__webpack_require__.d(getter, {
|
|
11
|
+
a: getter
|
|
12
|
+
});
|
|
13
|
+
return getter;
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
ImportXlsxMetaAction: ()=>ImportXlsxMetaAction
|
|
43
|
+
});
|
|
44
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
45
|
+
const external_react_namespaceObject = require("react");
|
|
46
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
47
|
+
const schema_namespaceObject = require("@tachybase/schema");
|
|
48
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
49
|
+
const external_antd_namespaceObject = require("antd");
|
|
50
|
+
const external_dayjs_namespaceObject = require("dayjs");
|
|
51
|
+
var external_dayjs_default = /*#__PURE__*/ __webpack_require__.n(external_dayjs_namespaceObject);
|
|
52
|
+
const external_lodash_namespaceObject = require("lodash");
|
|
53
|
+
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
54
|
+
const external_xlsx_namespaceObject = require("xlsx");
|
|
55
|
+
const index_js_namespaceObject = require("../../../schema-component/index.js");
|
|
56
|
+
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
|
|
57
|
+
const external_XlsxCollectionSchema_js_namespaceObject = require("./XlsxCollectionSchema.js");
|
|
58
|
+
const external_XlsxEditFieldAction_js_namespaceObject = require("./XlsxEditFieldAction.js");
|
|
59
|
+
const external_xlsxFieldsConfigure_js_namespaceObject = require("./xlsxFieldsConfigure.js");
|
|
60
|
+
const external_xlsxPreviewTable_js_namespaceObject = require("./xlsxPreviewTable.js");
|
|
61
|
+
const { Dragger } = external_antd_namespaceObject.Upload;
|
|
62
|
+
const ImportUpload = (props)=>{
|
|
63
|
+
const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
|
|
64
|
+
const { close } = props;
|
|
65
|
+
const { getInterface } = (0, external_hooks_index_js_namespaceObject.useCollectionManager_deprecated)();
|
|
66
|
+
const [fileList, setFile] = (0, external_react_namespaceObject.useState)([]);
|
|
67
|
+
const [filedata, setFileData] = (0, external_react_namespaceObject.useState)({});
|
|
68
|
+
const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
|
|
69
|
+
const [schema, setSchema] = (0, external_react_namespaceObject.useState)({});
|
|
70
|
+
const inferType = (values, header)=>{
|
|
71
|
+
const isDateHeader = /date|time|日期/i.test(header);
|
|
72
|
+
const isPossibleDate = isDateHeader && values.every((value)=>external_dayjs_default()(value).isValid());
|
|
73
|
+
if (isPossibleDate) return 'date';
|
|
74
|
+
const types = values.map((value)=>{
|
|
75
|
+
if (null != value) {
|
|
76
|
+
const valueLower = value.toString().toLowerCase();
|
|
77
|
+
if ('true' === valueLower || 'yes' === valueLower) return 'boolean';
|
|
78
|
+
if ('false' === valueLower || 'no' === valueLower) return 'boolean';
|
|
79
|
+
}
|
|
80
|
+
const num = Number(value);
|
|
81
|
+
if (!isNaN(num)) return Number.isInteger(num) ? 'integer' : 'float';
|
|
82
|
+
try {
|
|
83
|
+
JSON.parse(value);
|
|
84
|
+
return 'json';
|
|
85
|
+
} catch {}
|
|
86
|
+
return 'string';
|
|
87
|
+
});
|
|
88
|
+
const typeCount = types.reduce((acc, type)=>{
|
|
89
|
+
acc[type] = (acc[type] || 0) + 1;
|
|
90
|
+
return acc;
|
|
91
|
+
}, {});
|
|
92
|
+
const uniqueTypes = Object.keys(typeCount);
|
|
93
|
+
if (uniqueTypes.length > 1) return 'string';
|
|
94
|
+
return uniqueTypes[0];
|
|
95
|
+
};
|
|
96
|
+
const inferInterface = (type, header)=>{
|
|
97
|
+
switch(type){
|
|
98
|
+
case 'json':
|
|
99
|
+
return 'json';
|
|
100
|
+
case 'boolean':
|
|
101
|
+
return 'checkbox';
|
|
102
|
+
case 'string':
|
|
103
|
+
return 'input';
|
|
104
|
+
case 'integer':
|
|
105
|
+
return 'integer';
|
|
106
|
+
case 'float':
|
|
107
|
+
return 'number';
|
|
108
|
+
case 'date':
|
|
109
|
+
return 'datetime';
|
|
110
|
+
default:
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const handleFileUpload = (file)=>{
|
|
115
|
+
const reader = new FileReader();
|
|
116
|
+
reader.onload = async (e)=>{
|
|
117
|
+
const binaryStr = e.target.result;
|
|
118
|
+
const workbook = external_xlsx_namespaceObject.read(binaryStr, {
|
|
119
|
+
type: 'binary'
|
|
120
|
+
});
|
|
121
|
+
const firstSheetName = workbook.SheetNames[0];
|
|
122
|
+
const worksheet = workbook.Sheets[firstSheetName];
|
|
123
|
+
const jsonData = external_xlsx_namespaceObject.utils.sheet_to_json(worksheet, {
|
|
124
|
+
header: 1
|
|
125
|
+
});
|
|
126
|
+
if (0 === jsonData.length) return;
|
|
127
|
+
const headers = jsonData[0];
|
|
128
|
+
const rows = jsonData.slice(1);
|
|
129
|
+
const fields = await Promise.all(headers.map(async (header, index)=>{
|
|
130
|
+
const columnValues = rows.map((row)=>row[index]);
|
|
131
|
+
const type = inferType(columnValues, header);
|
|
132
|
+
const interfaceType = type ? inferInterface(type, header) : null;
|
|
133
|
+
const interfaceConfig = interfaceType ? getInterface(interfaceType) : null;
|
|
134
|
+
const interfaceConfigValues = (0, external_lodash_namespaceObject.cloneDeep)(interfaceConfig);
|
|
135
|
+
const defaultUiSchema = (null == interfaceConfigValues ? void 0 : interfaceConfigValues.default.uiSchema) || {};
|
|
136
|
+
const fieldsName = "f_".concat((0, schema_namespaceObject.uid)());
|
|
137
|
+
return {
|
|
138
|
+
name: fieldsName,
|
|
139
|
+
type,
|
|
140
|
+
interface: interfaceType,
|
|
141
|
+
uiSchema: {
|
|
142
|
+
title: header,
|
|
143
|
+
...defaultUiSchema
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}));
|
|
147
|
+
const parseValue = (value, type)=>{
|
|
148
|
+
try {
|
|
149
|
+
switch(type){
|
|
150
|
+
case 'boolean':
|
|
151
|
+
{
|
|
152
|
+
const valueLower = value.toString().toLowerCase();
|
|
153
|
+
if ('true' === valueLower || 'yes' === valueLower) return true;
|
|
154
|
+
if ('false' === valueLower || 'no' === valueLower) return false;
|
|
155
|
+
throw new Error('Invalid boolean');
|
|
156
|
+
}
|
|
157
|
+
case 'integer':
|
|
158
|
+
if (!/^-?\d+$/.test(value)) throw new Error('Invalid integer');
|
|
159
|
+
return parseInt(value, 10);
|
|
160
|
+
case 'float':
|
|
161
|
+
if (!/^-?\d+(\.\d+)?$/.test(value)) throw new Error('Invalid number');
|
|
162
|
+
return Number(value);
|
|
163
|
+
case 'json':
|
|
164
|
+
return JSON.parse(value);
|
|
165
|
+
case 'date':
|
|
166
|
+
if (isNaN(Date.parse(value))) throw new Error('Invalid date');
|
|
167
|
+
return new Date(value);
|
|
168
|
+
default:
|
|
169
|
+
if (null == value || '' === value) return '';
|
|
170
|
+
return value.toString();
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw new Error("Type conversion error: ".concat(error.message));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const convertedRows = rows.map((row, rowIndex)=>headers.reduce((acc, header, index)=>{
|
|
177
|
+
var _fields_index, _fields_index1;
|
|
178
|
+
const fieldsName = null === (_fields_index = fields[index]) || void 0 === _fields_index ? void 0 : _fields_index.name;
|
|
179
|
+
const type = null === (_fields_index1 = fields[index]) || void 0 === _fields_index1 ? void 0 : _fields_index1.type;
|
|
180
|
+
if (fieldsName && type) try {
|
|
181
|
+
const convertedValue = parseValue(row[index], type);
|
|
182
|
+
acc[fieldsName] = convertedValue;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
acc[fieldsName] = null;
|
|
185
|
+
external_antd_namespaceObject.message.error('Error in column "'.concat(header, '" at row ').concat(rowIndex + 1, ": ").concat(error.message));
|
|
186
|
+
}
|
|
187
|
+
return acc;
|
|
188
|
+
}, {}));
|
|
189
|
+
const fileData = {
|
|
190
|
+
fields: fields,
|
|
191
|
+
data: convertedRows
|
|
192
|
+
};
|
|
193
|
+
setFileData(fileData);
|
|
194
|
+
};
|
|
195
|
+
reader.readAsBinaryString(file);
|
|
196
|
+
};
|
|
197
|
+
const importProps = {
|
|
198
|
+
onRemove: (file)=>{
|
|
199
|
+
const index = fileList.indexOf(file);
|
|
200
|
+
const newFileList = fileList.slice();
|
|
201
|
+
newFileList.splice(index, 1);
|
|
202
|
+
setFile(newFileList);
|
|
203
|
+
},
|
|
204
|
+
beforeUpload: (file)=>{
|
|
205
|
+
const isExcel = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' === file.type || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
|
|
206
|
+
if (!isExcel) {
|
|
207
|
+
external_antd_namespaceObject.message.error(t('You can only upload Excel files!'));
|
|
208
|
+
return external_antd_namespaceObject.Upload.LIST_IGNORE;
|
|
209
|
+
}
|
|
210
|
+
handleFileUpload(file);
|
|
211
|
+
setFile([
|
|
212
|
+
file
|
|
213
|
+
]);
|
|
214
|
+
return false;
|
|
215
|
+
},
|
|
216
|
+
fileList
|
|
217
|
+
};
|
|
218
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
219
|
+
children: [
|
|
220
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Dragger, {
|
|
221
|
+
maxCount: 1,
|
|
222
|
+
...importProps,
|
|
223
|
+
children: [
|
|
224
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
225
|
+
className: "ant-upload-drag-icon",
|
|
226
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.InboxOutlined, {})
|
|
227
|
+
}),
|
|
228
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("p", {
|
|
229
|
+
className: "ant-upload-text",
|
|
230
|
+
children: [
|
|
231
|
+
" ",
|
|
232
|
+
t('Click or drag file to this area to upload')
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
}),
|
|
237
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_js_namespaceObject.ActionContextProvider, {
|
|
238
|
+
value: {
|
|
239
|
+
visible,
|
|
240
|
+
setVisible
|
|
241
|
+
},
|
|
242
|
+
children: [
|
|
243
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
|
|
244
|
+
type: "primary",
|
|
245
|
+
onClick: async ()=>{
|
|
246
|
+
const xlsxCollectionSchema = (0, external_XlsxCollectionSchema_js_namespaceObject.createXlsxCollectionSchema)(fileList, filedata);
|
|
247
|
+
setSchema(xlsxCollectionSchema);
|
|
248
|
+
setVisible(true);
|
|
249
|
+
close();
|
|
250
|
+
},
|
|
251
|
+
disabled: 0 === fileList.length,
|
|
252
|
+
style: {
|
|
253
|
+
marginTop: 16
|
|
254
|
+
},
|
|
255
|
+
children: t('Upload')
|
|
256
|
+
}),
|
|
257
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.SchemaComponent, {
|
|
258
|
+
schema: schema,
|
|
259
|
+
components: {
|
|
260
|
+
xlsxFieldsConfigure: external_xlsxFieldsConfigure_js_namespaceObject.xlsxFieldsConfigure
|
|
261
|
+
},
|
|
262
|
+
scope: {
|
|
263
|
+
xlsxPreviewTable: external_xlsxPreviewTable_js_namespaceObject.xlsxPreviewTable,
|
|
264
|
+
xlsxImportAction: external_XlsxEditFieldAction_js_namespaceObject.xlsxImportAction
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
const ImportXlsxMetaAction = /*#__PURE__*/ external_react_default().forwardRef((props, ref)=>{
|
|
273
|
+
const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
|
|
274
|
+
const [isModalOpen, setIsModalOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
275
|
+
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
276
|
+
const showModal = ()=>{
|
|
277
|
+
setIsModalOpen(true);
|
|
278
|
+
};
|
|
279
|
+
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>({
|
|
280
|
+
showModal
|
|
281
|
+
}));
|
|
282
|
+
const handleCancel = ()=>{
|
|
283
|
+
setIsModalOpen(false);
|
|
284
|
+
};
|
|
285
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
|
|
286
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Drawer, {
|
|
287
|
+
title: t('Import collection'),
|
|
288
|
+
footer: void 0,
|
|
289
|
+
open: isModalOpen,
|
|
290
|
+
onClose: handleCancel,
|
|
291
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
292
|
+
spinning: loading,
|
|
293
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ImportUpload, {
|
|
294
|
+
close: handleCancel
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
var __webpack_export_target__ = exports;
|
|
301
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
302
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
303
|
+
value: true
|
|
304
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
createXlsxCollectionSchema: ()=>createXlsxCollectionSchema
|
|
30
|
+
});
|
|
31
|
+
const schema_namespaceObject = require("@tachybase/schema");
|
|
32
|
+
const createXlsxCollectionSchema = (filelist, filedata)=>{
|
|
33
|
+
var _filelist_;
|
|
34
|
+
return {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
[(0, schema_namespaceObject.uid)()]: {
|
|
38
|
+
type: 'void',
|
|
39
|
+
'x-decorator': 'FormV2',
|
|
40
|
+
'x-component': 'Action.Drawer',
|
|
41
|
+
'x-component-props': {
|
|
42
|
+
width: '70%'
|
|
43
|
+
},
|
|
44
|
+
'x-use-component-props': 'useFormBlockProps',
|
|
45
|
+
properties: {
|
|
46
|
+
action: {
|
|
47
|
+
type: 'void',
|
|
48
|
+
'x-component': 'ActionBar',
|
|
49
|
+
'x-component-props': {
|
|
50
|
+
layout: 'one-column',
|
|
51
|
+
style: {
|
|
52
|
+
justifyContent: 'right'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
properties: {
|
|
56
|
+
cancel: {
|
|
57
|
+
title: 'Cancel',
|
|
58
|
+
'x-component': 'Action',
|
|
59
|
+
'x-use-component-props': 'useCancelActionProps'
|
|
60
|
+
},
|
|
61
|
+
submit: {
|
|
62
|
+
title: '{{t("Submit")}}',
|
|
63
|
+
'x-component': 'Action',
|
|
64
|
+
'x-component-props': {
|
|
65
|
+
type: 'primary',
|
|
66
|
+
htmlType: 'submit'
|
|
67
|
+
},
|
|
68
|
+
'x-use-component-props': 'xlsxImportAction'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
title: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: null === (_filelist_ = filelist[0]) || void 0 === _filelist_ ? void 0 : _filelist_.name.replace(/\.[^/.]+$/, ''),
|
|
75
|
+
title: '{{ t("Collection display name") }}',
|
|
76
|
+
required: true,
|
|
77
|
+
'x-decorator': 'FormItem',
|
|
78
|
+
'x-component': 'Input'
|
|
79
|
+
},
|
|
80
|
+
name: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
title: '{{t("Collection name")}}',
|
|
83
|
+
default: '{{ useNewId("t_") }}',
|
|
84
|
+
required: true,
|
|
85
|
+
'x-decorator': 'FormItem',
|
|
86
|
+
'x-component': 'Input',
|
|
87
|
+
'x-validator': 'uid',
|
|
88
|
+
description: "{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"
|
|
89
|
+
},
|
|
90
|
+
category: {
|
|
91
|
+
title: '{{t("Categories")}}',
|
|
92
|
+
type: 'hasMany',
|
|
93
|
+
name: 'category',
|
|
94
|
+
'x-decorator': 'FormItem',
|
|
95
|
+
'x-component': 'Select',
|
|
96
|
+
'x-component-props': {
|
|
97
|
+
mode: 'multiple'
|
|
98
|
+
},
|
|
99
|
+
'x-reactions': [
|
|
100
|
+
'{{useAsyncDataSource(loadCategories)}}'
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
description: {
|
|
104
|
+
title: '{{t("Description")}}',
|
|
105
|
+
type: 'string',
|
|
106
|
+
name: 'description',
|
|
107
|
+
'x-decorator': 'FormItem',
|
|
108
|
+
'x-component': 'Input.TextArea'
|
|
109
|
+
},
|
|
110
|
+
fields: {
|
|
111
|
+
type: 'array',
|
|
112
|
+
title: '{{t("Fields")}}',
|
|
113
|
+
default: filedata.fields,
|
|
114
|
+
'x-decorator': 'FormItem',
|
|
115
|
+
'x-component': 'xlsxFieldsConfigure',
|
|
116
|
+
'x-component-props': {
|
|
117
|
+
filedata
|
|
118
|
+
},
|
|
119
|
+
required: true
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
var __webpack_export_target__ = exports;
|
|
127
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
128
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
129
|
+
value: true
|
|
130
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
xlsxImportAction: ()=>xlsxImportAction
|
|
30
|
+
});
|
|
31
|
+
const schema_namespaceObject = require("@tachybase/schema");
|
|
32
|
+
const external_antd_namespaceObject = require("antd");
|
|
33
|
+
const external_lodash_namespaceObject = require("lodash");
|
|
34
|
+
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
35
|
+
const index_js_namespaceObject = require("../../../api-client/index.js");
|
|
36
|
+
const external_schema_component_index_js_namespaceObject = require("../../../schema-component/index.js");
|
|
37
|
+
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
|
|
38
|
+
const external_ResourceActionProvider_js_namespaceObject = require("../../ResourceActionProvider.js");
|
|
39
|
+
const xlsxImportAction = ()=>{
|
|
40
|
+
const form = (0, schema_namespaceObject.useForm)();
|
|
41
|
+
const ctx = (0, external_schema_component_index_js_namespaceObject.useActionContext)();
|
|
42
|
+
const field = (0, schema_namespaceObject.useField)();
|
|
43
|
+
const api = (0, index_js_namespaceObject.useAPIClient)();
|
|
44
|
+
const { refresh } = (0, external_ResourceActionProvider_js_namespaceObject.useResourceActionContext)();
|
|
45
|
+
const { refreshCM } = (0, external_hooks_index_js_namespaceObject.useCollectionManager_deprecated)();
|
|
46
|
+
const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
|
|
47
|
+
return {
|
|
48
|
+
async onClick () {
|
|
49
|
+
field.data = field.data || {};
|
|
50
|
+
field.data.loading = true;
|
|
51
|
+
try {
|
|
52
|
+
await form.submit();
|
|
53
|
+
const values = (0, external_lodash_namespaceObject.cloneDeep)(form.values);
|
|
54
|
+
const { collectionData, ...collections } = values;
|
|
55
|
+
if (!collections.autoCreateReverseField) delete collections.reverseField;
|
|
56
|
+
delete collections.autoCreateReverseField;
|
|
57
|
+
await api.resource('collections').create({
|
|
58
|
+
values: {
|
|
59
|
+
logging: true,
|
|
60
|
+
...collections
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
api.resource("".concat(collections.name)).create({
|
|
64
|
+
values: collectionData
|
|
65
|
+
});
|
|
66
|
+
ctx.setVisible(false);
|
|
67
|
+
null == refresh || refresh();
|
|
68
|
+
await refreshCM();
|
|
69
|
+
field.data.loading = false;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
field.data.loading = false;
|
|
72
|
+
external_antd_namespaceObject.message.error(t('Operation failed'));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var __webpack_export_target__ = exports;
|
|
78
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
79
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
80
|
+
value: true
|
|
81
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
setUpdateXlsxCollectionField: ()=>setUpdateXlsxCollectionField
|
|
30
|
+
});
|
|
31
|
+
const schema_namespaceObject = require("@tachybase/schema");
|
|
32
|
+
const external_antd_namespaceObject = require("antd");
|
|
33
|
+
const external_lodash_namespaceObject = require("lodash");
|
|
34
|
+
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
35
|
+
const index_js_namespaceObject = require("../../../schema-component/index.js");
|
|
36
|
+
const external_xlsxFormValueContextProvider_js_namespaceObject = require("./xlsxFormValueContextProvider.js");
|
|
37
|
+
const setUpdateXlsxCollectionField = ()=>{
|
|
38
|
+
const form = (0, schema_namespaceObject.useForm)();
|
|
39
|
+
const { value, setFormValue } = (0, external_xlsxFormValueContextProvider_js_namespaceObject.useFormValueContext)();
|
|
40
|
+
const ctx = (0, index_js_namespaceObject.useActionContext)();
|
|
41
|
+
const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
|
|
42
|
+
const handleFieldChange = (index, updatedField)=>{
|
|
43
|
+
const updatedFieldData = [
|
|
44
|
+
...value
|
|
45
|
+
];
|
|
46
|
+
if (updatedField.primaryKey) {
|
|
47
|
+
const existingPrimaryKey = updatedFieldData.find((field, i)=>true === field.primaryKey && i !== index);
|
|
48
|
+
if (existingPrimaryKey) {
|
|
49
|
+
external_antd_namespaceObject.message.error(t('existingPrimaryKeyError', {
|
|
50
|
+
name: existingPrimaryKey.name
|
|
51
|
+
}));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
updatedFieldData[index] = updatedField;
|
|
56
|
+
setFormValue(updatedFieldData);
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
async onClick () {
|
|
60
|
+
await form.submit();
|
|
61
|
+
const values = (0, external_lodash_namespaceObject.cloneDeep)(form.values);
|
|
62
|
+
values.autoCreateReverseField || delete values.reverseField;
|
|
63
|
+
delete values.autoCreateReverseField;
|
|
64
|
+
const { index, ...updatedField } = values;
|
|
65
|
+
if (index < 0 || index >= value.length) {
|
|
66
|
+
external_antd_namespaceObject.message.error('Invalid field index');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
handleFieldChange(index, updatedField);
|
|
70
|
+
ctx.setVisible(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
var __webpack_export_target__ = exports;
|
|
75
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
76
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
77
|
+
value: true
|
|
78
|
+
});
|