@bindu-dashing/dam-solution 1.0.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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/AssetType/assetTypeContainer.js +40 -0
  3. package/dist/AssetType/assetTypeTable.js +359 -0
  4. package/dist/AssetType/createAssetType.js +832 -0
  5. package/dist/AssetType/index.js +26 -0
  6. package/dist/AssetType/style.css +110 -0
  7. package/dist/Components/ImagePickerFiltersTest.js +121 -0
  8. package/dist/Components/ImagePickerTest.js +120 -0
  9. package/dist/CreateClient/createClient.js +34 -0
  10. package/dist/CreateClient/createClientForm.js +269 -0
  11. package/dist/CreateClient/index.js +26 -0
  12. package/dist/Folder/ImagePickerFolder.js +47 -0
  13. package/dist/Folder/index.js +26 -0
  14. package/dist/Folder/style.css +0 -0
  15. package/dist/Folders/bulkDownload.js +102 -0
  16. package/dist/Folders/bulkUpdate.js +186 -0
  17. package/dist/Folders/bulkUploadFiles.js +162 -0
  18. package/dist/Folders/bulkUploadUsingQueue.js +404 -0
  19. package/dist/Folders/createOrUpdateFolder.js +264 -0
  20. package/dist/Folders/exportFolder.js +109 -0
  21. package/dist/Folders/file.js +194 -0
  22. package/dist/Folders/fileManagementContainer.js +345 -0
  23. package/dist/Folders/files.js +315 -0
  24. package/dist/Folders/filesContainer.js +650 -0
  25. package/dist/Folders/filesListView.js +439 -0
  26. package/dist/Folders/foldersContainer.js +408 -0
  27. package/dist/Folders/foldersTree.js +136 -0
  28. package/dist/Folders/index.js +26 -0
  29. package/dist/Folders/style.css +400 -0
  30. package/dist/Folders/uploadFile.js +507 -0
  31. package/dist/ImagePicker/imagePicker.js +141 -0
  32. package/dist/ImagePicker/imagePickerFiles.js +42 -0
  33. package/dist/ImagePicker/index.js +26 -0
  34. package/dist/ImagePicker/style.css +128 -0
  35. package/dist/ImagePickerFilters/imagePickerFilters.js +382 -0
  36. package/dist/ImagePickerFilters/index.js +26 -0
  37. package/dist/ImagePickerFilters/style.css +15 -0
  38. package/dist/RefreshKey/index.js +26 -0
  39. package/dist/RefreshKey/refreshKey.js +86 -0
  40. package/dist/assets/images/default-img.svg +9 -0
  41. package/dist/constants/actionTypes.js +74 -0
  42. package/dist/constants/apiEndpoints.js +88 -0
  43. package/dist/constants/appConstants.js +55 -0
  44. package/dist/hocs/folderHelpers.js +76 -0
  45. package/dist/hocs/helpers.js +52 -0
  46. package/dist/hocs/useFetch.js +97 -0
  47. package/dist/index.js +55 -0
  48. package/package.json +61 -0
