@sd-angular/core 1.2.66 → 1.2.67
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/bundles/sd-angular-core-upload-excel.umd.js +34 -27
- package/bundles/sd-angular-core-upload-excel.umd.js.map +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.min.js +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.min.js.map +1 -1
- package/esm2015/upload-excel/src/lib/pipes/column-transform.pipe.js +10 -4
- package/esm2015/upload-excel/src/lib/upload-excel.component.js +21 -20
- package/fesm2015/sd-angular-core-upload-excel.js +29 -22
- package/fesm2015/sd-angular-core-upload-excel.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.2.66.tgz → sd-angular-core-1.2.67.tgz} +0 -0
|
@@ -542,14 +542,15 @@
|
|
|
542
542
|
item = excelItem.data, validation = excelItem.sd.validation;
|
|
543
543
|
translate = this.translateService.translate;
|
|
544
544
|
_loop_1 = function (column) {
|
|
545
|
-
var value, value, value, type, format, val, error, warning, ex_1;
|
|
545
|
+
var errors, value, value, value, type, format, val, error, warning, ex_1;
|
|
546
546
|
return __generator(this, function (_f) {
|
|
547
547
|
switch (_f.label) {
|
|
548
548
|
case 0:
|
|
549
|
+
validation.data[column.field] = {};
|
|
549
550
|
if (!this_1.sdColumnHidden.transform(column)) {
|
|
550
551
|
return [2 /*return*/, "continue"];
|
|
551
552
|
}
|
|
552
|
-
|
|
553
|
+
errors = [];
|
|
553
554
|
_f.label = 1;
|
|
554
555
|
case 1:
|
|
555
556
|
_f.trys.push([1, 6, , 7]);
|
|
@@ -558,19 +559,19 @@
|
|
|
558
559
|
}
|
|
559
560
|
else if (column.required && !item[column.field] && item[column.field] !== 0) {
|
|
560
561
|
validation.data[column.field].error = "" + translate('required');
|
|
561
|
-
|
|
562
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
562
563
|
return [2 /*return*/, "continue"];
|
|
563
564
|
}
|
|
564
565
|
if (column.type === 'string') {
|
|
565
566
|
value = (item[column.field] || '').toString();
|
|
566
567
|
if (column.minLength !== undefined && value.length < column.minLength) {
|
|
567
568
|
validation.data[column.field].error = translate('Min length') + ": " + column.minLength;
|
|
568
|
-
|
|
569
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
569
570
|
return [2 /*return*/, "continue"];
|
|
570
571
|
}
|
|
571
572
|
if (column.maxLength !== undefined && value.length > column.maxLength) {
|
|
572
573
|
validation.data[column.field].error = translate('Max length') + ": " + column.maxLength;
|
|
573
|
-
|
|
574
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
574
575
|
return [2 /*return*/, "continue"];
|
|
575
576
|
}
|
|
576
577
|
item[column.field] = value;
|
|
@@ -580,7 +581,7 @@
|
|
|
580
581
|
value = +item[column.field];
|
|
581
582
|
if (Number.isNaN(value)) {
|
|
582
583
|
validation.data[column.field].error = item[column.field] + " " + translate('is not a number');
|
|
583
|
-
|
|
584
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
584
585
|
return [2 /*return*/, "continue"];
|
|
585
586
|
}
|
|
586
587
|
item[column.field] = value;
|
|
@@ -590,12 +591,12 @@
|
|
|
590
591
|
}
|
|
591
592
|
if (column.minValue !== undefined && item[column.field] < column.minValue) {
|
|
592
593
|
validation.data[column.field].error = item[column.field] + " " + translate('Min value') + ": " + column.minValue;
|
|
593
|
-
|
|
594
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
594
595
|
return [2 /*return*/, "continue"];
|
|
595
596
|
}
|
|
596
597
|
if (column.maxValue !== undefined && item[column.field] > column.maxValue) {
|
|
597
598
|
validation.data[column.field].error = item[column.field] + " " + translate('Max value') + ": " + column.maxValue;
|
|
598
|
-
|
|
599
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
599
600
|
return [2 /*return*/, "continue"];
|
|
600
601
|
}
|
|
601
602
|
}
|
|
@@ -610,7 +611,7 @@
|
|
|
610
611
|
value = +item[column.field];
|
|
611
612
|
if (Number.isNaN(value) || (value !== 0 && value !== 1)) {
|
|
612
613
|
validation.data[column.field].error = "" + translate('Value shoud be 0 or 1');
|
|
613
|
-
|
|
614
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
614
615
|
}
|
|
615
616
|
else {
|
|
616
617
|
if (column.parseToBool) {
|
|
@@ -622,12 +623,12 @@
|
|
|
622
623
|
else if (column.type === 'values') {
|
|
623
624
|
if (item[column.field] && typeof (item[column.field]) !== 'number' && typeof (item[column.field]) !== 'string') {
|
|
624
625
|
validation.data[column.field].error = item[column.field] + " " + translate('Invalid data type');
|
|
625
|
-
|
|
626
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
626
627
|
return [2 /*return*/, "continue"];
|
|
627
628
|
}
|
|
628
629
|
if (column.checkValueInArray && item[column.field] && !column.values.some(function (e) { return e.toString() === item[column.field].toString(); })) {
|
|
629
630
|
validation.data[column.field].error = item[column.field] + " " + translate('Value not in') + " [" + column.values.join() + "]";
|
|
630
|
-
|
|
631
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
631
632
|
return [2 /*return*/, "continue"];
|
|
632
633
|
}
|
|
633
634
|
}
|
|
@@ -637,39 +638,39 @@
|
|
|
637
638
|
if (format && item[column.field]) {
|
|
638
639
|
if (typeof (val) !== 'string') {
|
|
639
640
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
640
|
-
|
|
641
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
641
642
|
return [2 /*return*/, "continue"];
|
|
642
643
|
}
|
|
643
644
|
if (type === 'date' && !__classPrivateFieldGet(this_1, _isValidDate).call(this_1, format, val)) {
|
|
644
645
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
645
|
-
|
|
646
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
646
647
|
return [2 /*return*/, "continue"];
|
|
647
648
|
}
|
|
648
649
|
if (type === 'time' && !__classPrivateFieldGet(this_1, _isValidTime).call(this_1, format, val)) {
|
|
649
650
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
650
|
-
|
|
651
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
651
652
|
return [2 /*return*/, "continue"];
|
|
652
653
|
}
|
|
653
654
|
if (type === 'datetime' && !__classPrivateFieldGet(this_1, _isValidDateTime).call(this_1, format, val)) {
|
|
654
655
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
655
|
-
|
|
656
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
656
657
|
return [2 /*return*/, "continue"];
|
|
657
658
|
}
|
|
658
659
|
item[column.field] = Date.parseFrom(val, column.format).toFormat('MM/dd/yyyy HH:mm:ss');
|
|
659
660
|
}
|
|
660
661
|
if (item[column.field] && !Date.isDate(item[column.field])) {
|
|
661
662
|
validation.data[column.field].error = translate('Invalid date') + ": " + item[column.field];
|
|
662
|
-
|
|
663
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
663
664
|
return [2 /*return*/, "continue"];
|
|
664
665
|
}
|
|
665
666
|
}
|
|
666
|
-
if (!(!
|
|
667
|
+
if (!(!errors.length && column.errorValidation)) return [3 /*break*/, 3];
|
|
667
668
|
return [4 /*yield*/, column.errorValidation(item, item[column.field])];
|
|
668
669
|
case 2:
|
|
669
670
|
error = _f.sent();
|
|
670
671
|
if (error) {
|
|
671
672
|
validation.data[column.field].error = "" + error;
|
|
672
|
-
|
|
673
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
673
674
|
}
|
|
674
675
|
_f.label = 3;
|
|
675
676
|
case 3:
|
|
@@ -686,9 +687,11 @@
|
|
|
686
687
|
case 6:
|
|
687
688
|
ex_1 = _f.sent();
|
|
688
689
|
validation.data[column.field].error = "" + ((ex_1 === null || ex_1 === void 0 ? void 0 : ex_1.message) || (ex_1 === null || ex_1 === void 0 ? void 0 : ex_1.error) || ex_1 || 'Có lỗi xảy ra');
|
|
689
|
-
|
|
690
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
690
691
|
return [3 /*break*/, 7];
|
|
691
|
-
case 7:
|
|
692
|
+
case 7:
|
|
693
|
+
validation.error = errors.join('<br>');
|
|
694
|
+
return [2 /*return*/];
|
|
692
695
|
}
|
|
693
696
|
});
|
|
694
697
|
};
|
|
@@ -719,9 +722,7 @@
|
|
|
719
722
|
}
|
|
720
723
|
finally { if (e_2) throw e_2.error; }
|
|
721
724
|
return [7 /*endfinally*/];
|
|
722
|
-
case 8:
|
|
723
|
-
item.validation = validation;
|
|
724
|
-
return [2 /*return*/];
|
|
725
|
+
case 8: return [2 /*return*/];
|
|
725
726
|
}
|
|
726
727
|
});
|
|
727
728
|
}); };
|
|
@@ -1019,17 +1020,17 @@
|
|
|
1019
1020
|
var _this = this;
|
|
1020
1021
|
this.decimalPipe = decimalPipe;
|
|
1021
1022
|
this.transform = function (rowData, column) { return __awaiter(_this, void 0, void 0, function () {
|
|
1022
|
-
var _a, _b, _c, _d, _e, value;
|
|
1023
|
-
return __generator(this, function (
|
|
1023
|
+
var _a, _b, _c, _d, _e, _f, value;
|
|
1024
|
+
return __generator(this, function (_g) {
|
|
1024
1025
|
value = rowData.data[column.field];
|
|
1025
1026
|
if ((_a = rowData.sd.validation.data[column.field]) === null || _a === void 0 ? void 0 : _a.error) {
|
|
1026
|
-
return [2 /*return*/, (
|
|
1027
|
+
return [2 /*return*/, (_c = (_b = rowData.sd.origin[column.field]) !== null && _b !== void 0 ? _b : value) !== null && _c !== void 0 ? _c : ''];
|
|
1027
1028
|
}
|
|
1028
1029
|
if (column === null || column === void 0 ? void 0 : column.transform) {
|
|
1029
1030
|
return [2 /*return*/, column.transform(value, rowData.data)];
|
|
1030
1031
|
}
|
|
1031
1032
|
if (column.type === 'number') {
|
|
1032
|
-
return [2 /*return*/, (
|
|
1033
|
+
return [2 /*return*/, (_d = Number.toVNCurrency(value)) !== null && _d !== void 0 ? _d : ''];
|
|
1033
1034
|
}
|
|
1034
1035
|
if (column.type === 'bool') {
|
|
1035
1036
|
if (value === '1' || value === true) {
|
|
@@ -1039,6 +1040,12 @@
|
|
|
1039
1040
|
return [2 /*return*/, "<div class=\"text-center\"><input type=\"checkbox\" disabled></div>"];
|
|
1040
1041
|
}
|
|
1041
1042
|
}
|
|
1043
|
+
if (column.type === 'date') {
|
|
1044
|
+
return [2 /*return*/, (_e = Date.toFormat(value, column.format || 'dd/MM/yyyy')) !== null && _e !== void 0 ? _e : ''];
|
|
1045
|
+
}
|
|
1046
|
+
if (column.type === 'datetime') {
|
|
1047
|
+
return [2 /*return*/, (_f = Date.toFormat(value, column.format || 'dd/MM/yyyy HH:mm')) !== null && _f !== void 0 ? _f : ''];
|
|
1048
|
+
}
|
|
1042
1049
|
return [2 /*return*/, value !== null && value !== void 0 ? value : ''];
|
|
1043
1050
|
});
|
|
1044
1051
|
}); };
|