blixify-ui-web 0.1.78 → 0.1.79
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 +340 -275
- 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/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
|
+
}))];
|
|
881
|
+
case 1:
|
|
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])];
|
|
848
906
|
case 1:
|
|
849
|
-
|
|
850
|
-
|
|
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);
|
|
@@ -1241,7 +1286,7 @@ function DataTemplate(props) {
|
|
|
1241
1286
|
}
|
|
1242
1287
|
};
|
|
1243
1288
|
var handleStepCSV = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1244
|
-
var csvList_1,
|
|
1289
|
+
var csvList_1, _loop_1, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, response, err_10;
|
|
1245
1290
|
var _c, _d, _e, _f, _g;
|
|
1246
1291
|
return __generator(this, function (_h) {
|
|
1247
1292
|
switch (_h.label) {
|
|
@@ -1256,7 +1301,7 @@ function DataTemplate(props) {
|
|
|
1256
1301
|
case 1:
|
|
1257
1302
|
if (!(stepCSVIndex === 1)) return [3 /*break*/, 3];
|
|
1258
1303
|
csvList_1 = [];
|
|
1259
|
-
|
|
1304
|
+
_loop_1 = function (eachKey, eachValue) {
|
|
1260
1305
|
if (eachKey && eachValue && typeof eachValue === "string") {
|
|
1261
1306
|
var selectedModel = props.model.find(function (eachModel) {
|
|
1262
1307
|
return eachModel.id === eachValue;
|
|
@@ -1295,7 +1340,7 @@ function DataTemplate(props) {
|
|
|
1295
1340
|
};
|
|
1296
1341
|
for (_i = 0, _a = Object.entries(listCSVMapAttribute); _i < _a.length; _i++) {
|
|
1297
1342
|
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
1298
|
-
|
|
1343
|
+
_loop_1(eachKey, eachValue);
|
|
1299
1344
|
}
|
|
1300
1345
|
valid_1 = true;
|
|
1301
1346
|
errorValue_1 = "";
|
|
@@ -1363,11 +1408,11 @@ function DataTemplate(props) {
|
|
|
1363
1408
|
_h.label = 5;
|
|
1364
1409
|
case 5: return [3 /*break*/, 7];
|
|
1365
1410
|
case 6:
|
|
1366
|
-
|
|
1411
|
+
err_10 = _h.sent();
|
|
1367
1412
|
setNotification({
|
|
1368
1413
|
type: false,
|
|
1369
1414
|
title: "Import Error",
|
|
1370
|
-
msg:
|
|
1415
|
+
msg: err_10.message,
|
|
1371
1416
|
});
|
|
1372
1417
|
return [3 /*break*/, 7];
|
|
1373
1418
|
case 7: return [2 /*return*/];
|
|
@@ -1375,7 +1420,7 @@ function DataTemplate(props) {
|
|
|
1375
1420
|
});
|
|
1376
1421
|
}); };
|
|
1377
1422
|
var handleExportCSVData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1378
|
-
var res,
|
|
1423
|
+
var res, err_11;
|
|
1379
1424
|
var _a, _b, _c;
|
|
1380
1425
|
return __generator(this, function (_d) {
|
|
1381
1426
|
switch (_d.label) {
|
|
@@ -1400,7 +1445,7 @@ function DataTemplate(props) {
|
|
|
1400
1445
|
setLoading(false);
|
|
1401
1446
|
return [3 /*break*/, 3];
|
|
1402
1447
|
case 2:
|
|
1403
|
-
|
|
1448
|
+
err_11 = _d.sent();
|
|
1404
1449
|
setLoading(false);
|
|
1405
1450
|
return [3 /*break*/, 3];
|
|
1406
1451
|
case 3: return [2 /*return*/];
|
|
@@ -1528,9 +1573,10 @@ function DataTemplate(props) {
|
|
|
1528
1573
|
return dataList;
|
|
1529
1574
|
};
|
|
1530
1575
|
var renderStepCSV = function () {
|
|
1576
|
+
var _a;
|
|
1531
1577
|
switch (stepCSVIndex) {
|
|
1532
1578
|
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 }));
|
|
1579
|
+
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
1580
|
case 1:
|
|
1535
1581
|
var filterOptions_1 = [];
|
|
1536
1582
|
props.model.map(function (eachData) {
|
|
@@ -1741,7 +1787,7 @@ function DataTemplate(props) {
|
|
|
1741
1787
|
});
|
|
1742
1788
|
filteredModel.forEach(function (eachAttribute, index) {
|
|
1743
1789
|
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1744
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1790
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1745
1791
|
var clonedSelectedData = handleClonedDataAttribute(data, model);
|
|
1746
1792
|
var label = eachAttribute.name + (!eachAttribute.optional ? " (*)" : "");
|
|
1747
1793
|
var disabled = props.type === "read"
|
|
@@ -1825,17 +1871,36 @@ function DataTemplate(props) {
|
|
|
1825
1871
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName + "%2F" + props.id, selectedObjectStructureId, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id])
|
|
1826
1872
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id]);
|
|
1827
1873
|
}
|
|
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: (
|
|
1874
|
+
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 }));
|
|
1875
|
+
break;
|
|
1876
|
+
case "multipleFile":
|
|
1877
|
+
case "multipleImage":
|
|
1878
|
+
var multipleDataUrl = clonedSelectedData[eachAttribute.id]["data"].map(function (eachImage) {
|
|
1879
|
+
return {
|
|
1880
|
+
token: eachImage.token,
|
|
1881
|
+
fileName: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachImage.fileName, eachImage.token),
|
|
1882
|
+
};
|
|
1883
|
+
});
|
|
1884
|
+
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"
|
|
1885
|
+
? ".png,.jpg,.jpe,.tiff"
|
|
1886
|
+
: ".pdf", fileDescription: eachAttribute.type === "multipleImage"
|
|
1887
|
+
? undefined
|
|
1888
|
+
: "PDF up to 30MB", maxFileSize: props.maxFileSize, onChange: function (_a) {
|
|
1889
|
+
var value = _a.value, action = _a.action;
|
|
1890
|
+
handleOnChangeFiles(eachAttribute.id, value, action);
|
|
1891
|
+
}, lib: {
|
|
1892
|
+
axios: (_h = props.lib) === null || _h === void 0 ? void 0 : _h.axios,
|
|
1893
|
+
}, disabled: disabled }));
|
|
1829
1894
|
break;
|
|
1830
1895
|
case "number":
|
|
1831
|
-
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "number", value: (
|
|
1896
|
+
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
1897
|
break;
|
|
1833
1898
|
case "reference":
|
|
1834
1899
|
case "listReference":
|
|
1835
1900
|
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: (
|
|
1901
|
+
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
1902
|
? referencesOptions[selectedObjectStructureId + "." + eachAttribute.id]
|
|
1838
|
-
: (
|
|
1903
|
+
: (_l = referencesOptions[eachAttribute.id]) !== null && _l !== void 0 ? _l : [], onChange: function (value) {
|
|
1839
1904
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1840
1905
|
}, additional: referenceLoading ? exports.loadingSelect : exports.additionalSelect, onSearch: function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|
1841
1906
|
var clonedReferencesOptions, filterObjectModel;
|
|
@@ -1858,7 +1923,7 @@ function DataTemplate(props) {
|
|
|
1858
1923
|
}); }, disabled: disabled })));
|
|
1859
1924
|
break;
|
|
1860
1925
|
case "string":
|
|
1861
|
-
inputList.push(react_2.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (
|
|
1926
|
+
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
1927
|
break;
|
|
1863
1928
|
case "date":
|
|
1864
1929
|
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 +1937,7 @@ function DataTemplate(props) {
|
|
|
1872
1937
|
var renderDetailListData = function () {
|
|
1873
1938
|
var _a;
|
|
1874
1939
|
var detailList = [];
|
|
1875
|
-
var
|
|
1940
|
+
var _loop_2 = function (eachKey, eachValue) {
|
|
1876
1941
|
if (eachKey !== "id" &&
|
|
1877
1942
|
eachKey !== "_id" &&
|
|
1878
1943
|
eachKey !== "baseUpdatedAt") {
|
|
@@ -1887,7 +1952,7 @@ function DataTemplate(props) {
|
|
|
1887
1952
|
};
|
|
1888
1953
|
for (var _i = 0, _b = Object.entries(selectedData); _i < _b.length; _i++) {
|
|
1889
1954
|
var _c = _b[_i], eachKey = _c[0], eachValue = _c[1];
|
|
1890
|
-
|
|
1955
|
+
_loop_2(eachKey, eachValue);
|
|
1891
1956
|
}
|
|
1892
1957
|
return detailList;
|
|
1893
1958
|
};
|
|
@@ -1905,7 +1970,7 @@ function DataTemplate(props) {
|
|
|
1905
1970
|
title: "",
|
|
1906
1971
|
};
|
|
1907
1972
|
var isTitle = true;
|
|
1908
|
-
var
|
|
1973
|
+
var _loop_3 = function (eachKey, eachValue) {
|
|
1909
1974
|
if (eachListObject.objectData) {
|
|
1910
1975
|
var model = eachListObject.objectData.find(function (eachAttribute) {
|
|
1911
1976
|
return eachAttribute.id === eachKey;
|
|
@@ -1955,7 +2020,7 @@ function DataTemplate(props) {
|
|
|
1955
2020
|
};
|
|
1956
2021
|
for (var _i = 0, _a = Object.entries(eachObject); _i < _a.length; _i++) {
|
|
1957
2022
|
var _b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
1958
|
-
|
|
2023
|
+
_loop_3(eachKey, eachValue);
|
|
1959
2024
|
}
|
|
1960
2025
|
if (list_2[eachListObject.id]) {
|
|
1961
2026
|
list_2[eachListObject.id].push(eachNewList);
|