blixify-ui-web 0.1.78 → 0.1.80
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/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +370 -280
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +3 -3
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/display/table/index.d.ts +2 -1
- package/lib/components/display/table/index.d.ts.map +1 -1
- package/lib/components/display/table/index.js +5 -3
- package/lib/components/display/table/index.js.map +1 -1
- package/lib/components/input/uploadInput/index.d.ts +26 -8
- package/lib/components/input/uploadInput/index.d.ts.map +1 -1
- package/lib/components/input/uploadInput/index.js +182 -28
- package/lib/components/input/uploadInput/index.js.map +1 -1
- package/lib/components/navigation/bars/index.d.ts +11 -1
- package/lib/components/navigation/bars/index.d.ts.map +1 -1
- package/lib/components/navigation/bars/index.js +66 -10
- package/lib/components/navigation/bars/index.js.map +1 -1
- package/lib/components/navigation/leftNav/index.d.ts +2 -0
- package/lib/components/navigation/leftNav/index.d.ts.map +1 -1
- package/lib/components/navigation/leftNav/index.js +4 -1
- package/lib/components/navigation/leftNav/index.js.map +1 -1
- package/lib/components/navigation/tabs/index.d.ts +10 -0
- package/lib/components/navigation/tabs/index.d.ts.map +1 -1
- package/lib/components/navigation/tabs/index.js +54 -5
- package/lib/components/navigation/tabs/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -58,6 +69,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
58
69
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
70
|
}
|
|
60
71
|
};
|
|
72
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
+
if (ar || !(i in from)) {
|
|
75
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
+
ar[i] = from[i];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
+
};
|
|
61
81
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
82
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
83
|
};
|
|
@@ -314,7 +334,7 @@ function DataTemplate(props) {
|
|
|
314
334
|
//SECTION: Handle Reference
|
|
315
335
|
//=====================================================================================
|
|
316
336
|
var handleRetrieveObjectReferenceOptions = function (eachModel, referencesOptions, selectedData, prefix, listObject, searchText) { return __awaiter(_this, void 0, void 0, function () {
|
|
317
|
-
var optionList_1, referenceRQ_1, selectionRes, selectedDataValue, currentRes_1, queryValue, res, modelId, err_1;
|
|
337
|
+
var optionList_1, referenceRQ_1, selectionRes, selectedDataValue, currentRes_1, unknownRes, queryValue, res, modelId, err_1;
|
|
318
338
|
var _this = this;
|
|
319
339
|
var _a, _b;
|
|
320
340
|
return __generator(this, function (_c) {
|
|
@@ -346,6 +366,7 @@ function DataTemplate(props) {
|
|
|
346
366
|
else
|
|
347
367
|
selectedDataValue = selectedData[eachModel.id];
|
|
348
368
|
currentRes_1 = [];
|
|
369
|
+
unknownRes = [];
|
|
349
370
|
if (!(selectedData && selectedDataValue)) return [3 /*break*/, 5];
|
|
350
371
|
if (!(listObject && Array.isArray(selectedDataValue))) return [3 /*break*/, 3];
|
|
351
372
|
return [4 /*yield*/, Promise.all(selectedDataValue.map(function (eachData) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -381,7 +402,12 @@ function DataTemplate(props) {
|
|
|
381
402
|
})];
|
|
382
403
|
case 4:
|
|
383
404
|
res = _c.sent();
|
|
384
|
-
|
|
405
|
+
if ((res === null || res === void 0 ? void 0 : res.data.length) > 0) {
|
|
406
|
+
currentRes_1 = res === null || res === void 0 ? void 0 : res.data;
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
unknownRes.push.apply(unknownRes, queryValue);
|
|
410
|
+
}
|
|
385
411
|
_c.label = 5;
|
|
386
412
|
case 5:
|
|
387
413
|
if (selectionRes === null || selectionRes === void 0 ? void 0 : selectionRes.data) {
|
|
@@ -412,6 +438,15 @@ function DataTemplate(props) {
|
|
|
412
438
|
return null;
|
|
413
439
|
});
|
|
414
440
|
}
|
|
441
|
+
if (unknownRes) {
|
|
442
|
+
unknownRes.map(function (eachData) {
|
|
443
|
+
optionList_1.push({
|
|
444
|
+
key: eachData,
|
|
445
|
+
label: eachData,
|
|
446
|
+
});
|
|
447
|
+
return null;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
415
450
|
modelId = prefix ? "".concat(prefix, ".").concat(eachModel.id) : eachModel.id;
|
|
416
451
|
referencesOptions[modelId] = optionList_1;
|
|
417
452
|
return [3 /*break*/, 7];
|
|
@@ -665,207 +700,232 @@ function DataTemplate(props) {
|
|
|
665
700
|
}
|
|
666
701
|
});
|
|
667
702
|
}); };
|
|
668
|
-
var
|
|
669
|
-
var clonedSelectedData,
|
|
703
|
+
var handleUploadImage = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
704
|
+
var clonedSelectedData, objectAttribute, listObjectAttribute;
|
|
670
705
|
var _this = this;
|
|
671
|
-
return __generator(this, function (
|
|
672
|
-
switch (
|
|
673
|
-
case 0:
|
|
706
|
+
return __generator(this, function (_a) {
|
|
707
|
+
switch (_a.label) {
|
|
708
|
+
case 0:
|
|
709
|
+
clonedSelectedData = handleClonedDataAttribute(selectedData, props.model, true);
|
|
710
|
+
//INFO: Parse & Upload Data "Image & File attributes"
|
|
711
|
+
return [4 /*yield*/, handleParseImageField(id, clonedSelectedData, props.model)];
|
|
674
712
|
case 1:
|
|
675
|
-
|
|
676
|
-
|
|
713
|
+
//INFO: Parse & Upload Data "Image & File attributes"
|
|
714
|
+
_a.sent();
|
|
677
715
|
objectAttribute = props.model.filter(function (eachAttribute) {
|
|
678
716
|
return eachAttribute.type === "object";
|
|
679
717
|
});
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
718
|
+
return [4 /*yield*/, Promise.all(objectAttribute.map(function (eachObject) { return __awaiter(_this, void 0, void 0, function () {
|
|
719
|
+
var _a;
|
|
720
|
+
return __generator(this, function (_b) {
|
|
721
|
+
switch (_b.label) {
|
|
722
|
+
case 0: return [4 /*yield*/, handleParseImageField(id, clonedSelectedData, (_a = eachObject.objectData) !== null && _a !== void 0 ? _a : [], eachObject.id)];
|
|
723
|
+
case 1:
|
|
724
|
+
_b.sent();
|
|
725
|
+
return [2 /*return*/, null];
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}); }))];
|
|
729
|
+
case 2:
|
|
730
|
+
_a.sent();
|
|
731
|
+
listObjectAttribute = props.model.filter(function (eachAttribute) {
|
|
732
|
+
return eachAttribute.type === "listObject";
|
|
688
733
|
});
|
|
689
|
-
|
|
734
|
+
return [4 /*yield*/, Promise.all(listObjectAttribute.map(function (eachObject) { return __awaiter(_this, void 0, void 0, function () {
|
|
735
|
+
var _a;
|
|
736
|
+
return __generator(this, function (_b) {
|
|
737
|
+
switch (_b.label) {
|
|
738
|
+
case 0: return [4 /*yield*/, handleParseImageField(id, clonedSelectedData, (_a = eachObject.objectData) !== null && _a !== void 0 ? _a : [], eachObject.id, true)];
|
|
739
|
+
case 1:
|
|
740
|
+
_b.sent();
|
|
741
|
+
return [2 /*return*/, null];
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
}); }))];
|
|
745
|
+
case 3:
|
|
746
|
+
_a.sent();
|
|
747
|
+
return [2 /*return*/, clonedSelectedData];
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}); };
|
|
751
|
+
/**
|
|
752
|
+
*
|
|
753
|
+
* INFO: Image Endpoint
|
|
754
|
+
* Image - imageColl/dataId/file.png
|
|
755
|
+
* Object - imageColl/dataId/attributeId/file.png
|
|
756
|
+
* List Object - imageColl/dataId/attributeId/itemId/file.png
|
|
757
|
+
*
|
|
758
|
+
* Multi Image - imageColl/dataId/token${imageFileExtension} - Applies to the same to object & listObject
|
|
759
|
+
*/
|
|
760
|
+
var handleParseImageField = function (dataId, selectedData, model, objectId, listObject) { return __awaiter(_this, void 0, void 0, function () {
|
|
761
|
+
var uploadAsset_1, removeAsset_1, imageAttribute, multiImageAttribute, err_4;
|
|
762
|
+
var _this = this;
|
|
763
|
+
return __generator(this, function (_a) {
|
|
764
|
+
switch (_a.label) {
|
|
765
|
+
case 0:
|
|
766
|
+
_a.trys.push([0, 3, , 4]);
|
|
767
|
+
uploadAsset_1 = function (eachImage, selectedField, listObjectId, multiple) { return __awaiter(_this, void 0, void 0, function () {
|
|
768
|
+
var uploadedData_1, imageCollectionName, imageParentId, responseData, err_5;
|
|
769
|
+
var _this = this;
|
|
770
|
+
var _a, _b, _c;
|
|
690
771
|
return __generator(this, function (_d) {
|
|
691
772
|
switch (_d.label) {
|
|
692
773
|
case 0:
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
774
|
+
_d.trys.push([0, 6, , 7]);
|
|
775
|
+
if (!(typeof selectedField === "string")) return [3 /*break*/, 1];
|
|
776
|
+
return [2 /*return*/];
|
|
777
|
+
case 1:
|
|
778
|
+
if (!(multiple &&
|
|
779
|
+
selectedField["upload"] &&
|
|
780
|
+
Array.isArray(selectedField["upload"]))) return [3 /*break*/, 3];
|
|
781
|
+
uploadedData_1 = [];
|
|
782
|
+
return [4 /*yield*/, Promise.all(selectedField["upload"].map(function (eachField) { return __awaiter(_this, void 0, void 0, function () {
|
|
783
|
+
var imageCollectionName, imageParentId, fileName, responseData;
|
|
696
784
|
var _a, _b;
|
|
697
785
|
return __generator(this, function (_c) {
|
|
698
786
|
switch (_c.label) {
|
|
699
787
|
case 0:
|
|
700
|
-
|
|
701
|
-
|
|
788
|
+
imageCollectionName = (_a = eachImage.imageCollectionName) !== null && _a !== void 0 ? _a : "";
|
|
789
|
+
if (objectId) {
|
|
790
|
+
imageCollectionName += "/".concat(dataId);
|
|
791
|
+
}
|
|
792
|
+
imageParentId = objectId ? objectId : dataId;
|
|
793
|
+
if (listObjectId) {
|
|
794
|
+
imageParentId += "/".concat(listObjectId);
|
|
795
|
+
}
|
|
796
|
+
fileName = (0, uuid_1.v4)() + eachImage.imageFileName;
|
|
797
|
+
return [4 /*yield*/, handleUploadAxios((_b = eachImage.imageEndpoint) !== null && _b !== void 0 ? _b : "", imageParentId, imageCollectionName, fileName, eachField.fileName)];
|
|
702
798
|
case 1:
|
|
703
|
-
if (!(selectedData[eachKey][eachImage.id] instanceof File)) return [3 /*break*/, 3];
|
|
704
|
-
return [4 /*yield*/, handleUploadAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", eachKey, eachImage.imageCollectionName + "/" + id, (_b = eachImage.imageFileName) !== null && _b !== void 0 ? _b : "", selectedData[eachKey][eachImage.id])];
|
|
705
|
-
case 2:
|
|
706
799
|
responseData = _c.sent();
|
|
707
|
-
if (responseData.data)
|
|
708
|
-
|
|
709
|
-
responseData.data.data
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
800
|
+
if (responseData.data)
|
|
801
|
+
uploadedData_1.push({
|
|
802
|
+
token: responseData.data.data,
|
|
803
|
+
fileName: fileName,
|
|
804
|
+
});
|
|
805
|
+
return [2 /*return*/, null];
|
|
713
806
|
}
|
|
714
807
|
});
|
|
715
808
|
}); }))];
|
|
716
|
-
case
|
|
809
|
+
case 2:
|
|
717
810
|
_d.sent();
|
|
718
|
-
|
|
719
|
-
case
|
|
811
|
+
return [2 /*return*/, selectedField["data"].concat(uploadedData_1)];
|
|
812
|
+
case 3:
|
|
813
|
+
if (!(selectedField instanceof File)) return [3 /*break*/, 5];
|
|
814
|
+
imageCollectionName = (_a = eachImage.imageCollectionName) !== null && _a !== void 0 ? _a : "";
|
|
815
|
+
if (objectId) {
|
|
816
|
+
imageCollectionName += "/".concat(dataId);
|
|
817
|
+
}
|
|
818
|
+
imageParentId = objectId ? objectId : dataId;
|
|
819
|
+
if (listObjectId) {
|
|
820
|
+
imageParentId += "/".concat(listObjectId);
|
|
821
|
+
}
|
|
822
|
+
return [4 /*yield*/, handleUploadAxios((_b = eachImage.imageEndpoint) !== null && _b !== void 0 ? _b : "", imageParentId, imageCollectionName, (_c = eachImage.imageFileName) !== null && _c !== void 0 ? _c : "", selectedField)];
|
|
823
|
+
case 4:
|
|
824
|
+
responseData = _d.sent();
|
|
825
|
+
if (responseData.data)
|
|
826
|
+
selectedField = responseData.data.data;
|
|
827
|
+
_d.label = 5;
|
|
828
|
+
case 5: return [3 /*break*/, 7];
|
|
829
|
+
case 6:
|
|
830
|
+
err_5 = _d.sent();
|
|
831
|
+
return [3 /*break*/, 7];
|
|
832
|
+
case 7: return [2 /*return*/];
|
|
720
833
|
}
|
|
721
834
|
});
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
switch (_c.label) {
|
|
744
|
-
case 0:
|
|
745
|
-
clonedSelectedData = handleClonedDataAttribute(selectedData, props.model, true);
|
|
746
|
-
uploadObjectAttribute = {};
|
|
747
|
-
objectAttribute = props.model.filter(function (eachAttribute) {
|
|
748
|
-
return eachAttribute.type === "listObject";
|
|
749
|
-
});
|
|
750
|
-
if (!(objectAttribute.length > 0)) return [3 /*break*/, 4];
|
|
751
|
-
objectAttribute.map(function (eachObject) {
|
|
752
|
-
var _a;
|
|
753
|
-
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
754
|
-
return (eachAttribute.type === "image" || eachAttribute.type === "file");
|
|
755
|
-
});
|
|
756
|
-
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
757
|
-
return null;
|
|
758
|
-
});
|
|
759
|
-
_loop_2 = function (eachKey, eachValue) {
|
|
760
|
-
return __generator(this, function (_d) {
|
|
761
|
-
switch (_d.label) {
|
|
762
|
-
case 0:
|
|
763
|
-
if (!(clonedSelectedData[eachKey] &&
|
|
764
|
-
Array.isArray(clonedSelectedData[eachKey]))) return [3 /*break*/, 2];
|
|
765
|
-
if (!Array.isArray(eachValue)) return [3 /*break*/, 2];
|
|
766
|
-
return [4 /*yield*/, Promise.all(eachValue.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
767
|
-
var _this = this;
|
|
768
|
-
return __generator(this, function (_a) {
|
|
769
|
-
switch (_a.label) {
|
|
770
|
-
case 0:
|
|
771
|
-
//INFO : Only upload if this is a File Blob
|
|
772
|
-
return [4 /*yield*/, Promise.all(clonedSelectedData[eachKey].map(function (eachData, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
773
|
-
var objectId, responseData;
|
|
774
|
-
var _a, _b, _c;
|
|
775
|
-
return __generator(this, function (_d) {
|
|
776
|
-
switch (_d.label) {
|
|
777
|
-
case 0:
|
|
778
|
-
if (!(typeof eachData[eachImage.id] === "string")) return [3 /*break*/, 1];
|
|
779
|
-
return [2 /*return*/];
|
|
780
|
-
case 1:
|
|
781
|
-
if (!(eachData[eachImage.id] instanceof File)) return [3 /*break*/, 3];
|
|
782
|
-
objectId = (_a = eachData["id"]) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
783
|
-
return [4 /*yield*/, handleUploadAxios((_b = eachImage.imageEndpoint) !== null && _b !== void 0 ? _b : "", eachKey, eachImage.imageCollectionName +
|
|
784
|
-
"/" +
|
|
785
|
-
id +
|
|
786
|
-
"/" +
|
|
787
|
-
objectId, (_c = eachImage.imageFileName) !== null && _c !== void 0 ? _c : "", eachData[eachImage.id])];
|
|
788
|
-
case 2:
|
|
789
|
-
responseData = _d.sent();
|
|
790
|
-
if (responseData.data) {
|
|
791
|
-
eachData[eachImage.id] = responseData.data.data;
|
|
792
|
-
clonedSelectedData[eachKey][index] = eachData;
|
|
793
|
-
}
|
|
794
|
-
_d.label = 3;
|
|
795
|
-
case 3: return [2 /*return*/, null];
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
}); }))];
|
|
799
|
-
case 1:
|
|
800
|
-
//INFO : Only upload if this is a File Blob
|
|
801
|
-
_a.sent();
|
|
802
|
-
return [2 /*return*/, null];
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
}); }))];
|
|
835
|
+
}); };
|
|
836
|
+
removeAsset_1 = function (eachImage, selectedField) { return __awaiter(_this, void 0, void 0, function () {
|
|
837
|
+
var _this = this;
|
|
838
|
+
return __generator(this, function (_a) {
|
|
839
|
+
switch (_a.label) {
|
|
840
|
+
case 0: return [4 /*yield*/, Promise.all(selectedField["remove"].map(function (eachField) { return __awaiter(_this, void 0, void 0, function () {
|
|
841
|
+
var startIndex, endIndex, imageFileName;
|
|
842
|
+
var _a, _b, _c;
|
|
843
|
+
return __generator(this, function (_d) {
|
|
844
|
+
switch (_d.label) {
|
|
845
|
+
case 0:
|
|
846
|
+
startIndex = eachField.fileName.lastIndexOf("%2F") + 3;
|
|
847
|
+
endIndex = eachField.fileName.indexOf("?alt=media&token=");
|
|
848
|
+
imageFileName = eachField.fileName.substring(startIndex, endIndex);
|
|
849
|
+
return [4 /*yield*/, handleRemoveImageAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", (_b = props.id) !== null && _b !== void 0 ? _b : "", (_c = eachImage.imageCollectionName) !== null && _c !== void 0 ? _c : "", imageFileName)];
|
|
850
|
+
case 1:
|
|
851
|
+
_d.sent();
|
|
852
|
+
return [2 /*return*/];
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}); }))];
|
|
806
856
|
case 1:
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
case 2: return [2 /*return*/];
|
|
857
|
+
_a.sent();
|
|
858
|
+
return [2 /*return*/];
|
|
810
859
|
}
|
|
811
860
|
});
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
_c.label = 1;
|
|
815
|
-
case 1:
|
|
816
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
817
|
-
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
818
|
-
return [5 /*yield**/, _loop_2(eachKey, eachValue)];
|
|
819
|
-
case 2:
|
|
820
|
-
_c.sent();
|
|
821
|
-
_c.label = 3;
|
|
822
|
-
case 3:
|
|
823
|
-
_i++;
|
|
824
|
-
return [3 /*break*/, 1];
|
|
825
|
-
case 4: return [2 /*return*/, clonedSelectedData];
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
}); };
|
|
829
|
-
var handleUploadImage = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
830
|
-
var clonedSelectedData, imageAttribute;
|
|
831
|
-
var _this = this;
|
|
832
|
-
return __generator(this, function (_a) {
|
|
833
|
-
switch (_a.label) {
|
|
834
|
-
case 0: return [4 /*yield*/, handleUploadObjectImage(id)];
|
|
835
|
-
case 1:
|
|
836
|
-
clonedSelectedData = _a.sent();
|
|
837
|
-
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
861
|
+
}); };
|
|
862
|
+
imageAttribute = model.filter(function (eachAttribute) {
|
|
838
863
|
return eachAttribute.type === "image" || eachAttribute.type === "file";
|
|
839
864
|
});
|
|
840
865
|
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
switch (_d.label) {
|
|
866
|
+
var selectedField;
|
|
867
|
+
return __generator(this, function (_a) {
|
|
868
|
+
switch (_a.label) {
|
|
845
869
|
case 0:
|
|
846
|
-
if (!
|
|
847
|
-
|
|
870
|
+
if (!listObject) return [3 /*break*/, 3];
|
|
871
|
+
if (!objectId)
|
|
872
|
+
return [2 /*return*/];
|
|
873
|
+
if (!Array.isArray(selectedData[objectId])) return [3 /*break*/, 2];
|
|
874
|
+
return [4 /*yield*/, Promise.all(selectedData[objectId].map(function (eachListItem, index) {
|
|
875
|
+
var _a;
|
|
876
|
+
var selectedField = selectedData[objectId][index][eachImage.id];
|
|
877
|
+
var selectedObjectId = (_a = eachListItem.id) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
878
|
+
uploadAsset_1(eachImage, selectedField, selectedObjectId);
|
|
879
|
+
return null;
|
|
880
|
+
}))];
|
|
848
881
|
case 1:
|
|
849
|
-
|
|
850
|
-
|
|
882
|
+
_a.sent();
|
|
883
|
+
_a.label = 2;
|
|
884
|
+
case 2: return [3 /*break*/, 4];
|
|
885
|
+
case 3:
|
|
886
|
+
selectedField = objectId
|
|
887
|
+
? selectedData[objectId][eachImage.id]
|
|
888
|
+
: selectedData[eachImage.id];
|
|
889
|
+
uploadAsset_1(eachImage, selectedField);
|
|
890
|
+
_a.label = 4;
|
|
891
|
+
case 4: return [2 /*return*/, null];
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
}); }))];
|
|
895
|
+
case 1:
|
|
896
|
+
_a.sent();
|
|
897
|
+
multiImageAttribute = model.filter(function (eachAttribute) {
|
|
898
|
+
return (eachAttribute.type === "multipleImage" ||
|
|
899
|
+
eachAttribute.type === "multipleFile");
|
|
900
|
+
});
|
|
901
|
+
return [4 /*yield*/, Promise.all(multiImageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
902
|
+
var _a, _b;
|
|
903
|
+
return __generator(this, function (_c) {
|
|
904
|
+
switch (_c.label) {
|
|
905
|
+
case 0: return [4 /*yield*/, removeAsset_1(eachImage, selectedData[eachImage.id])];
|
|
906
|
+
case 1:
|
|
907
|
+
_c.sent();
|
|
908
|
+
_a = selectedData;
|
|
909
|
+
_b = eachImage.id;
|
|
910
|
+
return [4 /*yield*/, uploadAsset_1(eachImage, selectedData[eachImage.id], "", true)];
|
|
851
911
|
case 2:
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
clonedSelectedData[eachImage.id] = responseData.data.data;
|
|
855
|
-
}
|
|
856
|
-
_d.label = 3;
|
|
857
|
-
case 3: return [2 /*return*/, null];
|
|
912
|
+
_a[_b] = _c.sent();
|
|
913
|
+
return [2 /*return*/, null];
|
|
858
914
|
}
|
|
859
915
|
});
|
|
860
916
|
}); }))];
|
|
861
917
|
case 2:
|
|
862
918
|
_a.sent();
|
|
863
|
-
return [2 /*return*/,
|
|
919
|
+
return [2 /*return*/, selectedData];
|
|
920
|
+
case 3:
|
|
921
|
+
err_4 = _a.sent();
|
|
922
|
+
return [3 /*break*/, 4];
|
|
923
|
+
case 4: return [2 /*return*/];
|
|
864
924
|
}
|
|
865
925
|
});
|
|
866
926
|
}); };
|
|
867
927
|
var handleRemoveImageAxios = function (imageEndpoint, assetParentId, assetCollectionName, assetFileName) { return __awaiter(_this, void 0, void 0, function () {
|
|
868
|
-
var
|
|
928
|
+
var err_6;
|
|
869
929
|
var _a, _b;
|
|
870
930
|
return __generator(this, function (_c) {
|
|
871
931
|
switch (_c.label) {
|
|
@@ -886,93 +946,32 @@ function DataTemplate(props) {
|
|
|
886
946
|
_c.sent();
|
|
887
947
|
return [3 /*break*/, 3];
|
|
888
948
|
case 2:
|
|
889
|
-
|
|
949
|
+
err_6 = _c.sent();
|
|
890
950
|
return [3 /*break*/, 3];
|
|
891
951
|
case 3: return [2 /*return*/];
|
|
892
952
|
}
|
|
893
953
|
});
|
|
894
954
|
}); };
|
|
895
955
|
var handleRemoveImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
896
|
-
var
|
|
897
|
-
var
|
|
898
|
-
return __generator(this, function (
|
|
899
|
-
switch (
|
|
900
|
-
case 0:
|
|
901
|
-
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
902
|
-
return eachAttribute.type === "image" || eachAttribute.type === "file";
|
|
903
|
-
});
|
|
904
|
-
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
905
|
-
var _a, _b, _c, _d;
|
|
906
|
-
return __generator(this, function (_e) {
|
|
907
|
-
switch (_e.label) {
|
|
908
|
-
case 0: return [4 /*yield*/, handleRemoveImageAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", (_b = props.id) !== null && _b !== void 0 ? _b : "", (_c = eachImage.imageCollectionName) !== null && _c !== void 0 ? _c : "", (_d = eachImage.imageFileName) !== null && _d !== void 0 ? _d : "")];
|
|
909
|
-
case 1:
|
|
910
|
-
_e.sent();
|
|
911
|
-
return [2 /*return*/];
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
}); }))];
|
|
915
|
-
case 1:
|
|
916
|
-
_a.sent();
|
|
917
|
-
return [2 /*return*/];
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
}); };
|
|
921
|
-
var handleRemoveObjectImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
922
|
-
var uploadObjectAttribute, objectAttribute, _loop_3, _i, _a, _b, eachKey, eachValue;
|
|
923
|
-
var _this = this;
|
|
924
|
-
return __generator(this, function (_c) {
|
|
925
|
-
switch (_c.label) {
|
|
956
|
+
var err_7;
|
|
957
|
+
var _a;
|
|
958
|
+
return __generator(this, function (_b) {
|
|
959
|
+
switch (_b.label) {
|
|
926
960
|
case 0:
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
935
|
-
return (eachAttribute.type === "image" || eachAttribute.type === "file");
|
|
936
|
-
});
|
|
937
|
-
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
938
|
-
return null;
|
|
939
|
-
});
|
|
940
|
-
_loop_3 = function (eachKey, eachValue) {
|
|
941
|
-
return __generator(this, function (_d) {
|
|
942
|
-
switch (_d.label) {
|
|
943
|
-
case 0:
|
|
944
|
-
if (!Array.isArray(eachValue)) return [3 /*break*/, 2];
|
|
945
|
-
return [4 /*yield*/, Promise.all(eachValue.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
946
|
-
var _a, _b, _c;
|
|
947
|
-
return __generator(this, function (_d) {
|
|
948
|
-
switch (_d.label) {
|
|
949
|
-
case 0: return [4 /*yield*/, handleRemoveImageAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", eachKey !== null && eachKey !== void 0 ? eachKey : "", (_b = eachImage.imageCollectionName + "/" + props.id) !== null && _b !== void 0 ? _b : "", (_c = eachImage.imageFileName) !== null && _c !== void 0 ? _c : "")];
|
|
950
|
-
case 1:
|
|
951
|
-
_d.sent();
|
|
952
|
-
return [2 /*return*/, null];
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
}); }))];
|
|
956
|
-
case 1:
|
|
957
|
-
_d.sent();
|
|
958
|
-
_d.label = 2;
|
|
959
|
-
case 2: return [2 /*return*/];
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
_i = 0, _a = Object.entries(uploadObjectAttribute);
|
|
964
|
-
_c.label = 1;
|
|
961
|
+
_b.trys.push([0, 2, , 3]);
|
|
962
|
+
return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((props === null || props === void 0 ? void 0 : props.imageEndpoint) + "/deleteDirectory", {
|
|
963
|
+
data: {
|
|
964
|
+
assetCollectionName: props.collectionId,
|
|
965
|
+
assetParentId: props.id,
|
|
966
|
+
},
|
|
967
|
+
}))];
|
|
965
968
|
case 1:
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
return [5 /*yield**/, _loop_3(eachKey, eachValue)];
|
|
969
|
+
_b.sent();
|
|
970
|
+
return [3 /*break*/, 3];
|
|
969
971
|
case 2:
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
case 3:
|
|
973
|
-
_i++;
|
|
974
|
-
return [3 /*break*/, 1];
|
|
975
|
-
case 4: return [2 /*return*/];
|
|
972
|
+
err_7 = _b.sent();
|
|
973
|
+
return [3 /*break*/, 3];
|
|
974
|
+
case 3: return [2 /*return*/];
|
|
976
975
|
}
|
|
977
976
|
});
|
|
978
977
|
}); };
|
|
@@ -980,42 +979,39 @@ function DataTemplate(props) {
|
|
|
980
979
|
//SECTION: Handle CRUD
|
|
981
980
|
//=====================================================================================
|
|
982
981
|
var handleRemoveSelectedData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
983
|
-
var selectedId, res,
|
|
982
|
+
var selectedId, res, err_8;
|
|
984
983
|
return __generator(this, function (_a) {
|
|
985
984
|
switch (_a.label) {
|
|
986
985
|
case 0:
|
|
987
|
-
_a.trys.push([0,
|
|
986
|
+
_a.trys.push([0, 4, , 5]);
|
|
988
987
|
selectedId = props.id;
|
|
989
|
-
if (!selectedId) return [3 /*break*/,
|
|
988
|
+
if (!selectedId) return [3 /*break*/, 3];
|
|
990
989
|
setLoading(true);
|
|
991
990
|
setDeleteModal(true);
|
|
992
991
|
return [4 /*yield*/, handleRemoveImage()];
|
|
993
992
|
case 1:
|
|
994
|
-
_a.sent();
|
|
995
|
-
return [4 /*yield*/, handleRemoveObjectImage()];
|
|
996
|
-
case 2:
|
|
997
993
|
_a.sent();
|
|
998
994
|
return [4 /*yield*/, writeServerQuery.call("delete", { id: selectedId })];
|
|
999
|
-
case
|
|
995
|
+
case 2:
|
|
1000
996
|
res = _a.sent();
|
|
1001
997
|
setModalVisible(false);
|
|
1002
998
|
setLoading(false);
|
|
1003
999
|
if (res) {
|
|
1004
1000
|
handleNavigate("".concat(props.localURLEndpoint, "?type=list&collection=").concat(props.collectionId, "&data=r"));
|
|
1005
1001
|
}
|
|
1006
|
-
_a.label =
|
|
1007
|
-
case
|
|
1008
|
-
case
|
|
1009
|
-
|
|
1002
|
+
_a.label = 3;
|
|
1003
|
+
case 3: return [3 /*break*/, 5];
|
|
1004
|
+
case 4:
|
|
1005
|
+
err_8 = _a.sent();
|
|
1010
1006
|
setDeleteModal(false);
|
|
1011
1007
|
setLoading(false);
|
|
1012
|
-
return [3 /*break*/,
|
|
1013
|
-
case
|
|
1008
|
+
return [3 /*break*/, 5];
|
|
1009
|
+
case 5: return [2 /*return*/];
|
|
1014
1010
|
}
|
|
1015
1011
|
});
|
|
1016
1012
|
}); };
|
|
1017
1013
|
var handleSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1018
|
-
var selectedId, id, createSelectedData, res,
|
|
1014
|
+
var selectedId, id, createSelectedData, res, err_9;
|
|
1019
1015
|
var _a;
|
|
1020
1016
|
return __generator(this, function (_b) {
|
|
1021
1017
|
switch (_b.label) {
|
|
@@ -1059,7 +1055,7 @@ function DataTemplate(props) {
|
|
|
1059
1055
|
}
|
|
1060
1056
|
return [3 /*break*/, 7];
|
|
1061
1057
|
case 6:
|
|
1062
|
-
|
|
1058
|
+
err_9 = _b.sent();
|
|
1063
1059
|
setModalVisible(false);
|
|
1064
1060
|
setLoading(false);
|
|
1065
1061
|
return [3 /*break*/, 7];
|
|
@@ -1137,6 +1133,26 @@ function DataTemplate(props) {
|
|
|
1137
1133
|
case "file":
|
|
1138
1134
|
clonedSelectedData[eachAttribute.id] = defaultValue[eachAttribute.id];
|
|
1139
1135
|
break;
|
|
1136
|
+
case "multipleImage":
|
|
1137
|
+
case "multipleFile":
|
|
1138
|
+
if (Array.isArray(clonedSelectedData[eachAttribute.id])) {
|
|
1139
|
+
clonedSelectedData[eachAttribute.id] = {
|
|
1140
|
+
data: defaultValue[eachAttribute.id],
|
|
1141
|
+
upload: [],
|
|
1142
|
+
remove: [],
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
else if (clonedSelectedData[eachAttribute.id] instanceof Object) {
|
|
1146
|
+
clonedSelectedData[eachAttribute.id] =
|
|
1147
|
+
defaultValue[eachAttribute.id];
|
|
1148
|
+
}
|
|
1149
|
+
else
|
|
1150
|
+
clonedSelectedData[eachAttribute.id] = {
|
|
1151
|
+
data: [],
|
|
1152
|
+
upload: [],
|
|
1153
|
+
remove: [],
|
|
1154
|
+
};
|
|
1155
|
+
break;
|
|
1140
1156
|
case "number":
|
|
1141
1157
|
if (defaultValue[eachAttribute.id]) {
|
|
1142
1158
|
clonedSelectedData[eachAttribute.id] = Number(defaultValue[eachAttribute.id]);
|
|
@@ -1184,6 +1200,35 @@ function DataTemplate(props) {
|
|
|
1184
1200
|
e.target.files.length > 0 ? e.target.files[0] : undefined;
|
|
1185
1201
|
handleUpdateChangeData(clonedData);
|
|
1186
1202
|
};
|
|
1203
|
+
var handleOnChangeFiles = function (id, value, action) {
|
|
1204
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
1205
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
1206
|
+
var previousData = clonedData[id] && clonedData[id]["data"] ? clonedData[id]["data"] : [];
|
|
1207
|
+
var previousUploadData = clonedData[id] && clonedData[id]["upload"]
|
|
1208
|
+
? clonedData[id]["upload"]
|
|
1209
|
+
: [];
|
|
1210
|
+
var previousRemoveData = clonedData[id] && clonedData[id]["remove"]
|
|
1211
|
+
? clonedData[id]["remove"]
|
|
1212
|
+
: [];
|
|
1213
|
+
if (action === "upload") {
|
|
1214
|
+
clonedData[id] = __assign(__assign({}, clonedData[id]), { upload: __spreadArray(__spreadArray([], value, true), previousUploadData, true) });
|
|
1215
|
+
}
|
|
1216
|
+
else {
|
|
1217
|
+
if (previousData.some(function (file) {
|
|
1218
|
+
return file.token === value.token;
|
|
1219
|
+
})) {
|
|
1220
|
+
clonedData[id] = __assign(__assign({}, clonedData[id]), { data: previousData.filter(function (file) {
|
|
1221
|
+
return file.token !== value.token;
|
|
1222
|
+
}), remove: __spreadArray(__spreadArray([], previousRemoveData, true), [value], false) });
|
|
1223
|
+
}
|
|
1224
|
+
else {
|
|
1225
|
+
clonedData[id] = __assign(__assign({}, clonedData[id]), { upload: previousUploadData.filter(function (file) {
|
|
1226
|
+
return file.token !== value.token;
|
|
1227
|
+
}) });
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
handleUpdateChangeData(clonedData);
|
|
1231
|
+
};
|
|
1187
1232
|
var handleOnChangeAddress = function (id, address) {
|
|
1188
1233
|
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
1189
1234
|
var clonedData = handleClonedDataAttribute(data, model);
|
|
@@ -1220,17 +1265,37 @@ function DataTemplate(props) {
|
|
|
1220
1265
|
header: true,
|
|
1221
1266
|
dynamicTyping: true,
|
|
1222
1267
|
complete: function (results) {
|
|
1223
|
-
|
|
1268
|
+
var fileSize = file.size / 1024 / 1024;
|
|
1269
|
+
if (results.data && fileSize < 25) {
|
|
1224
1270
|
setCSVFileData(results.data);
|
|
1271
|
+
var prefilledCSVMapAttribute_1 = {};
|
|
1272
|
+
Object.entries(results.data[0]).map(function (eachRow, index) {
|
|
1273
|
+
var eachKey = eachRow[0];
|
|
1274
|
+
if (!eachKey)
|
|
1275
|
+
return null;
|
|
1276
|
+
props.model.map(function (eachModel) {
|
|
1277
|
+
if (eachKey.toLowerCase().includes(eachModel.id) &&
|
|
1278
|
+
eachModel.id !== "_id" &&
|
|
1279
|
+
eachModel.id !== "id" &&
|
|
1280
|
+
eachModel.type !== "object" &&
|
|
1281
|
+
eachModel.type !== "listObject") {
|
|
1282
|
+
prefilledCSVMapAttribute_1[index] = eachModel.id;
|
|
1283
|
+
}
|
|
1284
|
+
return null;
|
|
1285
|
+
});
|
|
1286
|
+
return null;
|
|
1287
|
+
});
|
|
1288
|
+
setListCSVMapAttribute(prefilledCSVMapAttribute_1);
|
|
1289
|
+
setStepCSVIndex(1);
|
|
1290
|
+
}
|
|
1225
1291
|
else
|
|
1226
1292
|
setNotification({
|
|
1227
1293
|
type: false,
|
|
1228
1294
|
title: "Import Error",
|
|
1229
|
-
msg: "Data is more than
|
|
1295
|
+
msg: "Data file size is more than 25 MB",
|
|
1230
1296
|
});
|
|
1231
1297
|
},
|
|
1232
1298
|
});
|
|
1233
|
-
setStepCSVIndex(1);
|
|
1234
1299
|
}
|
|
1235
1300
|
else {
|
|
1236
1301
|
setNotification({
|
|
@@ -1241,7 +1306,7 @@ function DataTemplate(props) {
|
|
|
1241
1306
|
}
|
|
1242
1307
|
};
|
|
1243
1308
|
var handleStepCSV = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1244
|
-
var csvList_1,
|
|
1309
|
+
var csvList_1, _loop_1, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, response, err_10;
|
|
1245
1310
|
var _c, _d, _e, _f, _g;
|
|
1246
1311
|
return __generator(this, function (_h) {
|
|
1247
1312
|
switch (_h.label) {
|
|
@@ -1256,7 +1321,7 @@ function DataTemplate(props) {
|
|
|
1256
1321
|
case 1:
|
|
1257
1322
|
if (!(stepCSVIndex === 1)) return [3 /*break*/, 3];
|
|
1258
1323
|
csvList_1 = [];
|
|
1259
|
-
|
|
1324
|
+
_loop_1 = function (eachKey, eachValue) {
|
|
1260
1325
|
if (eachKey && eachValue && typeof eachValue === "string") {
|
|
1261
1326
|
var selectedModel = props.model.find(function (eachModel) {
|
|
1262
1327
|
return eachModel.id === eachValue;
|
|
@@ -1274,11 +1339,14 @@ function DataTemplate(props) {
|
|
|
1274
1339
|
objectValueType: (_e = selectedObjectModel === null || selectedObjectModel === void 0 ? void 0 : selectedObjectModel.type) !== null && _e !== void 0 ? _e : "string",
|
|
1275
1340
|
});
|
|
1276
1341
|
}
|
|
1277
|
-
else if ((selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type) === "image"
|
|
1342
|
+
else if ((selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type) === "image" ||
|
|
1343
|
+
(selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type) === "file" ||
|
|
1344
|
+
(selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type) === "multipleFile" ||
|
|
1345
|
+
(selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type) === "multipleImage") {
|
|
1278
1346
|
csvList_1.push({
|
|
1279
1347
|
id: eachValue !== null && eachValue !== void 0 ? eachValue : "",
|
|
1280
1348
|
ori: Number(eachKey),
|
|
1281
|
-
type:
|
|
1349
|
+
type: selectedModel === null || selectedModel === void 0 ? void 0 : selectedModel.type,
|
|
1282
1350
|
imageCollectionName: selectedModel.imageCollectionName,
|
|
1283
1351
|
imageFileName: selectedModel.imageFileName,
|
|
1284
1352
|
imageEndpoint: selectedModel.imageEndpoint,
|
|
@@ -1295,7 +1363,7 @@ function DataTemplate(props) {
|
|
|
1295
1363
|
};
|
|
1296
1364
|
for (_i = 0, _a = Object.entries(listCSVMapAttribute); _i < _a.length; _i++) {
|
|
1297
1365
|
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
1298
|
-
|
|
1366
|
+
_loop_1(eachKey, eachValue);
|
|
1299
1367
|
}
|
|
1300
1368
|
valid_1 = true;
|
|
1301
1369
|
errorValue_1 = "";
|
|
@@ -1363,11 +1431,11 @@ function DataTemplate(props) {
|
|
|
1363
1431
|
_h.label = 5;
|
|
1364
1432
|
case 5: return [3 /*break*/, 7];
|
|
1365
1433
|
case 6:
|
|
1366
|
-
|
|
1434
|
+
err_10 = _h.sent();
|
|
1367
1435
|
setNotification({
|
|
1368
1436
|
type: false,
|
|
1369
1437
|
title: "Import Error",
|
|
1370
|
-
msg:
|
|
1438
|
+
msg: err_10.message,
|
|
1371
1439
|
});
|
|
1372
1440
|
return [3 /*break*/, 7];
|
|
1373
1441
|
case 7: return [2 /*return*/];
|
|
@@ -1375,7 +1443,7 @@ function DataTemplate(props) {
|
|
|
1375
1443
|
});
|
|
1376
1444
|
}); };
|
|
1377
1445
|
var handleExportCSVData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1378
|
-
var res,
|
|
1446
|
+
var res, err_11;
|
|
1379
1447
|
var _a, _b, _c;
|
|
1380
1448
|
return __generator(this, function (_d) {
|
|
1381
1449
|
switch (_d.label) {
|
|
@@ -1400,7 +1468,7 @@ function DataTemplate(props) {
|
|
|
1400
1468
|
setLoading(false);
|
|
1401
1469
|
return [3 /*break*/, 3];
|
|
1402
1470
|
case 2:
|
|
1403
|
-
|
|
1471
|
+
err_11 = _d.sent();
|
|
1404
1472
|
setLoading(false);
|
|
1405
1473
|
return [3 /*break*/, 3];
|
|
1406
1474
|
case 3: return [2 /*return*/];
|
|
@@ -1528,9 +1596,10 @@ function DataTemplate(props) {
|
|
|
1528
1596
|
return dataList;
|
|
1529
1597
|
};
|
|
1530
1598
|
var renderStepCSV = function () {
|
|
1599
|
+
var _a;
|
|
1531
1600
|
switch (stepCSVIndex) {
|
|
1532
1601
|
case 0:
|
|
1533
|
-
return (react_2.default.createElement(uploadInput_1.UploadInput, { label: "Please insert a csv file", fileDescription: "CSV file thats doesn't exceeds 30MB and row not more than 100 data", accept: ".csv", hidePreview: true, onChange: handleOnChangeCSV }));
|
|
1602
|
+
return (react_2.default.createElement(uploadInput_1.UploadInput, { lib: { axios: (_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios }, label: "Please insert a csv file", fileDescription: "CSV file thats doesn't exceeds 30MB and row not more than 100 data", accept: ".csv", hidePreview: true, onChange: handleOnChangeCSV }));
|
|
1534
1603
|
case 1:
|
|
1535
1604
|
var filterOptions_1 = [];
|
|
1536
1605
|
props.model.map(function (eachData) {
|
|
@@ -1545,6 +1614,8 @@ function DataTemplate(props) {
|
|
|
1545
1614
|
});
|
|
1546
1615
|
return (react_2.default.createElement(react_2.default.Fragment, null, csvFileData.length > 0 && (react_2.default.createElement("div", { className: "pb-32" }, Object.entries(csvFileData[0]).map(function (eachRow, index) {
|
|
1547
1616
|
var eachKey = eachRow[0];
|
|
1617
|
+
if (!eachKey)
|
|
1618
|
+
return null;
|
|
1548
1619
|
var clonedListValue = JSON.parse(JSON.stringify(listCSVMapAttribute));
|
|
1549
1620
|
var selectedObjectModel = props.model.find(function (eachModel) {
|
|
1550
1621
|
return ((eachModel.id === clonedListValue[index] &&
|
|
@@ -1741,7 +1812,7 @@ function DataTemplate(props) {
|
|
|
1741
1812
|
});
|
|
1742
1813
|
filteredModel.forEach(function (eachAttribute, index) {
|
|
1743
1814
|
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1744
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1815
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1745
1816
|
var clonedSelectedData = handleClonedDataAttribute(data, model);
|
|
1746
1817
|
var label = eachAttribute.name + (!eachAttribute.optional ? " (*)" : "");
|
|
1747
1818
|
var disabled = props.type === "read"
|
|
@@ -1825,17 +1896,36 @@ function DataTemplate(props) {
|
|
|
1825
1896
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName + "%2F" + props.id, selectedObjectStructureId, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id])
|
|
1826
1897
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id]);
|
|
1827
1898
|
}
|
|
1828
|
-
inputList.push(react_2.default.createElement(uploadInput_1.UploadInput, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: label, hidePreview: eachAttribute.type === "image" ? false : true, file: (
|
|
1899
|
+
inputList.push(react_2.default.createElement(uploadInput_1.UploadInput, { lib: { axios: (_f = props.lib) === null || _f === void 0 ? void 0 : _f.axios }, ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: label, hidePreview: eachAttribute.type === "image" ? false : true, file: (_g = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _g !== void 0 ? _g : "", accept: eachAttribute.type === "image" ? ".png,.jpg,.jpe,.tiff" : ".pdf", fileDescription: eachAttribute.type === "image" ? undefined : "PDF up to 30MB", maxFileSize: props.maxFileSize, onChange: handleOnChangeFile, disabled: disabled }));
|
|
1900
|
+
break;
|
|
1901
|
+
case "multipleFile":
|
|
1902
|
+
case "multipleImage":
|
|
1903
|
+
var multipleDataUrl = clonedSelectedData[eachAttribute.id]["data"].map(function (eachImage) {
|
|
1904
|
+
return {
|
|
1905
|
+
token: eachImage.token,
|
|
1906
|
+
fileName: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachImage.fileName, eachImage.token),
|
|
1907
|
+
};
|
|
1908
|
+
});
|
|
1909
|
+
inputList.push(react_2.default.createElement(uploadInput_1.UploadInput, { type: "multi", files: __assign(__assign({}, clonedSelectedData[eachAttribute.id]), { data: multipleDataUrl }), ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: label, hidePreview: eachAttribute.type === "multipleImage" ? false : true, accept: eachAttribute.type === "multipleImage"
|
|
1910
|
+
? ".png,.jpg,.jpe,.tiff"
|
|
1911
|
+
: ".pdf", fileDescription: eachAttribute.type === "multipleImage"
|
|
1912
|
+
? undefined
|
|
1913
|
+
: "PDF up to 30MB", maxFileSize: props.maxFileSize, onChange: function (_a) {
|
|
1914
|
+
var value = _a.value, action = _a.action;
|
|
1915
|
+
handleOnChangeFiles(eachAttribute.id, value, action);
|
|
1916
|
+
}, lib: {
|
|
1917
|
+
axios: (_h = props.lib) === null || _h === void 0 ? void 0 : _h.axios,
|
|
1918
|
+
}, disabled: disabled }));
|
|
1829
1919
|
break;
|
|
1830
1920
|
case "number":
|
|
1831
|
-
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "number", value: (
|
|
1921
|
+
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "number", value: (_j = clonedSelectedData[eachAttribute.id]) !== null && _j !== void 0 ? _j : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled: disabled }));
|
|
1832
1922
|
break;
|
|
1833
1923
|
case "reference":
|
|
1834
1924
|
case "listReference":
|
|
1835
1925
|
inputList.push(react_2.default.createElement(react_2.default.Fragment, null,
|
|
1836
|
-
react_2.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (
|
|
1926
|
+
react_2.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_k = clonedSelectedData[eachAttribute.id]) !== null && _k !== void 0 ? _k : (eachAttribute.type === "reference" ? "" : []), label: label, options: isObject
|
|
1837
1927
|
? referencesOptions[selectedObjectStructureId + "." + eachAttribute.id]
|
|
1838
|
-
: (
|
|
1928
|
+
: (_l = referencesOptions[eachAttribute.id]) !== null && _l !== void 0 ? _l : [], onChange: function (value) {
|
|
1839
1929
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1840
1930
|
}, additional: referenceLoading ? exports.loadingSelect : exports.additionalSelect, onSearch: function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|
1841
1931
|
var clonedReferencesOptions, filterObjectModel;
|
|
@@ -1858,7 +1948,7 @@ function DataTemplate(props) {
|
|
|
1858
1948
|
}); }, disabled: disabled })));
|
|
1859
1949
|
break;
|
|
1860
1950
|
case "string":
|
|
1861
|
-
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (
|
|
1951
|
+
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (_m = clonedSelectedData[eachAttribute.id]) !== null && _m !== void 0 ? _m : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled: disabled }));
|
|
1862
1952
|
break;
|
|
1863
1953
|
case "date":
|
|
1864
1954
|
inputList.push(react_2.default.createElement(datePicker_1.InputDatePicker, { title: label, id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], onChange: handleOnChangeDate, value: clonedSelectedData[eachAttribute.id], disabled: disabled }));
|
|
@@ -1872,7 +1962,7 @@ function DataTemplate(props) {
|
|
|
1872
1962
|
var renderDetailListData = function () {
|
|
1873
1963
|
var _a;
|
|
1874
1964
|
var detailList = [];
|
|
1875
|
-
var
|
|
1965
|
+
var _loop_2 = function (eachKey, eachValue) {
|
|
1876
1966
|
if (eachKey !== "id" &&
|
|
1877
1967
|
eachKey !== "_id" &&
|
|
1878
1968
|
eachKey !== "baseUpdatedAt") {
|
|
@@ -1887,7 +1977,7 @@ function DataTemplate(props) {
|
|
|
1887
1977
|
};
|
|
1888
1978
|
for (var _i = 0, _b = Object.entries(selectedData); _i < _b.length; _i++) {
|
|
1889
1979
|
var _c = _b[_i], eachKey = _c[0], eachValue = _c[1];
|
|
1890
|
-
|
|
1980
|
+
_loop_2(eachKey, eachValue);
|
|
1891
1981
|
}
|
|
1892
1982
|
return detailList;
|
|
1893
1983
|
};
|
|
@@ -1905,7 +1995,7 @@ function DataTemplate(props) {
|
|
|
1905
1995
|
title: "",
|
|
1906
1996
|
};
|
|
1907
1997
|
var isTitle = true;
|
|
1908
|
-
var
|
|
1998
|
+
var _loop_3 = function (eachKey, eachValue) {
|
|
1909
1999
|
if (eachListObject.objectData) {
|
|
1910
2000
|
var model = eachListObject.objectData.find(function (eachAttribute) {
|
|
1911
2001
|
return eachAttribute.id === eachKey;
|
|
@@ -1955,7 +2045,7 @@ function DataTemplate(props) {
|
|
|
1955
2045
|
};
|
|
1956
2046
|
for (var _i = 0, _a = Object.entries(eachObject); _i < _a.length; _i++) {
|
|
1957
2047
|
var _b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
1958
|
-
|
|
2048
|
+
_loop_3(eachKey, eachValue);
|
|
1959
2049
|
}
|
|
1960
2050
|
if (list_2[eachListObject.id]) {
|
|
1961
2051
|
list_2[eachListObject.id].push(eachNewList);
|