@@ -0,0 +1,832 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _antd = require("antd");
10
+ var _icons = require("@ant-design/icons");
11
+ var _appConstants = require("../constants/appConstants");
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _lodash = _interopRequireWildcard(require("lodash"));
14
+ require("./style.css");
15
+ var _useFetch = _interopRequireDefault(require("../hocs/useFetch"));
16
+ var APIS = _interopRequireWildcard(require("../constants/apiEndpoints"));
17
+ var _reactBeautifulDnd = require("react-beautiful-dnd");
18
+ const CreateAssetType = _ref => {
19
+ let {
20
+ setShowCreateOrEditAsset,
21
+ id,
22
+ fetchAssets,
23
+ setAssetTypes,
24
+ setCurrentUpdatingId,
25
+ damAccessKey,
26
+ secretKey,
27
+ subdomain,
28
+ styles,
29
+ setReservedWords,
30
+ reservedWords,
31
+ accessToken
32
+ } = _ref;
33
+ const [form] = _antd.Form.useForm();
34
+ const [data, setData] = (0, _react.useState)({});
35
+ const [loading, setLoading] = (0, _react.useState)(false);
36
+ const {
37
+ fetchApi
38
+ } = (0, _useFetch.default)();
39
+ const [initialValues, setInitialValues] = (0, _react.useState)({});
40
+ const [dataSource, setDataSource] = (0, _react.useState)([]);
41
+ const [fetchRecordLoading, setFetchRecordLoading] = (0, _react.useState)(false);
42
+ const optionsSupportedTypes = ["DROPDOWN", "MULTI_SELECT", "CHECKBOX", "RADIO"];
43
+ const [outputFormatData, setOutputFormatData] = (0, _react.useState)([]);
44
+ const onChangeType = (index, value) => {
45
+ setData(prevData => ({
46
+ ...prevData,
47
+ [index]: {
48
+ type: value,
49
+ isNew: data !== null && data !== void 0 && data[index] ? false : true
50
+ }
51
+ }));
52
+ };
53
+ (0, _react.useEffect)(() => {
54
+ if (id) {
55
+ setFetchRecordLoading(true);
56
+ fetchApi({
57
+ httpMethod: "get",
58
+ route: APIS.FETCH_ASSET_TYPE.replace(":id", id),
59
+ onSuccess: response => {
60
+ var _get, _get2;
61
+ const result = response === null || response === void 0 ? void 0 : response.data;
62
+ form.setFieldsValue(result);
63
+ setInitialValues(result);
64
+ const updatedData = {};
65
+ (_get = (0, _lodash.get)(result, "metadata_fields")) === null || _get === void 0 ? void 0 : _get.forEach((field, index) => {
66
+ updatedData[index] = {
67
+ type: field === null || field === void 0 ? void 0 : field.type,
68
+ isNew: false
69
+ };
70
+ });
71
+ setData(updatedData);
72
+ setDataSource((_get2 = (0, _lodash.get)(result, "metadata_fields")) === null || _get2 === void 0 ? void 0 : _get2.map((field, index) => {
73
+ var _ref2;
74
+ return {
75
+ ...field,
76
+ key: (_ref2 = index + 1) === null || _ref2 === void 0 ? void 0 : _ref2.toString(),
77
+ index: index
78
+ };
79
+ }));
80
+ setOutputFormatData(_lodash.default.sortBy((0, _lodash.get)(result, "output_format", []), "order"));
81
+ setFetchRecordLoading(false);
82
+ },
83
+ onFailure: () => {
84
+ setFetchRecordLoading(false);
85
+ },
86
+ accessToken,
87
+ damAccessKey,
88
+ secretKey,
89
+ subdomain
90
+ });
91
+ }
92
+ }, [id]);
93
+ (0, _react.useEffect)(() => {
94
+ if ((reservedWords === null || reservedWords === void 0 ? void 0 : reservedWords.length) == 0) {
95
+ fetchApi({
96
+ httpMethod: "get",
97
+ route: APIS.GET_RESERVED_KEYWORDS,
98
+ onSuccess: response => {
99
+ const result = response === null || response === void 0 ? void 0 : response.data;
100
+ setReservedWords(result);
101
+ },
102
+ onFailure: () => {},
103
+ accessToken,
104
+ damAccessKey,
105
+ secretKey,
106
+ subdomain
107
+ });
108
+ }
109
+ }, []);
110
+ const validation = () => {
111
+ const errors = [];
112
+ const requiredFields = outputFormatData === null || outputFormatData === void 0 ? void 0 : outputFormatData.filter(row => {
113
+ return row === null || row === void 0 ? void 0 : row.required;
114
+ });
115
+ const lastRequiredField = requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields[(requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) - 1];
116
+ const finalData = outputFormatData === null || outputFormatData === void 0 ? void 0 : outputFormatData.map((row, index) => {
117
+ var _row$separator;
118
+ if ((!(row !== null && row !== void 0 && row.separator) || row !== null && row !== void 0 && row.separator && !(row !== null && row !== void 0 && (_row$separator = row.separator) !== null && _row$separator !== void 0 && _row$separator.trim())) && (row === null || row === void 0 ? void 0 : row.name) !== (lastRequiredField === null || lastRequiredField === void 0 ? void 0 : lastRequiredField.name)) {
119
+ if (row !== null && row !== void 0 && row.required) {
120
+ row["error"] = "Required";
121
+ errors === null || errors === void 0 ? void 0 : errors.push(true);
122
+ }
123
+ }
124
+ return row;
125
+ });
126
+ setOutputFormatData(finalData);
127
+ return errors;
128
+ };
129
+ const onFinish = values => {
130
+ const errors = validation();
131
+ if ((errors === null || errors === void 0 ? void 0 : errors.length) == 0) {
132
+ var _data$metadata_fields;
133
+ const data = {
134
+ ...initialValues,
135
+ ...values
136
+ };
137
+ data["metadata_fields"] = data === null || data === void 0 ? void 0 : (_data$metadata_fields = data.metadata_fields) === null || _data$metadata_fields === void 0 ? void 0 : _data$metadata_fields.map(field => {
138
+ var _typeOption$dataType;
139
+ const typeOption = _appConstants.METADATA_DROPDOWN_OPTIONS === null || _appConstants.METADATA_DROPDOWN_OPTIONS === void 0 ? void 0 : _appConstants.METADATA_DROPDOWN_OPTIONS.find(option => (option === null || option === void 0 ? void 0 : option.value) === (field === null || field === void 0 ? void 0 : field.type));
140
+ const hasOptions = optionsSupportedTypes === null || optionsSupportedTypes === void 0 ? void 0 : optionsSupportedTypes.find(option => option === (field === null || field === void 0 ? void 0 : field.type));
141
+ if (field !== null && field !== void 0 && field.options && !hasOptions) {
142
+ delete field.options;
143
+ }
144
+ field["data_type"] = (_typeOption$dataType = typeOption === null || typeOption === void 0 ? void 0 : typeOption.dataType) !== null && _typeOption$dataType !== void 0 ? _typeOption$dataType : "text";
145
+ field["is_searchable"] = true;
146
+ return field;
147
+ });
148
+ data["output_format"] = outputFormatData;
149
+ setLoading(true);
150
+ if (id) {
151
+ fetchApi({
152
+ route: APIS.UPDATE_ASSET_TYPE.replace(":id", id),
153
+ body: data,
154
+ httpMethod: "put",
155
+ onSuccess: response => {
156
+ const result = response === null || response === void 0 ? void 0 : response.data;
157
+ setLoading(false);
158
+ setShowCreateOrEditAsset(null);
159
+ setCurrentUpdatingId(null);
160
+ _antd.notification.success({
161
+ message: "Asset Type updated successfully"
162
+ });
163
+ setAssetTypes(prevAssets => prevAssets === null || prevAssets === void 0 ? void 0 : prevAssets.map(assetType => {
164
+ if ((assetType === null || assetType === void 0 ? void 0 : assetType.id) === id) {
165
+ return result === null || result === void 0 ? void 0 : result.data;
166
+ } else {
167
+ return assetType;
168
+ }
169
+ }));
170
+ },
171
+ onFailure: () => {
172
+ setLoading(false);
173
+ _antd.notification.error({
174
+ message: "Error while updating asset type"
175
+ });
176
+ },
177
+ accessToken,
178
+ damAccessKey,
179
+ secretKey,
180
+ subdomain
181
+ });
182
+ } else {
183
+ fetchApi({
184
+ route: APIS.CREATE_ASSET_TYPE,
185
+ httpMethod: "post",
186
+ body: data,
187
+ onSuccess: () => {
188
+ setLoading(false);
189
+ setShowCreateOrEditAsset(false);
190
+ setCurrentUpdatingId(null);
191
+ _antd.notification.success({
192
+ message: "Asset Type created successfully"
193
+ });
194
+ fetchAssets();
195
+ },
196
+ onFailure: () => {
197
+ setLoading(false);
198
+ _antd.notification.error({
199
+ message: "Error while creating asset type"
200
+ });
201
+ },
202
+ accessToken,
203
+ damAccessKey,
204
+ secretKey,
205
+ subdomain
206
+ });
207
+ }
208
+ }
209
+ };
210
+ const columns = [{
211
+ title: "",
212
+ render: () => {
213
+ return /*#__PURE__*/_react.default.createElement(_icons.HolderOutlined, null);
214
+ },
215
+ width: "20px"
216
+ }, {
217
+ title: "Name",
218
+ dataIndex: "name",
219
+ ellipsis: true
220
+ }, {
221
+ title: "Type",
222
+ dataIndex: "type"
223
+ }, {
224
+ title: "Order",
225
+ dataIndex: "display_order"
226
+ }];
227
+ const outputFormatColumns = [{
228
+ title: "",
229
+ render: () => {
230
+ return /*#__PURE__*/_react.default.createElement(_icons.HolderOutlined, null);
231
+ },
232
+ width: "20px"
233
+ }, {
234
+ title: "Name",
235
+ dataIndex: "name",
236
+ ellipsis: true
237
+ }, {
238
+ title: "Required",
239
+ dataIndex: "required",
240
+ render: (value, record) => {
241
+ return /*#__PURE__*/_react.default.createElement(_antd.Checkbox, {
242
+ onChange: e => setOutputFormatData(prevData => {
243
+ return prevData === null || prevData === void 0 ? void 0 : prevData.map(row => {
244
+ if ((row === null || row === void 0 ? void 0 : row.name) == (record === null || record === void 0 ? void 0 : record.name)) {
245
+ row["required"] = e.target.checked;
246
+ row["error"] = !(record !== null && record !== void 0 && record.required) || record !== null && record !== void 0 && record.separator ? null : record === null || record === void 0 ? void 0 : record.error;
247
+ }
248
+ return row;
249
+ });
250
+ }),
251
+ checked: value
252
+ });
253
+ },
254
+ width: 100
255
+ }, {
256
+ title: "Separator",
257
+ dataIndex: "separator",
258
+ render: (value, record) => {
259
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_antd.Input, {
260
+ onChange: e => setOutputFormatData(prevData => {
261
+ return prevData === null || prevData === void 0 ? void 0 : prevData.map(row => {
262
+ if ((row === null || row === void 0 ? void 0 : row.name) == (record === null || record === void 0 ? void 0 : record.name)) {
263
+ row["separator"] = e.target.value;
264
+ row["error"] = !(record !== null && record !== void 0 && record.required) || record !== null && record !== void 0 && record.separator ? null : record === null || record === void 0 ? void 0 : record.error;
265
+ }
266
+ return row;
267
+ });
268
+ }),
269
+ value: value
270
+ }), (record === null || record === void 0 ? void 0 : record.error) && /*#__PURE__*/_react.default.createElement(_antd.Typography.Text, {
271
+ style: {
272
+ color: "red"
273
+ }
274
+ }, record === null || record === void 0 ? void 0 : record.error));
275
+ },
276
+ width: 100
277
+ }, {
278
+ title: "Order",
279
+ dataIndex: "order",
280
+ width: 100
281
+ }];
282
+ const onFieldsChange = (_, allFields) => {
283
+ const metadataField = allFields === null || allFields === void 0 ? void 0 : allFields.find(field => {
284
+ var _field$name, _field$name2, _field$value;
285
+ return (field === null || field === void 0 ? void 0 : (_field$name = field.name) === null || _field$name === void 0 ? void 0 : _field$name.includes("metadata_fields")) && (field === null || field === void 0 ? void 0 : (_field$name2 = field.name) === null || _field$name2 === void 0 ? void 0 : _field$name2.length) == 1 &&
286
+ // field?.touched &&
287
+ (field === null || field === void 0 ? void 0 : (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.length) > 0;
288
+ });
289
+ if (metadataField) {
290
+ var _metadataField$value;
291
+ setDataSource(metadataField === null || metadataField === void 0 ? void 0 : (_metadataField$value = metadataField.value) === null || _metadataField$value === void 0 ? void 0 : _metadataField$value.map((value, index) => {
292
+ var _ref3;
293
+ return {
294
+ ...value,
295
+ key: (_ref3 = index + 1) === null || _ref3 === void 0 ? void 0 : _ref3.toString(),
296
+ index: index
297
+ };
298
+ }));
299
+ setOutputFormatData(function () {
300
+ var _metadataField$value2;
301
+ let prevOutputFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
302
+ const finalRecords = [...prevOutputFormat];
303
+ const fileUrlRecord = prevOutputFormat === null || prevOutputFormat === void 0 ? void 0 : prevOutputFormat.find(record => (record === null || record === void 0 ? void 0 : record.name) == "File Url");
304
+ // add new fields
305
+ metadataField === null || metadataField === void 0 ? void 0 : (_metadataField$value2 = metadataField.value) === null || _metadataField$value2 === void 0 ? void 0 : _metadataField$value2.forEach((value, index) => {
306
+ const existingRecord = finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.find(row => (row === null || row === void 0 ? void 0 : row.name) == (value === null || value === void 0 ? void 0 : value.name));
307
+ if (!existingRecord) {
308
+ var _ref4;
309
+ finalRecords.push({
310
+ name: value === null || value === void 0 ? void 0 : value.name,
311
+ required: false,
312
+ key: (_ref4 = index + 1) === null || _ref4 === void 0 ? void 0 : _ref4.toString(),
313
+ index: index,
314
+ error: null,
315
+ order: index + 1
316
+ });
317
+ }
318
+ });
319
+ // remove fields
320
+ finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.forEach((value, index) => {
321
+ var _metadataField$value3;
322
+ const existingRecord = (value === null || value === void 0 ? void 0 : value.name) !== "File Url" ? metadataField === null || metadataField === void 0 ? void 0 : (_metadataField$value3 = metadataField.value) === null || _metadataField$value3 === void 0 ? void 0 : _metadataField$value3.findIndex(row => (row === null || row === void 0 ? void 0 : row.name) == (value === null || value === void 0 ? void 0 : value.name)) : 0;
323
+ if (existingRecord == -1) {
324
+ finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.splice(index);
325
+ }
326
+ });
327
+ const finalDataSource = finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.map((item, index) => {
328
+ var _ref5;
329
+ return {
330
+ ...item,
331
+ key: (_ref5 = index + 1) === null || _ref5 === void 0 ? void 0 : _ref5.toString(),
332
+ index: index
333
+ };
334
+ });
335
+ if (!fileUrlRecord) {
336
+ var _ref6;
337
+ return [{
338
+ name: "File Url",
339
+ key: (_ref6 = (finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.length) + 1) === null || _ref6 === void 0 ? void 0 : _ref6.toString(),
340
+ index: finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.length,
341
+ order: (finalRecords === null || finalRecords === void 0 ? void 0 : finalRecords.length) + 1,
342
+ required: false
343
+ }, ...finalDataSource];
344
+ }
345
+ return finalDataSource === null || finalDataSource === void 0 ? void 0 : finalDataSource.map((item, index) => {
346
+ var _ref7, _item$separator;
347
+ return {
348
+ ...item,
349
+ key: (_ref7 = index + 1) === null || _ref7 === void 0 ? void 0 : _ref7.toString(),
350
+ index: index,
351
+ order: index + 1,
352
+ separator: (_item$separator = item === null || item === void 0 ? void 0 : item.separator) !== null && _item$separator !== void 0 ? _item$separator : null
353
+ };
354
+ });
355
+ });
356
+ }
357
+ };
358
+ const onOutputFormatDragEnd = result => {
359
+ if (!result.destination) {
360
+ return;
361
+ }
362
+ const {
363
+ source,
364
+ destination
365
+ } = result;
366
+ const newDataSource = [...outputFormatData];
367
+ const movedItem = newDataSource[source.index];
368
+ newDataSource.splice(source.index, 1);
369
+ newDataSource.splice(destination.index, 0, movedItem);
370
+ const finalDataSource = newDataSource === null || newDataSource === void 0 ? void 0 : newDataSource.map((item, index) => {
371
+ item["order"] = index + 1;
372
+ item["index"] = index;
373
+ item["key"] = (index + 1).toString();
374
+ return item;
375
+ });
376
+ setOutputFormatData(finalDataSource);
377
+ };
378
+ const onDragEnd = result => {
379
+ if (!result.destination) {
380
+ return;
381
+ }
382
+ const {
383
+ source,
384
+ destination
385
+ } = result;
386
+ const newDataSource = [...dataSource];
387
+ const movedItem = newDataSource[source.index];
388
+ newDataSource.splice(source.index, 1);
389
+ newDataSource.splice(destination.index, 0, movedItem);
390
+ const finalDataSource = newDataSource === null || newDataSource === void 0 ? void 0 : newDataSource.map((item, index) => {
391
+ item["display_order"] = index + 1;
392
+ item["index"] = index;
393
+ item["key"] = (index + 1).toString();
394
+ return item;
395
+ });
396
+ form.setFieldValue("metadata_fields", finalDataSource);
397
+ setDataSource(finalDataSource);
398
+ const newData = Object === null || Object === void 0 ? void 0 : Object.values(data);
399
+ const movedDataItem = newData[source.index];
400
+ newData.splice(source.index, 1);
401
+ newData.splice(destination.index, 0, movedDataItem);
402
+ const finalData = newData === null || newData === void 0 ? void 0 : newData.map((item, index) => {
403
+ return item;
404
+ });
405
+ const updatedData = {};
406
+ finalData === null || finalData === void 0 ? void 0 : finalData.forEach((field, index) => {
407
+ updatedData[index] = field;
408
+ });
409
+ setData(updatedData);
410
+ };
411
+ const DroppableTableBody = _ref8 => {
412
+ let {
413
+ columnId,
414
+ ...props
415
+ } = _ref8;
416
+ return /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.Droppable, {
417
+ droppableId: "1"
418
+ }, (provided, snapshot) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("tbody", Object.assign({
419
+ ref: provided.innerRef
420
+ }, props, provided.droppableProps, {
421
+ className: `${props.className} ${snapshot.isDraggingOver ? "is-dragging-over" : ""}`
422
+ }))));
423
+ };
424
+ const DraggableTableRow = _ref9 => {
425
+ let {
426
+ tasks,
427
+ ...props
428
+ } = _ref9;
429
+ if ((tasks === null || tasks === void 0 ? void 0 : tasks.length) === 0) {
430
+ return /*#__PURE__*/_react.default.createElement("tr", Object.assign({
431
+ className: "ant-table-placeholder row-item"
432
+ }, props), /*#__PURE__*/_react.default.createElement("td", {
433
+ colSpan: columns.length,
434
+ className: "ant-table-cell"
435
+ }, /*#__PURE__*/_react.default.createElement("div", {
436
+ className: "ant-empty ant-empty-normal"
437
+ }, /*#__PURE__*/_react.default.createElement(_antd.Empty, {
438
+ image: _antd.Empty.PRESENTED_IMAGE_SIMPLE
439
+ }))));
440
+ }
441
+ const task = tasks === null || tasks === void 0 ? void 0 : tasks.find(task => (task === null || task === void 0 ? void 0 : task.key) === (props === null || props === void 0 ? void 0 : props["data-row-key"]));
442
+ return /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.Draggable, {
443
+ key: props === null || props === void 0 ? void 0 : props["data-row-key"],
444
+ draggableId: props === null || props === void 0 ? void 0 : props["data-row-key"],
445
+ index: task === null || task === void 0 ? void 0 : task.index
446
+ }, (provided, snapshot) => {
447
+ return /*#__PURE__*/_react.default.createElement("tr", Object.assign({
448
+ ref: provided.innerRef
449
+ }, props, provided.draggableProps, provided.dragHandleProps, {
450
+ className: `row-item
451
+ } ${snapshot.isDragging ? "row-dragging" : ""}`
452
+ }));
453
+ });
454
+ };
455
+ const DraggableOutputFormatTableRow = _ref10 => {
456
+ let {
457
+ tasks,
458
+ ...props
459
+ } = _ref10;
460
+ if ((tasks === null || tasks === void 0 ? void 0 : tasks.length) === 0) {
461
+ return /*#__PURE__*/_react.default.createElement("tr", Object.assign({
462
+ className: "ant-table-placeholder row-item"
463
+ }, props), /*#__PURE__*/_react.default.createElement("td", {
464
+ colSpan: outputFormatColumns.length,
465
+ className: "ant-table-cell"
466
+ }, /*#__PURE__*/_react.default.createElement("div", {
467
+ className: "ant-empty ant-empty-normal"
468
+ }, /*#__PURE__*/_react.default.createElement(_antd.Empty, {
469
+ image: _antd.Empty.PRESENTED_IMAGE_SIMPLE
470
+ }))));
471
+ }
472
+ const task = tasks === null || tasks === void 0 ? void 0 : tasks.find(task => (task === null || task === void 0 ? void 0 : task.key) === (props === null || props === void 0 ? void 0 : props["data-row-key"]));
473
+ return /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.Draggable, {
474
+ key: props === null || props === void 0 ? void 0 : props["data-row-key"],
475
+ draggableId: props === null || props === void 0 ? void 0 : props["data-row-key"],
476
+ index: task === null || task === void 0 ? void 0 : task.index
477
+ }, (provided, snapshot) => {
478
+ return /*#__PURE__*/_react.default.createElement("tr", Object.assign({
479
+ ref: provided.innerRef
480
+ }, props, provided.draggableProps, provided.dragHandleProps, {
481
+ className: `row-item
482
+ } ${snapshot.isDragging ? "row-dragging" : ""}`
483
+ }));
484
+ });
485
+ };
486
+ const getFormattedValue = data => {
487
+ const sortedData = _lodash.default.sortBy(data, "order");
488
+ const value = sortedData === null || sortedData === void 0 ? void 0 : sortedData.reduce((acc, field) => {
489
+ if (field !== null && field !== void 0 && field.required) {
490
+ // if (field?.name !== "File Url") {
491
+ acc = acc + (field === null || field === void 0 ? void 0 : field.name);
492
+ if (field !== null && field !== void 0 && field.separator) {
493
+ acc = acc + (field === null || field === void 0 ? void 0 : field.separator);
494
+ }
495
+ // }
496
+ }
497
+
498
+ return acc;
499
+ }, "");
500
+ return value;
501
+ };
502
+ return /*#__PURE__*/_react.default.createElement(_antd.Drawer, {
503
+ width: 650,
504
+ open: true,
505
+ onClose: () => {
506
+ setCurrentUpdatingId(null);
507
+ setShowCreateOrEditAsset(false);
508
+ },
509
+ className: "create-asset-page",
510
+ title: `${id ? "Update" : "Create"} Asset Type`,
511
+ maskClosable: false,
512
+ style: {
513
+ "--color": styles === null || styles === void 0 ? void 0 : styles.primaryColor
514
+ }
515
+ }, fetchRecordLoading ? /*#__PURE__*/_react.default.createElement("div", {
516
+ className: "dam-loading"
517
+ }, /*#__PURE__*/_react.default.createElement(_antd.Spin, null)) : /*#__PURE__*/_react.default.createElement(_antd.Form, {
518
+ layout: "vertical",
519
+ className: "form",
520
+ form: form,
521
+ onFinish: onFinish,
522
+ onFieldsChange: onFieldsChange
523
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
524
+ label: "Name",
525
+ name: "name",
526
+ rules: [{
527
+ required: true,
528
+ message: "Name is required"
529
+ }]
530
+ }, /*#__PURE__*/_react.default.createElement(_antd.Input, {
531
+ style: {
532
+ width: "100%"
533
+ },
534
+ placeholder: "Name"
535
+ })), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
536
+ label: "Sort Metadata Fields"
537
+ }, /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.DragDropContext, {
538
+ onDragEnd: onDragEnd
539
+ }, /*#__PURE__*/_react.default.createElement(_antd.Table, {
540
+ dataSource: dataSource,
541
+ columns: columns,
542
+ pagination: false,
543
+ rowKey: "key",
544
+ components: {
545
+ body: {
546
+ // Custom tbody
547
+ wrapper: val => DroppableTableBody({
548
+ ...val
549
+ }),
550
+ // Custom td
551
+ row: val => DraggableTableRow({
552
+ tasks: dataSource,
553
+ ...val
554
+ })
555
+ }
556
+ }
557
+ }))), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
558
+ label: "Image Picker Output format"
559
+ }, /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.DragDropContext, {
560
+ onDragEnd: onOutputFormatDragEnd
561
+ }, /*#__PURE__*/_react.default.createElement(_antd.Table, {
562
+ dataSource: outputFormatData,
563
+ columns: outputFormatColumns,
564
+ pagination: false,
565
+ rowKey: "key",
566
+ components: {
567
+ body: {
568
+ // Custom tbody
569
+ wrapper: val => DroppableTableBody({
570
+ ...val
571
+ }),
572
+ // Custom td
573
+ row: val => DraggableOutputFormatTableRow({
574
+ tasks: outputFormatData,
575
+ ...val
576
+ })
577
+ }
578
+ }
579
+ })), /*#__PURE__*/_react.default.createElement("div", {
580
+ style: {
581
+ marginTop: "10px"
582
+ }
583
+ }, /*#__PURE__*/_react.default.createElement(_antd.Typography.Text, {
584
+ style: {
585
+ color: "gray"
586
+ }
587
+ }, "Sample: ", getFormattedValue(outputFormatData)))), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
588
+ label: "Metadata Fields",
589
+ name: "metadata_fields",
590
+ rules: [{
591
+ required: true,
592
+ message: "Metadata is required"
593
+ }]
594
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.List, {
595
+ name: "metadata_fields"
596
+ }, (fields, _ref11) => {
597
+ let {
598
+ add,
599
+ remove
600
+ } = _ref11;
601
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, fields.map((_ref12, index) => {
602
+ var _data$index2, _data$index3, _data$index4, _data$index5;
603
+ let {
604
+ key,
605
+ name,
606
+ ...restField
607
+ } = _ref12;
608
+ const fieldKey = key + 1;
609
+ return /*#__PURE__*/_react.default.createElement(_antd.Row, {
610
+ className: "metadata-field-container"
611
+ }, /*#__PURE__*/_react.default.createElement(_antd.Col, {
612
+ span: 22
613
+ }, /*#__PURE__*/_react.default.createElement("div", {
614
+ className: "metadata-field"
615
+ }, /*#__PURE__*/_react.default.createElement(_antd.Row, null, /*#__PURE__*/_react.default.createElement(_antd.Col, {
616
+ span: 12
617
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
618
+ name: [name, "name"],
619
+ label: "Label",
620
+ rules: [{
621
+ required: true,
622
+ message: "Label is required"
623
+ }, () => ({
624
+ validator(_, value) {
625
+ if (!value || !(0, _lodash.includes)(reservedWords, value)) {
626
+ const filteredName = dataSource === null || dataSource === void 0 ? void 0 : dataSource.find(label => {
627
+ var _label$name;
628
+ return (label === null || label === void 0 ? void 0 : (_label$name = label.name) === null || _label$name === void 0 ? void 0 : _label$name.trim()) === (value === null || value === void 0 ? void 0 : value.trim()) && (label === null || label === void 0 ? void 0 : label.key) != key + 1;
629
+ });
630
+ if (!filteredName) {
631
+ return Promise.resolve();
632
+ } else {
633
+ return Promise.reject(new Error("This Metadata Field already exists"));
634
+ }
635
+ }
636
+ return Promise.reject(new Error("This is a reserved word"));
637
+ }
638
+ })]
639
+ }), /*#__PURE__*/_react.default.createElement(_antd.Input, {
640
+ placeholder: "Label",
641
+ style: {
642
+ width: "100%"
643
+ }
644
+ }))), /*#__PURE__*/_react.default.createElement(_antd.Col, {
645
+ span: 11,
646
+ push: 1
647
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
648
+ name: [name, "type"],
649
+ label: "Type",
650
+ rules: [{
651
+ required: true,
652
+ message: "Type is required"
653
+ }]
654
+ }), /*#__PURE__*/_react.default.createElement(_antd.Select, {
655
+ placeholder: "Type",
656
+ options: _appConstants.METADATA_DROPDOWN_OPTIONS === null || _appConstants.METADATA_DROPDOWN_OPTIONS === void 0 ? void 0 : _appConstants.METADATA_DROPDOWN_OPTIONS.map(option => {
657
+ var _data$index;
658
+ if ((option === null || option === void 0 ? void 0 : option.value) === "DATE" && id && data !== null && data !== void 0 && data[index] && !(data !== null && data !== void 0 && (_data$index = data[index]) !== null && _data$index !== void 0 && _data$index.isNew)) {
659
+ return {
660
+ ...option,
661
+ disabled: true
662
+ };
663
+ } else {
664
+ return option;
665
+ }
666
+ }),
667
+ style: {
668
+ width: "100%"
669
+ },
670
+ onChange: e => onChangeType(index, e),
671
+ disabled: id && (data === null || data === void 0 ? void 0 : (_data$index2 = data[index]) === null || _data$index2 === void 0 ? void 0 : _data$index2.type) == "DATE" && !(data !== null && data !== void 0 && (_data$index3 = data[index]) !== null && _data$index3 !== void 0 && _data$index3.isNew) ? true : false
672
+ })))), /*#__PURE__*/_react.default.createElement(_antd.Row, null, /*#__PURE__*/_react.default.createElement(_antd.Col, {
673
+ span: 12
674
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
675
+ name: [name, "default_value"],
676
+ label: "Default Value",
677
+ extra: (data === null || data === void 0 ? void 0 : (_data$index4 = data[index]) === null || _data$index4 === void 0 ? void 0 : _data$index4.type) == "DATE" ? "Date should be of type yyyy-mm-dd" : "",
678
+ rules: [() => ({
679
+ validator(_, value) {
680
+ const metadata = form.getFieldValue("metadata_fields");
681
+ const currentMetadataField = metadata === null || metadata === void 0 ? void 0 : metadata.find((field, fieldIndex) => fieldIndex == index);
682
+ if (currentMetadataField && (0, _lodash.includes)(optionsSupportedTypes, currentMetadataField === null || currentMetadataField === void 0 ? void 0 : currentMetadataField.type)) {
683
+ var _currentMetadataField, _currentMetadataField2;
684
+ const optionValues = (currentMetadataField === null || currentMetadataField === void 0 ? void 0 : (_currentMetadataField = currentMetadataField.options) === null || _currentMetadataField === void 0 ? void 0 : _currentMetadataField.length) > 0 ? currentMetadataField === null || currentMetadataField === void 0 ? void 0 : (_currentMetadataField2 = currentMetadataField.options) === null || _currentMetadataField2 === void 0 ? void 0 : _currentMetadataField2.map(option => {
685
+ return option === null || option === void 0 ? void 0 : option.value;
686
+ }) : [];
687
+ if (value && !(0, _lodash.includes)(optionValues, value)) {
688
+ return Promise.reject(new Error("Value should exists in options value"));
689
+ } else {
690
+ return Promise.resolve();
691
+ }
692
+ }
693
+ return Promise.resolve();
694
+ }
695
+ })]
696
+ }), /*#__PURE__*/_react.default.createElement(_antd.Input, {
697
+ placeholder: "Default Value"
698
+ }))), /*#__PURE__*/_react.default.createElement(_antd.Col, {
699
+ span: 11,
700
+ push: 1
701
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
702
+ name: [name, "display_order"],
703
+ label: "Display Order",
704
+ rules: [{
705
+ required: true,
706
+ message: "Display Order is required"
707
+ }]
708
+ }), /*#__PURE__*/_react.default.createElement(_antd.Input, {
709
+ placeholder: "Display Order",
710
+ style: {
711
+ width: "100%"
712
+ }
713
+ })))), /*#__PURE__*/_react.default.createElement(_antd.Row, null, /*#__PURE__*/_react.default.createElement(_antd.Col, {
714
+ span: 12
715
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
716
+ name: [name, "is_mandatory"],
717
+ valuePropName: "checked"
718
+ }), /*#__PURE__*/_react.default.createElement(_antd.Checkbox, null, "Is Mandatory")))), (0, _lodash.includes)(optionsSupportedTypes, data === null || data === void 0 ? void 0 : (_data$index5 = data[index]) === null || _data$index5 === void 0 ? void 0 : _data$index5.type) && /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
719
+ name: [name, "options"],
720
+ label: "Options",
721
+ rules: [{
722
+ required: true,
723
+ message: "Options is required"
724
+ }]
725
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.List, Object.assign({}, restField, {
726
+ name: [name, "options"]
727
+ }), (options, _ref13) => {
728
+ let {
729
+ add,
730
+ remove
731
+ } = _ref13;
732
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, options.map(_ref14 => {
733
+ let {
734
+ key,
735
+ name,
736
+ ...restField
737
+ } = _ref14;
738
+ return /*#__PURE__*/_react.default.createElement(_antd.Row, {
739
+ style: {
740
+ display: "flex"
741
+ }
742
+ }, /*#__PURE__*/_react.default.createElement(_antd.Col, {
743
+ span: 10
744
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
745
+ name: [name, "label"],
746
+ rules: [{
747
+ required: true,
748
+ message: "Label is required"
749
+ }]
750
+ }), /*#__PURE__*/_react.default.createElement(_antd.Input, {
751
+ placeholder: "Label",
752
+ style: {
753
+ width: "100%"
754
+ }
755
+ }))), /*#__PURE__*/_react.default.createElement(_antd.Col, {
756
+ span: 10,
757
+ push: 1
758
+ }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, Object.assign({}, restField, {
759
+ name: [name, "value"],
760
+ rules: [{
761
+ required: true,
762
+ message: "Missing Value"
763
+ }, () => ({
764
+ validator(_, value) {
765
+ var _currentField$options;
766
+ const currentField = dataSource === null || dataSource === void 0 ? void 0 : dataSource.find(field => (field === null || field === void 0 ? void 0 : field.key) == fieldKey);
767
+ const filteredOption = currentField === null || currentField === void 0 ? void 0 : (_currentField$options = currentField.options) === null || _currentField$options === void 0 ? void 0 : _currentField$options.find((label, index) => {
768
+ var _label$value;
769
+ return (label === null || label === void 0 ? void 0 : (_label$value = label.value) === null || _label$value === void 0 ? void 0 : _label$value.trim()) === (value === null || value === void 0 ? void 0 : value.trim()) && index != key;
770
+ });
771
+ if (!filteredOption) {
772
+ return Promise.resolve();
773
+ } else {
774
+ return Promise.reject(new Error("This Value already exists"));
775
+ }
776
+ }
777
+ })]
778
+ }), /*#__PURE__*/_react.default.createElement(_antd.Input, {
779
+ placeholder: "Value",
780
+ style: {
781
+ width: "100%"
782
+ }
783
+ }))), /*#__PURE__*/_react.default.createElement(_antd.Col, {
784
+ span: 2,
785
+ push: 2
786
+ }, /*#__PURE__*/_react.default.createElement(_icons.MinusCircleOutlined, {
787
+ onClick: () => remove(name)
788
+ })));
789
+ }), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, null, /*#__PURE__*/_react.default.createElement(_antd.Button, {
790
+ type: "dashed",
791
+ onClick: () => add(),
792
+ block: true,
793
+ icon: /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null)
794
+ }, "Add Option")));
795
+ })))), /*#__PURE__*/_react.default.createElement(_antd.Col, {
796
+ span: 2
797
+ }, /*#__PURE__*/_react.default.createElement(_icons.MinusCircleOutlined, {
798
+ style: {
799
+ marginLeft: "10px"
800
+ },
801
+ onClick: () => remove(name)
802
+ })));
803
+ }), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, null, /*#__PURE__*/_react.default.createElement(_antd.Button, {
804
+ type: "dashed",
805
+ onClick: () => {
806
+ add();
807
+ const currentMetadata = form.getFieldValue("metadata_fields");
808
+ form.setFieldValue("metadata_fields", currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.map(function () {
809
+ let field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
810
+ let index = arguments.length > 1 ? arguments[1] : undefined;
811
+ return {
812
+ ...field,
813
+ display_order: index + 1
814
+ };
815
+ }));
816
+ },
817
+ block: true,
818
+ icon: /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null)
819
+ }, "Add field")));
820
+ })), /*#__PURE__*/_react.default.createElement(_antd.Button, {
821
+ type: "primary",
822
+ block: true,
823
+ style: {
824
+ marginLeft: "auto",
825
+ backgroundColor: styles === null || styles === void 0 ? void 0 : styles.primaryColor
826
+ },
827
+ htmlType: "submit",
828
+ loading: loading
829
+ }, "Submit")));
830
+ };
831
+ var _default = CreateAssetType;
832
+ exports.default = _default;