udp-react-enterprise-component-library 26.9.0 → 26.10.0-beta.0
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/dist/.tsbuildinfo +1 -1
- package/dist/udp/fileImportMapping/FileImportMappingWizard.d.ts.map +1 -1
- package/dist/udp/fileImportMapping/FileImportMappingWizard.js +16 -13
- package/dist/udp/fileImportMapping/FileImportMappingWizard.js.map +1 -1
- package/dist/udp/fileImportMapping/FileImportMappingWizard.mjs +245 -226
- package/dist/udp/fileImportMapping/FileImportMappingWizard.mjs.map +1 -1
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.d.ts +31 -1
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.d.ts.map +1 -1
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.js +56 -8
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.js.map +1 -1
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.mjs +244 -184
- package/dist/udp/fileImportMapping/ImportDataFromFileMapping.mjs.map +1 -1
- package/dist/udp/fileImportMapping/fileImportProperties.d.ts +11 -0
- package/dist/udp/fileImportMapping/fileImportProperties.d.ts.map +1 -0
- package/dist/udp/fileImportMapping/fileImportProperties.js +21 -0
- package/dist/udp/fileImportMapping/fileImportProperties.js.map +1 -0
- package/dist/udp/fileImportMapping/fileImportProperties.mjs +22 -0
- package/dist/udp/fileImportMapping/fileImportProperties.mjs.map +1 -0
- package/dist/udp/utilities/useDateStringColumnDef.d.ts +1 -1
- package/package.json +5 -1
|
@@ -15,30 +15,48 @@ import FileImportMappingWizard from "./FileImportMappingWizard.mjs";
|
|
|
15
15
|
import React, { useEffect, useState } from "react";
|
|
16
16
|
import { useTranslation } from "react-i18next";
|
|
17
17
|
//#region src/udp/fileImportMapping/ImportDataFromFileMapping.jsx
|
|
18
|
+
const DEFAULT_ACCEPT = ".csv,.txt,.xlsx,.json";
|
|
19
|
+
const ACCEPT_BY_EXTENSION = { ".csv": ".csv,.txt" };
|
|
20
|
+
/**
|
|
21
|
+
* A saved file mapping (`UdpFileImportMapping`), as the panel loads it and as
|
|
22
|
+
* `POST UdpFileImportMapping` returns it.
|
|
23
|
+
* @typedef {{ id: number, name: string, udpFileImportMappingUdpFileImportType?: { extension?: string } } & Record<string, any>} FileImportMapping
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @param {object} props
|
|
27
|
+
* @param {() => void} [props.onImportSuccess] - Called after the file is imported.
|
|
28
|
+
* @param {() => void} [props.onImportFail] - Called when the import request fails.
|
|
29
|
+
* @param {boolean} [props.verifyRequiredFields=true] - Create New Mapping requires every required field of the domain to be mapped.
|
|
30
|
+
* @param {(mapping: FileImportMapping) => boolean} [props.mappingFilter] - Only mappings it returns true for are offered, also after a refetch; a selection that stops passing it is cleared. Omit to offer every mapping.
|
|
31
|
+
* @param {boolean} [props.acceptFromMapping=false] - The file picker accepts only the selected mapping's file extension (a CSV mapping also accepts `.txt`) instead of `.csv,.txt,.xlsx,.json`.
|
|
32
|
+
* @param {string[]} [props.allowedFileTypes] - Extensions (e.g. `['.csv', '.xlsx']`) Create New Mapping offers as file types. Omit to offer every file type.
|
|
33
|
+
* @param {(mapping: FileImportMapping) => void} [props.onMappingSaved] - Called once after Create New Mapping saves, with the saved mapping (including its `id`).
|
|
34
|
+
*/
|
|
18
35
|
const ImportDataFromFileMapping = (props) => {
|
|
19
|
-
const $ = c(
|
|
20
|
-
const { onImportSuccess, onImportFail, verifyRequiredFields: t0 } = props;
|
|
36
|
+
const $ = c(69);
|
|
37
|
+
const { onImportSuccess, onImportFail, verifyRequiredFields: t0, mappingFilter, acceptFromMapping: t1, allowedFileTypes, onMappingSaved } = props;
|
|
21
38
|
const verifyRequiredFields = t0 === void 0 ? true : t0;
|
|
39
|
+
const acceptFromMapping = t1 === void 0 ? false : t1;
|
|
22
40
|
const { t } = useTranslation();
|
|
23
41
|
const user = useUser();
|
|
24
42
|
const [selectedFileMapping, setSelectedFileMapping] = useState();
|
|
25
43
|
const [udpImportMappingData, setUdpImportMappingData] = useState();
|
|
26
44
|
const [newFileMappingSidesheetOpen, setNewFileMappingSidesheetOpen] = useState(false);
|
|
27
45
|
const [fileObject, setFileObject] = useState();
|
|
28
|
-
let
|
|
46
|
+
let t2;
|
|
29
47
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
30
|
-
|
|
31
|
-
$[0] =
|
|
32
|
-
} else
|
|
33
|
-
const [fileItems, setFileItems] = useState(
|
|
48
|
+
t2 = [];
|
|
49
|
+
$[0] = t2;
|
|
50
|
+
} else t2 = $[0];
|
|
51
|
+
const [fileItems, setFileItems] = useState(t2);
|
|
34
52
|
const [isLoading, setIsLoading] = useState(false);
|
|
35
53
|
const { handleErrorSnackbar, handleSuccessSnackbar } = useHandleAxiosSnackbar();
|
|
36
54
|
const { data: udpFileImportMappingEntity } = usePromotedMethodEntity("UdpFileImportMapping", true);
|
|
37
55
|
const fm = selectedFileMapping ?? {};
|
|
38
56
|
const executeImportDataFromFile = async (data) => apiMutate(ConfigService.productV1ApiUrl, `${fm.objectInfoSanitizedName}/fileImportMapping`, { method: "post" }, { data });
|
|
39
|
-
let
|
|
57
|
+
let t3;
|
|
40
58
|
if ($[1] !== udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId) {
|
|
41
|
-
|
|
59
|
+
t3 = async () => {
|
|
42
60
|
if (udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId) {
|
|
43
61
|
const res = await executeQueryAdHoc({ data: {
|
|
44
62
|
eagerLoad: true,
|
|
@@ -49,25 +67,73 @@ const ImportDataFromFileMapping = (props) => {
|
|
|
49
67
|
}
|
|
50
68
|
};
|
|
51
69
|
$[1] = udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId;
|
|
52
|
-
$[2] =
|
|
53
|
-
} else
|
|
70
|
+
$[2] = t3;
|
|
71
|
+
} else t3 = $[2];
|
|
54
72
|
udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId;
|
|
55
|
-
const searchFileImportMappingData =
|
|
56
|
-
let t3;
|
|
73
|
+
const searchFileImportMappingData = t3;
|
|
57
74
|
let t4;
|
|
75
|
+
let t5;
|
|
58
76
|
if ($[3] !== searchFileImportMappingData) {
|
|
59
|
-
|
|
77
|
+
t4 = () => {
|
|
60
78
|
searchFileImportMappingData();
|
|
61
79
|
};
|
|
62
|
-
|
|
80
|
+
t5 = [searchFileImportMappingData];
|
|
63
81
|
$[3] = searchFileImportMappingData;
|
|
64
|
-
$[4] =
|
|
65
|
-
$[5] =
|
|
82
|
+
$[4] = t4;
|
|
83
|
+
$[5] = t5;
|
|
84
|
+
} else {
|
|
85
|
+
t4 = $[4];
|
|
86
|
+
t5 = $[5];
|
|
87
|
+
}
|
|
88
|
+
useEffect(t4, t5);
|
|
89
|
+
let t6;
|
|
90
|
+
if ($[6] !== mappingFilter || $[7] !== udpImportMappingData) {
|
|
91
|
+
t6 = mappingFilter && udpImportMappingData ? udpImportMappingData.filter(mappingFilter) : udpImportMappingData;
|
|
92
|
+
$[6] = mappingFilter;
|
|
93
|
+
$[7] = udpImportMappingData;
|
|
94
|
+
$[8] = t6;
|
|
95
|
+
} else t6 = $[8];
|
|
96
|
+
const mappingOptions = t6;
|
|
97
|
+
let t7;
|
|
98
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
99
|
+
t7 = () => {
|
|
100
|
+
setFileItems([]);
|
|
101
|
+
setFileObject(void 0);
|
|
102
|
+
};
|
|
103
|
+
$[9] = t7;
|
|
104
|
+
} else t7 = $[9];
|
|
105
|
+
const clearSelectedFile = t7;
|
|
106
|
+
let t8;
|
|
107
|
+
let t9;
|
|
108
|
+
if ($[10] !== mappingOptions || $[11] !== selectedFileMapping) {
|
|
109
|
+
t8 = () => {
|
|
110
|
+
if (selectedFileMapping && mappingOptions && !mappingOptions.some((mapping) => mapping.id === selectedFileMapping.id)) {
|
|
111
|
+
setSelectedFileMapping(void 0);
|
|
112
|
+
clearSelectedFile();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
t9 = [mappingOptions, selectedFileMapping];
|
|
116
|
+
$[10] = mappingOptions;
|
|
117
|
+
$[11] = selectedFileMapping;
|
|
118
|
+
$[12] = t8;
|
|
119
|
+
$[13] = t9;
|
|
66
120
|
} else {
|
|
67
|
-
|
|
68
|
-
|
|
121
|
+
t8 = $[12];
|
|
122
|
+
t9 = $[13];
|
|
69
123
|
}
|
|
70
|
-
useEffect(
|
|
124
|
+
useEffect(t8, t9);
|
|
125
|
+
let t10;
|
|
126
|
+
if ($[14] !== acceptFromMapping) {
|
|
127
|
+
t10 = (e) => {
|
|
128
|
+
setSelectedFileMapping(e.target.value);
|
|
129
|
+
if (acceptFromMapping) clearSelectedFile();
|
|
130
|
+
};
|
|
131
|
+
$[14] = acceptFromMapping;
|
|
132
|
+
$[15] = t10;
|
|
133
|
+
} else t10 = $[15];
|
|
134
|
+
const handleSelectFileMapping = t10;
|
|
135
|
+
const mappingExtension = fm.udpFileImportMappingUdpFileImportType?.extension?.toLowerCase();
|
|
136
|
+
const fileAccept = acceptFromMapping && mappingExtension && (ACCEPT_BY_EXTENSION[mappingExtension] ?? mappingExtension) || DEFAULT_ACCEPT;
|
|
71
137
|
const handleImportDataFromFile = async () => {
|
|
72
138
|
setIsLoading(true);
|
|
73
139
|
const file = fileObject;
|
|
@@ -84,206 +150,200 @@ const ImportDataFromFileMapping = (props) => {
|
|
|
84
150
|
if ((await executeImportDataFromFile(formData).catch((res_0) => {
|
|
85
151
|
setIsLoading(false);
|
|
86
152
|
handleErrorSnackbar(res_0);
|
|
87
|
-
onImportFail();
|
|
153
|
+
onImportFail?.();
|
|
88
154
|
}))?.status === 201) {
|
|
89
155
|
handleSuccessSnackbar(t("fileImport.snackbar.imported", { defaultValue: "Imported Data" }));
|
|
90
156
|
setIsLoading(false);
|
|
91
|
-
onImportSuccess
|
|
157
|
+
onImportSuccess?.();
|
|
92
158
|
}
|
|
93
159
|
};
|
|
94
160
|
const getFileMappingOptionlabel = _temp;
|
|
95
|
-
let
|
|
96
|
-
if ($[
|
|
97
|
-
|
|
98
|
-
const items =
|
|
161
|
+
let t11;
|
|
162
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
163
|
+
t11 = (e_0) => {
|
|
164
|
+
const items = e_0.target.value;
|
|
99
165
|
setFileItems(items);
|
|
100
166
|
setFileObject(items.find(_temp2)?.file);
|
|
101
167
|
};
|
|
102
|
-
$[
|
|
103
|
-
} else
|
|
104
|
-
const handleAddFileToUpload =
|
|
105
|
-
let
|
|
106
|
-
if ($[
|
|
107
|
-
|
|
108
|
-
$[
|
|
109
|
-
} else
|
|
110
|
-
let
|
|
111
|
-
if ($[
|
|
112
|
-
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
} else
|
|
116
|
-
let
|
|
117
|
-
if ($[
|
|
118
|
-
|
|
119
|
-
$[10] = t8;
|
|
120
|
-
} else t8 = $[10];
|
|
121
|
-
let t9;
|
|
122
|
-
if ($[11] !== selectedFileMapping || $[12] !== t7 || $[13] !== udpImportMappingData) {
|
|
123
|
-
t9 = /* @__PURE__ */ React.createElement("div", { style: t6 }, /* @__PURE__ */ React.createElement(UdpAutocomplete, {
|
|
168
|
+
$[16] = t11;
|
|
169
|
+
} else t11 = $[16];
|
|
170
|
+
const handleAddFileToUpload = t11;
|
|
171
|
+
let t12;
|
|
172
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
173
|
+
t12 = { display: "flex" };
|
|
174
|
+
$[17] = t12;
|
|
175
|
+
} else t12 = $[17];
|
|
176
|
+
let t13;
|
|
177
|
+
if ($[18] !== t) {
|
|
178
|
+
t13 = t("fileImport.import.fileMapping", { defaultValue: "File Mapping" });
|
|
179
|
+
$[18] = t;
|
|
180
|
+
$[19] = t13;
|
|
181
|
+
} else t13 = $[19];
|
|
182
|
+
let t14;
|
|
183
|
+
if ($[20] !== handleSelectFileMapping || $[21] !== mappingOptions || $[22] !== selectedFileMapping || $[23] !== t13) {
|
|
184
|
+
t14 = /* @__PURE__ */ React.createElement("div", { style: t12 }, /* @__PURE__ */ React.createElement(UdpAutocomplete, {
|
|
124
185
|
name: "fileMapping",
|
|
125
|
-
label:
|
|
126
|
-
onChange:
|
|
127
|
-
options:
|
|
186
|
+
label: t13,
|
|
187
|
+
onChange: handleSelectFileMapping,
|
|
188
|
+
options: mappingOptions,
|
|
128
189
|
optionLabel: getFileMappingOptionlabel,
|
|
129
190
|
optionValue: "id",
|
|
130
191
|
value: selectedFileMapping,
|
|
131
192
|
required: true,
|
|
132
193
|
optionGroup: _temp3
|
|
133
194
|
}));
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
$[17] = t10;
|
|
150
|
-
} else t10 = $[17];
|
|
151
|
-
let t11;
|
|
152
|
-
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
153
|
-
t11 = {
|
|
195
|
+
$[20] = handleSelectFileMapping;
|
|
196
|
+
$[21] = mappingOptions;
|
|
197
|
+
$[22] = selectedFileMapping;
|
|
198
|
+
$[23] = t13;
|
|
199
|
+
$[24] = t14;
|
|
200
|
+
} else t14 = $[24];
|
|
201
|
+
const t15 = selectedFileMapping && /* @__PURE__ */ React.createElement(UdpFileInput, {
|
|
202
|
+
value: fileItems,
|
|
203
|
+
onChange: handleAddFileToUpload,
|
|
204
|
+
accept: fileAccept,
|
|
205
|
+
maxFiles: 1
|
|
206
|
+
});
|
|
207
|
+
let t16;
|
|
208
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
209
|
+
t16 = {
|
|
154
210
|
display: "flex",
|
|
155
211
|
flexDirection: "row",
|
|
156
212
|
gap: 5,
|
|
157
213
|
float: "right",
|
|
158
214
|
marginTop: 10
|
|
159
215
|
};
|
|
160
|
-
$[18] = t11;
|
|
161
|
-
} else t11 = $[18];
|
|
162
|
-
let t12;
|
|
163
|
-
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
164
|
-
t12 = () => setNewFileMappingSidesheetOpen(true);
|
|
165
|
-
$[19] = t12;
|
|
166
|
-
} else t12 = $[19];
|
|
167
|
-
let t13;
|
|
168
|
-
if ($[20] !== t) {
|
|
169
|
-
t13 = t("fileImport.import.createNewMapping", { defaultValue: "Create New Mapping" });
|
|
170
|
-
$[20] = t;
|
|
171
|
-
$[21] = t13;
|
|
172
|
-
} else t13 = $[21];
|
|
173
|
-
let t14;
|
|
174
|
-
if ($[22] !== t13) {
|
|
175
|
-
t14 = /* @__PURE__ */ React.createElement(UdpButton, {
|
|
176
|
-
onClick: t12,
|
|
177
|
-
appearance: "outline"
|
|
178
|
-
}, t13);
|
|
179
|
-
$[22] = t13;
|
|
180
|
-
$[23] = t14;
|
|
181
|
-
} else t14 = $[23];
|
|
182
|
-
const t15 = !fileObject;
|
|
183
|
-
let t16;
|
|
184
|
-
if ($[24] !== t) {
|
|
185
|
-
t16 = t("fileImport.import.importData", { defaultValue: "Import Data" });
|
|
186
|
-
$[24] = t;
|
|
187
216
|
$[25] = t16;
|
|
188
217
|
} else t16 = $[25];
|
|
189
218
|
let t17;
|
|
190
|
-
if ($[26]
|
|
191
|
-
t17 =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
loading: isLoading,
|
|
195
|
-
disabled: t15
|
|
196
|
-
}, t16);
|
|
197
|
-
$[26] = handleImportDataFromFile;
|
|
198
|
-
$[27] = isLoading;
|
|
199
|
-
$[28] = t15;
|
|
200
|
-
$[29] = t16;
|
|
201
|
-
$[30] = t17;
|
|
202
|
-
} else t17 = $[30];
|
|
219
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
220
|
+
t17 = () => setNewFileMappingSidesheetOpen(true);
|
|
221
|
+
$[26] = t17;
|
|
222
|
+
} else t17 = $[26];
|
|
203
223
|
let t18;
|
|
204
|
-
if ($[
|
|
205
|
-
t18 =
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
|
|
209
|
-
} else t18 = $[33];
|
|
224
|
+
if ($[27] !== t) {
|
|
225
|
+
t18 = t("fileImport.import.createNewMapping", { defaultValue: "Create New Mapping" });
|
|
226
|
+
$[27] = t;
|
|
227
|
+
$[28] = t18;
|
|
228
|
+
} else t18 = $[28];
|
|
210
229
|
let t19;
|
|
211
|
-
if ($[
|
|
212
|
-
t19 =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else t20 = $[36];
|
|
230
|
+
if ($[29] !== t18) {
|
|
231
|
+
t19 = /* @__PURE__ */ React.createElement(UdpButton, {
|
|
232
|
+
onClick: t17,
|
|
233
|
+
appearance: "outline"
|
|
234
|
+
}, t18);
|
|
235
|
+
$[29] = t18;
|
|
236
|
+
$[30] = t19;
|
|
237
|
+
} else t19 = $[30];
|
|
238
|
+
const t20 = !fileObject;
|
|
221
239
|
let t21;
|
|
222
|
-
if ($[
|
|
223
|
-
t21 =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
$[37] = searchFileImportMappingData;
|
|
229
|
-
$[38] = verifyRequiredFields;
|
|
230
|
-
$[39] = t21;
|
|
231
|
-
} else t21 = $[39];
|
|
240
|
+
if ($[31] !== t) {
|
|
241
|
+
t21 = t("fileImport.import.importData", { defaultValue: "Import Data" });
|
|
242
|
+
$[31] = t;
|
|
243
|
+
$[32] = t21;
|
|
244
|
+
} else t21 = $[32];
|
|
232
245
|
let t22;
|
|
233
|
-
if ($[
|
|
234
|
-
t22 = /* @__PURE__ */ React.createElement(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
if ($[33] !== handleImportDataFromFile || $[34] !== isLoading || $[35] !== t20 || $[36] !== t21) {
|
|
247
|
+
t22 = /* @__PURE__ */ React.createElement(UdpButton, {
|
|
248
|
+
appearance: "primary",
|
|
249
|
+
onClick: handleImportDataFromFile,
|
|
250
|
+
loading: isLoading,
|
|
251
|
+
disabled: t20
|
|
239
252
|
}, t21);
|
|
240
|
-
$[
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
|
|
253
|
+
$[33] = handleImportDataFromFile;
|
|
254
|
+
$[34] = isLoading;
|
|
255
|
+
$[35] = t20;
|
|
256
|
+
$[36] = t21;
|
|
257
|
+
$[37] = t22;
|
|
258
|
+
} else t22 = $[37];
|
|
245
259
|
let t23;
|
|
246
|
-
if ($[
|
|
247
|
-
t23 = /* @__PURE__ */ React.createElement(
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
|
|
252
|
-
$[48] = t23;
|
|
253
|
-
} else t23 = $[48];
|
|
260
|
+
if ($[38] !== t19 || $[39] !== t22) {
|
|
261
|
+
t23 = /* @__PURE__ */ React.createElement("div", { style: t16 }, t19, t22);
|
|
262
|
+
$[38] = t19;
|
|
263
|
+
$[39] = t22;
|
|
264
|
+
$[40] = t23;
|
|
265
|
+
} else t23 = $[40];
|
|
254
266
|
let t24;
|
|
255
|
-
if ($[
|
|
256
|
-
t24 = {
|
|
257
|
-
$[
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
if ($[41] !== t) {
|
|
268
|
+
t24 = t("fileImport.import.drawerTitle", { defaultValue: "Create New File Mapping" });
|
|
269
|
+
$[41] = t;
|
|
270
|
+
$[42] = t24;
|
|
271
|
+
} else t24 = $[42];
|
|
272
|
+
let t25;
|
|
273
|
+
if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
|
|
274
|
+
t25 = () => setNewFileMappingSidesheetOpen(false);
|
|
275
|
+
$[43] = t25;
|
|
276
|
+
} else t25 = $[43];
|
|
261
277
|
let t26;
|
|
262
|
-
if ($[
|
|
263
|
-
t26 = /* @__PURE__ */ React.createElement(
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
if ($[44] !== allowedFileTypes || $[45] !== onMappingSaved || $[46] !== searchFileImportMappingData || $[47] !== verifyRequiredFields) {
|
|
279
|
+
t26 = /* @__PURE__ */ React.createElement(FileImportMappingWizard, {
|
|
280
|
+
refetchMappings: searchFileImportMappingData,
|
|
281
|
+
setNewFileMappingSidesheetOpen,
|
|
282
|
+
verifyRequiredFields,
|
|
283
|
+
allowedFileTypes,
|
|
284
|
+
onMappingSaved
|
|
266
285
|
});
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
270
|
-
$[
|
|
271
|
-
|
|
286
|
+
$[44] = allowedFileTypes;
|
|
287
|
+
$[45] = onMappingSaved;
|
|
288
|
+
$[46] = searchFileImportMappingData;
|
|
289
|
+
$[47] = verifyRequiredFields;
|
|
290
|
+
$[48] = t26;
|
|
291
|
+
} else t26 = $[48];
|
|
272
292
|
let t27;
|
|
273
|
-
if ($[
|
|
274
|
-
t27 = /* @__PURE__ */ React.createElement(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
293
|
+
if ($[49] !== newFileMappingSidesheetOpen || $[50] !== t24 || $[51] !== t26) {
|
|
294
|
+
t27 = /* @__PURE__ */ React.createElement(UdpDrawer, {
|
|
295
|
+
drawerTitle: t24,
|
|
296
|
+
open: newFileMappingSidesheetOpen,
|
|
297
|
+
onDrawerClose: t25,
|
|
298
|
+
drawerWidth: "60%"
|
|
299
|
+
}, t26);
|
|
300
|
+
$[49] = newFileMappingSidesheetOpen;
|
|
301
|
+
$[50] = t24;
|
|
302
|
+
$[51] = t26;
|
|
303
|
+
$[52] = t27;
|
|
304
|
+
} else t27 = $[52];
|
|
279
305
|
let t28;
|
|
280
|
-
if ($[
|
|
281
|
-
t28 = /* @__PURE__ */ React.createElement(
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
$[
|
|
285
|
-
|
|
286
|
-
|
|
306
|
+
if ($[53] !== t14 || $[54] !== t15 || $[55] !== t23 || $[56] !== t27) {
|
|
307
|
+
t28 = /* @__PURE__ */ React.createElement(UdpCard, { width: "100%" }, t14, t15, t23, t27);
|
|
308
|
+
$[53] = t14;
|
|
309
|
+
$[54] = t15;
|
|
310
|
+
$[55] = t23;
|
|
311
|
+
$[56] = t27;
|
|
312
|
+
$[57] = t28;
|
|
313
|
+
} else t28 = $[57];
|
|
314
|
+
let t29;
|
|
315
|
+
if ($[58] === Symbol.for("react.memo_cache_sentinel")) {
|
|
316
|
+
t29 = { marginTop: 10 };
|
|
317
|
+
$[58] = t29;
|
|
318
|
+
} else t29 = $[58];
|
|
319
|
+
const T0 = FileImportConfigCard;
|
|
320
|
+
const t30 = fm.udpFileImportMappingUdpObjectInfo?.sanitizedName.replace(/([A-Z])/g, " $1").trim();
|
|
321
|
+
let t31;
|
|
322
|
+
if ($[59] !== T0 || $[60] !== selectedFileMapping || $[61] !== t30) {
|
|
323
|
+
t31 = /* @__PURE__ */ React.createElement(T0, {
|
|
324
|
+
fileMappingRecord: selectedFileMapping,
|
|
325
|
+
domain: t30
|
|
326
|
+
});
|
|
327
|
+
$[59] = T0;
|
|
328
|
+
$[60] = selectedFileMapping;
|
|
329
|
+
$[61] = t30;
|
|
330
|
+
$[62] = t31;
|
|
331
|
+
} else t31 = $[62];
|
|
332
|
+
let t32;
|
|
333
|
+
if ($[63] !== t29 || $[64] !== t31) {
|
|
334
|
+
t32 = /* @__PURE__ */ React.createElement("div", { style: t29 }, t31);
|
|
335
|
+
$[63] = t29;
|
|
336
|
+
$[64] = t31;
|
|
337
|
+
$[65] = t32;
|
|
338
|
+
} else t32 = $[65];
|
|
339
|
+
let t33;
|
|
340
|
+
if ($[66] !== t28 || $[67] !== t32) {
|
|
341
|
+
t33 = /* @__PURE__ */ React.createElement(React.Fragment, null, t28, t32);
|
|
342
|
+
$[66] = t28;
|
|
343
|
+
$[67] = t32;
|
|
344
|
+
$[68] = t33;
|
|
345
|
+
} else t33 = $[68];
|
|
346
|
+
return t33;
|
|
287
347
|
};
|
|
288
348
|
function _temp(option) {
|
|
289
349
|
return `${option.name} (${option?.udpFileImportMappingUdpFileImportType?.extension})`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportDataFromFileMapping.mjs","names":["React","useState","useCallback","useEffect","useTranslation","UdpCard","UdpAutocomplete","UdpButton","apiMutate","useHandleAxiosSnackbar","UdpDrawer","UdpFileInput","FileImportMappingWizard","usePromotedMethodEntity","executeQueryAdHoc","useUser","FileImportConfigCard","ConfigService","ImportDataFromFileMapping","props","$","_c","onImportSuccess","onImportFail","verifyRequiredFields","t0","undefined","t","user","selectedFileMapping","setSelectedFileMapping","udpImportMappingData","setUdpImportMappingData","newFileMappingSidesheetOpen","setNewFileMappingSidesheetOpen","fileObject","setFileObject","t1","Symbol","for","fileItems","setFileItems","isLoading","setIsLoading","handleErrorSnackbar","handleSuccessSnackbar","data","udpFileImportMappingEntity","fm","executeImportDataFromFile","productV1ApiUrl","objectInfoSanitizedName","method","t2","unityBaseSearchMethod","apiMethodId","res","eagerLoad","pageSize","filterElements","pageList","length","searchFileImportMappingData","t3","t4","handleImportDataFromFile","file","blob","Blob","type","formData","FormData","append","name","currentTenantId","fileImportType","mapping","properties","id","response","catch","res_0","status","defaultValue","getFileMappingOptionlabel","_temp","t5","e","items","target","value","find","_temp2","handleAddFileToUpload","t6","display","t7","t8","e_0","t9","_temp3","t10","t11","flexDirection","gap","float","marginTop","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","T0","t25","udpFileImportMappingUdpObjectInfo","sanitizedName","replace","trim","t26","t27","t28","option","udpFileImportMappingUdpFileImportType","extension","item","kind","option_0"],"sources":["../../../src/udp/fileImportMapping/ImportDataFromFileMapping.jsx"],"sourcesContent":["import React, { useState, useCallback, useEffect } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { UdpCard } from '../../UI/fluent-web-components/UdpCard';\nimport { UdpAutocomplete } from '../../UI/fluent-web-components/UdpAutocomplete';\nimport { UdpButton } from '../../UI/fluent-web-components/UdpButton';\nimport { apiMutate } from '../../utilities/useAxiosMutate';\nimport { useHandleAxiosSnackbar } from '../../utilities/apiHelpers';\nimport { UdpDrawer } from '../../UI/fluent-web-components/UdpDrawer';\nimport { UdpFileInput } from '../../UI/fluent-web-components/UdpFileInput';\nimport FileImportMappingWizard from './FileImportMappingWizard';\nimport { usePromotedMethodEntity } from '../../hooks/usePromotedMethodEntity';\nimport { executeQueryAdHoc } from '../utilities/methodUtils';\nimport { useUser } from '../../utilities/auth/useUser';\nimport { FileImportConfigCard } from './FileImportConfigCard';\nimport { ConfigService } from '../../configService';\n\nexport const ImportDataFromFileMapping = (props) => {\n const {onImportSuccess, onImportFail, verifyRequiredFields = true} = props\n const { t } = useTranslation();\n const user = useUser();\n const [selectedFileMapping, setSelectedFileMapping] = useState();\n const [udpImportMappingData, setUdpImportMappingData] = useState();\n const [newFileMappingSidesheetOpen, setNewFileMappingSidesheetOpen] =\n useState(false);\n const [fileObject, setFileObject] = useState();\n const [fileItems, setFileItems] = useState([]);\n const [isLoading, setIsLoading] = useState(false)\n const { handleErrorSnackbar, handleSuccessSnackbar } =\n useHandleAxiosSnackbar();\n\n const { data: udpFileImportMappingEntity } = usePromotedMethodEntity(\n 'UdpFileImportMapping',\n true\n );\n\n // React Compiler narrows property accesses inside closures into cache-key\n // checks that run on every render and drop optional chaining. Reading from\n // an always-defined alias keeps those checks safe before a mapping is picked.\n const fm = selectedFileMapping ?? {};\n\n const executeImportDataFromFile = async (data) =>\n apiMutate(\n ConfigService.productV1ApiUrl,\n `${fm.objectInfoSanitizedName}/fileImportMapping`,\n {\n method: 'post'\n },\n { data }\n );\n\n const searchFileImportMappingData = useCallback(async () => {\n if (udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId) {\n const res = await executeQueryAdHoc(\n {\n data: {\n eagerLoad: true,\n pageSize: 200,\n filterElements: []\n }\n },\n udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId\n );\n if (res?.data?.pageList.length > 0) {\n setUdpImportMappingData(res?.data?.pageList);\n }\n }\n }, [udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId]);\n\n useEffect(() => {\n searchFileImportMappingData();\n }, [searchFileImportMappingData]);\n\n const handleImportDataFromFile = async () => {\n setIsLoading(true)\n const file = fileObject;\n const blob = new Blob([file], { type: file.type });\n const formData = new FormData();\n formData.append('file', blob, file.name);\n formData.append('tenantId', user?.currentTenantId);\n formData.append('name', fm.name);\n formData.append('objectInfoSanitizedName', fm.objectInfoSanitizedName);\n formData.append('fileImportType', fm.fileImportType);\n formData.append('mapping', fm.mapping);\n formData.append('properties', fm.properties);\n formData.append('id', fm.id);\n const response = await executeImportDataFromFile(formData).catch((res) => {\n setIsLoading(false)\n handleErrorSnackbar(res);\n onImportFail()\n });\n if (response?.status === 201) {\n handleSuccessSnackbar(t('fileImport.snackbar.imported', { defaultValue: 'Imported Data' }));\n setIsLoading(false)\n onImportSuccess && onImportSuccess()\n }\n };\n\n const getFileMappingOptionlabel = (option) => {\n return `${option.name} (${option?.udpFileImportMappingUdpFileImportType?.extension})`;\n };\n\n const handleAddFileToUpload = (e) => {\n const items = e.target.value;\n setFileItems(items);\n setFileObject(items.find(item => item.kind === 'pending')?.file);\n };\n\n return (\n <>\n <UdpCard width=\"100%\">\n <div style={{ display: 'flex' }}>\n <UdpAutocomplete\n name={'fileMapping'}\n label={t('fileImport.import.fileMapping', { defaultValue: 'File Mapping' })}\n onChange={(e) => setSelectedFileMapping(e.target.value)}\n options={udpImportMappingData}\n optionLabel={getFileMappingOptionlabel}\n optionValue=\"id\"\n value={selectedFileMapping}\n required\n optionGroup={(option) =>\n option?.udpFileImportMappingUdpObjectInfo?.sanitizedName\n }\n />\n </div>\n {selectedFileMapping && (\n <UdpFileInput\n value={fileItems}\n onChange={handleAddFileToUpload}\n accept=\".csv,.txt,.xlsx,.json\"\n maxFiles={1}\n />\n )}\n <div\n style={{\n display: 'flex',\n flexDirection: 'row',\n gap: 5,\n float: 'right',\n marginTop: 10\n }}\n >\n <UdpButton\n onClick={() => setNewFileMappingSidesheetOpen(true)}\n appearance='outline'\n >\n {t('fileImport.import.createNewMapping', { defaultValue: 'Create New Mapping' })}\n </UdpButton>\n <UdpButton\n appearance='primary'\n onClick={handleImportDataFromFile}\n loading={isLoading}\n disabled={!fileObject}\n >\n {t('fileImport.import.importData', { defaultValue: 'Import Data' })}\n </UdpButton>\n </div>\n <UdpDrawer\n drawerTitle={t('fileImport.import.drawerTitle', { defaultValue: 'Create New File Mapping' })}\n open={newFileMappingSidesheetOpen}\n onDrawerClose={() => setNewFileMappingSidesheetOpen(false)}\n drawerWidth={'60%'}\n >\n <FileImportMappingWizard\n refetchMappings={searchFileImportMappingData}\n setNewFileMappingSidesheetOpen={setNewFileMappingSidesheetOpen}\n verifyRequiredFields={verifyRequiredFields}\n />\n </UdpDrawer>\n </UdpCard>\n <div style={{ marginTop: 10 }}>\n <FileImportConfigCard fileMappingRecord={selectedFileMapping} domain={fm.udpFileImportMappingUdpObjectInfo?.sanitizedName.replace(/([A-Z])/g, ' $1').trim()}/>\n </div>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAakB,6BAA4BC,UAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CACvC,MAAA,EAAAC,iBAAAC,cAAAC,sBAAAC,OAAqEN;CAA/B,MAAAK,uBAAAC,OAAAC,KAAAA,IAAA,OAAAD;CACtC,MAAA,EAAAE,MAAcvB,gBAAgB;CAC9B,MAAAwB,OAAab,SAAS;CACtB,MAAA,CAAAc,qBAAAC,0BAAsD7B,UAAU;CAChE,MAAA,CAAA8B,sBAAAC,2BAAwD/B,UAAU;CAClE,MAAA,CAAAgC,6BAAAC,kCACEjC,SAAS,MAAM;CACjB,MAAA,CAAAkC,YAAAC,iB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AAA;;AAlF7C,SAAAvC,OAAAwC,MAAA;AAAA,QAwFJA,KAAIC,SAAU;;AAxFV,SAAAjC,OAAAkC,UAAA;AAAA,QAyG3BL,UAAMP,mCAAkDC"}
|
|
1
|
+
{"version":3,"file":"ImportDataFromFileMapping.mjs","names":["React","useState","useCallback","useEffect","useMemo","useTranslation","UdpCard","UdpAutocomplete","UdpButton","apiMutate","useHandleAxiosSnackbar","UdpDrawer","UdpFileInput","FileImportMappingWizard","usePromotedMethodEntity","executeQueryAdHoc","useUser","FileImportConfigCard","ConfigService","DEFAULT_ACCEPT","ACCEPT_BY_EXTENSION","ImportDataFromFileMapping","props","$","_c","onImportSuccess","onImportFail","verifyRequiredFields","t0","mappingFilter","acceptFromMapping","t1","allowedFileTypes","onMappingSaved","undefined","t","user","selectedFileMapping","setSelectedFileMapping","udpImportMappingData","setUdpImportMappingData","newFileMappingSidesheetOpen","setNewFileMappingSidesheetOpen","fileObject","setFileObject","t2","Symbol","for","fileItems","setFileItems","isLoading","setIsLoading","handleErrorSnackbar","handleSuccessSnackbar","data","udpFileImportMappingEntity","fm","executeImportDataFromFile","productV1ApiUrl","objectInfoSanitizedName","method","t3","unityBaseSearchMethod","apiMethodId","res","eagerLoad","pageSize","filterElements","pageList","length","searchFileImportMappingData","t4","t5","t6","filter","mappingOptions","t7","clearSelectedFile","t8","t9","some","mapping","id","t10","e","target","value","handleSelectFileMapping","mappingExtension","udpFileImportMappingUdpFileImportType","extension","toLowerCase","fileAccept","handleImportDataFromFile","file","blob","Blob","type","formData","FormData","append","name","currentTenantId","fileImportType","properties","response","catch","res_0","status","defaultValue","getFileMappingOptionlabel","_temp","t11","e_0","items","find","_temp2","handleAddFileToUpload","t12","display","t13","t14","_temp3","t15","t16","flexDirection","gap","float","marginTop","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","T0","t30","udpFileImportMappingUdpObjectInfo","sanitizedName","replace","trim","t31","t32","t33","option","item","kind","option_0"],"sources":["../../../src/udp/fileImportMapping/ImportDataFromFileMapping.jsx"],"sourcesContent":["import React, { useState, useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { UdpCard } from '../../UI/fluent-web-components/UdpCard';\nimport { UdpAutocomplete } from '../../UI/fluent-web-components/UdpAutocomplete';\nimport { UdpButton } from '../../UI/fluent-web-components/UdpButton';\nimport { apiMutate } from '../../utilities/useAxiosMutate';\nimport { useHandleAxiosSnackbar } from '../../utilities/apiHelpers';\nimport { UdpDrawer } from '../../UI/fluent-web-components/UdpDrawer';\nimport { UdpFileInput } from '../../UI/fluent-web-components/UdpFileInput';\nimport FileImportMappingWizard from './FileImportMappingWizard';\nimport { usePromotedMethodEntity } from '../../hooks/usePromotedMethodEntity';\nimport { executeQueryAdHoc } from '../utilities/methodUtils';\nimport { useUser } from '../../utilities/auth/useUser';\nimport { FileImportConfigCard } from './FileImportConfigCard';\nimport { ConfigService } from '../../configService';\n\nconst DEFAULT_ACCEPT = '.csv,.txt,.xlsx,.json';\n// A CSV mapping also reads .txt files: the wizard parses both with the same\n// delimited-text reader, and P-Card statements arrive as .txt.\nconst ACCEPT_BY_EXTENSION = { '.csv': '.csv,.txt' };\n\n/**\n * A saved file mapping (`UdpFileImportMapping`), as the panel loads it and as\n * `POST UdpFileImportMapping` returns it.\n * @typedef {{ id: number, name: string, udpFileImportMappingUdpFileImportType?: { extension?: string } } & Record<string, any>} FileImportMapping\n */\n\n/**\n * @param {object} props\n * @param {() => void} [props.onImportSuccess] - Called after the file is imported.\n * @param {() => void} [props.onImportFail] - Called when the import request fails.\n * @param {boolean} [props.verifyRequiredFields=true] - Create New Mapping requires every required field of the domain to be mapped.\n * @param {(mapping: FileImportMapping) => boolean} [props.mappingFilter] - Only mappings it returns true for are offered, also after a refetch; a selection that stops passing it is cleared. Omit to offer every mapping.\n * @param {boolean} [props.acceptFromMapping=false] - The file picker accepts only the selected mapping's file extension (a CSV mapping also accepts `.txt`) instead of `.csv,.txt,.xlsx,.json`.\n * @param {string[]} [props.allowedFileTypes] - Extensions (e.g. `['.csv', '.xlsx']`) Create New Mapping offers as file types. Omit to offer every file type.\n * @param {(mapping: FileImportMapping) => void} [props.onMappingSaved] - Called once after Create New Mapping saves, with the saved mapping (including its `id`).\n */\nexport const ImportDataFromFileMapping = (props) => {\n const {\n onImportSuccess,\n onImportFail,\n verifyRequiredFields = true,\n mappingFilter,\n acceptFromMapping = false,\n allowedFileTypes,\n onMappingSaved\n } = props;\n const { t } = useTranslation();\n const user = useUser();\n const [selectedFileMapping, setSelectedFileMapping] = useState();\n const [udpImportMappingData, setUdpImportMappingData] = useState();\n const [newFileMappingSidesheetOpen, setNewFileMappingSidesheetOpen] =\n useState(false);\n const [fileObject, setFileObject] = useState();\n const [fileItems, setFileItems] = useState([]);\n const [isLoading, setIsLoading] = useState(false)\n const { handleErrorSnackbar, handleSuccessSnackbar } =\n useHandleAxiosSnackbar();\n\n const { data: udpFileImportMappingEntity } = usePromotedMethodEntity(\n 'UdpFileImportMapping',\n true\n );\n\n // React Compiler narrows property accesses inside closures into cache-key\n // checks that run on every render and drop optional chaining. Reading from\n // an always-defined alias keeps those checks safe before a mapping is picked.\n const fm = selectedFileMapping ?? {};\n\n const executeImportDataFromFile = async (data) =>\n apiMutate(\n ConfigService.productV1ApiUrl,\n `${fm.objectInfoSanitizedName}/fileImportMapping`,\n {\n method: 'post'\n },\n { data }\n );\n\n const searchFileImportMappingData = useCallback(async () => {\n if (udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId) {\n const res = await executeQueryAdHoc(\n {\n data: {\n eagerLoad: true,\n pageSize: 200,\n filterElements: []\n }\n },\n udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId\n );\n if (res?.data?.pageList.length > 0) {\n setUdpImportMappingData(res?.data?.pageList);\n }\n }\n }, [udpFileImportMappingEntity?.unityBaseSearchMethod?.apiMethodId]);\n\n useEffect(() => {\n searchFileImportMappingData();\n }, [searchFileImportMappingData]);\n\n const mappingOptions = useMemo(\n () =>\n mappingFilter && udpImportMappingData\n ? udpImportMappingData.filter(mappingFilter)\n : udpImportMappingData,\n [udpImportMappingData, mappingFilter]\n );\n\n const clearSelectedFile = () => {\n setFileItems([]);\n setFileObject(undefined);\n };\n\n // A selection the filter no longer offers (the page changed it) is cleared,\n // with its file, so Import Data can't run against a hidden mapping.\n useEffect(() => {\n if (\n selectedFileMapping &&\n mappingOptions &&\n !mappingOptions.some((mapping) => mapping.id === selectedFileMapping.id)\n ) {\n setSelectedFileMapping(undefined);\n clearSelectedFile();\n }\n }, [mappingOptions, selectedFileMapping]);\n\n const handleSelectFileMapping = (e) => {\n setSelectedFileMapping(e.target.value);\n // A file picked for the previous mapping may not be this mapping's type.\n if (acceptFromMapping) clearSelectedFile();\n };\n\n const mappingExtension =\n fm.udpFileImportMappingUdpFileImportType?.extension?.toLowerCase();\n const fileAccept =\n (acceptFromMapping &&\n mappingExtension &&\n (ACCEPT_BY_EXTENSION[mappingExtension] ?? mappingExtension)) ||\n DEFAULT_ACCEPT;\n\n const handleImportDataFromFile = async () => {\n setIsLoading(true)\n const file = fileObject;\n const blob = new Blob([file], { type: file.type });\n const formData = new FormData();\n formData.append('file', blob, file.name);\n formData.append('tenantId', user?.currentTenantId);\n formData.append('name', fm.name);\n formData.append('objectInfoSanitizedName', fm.objectInfoSanitizedName);\n formData.append('fileImportType', fm.fileImportType);\n formData.append('mapping', fm.mapping);\n formData.append('properties', fm.properties);\n formData.append('id', fm.id);\n const response = await executeImportDataFromFile(formData).catch((res) => {\n setIsLoading(false)\n handleErrorSnackbar(res);\n onImportFail?.()\n });\n if (response?.status === 201) {\n handleSuccessSnackbar(t('fileImport.snackbar.imported', { defaultValue: 'Imported Data' }));\n setIsLoading(false)\n onImportSuccess?.()\n }\n };\n\n const getFileMappingOptionlabel = (option) => {\n return `${option.name} (${option?.udpFileImportMappingUdpFileImportType?.extension})`;\n };\n\n const handleAddFileToUpload = (e) => {\n const items = e.target.value;\n setFileItems(items);\n setFileObject(items.find(item => item.kind === 'pending')?.file);\n };\n\n return (\n <>\n <UdpCard width=\"100%\">\n <div style={{ display: 'flex' }}>\n <UdpAutocomplete\n name={'fileMapping'}\n label={t('fileImport.import.fileMapping', { defaultValue: 'File Mapping' })}\n onChange={handleSelectFileMapping}\n options={mappingOptions}\n optionLabel={getFileMappingOptionlabel}\n optionValue=\"id\"\n value={selectedFileMapping}\n required\n optionGroup={(option) =>\n option?.udpFileImportMappingUdpObjectInfo?.sanitizedName\n }\n />\n </div>\n {selectedFileMapping && (\n <UdpFileInput\n value={fileItems}\n onChange={handleAddFileToUpload}\n accept={fileAccept}\n maxFiles={1}\n />\n )}\n <div\n style={{\n display: 'flex',\n flexDirection: 'row',\n gap: 5,\n float: 'right',\n marginTop: 10\n }}\n >\n <UdpButton\n onClick={() => setNewFileMappingSidesheetOpen(true)}\n appearance='outline'\n >\n {t('fileImport.import.createNewMapping', { defaultValue: 'Create New Mapping' })}\n </UdpButton>\n <UdpButton\n appearance='primary'\n onClick={handleImportDataFromFile}\n loading={isLoading}\n disabled={!fileObject}\n >\n {t('fileImport.import.importData', { defaultValue: 'Import Data' })}\n </UdpButton>\n </div>\n <UdpDrawer\n drawerTitle={t('fileImport.import.drawerTitle', { defaultValue: 'Create New File Mapping' })}\n open={newFileMappingSidesheetOpen}\n onDrawerClose={() => setNewFileMappingSidesheetOpen(false)}\n drawerWidth={'60%'}\n >\n <FileImportMappingWizard\n refetchMappings={searchFileImportMappingData}\n setNewFileMappingSidesheetOpen={setNewFileMappingSidesheetOpen}\n verifyRequiredFields={verifyRequiredFields}\n allowedFileTypes={allowedFileTypes}\n onMappingSaved={onMappingSaved}\n />\n </UdpDrawer>\n </UdpCard>\n <div style={{ marginTop: 10 }}>\n <FileImportConfigCard fileMappingRecord={selectedFileMapping} domain={fm.udpFileImportMappingUdpObjectInfo?.sanitizedName.replace(/([A-Z])/g, ' $1').trim()}/>\n </div>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA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O,IACI;AAAA7H,IAAA,MAAAsH;AAAAtH,IAAA,MAAA6H;AAAA7H,IAAA,MAAA8H;OAAAA,OAAA9H,EAAA;CAAA,IAAA+H;AAAA,KAAA/H,EAAA,QAAAqH,OAAArH,EAAA,QAAA8H,KAAA;AAlERC,QAAA,sBAAA,cAAA,MAAA,UAAA,MACEV,KA+DAS,IAGC;AAAA9H,IAAA,MAAAqH;AAAArH,IAAA,MAAA8H;AAAA9H,IAAA,MAAA+H;OAAAA,OAAA/H,EAAA;AAAA,QAnEH+H;;AA5IqC,SAAAvC,MAAAwC,QAAA;AAAA,QAkI9B,GAAGA,OAAMlD,KAAK,IAAKkD,QAAM9D,uCAAkDC,UAAA;;AAlI7C,SAAA0B,OAAAoC,MAAA;AAAA,QAwIJA,KAAIC,SAAU;;AAxIV,SAAA/B,OAAAgC,UAAA;AAAA,QAyJ3BH,UAAMP,mCAAkDC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The File step's form values → the layout's `properties`.
|
|
3
|
+
*
|
|
4
|
+
* A file type setting with `options` is a dropdown, whose form value is the
|
|
5
|
+
* selected option (`{ name, value }`); its option's `value` is saved. A setting
|
|
6
|
+
* without `options` is a text box, whose form value is the typed text; it is
|
|
7
|
+
* saved as-is. An untouched setting is not in the form values, so it is not
|
|
8
|
+
* saved.
|
|
9
|
+
*/
|
|
10
|
+
export declare const toFileImportProperties: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
11
|
+
//# sourceMappingURL=fileImportProperties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileImportProperties.d.ts","sourceRoot":"","sources":["../../../src/udp/fileImportMapping/fileImportProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,8DAYlC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The File step's form values → the layout's `properties`.
|
|
3
|
+
*
|
|
4
|
+
* A file type setting with `options` is a dropdown, whose form value is the
|
|
5
|
+
* selected option (`{ name, value }`); its option's `value` is saved. A setting
|
|
6
|
+
* without `options` is a text box, whose form value is the typed text; it is
|
|
7
|
+
* saved as-is. An untouched setting is not in the form values, so it is not
|
|
8
|
+
* saved.
|
|
9
|
+
*/
|
|
10
|
+
export const toFileImportProperties = (values) => {
|
|
11
|
+
const properties = {};
|
|
12
|
+
Object.keys(values).forEach((propKey) => {
|
|
13
|
+
const entry = values[propKey];
|
|
14
|
+
properties[propKey] =
|
|
15
|
+
entry !== null && typeof entry === 'object' && 'value' in entry
|
|
16
|
+
? entry.value
|
|
17
|
+
: entry;
|
|
18
|
+
});
|
|
19
|
+
return properties;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=fileImportProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileImportProperties.js","sourceRoot":"","sources":["../../../src/udp/fileImportMapping/fileImportProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,MAA+B,EACN,EAAE,CAAC;IAC5B,MAAM,UAAU,GAA4B,EAAE,CAAC;IAC/C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,UAAU,CAAC,OAAO,CAAC;YACjB,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK;gBAC7D,CAAC,CAAE,KAA4B,CAAC,KAAK;gBACrC,CAAC,CAAC,KAAK,CAAC;IAAA,CACb,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AAAA,CACnB,CAAC"}
|