@sd-angular/core 1.2.65 → 1.2.68
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-common.umd.js +1 -1
- package/bundles/sd-angular-core-common.umd.js.map +1 -1
- package/bundles/sd-angular-core-common.umd.min.js +1 -1
- package/bundles/sd-angular-core-common.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.js +65 -59
- 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/common/src/lib/typings/number.extension.js +2 -2
- package/esm2015/upload-excel/src/lib/pipes/column-transform.pipe.js +10 -4
- package/esm2015/upload-excel/src/lib/upload-excel.component.js +25 -31
- package/esm2015/upload-excel/src/lib/upload-excel.model.js +6 -1
- package/fesm2015/sd-angular-core-common.js +1 -1
- package/fesm2015/sd-angular-core-common.js.map +1 -1
- package/fesm2015/sd-angular-core-upload-excel.js +39 -33
- package/fesm2015/sd-angular-core-upload-excel.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.2.65.tgz → sd-angular-core-1.2.68.tgz} +0 -0
- package/upload-excel/sd-angular-core-upload-excel.metadata.json +1 -1
- package/upload-excel/src/lib/upload-excel.model.d.ts +2 -7
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
10
10
|
var XLSX__default = /*#__PURE__*/_interopDefaultLegacy(XLSX);
|
|
11
11
|
|
|
12
|
+
// export type ExcelItem<T> = {
|
|
13
|
+
// origin?: T;
|
|
14
|
+
// excelIndex?: number;
|
|
15
|
+
// validation: SdUploadExcelValidation;
|
|
16
|
+
// } & T;
|
|
17
|
+
|
|
12
18
|
/*! *****************************************************************************
|
|
13
19
|
Copyright (c) Microsoft Corporation.
|
|
14
20
|
|
|
@@ -417,24 +423,19 @@
|
|
|
417
423
|
_isWarning.set(this, function (item) { var _a, _b; return ((_a = item.sd.validation) === null || _a === void 0 ? void 0 : _a.warning) && !((_b = item.sd.validation) === null || _b === void 0 ? void 0 : _b.error); });
|
|
418
424
|
_isSuccess.set(this, function (item) { var _a, _b; return !((_a = item.sd.validation) === null || _a === void 0 ? void 0 : _a.error) && !((_b = item.sd.validation) === null || _b === void 0 ? void 0 : _b.warning); });
|
|
419
425
|
this.upload = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
420
|
-
var _f, mappingItems, errorValidation, warningValidation, translate, _g, items, file, offset, mappedItems, _h, _j, _k,
|
|
421
|
-
var e_1,
|
|
426
|
+
var _f, mappingItems, errorValidation, warningValidation, translate, _g, items, file, offset, mappedItems, _h, _j, _k, item, e_1_1, results, results, err_1;
|
|
427
|
+
var e_1, _l;
|
|
422
428
|
var _this = this;
|
|
423
|
-
return __generator(this, function (
|
|
424
|
-
switch (
|
|
429
|
+
return __generator(this, function (_m) {
|
|
430
|
+
switch (_m.label) {
|
|
425
431
|
case 0:
|
|
426
|
-
|
|
432
|
+
_m.trys.push([0, 17, 18, 19]);
|
|
427
433
|
_f = this.option, mappingItems = _f.mappingItems, errorValidation = _f.errorValidation, warningValidation = _f.warningValidation;
|
|
428
434
|
translate = this.translateService.translate;
|
|
429
435
|
return [4 /*yield*/, __classPrivateFieldGet(this, _import).call(this)];
|
|
430
436
|
case 1:
|
|
431
|
-
_g =
|
|
432
|
-
|
|
433
|
-
this.hasDescription = true;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
this.hasDescription = false;
|
|
437
|
-
}
|
|
437
|
+
_g = _m.sent(), items = _g.items, file = _g.file;
|
|
438
|
+
this.hasDescription = this.option.columns.some(function (e) { return !!e.description; });
|
|
438
439
|
offset = this.hasDescription ? 2 : 1;
|
|
439
440
|
items.splice(0, offset);
|
|
440
441
|
if (items.length === 0) {
|
|
@@ -467,37 +468,37 @@
|
|
|
467
468
|
_h = this;
|
|
468
469
|
return [4 /*yield*/, mappedItems.finally(function () { return _this.uploading = false; })];
|
|
469
470
|
case 2:
|
|
470
|
-
_h.items = (
|
|
471
|
+
_h.items = (_m.sent());
|
|
471
472
|
return [3 /*break*/, 4];
|
|
472
473
|
case 3:
|
|
473
474
|
this.items = (mappedItems || this.items);
|
|
474
|
-
|
|
475
|
+
_m.label = 4;
|
|
475
476
|
case 4:
|
|
476
477
|
this.file = file;
|
|
477
478
|
this.loadingService.start();
|
|
478
|
-
|
|
479
|
+
_m.label = 5;
|
|
479
480
|
case 5:
|
|
480
|
-
|
|
481
|
-
_j = __values(this.items
|
|
482
|
-
|
|
481
|
+
_m.trys.push([5, 10, 11, 12]);
|
|
482
|
+
_j = __values(this.items), _k = _j.next();
|
|
483
|
+
_m.label = 6;
|
|
483
484
|
case 6:
|
|
484
485
|
if (!!_k.done) return [3 /*break*/, 9];
|
|
485
|
-
|
|
486
|
+
item = _k.value;
|
|
486
487
|
return [4 /*yield*/, this.validate(item)];
|
|
487
488
|
case 7:
|
|
488
|
-
|
|
489
|
-
|
|
489
|
+
_m.sent();
|
|
490
|
+
_m.label = 8;
|
|
490
491
|
case 8:
|
|
491
492
|
_k = _j.next();
|
|
492
493
|
return [3 /*break*/, 6];
|
|
493
494
|
case 9: return [3 /*break*/, 12];
|
|
494
495
|
case 10:
|
|
495
|
-
e_1_1 =
|
|
496
|
+
e_1_1 = _m.sent();
|
|
496
497
|
e_1 = { error: e_1_1 };
|
|
497
498
|
return [3 /*break*/, 12];
|
|
498
499
|
case 11:
|
|
499
500
|
try {
|
|
500
|
-
if (_k && !_k.done && (
|
|
501
|
+
if (_k && !_k.done && (_l = _j.return)) _l.call(_j);
|
|
501
502
|
}
|
|
502
503
|
finally { if (e_1) throw e_1.error; }
|
|
503
504
|
return [7 /*endfinally*/];
|
|
@@ -505,16 +506,16 @@
|
|
|
505
506
|
if (!(!this.items.some(__classPrivateFieldGet(this, _isError)) && errorValidation)) return [3 /*break*/, 14];
|
|
506
507
|
return [4 /*yield*/, errorValidation(this.items.map(function (e) { return e.data; }))];
|
|
507
508
|
case 13:
|
|
508
|
-
results =
|
|
509
|
+
results = _m.sent();
|
|
509
510
|
results.forEach(function (result) { return _this.items[result.idx].sd.validation.error = result.message; });
|
|
510
|
-
|
|
511
|
+
_m.label = 14;
|
|
511
512
|
case 14:
|
|
512
513
|
if (!(!this.items.some(__classPrivateFieldGet(this, _isWarning)) && warningValidation)) return [3 /*break*/, 16];
|
|
513
514
|
return [4 /*yield*/, warningValidation(this.items.map(function (e) { return e.data; }))];
|
|
514
515
|
case 15:
|
|
515
|
-
results =
|
|
516
|
+
results = _m.sent();
|
|
516
517
|
results.forEach(function (result) { return _this.items[result.idx].sd.validation.warning = result.message; });
|
|
517
|
-
|
|
518
|
+
_m.label = 16;
|
|
518
519
|
case 16:
|
|
519
520
|
__classPrivateFieldGet(this, _paginator).pageIndex = 0;
|
|
520
521
|
__classPrivateFieldGet(this, _reload).call(this);
|
|
@@ -522,7 +523,7 @@
|
|
|
522
523
|
this.isUploaded = false;
|
|
523
524
|
return [3 /*break*/, 19];
|
|
524
525
|
case 17:
|
|
525
|
-
err_1 =
|
|
526
|
+
err_1 = _m.sent();
|
|
526
527
|
this.notifyService.handle.error(err_1);
|
|
527
528
|
return [3 /*break*/, 19];
|
|
528
529
|
case 18:
|
|
@@ -538,19 +539,18 @@
|
|
|
538
539
|
return __generator(this, function (_j) {
|
|
539
540
|
switch (_j.label) {
|
|
540
541
|
case 0:
|
|
541
|
-
excelItem.
|
|
542
|
-
item = excelItem.data;
|
|
543
|
-
validation = excelItem.sd.validation;
|
|
542
|
+
item = excelItem.data, validation = excelItem.sd.validation;
|
|
544
543
|
translate = this.translateService.translate;
|
|
545
544
|
_loop_1 = function (column) {
|
|
546
|
-
var value, value, value, type, format, val, error, warning, ex_1;
|
|
545
|
+
var errors, value, value, value, type, format, val, error, warning, ex_1;
|
|
547
546
|
return __generator(this, function (_f) {
|
|
548
547
|
switch (_f.label) {
|
|
549
548
|
case 0:
|
|
549
|
+
validation.data[column.field] = {};
|
|
550
550
|
if (!this_1.sdColumnHidden.transform(column)) {
|
|
551
551
|
return [2 /*return*/, "continue"];
|
|
552
552
|
}
|
|
553
|
-
|
|
553
|
+
errors = [];
|
|
554
554
|
_f.label = 1;
|
|
555
555
|
case 1:
|
|
556
556
|
_f.trys.push([1, 6, , 7]);
|
|
@@ -559,19 +559,19 @@
|
|
|
559
559
|
}
|
|
560
560
|
else if (column.required && !item[column.field] && item[column.field] !== 0) {
|
|
561
561
|
validation.data[column.field].error = "" + translate('required');
|
|
562
|
-
|
|
562
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
563
563
|
return [2 /*return*/, "continue"];
|
|
564
564
|
}
|
|
565
565
|
if (column.type === 'string') {
|
|
566
566
|
value = (item[column.field] || '').toString();
|
|
567
567
|
if (column.minLength !== undefined && value.length < column.minLength) {
|
|
568
568
|
validation.data[column.field].error = translate('Min length') + ": " + column.minLength;
|
|
569
|
-
|
|
569
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
570
570
|
return [2 /*return*/, "continue"];
|
|
571
571
|
}
|
|
572
572
|
if (column.maxLength !== undefined && value.length > column.maxLength) {
|
|
573
573
|
validation.data[column.field].error = translate('Max length') + ": " + column.maxLength;
|
|
574
|
-
|
|
574
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
575
575
|
return [2 /*return*/, "continue"];
|
|
576
576
|
}
|
|
577
577
|
item[column.field] = value;
|
|
@@ -581,7 +581,7 @@
|
|
|
581
581
|
value = +item[column.field];
|
|
582
582
|
if (Number.isNaN(value)) {
|
|
583
583
|
validation.data[column.field].error = item[column.field] + " " + translate('is not a number');
|
|
584
|
-
|
|
584
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
585
585
|
return [2 /*return*/, "continue"];
|
|
586
586
|
}
|
|
587
587
|
item[column.field] = value;
|
|
@@ -591,12 +591,12 @@
|
|
|
591
591
|
}
|
|
592
592
|
if (column.minValue !== undefined && item[column.field] < column.minValue) {
|
|
593
593
|
validation.data[column.field].error = item[column.field] + " " + translate('Min value') + ": " + column.minValue;
|
|
594
|
-
|
|
594
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
595
595
|
return [2 /*return*/, "continue"];
|
|
596
596
|
}
|
|
597
597
|
if (column.maxValue !== undefined && item[column.field] > column.maxValue) {
|
|
598
598
|
validation.data[column.field].error = item[column.field] + " " + translate('Max value') + ": " + column.maxValue;
|
|
599
|
-
|
|
599
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
600
600
|
return [2 /*return*/, "continue"];
|
|
601
601
|
}
|
|
602
602
|
}
|
|
@@ -611,7 +611,7 @@
|
|
|
611
611
|
value = +item[column.field];
|
|
612
612
|
if (Number.isNaN(value) || (value !== 0 && value !== 1)) {
|
|
613
613
|
validation.data[column.field].error = "" + translate('Value shoud be 0 or 1');
|
|
614
|
-
|
|
614
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
615
615
|
}
|
|
616
616
|
else {
|
|
617
617
|
if (column.parseToBool) {
|
|
@@ -623,12 +623,12 @@
|
|
|
623
623
|
else if (column.type === 'values') {
|
|
624
624
|
if (item[column.field] && typeof (item[column.field]) !== 'number' && typeof (item[column.field]) !== 'string') {
|
|
625
625
|
validation.data[column.field].error = item[column.field] + " " + translate('Invalid data type');
|
|
626
|
-
|
|
626
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
627
627
|
return [2 /*return*/, "continue"];
|
|
628
628
|
}
|
|
629
629
|
if (column.checkValueInArray && item[column.field] && !column.values.some(function (e) { return e.toString() === item[column.field].toString(); })) {
|
|
630
630
|
validation.data[column.field].error = item[column.field] + " " + translate('Value not in') + " [" + column.values.join() + "]";
|
|
631
|
-
|
|
631
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
632
632
|
return [2 /*return*/, "continue"];
|
|
633
633
|
}
|
|
634
634
|
}
|
|
@@ -638,39 +638,39 @@
|
|
|
638
638
|
if (format && item[column.field]) {
|
|
639
639
|
if (typeof (val) !== 'string') {
|
|
640
640
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
641
|
-
|
|
641
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
642
642
|
return [2 /*return*/, "continue"];
|
|
643
643
|
}
|
|
644
644
|
if (type === 'date' && !__classPrivateFieldGet(this_1, _isValidDate).call(this_1, format, val)) {
|
|
645
645
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
646
|
-
|
|
646
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
647
647
|
return [2 /*return*/, "continue"];
|
|
648
648
|
}
|
|
649
649
|
if (type === 'time' && !__classPrivateFieldGet(this_1, _isValidTime).call(this_1, format, val)) {
|
|
650
650
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
651
|
-
|
|
651
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
652
652
|
return [2 /*return*/, "continue"];
|
|
653
653
|
}
|
|
654
654
|
if (type === 'datetime' && !__classPrivateFieldGet(this_1, _isValidDateTime).call(this_1, format, val)) {
|
|
655
655
|
validation.data[column.field].error = translate('Invalid format') + " " + column.format + ": " + val;
|
|
656
|
-
|
|
656
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
657
657
|
return [2 /*return*/, "continue"];
|
|
658
658
|
}
|
|
659
659
|
item[column.field] = Date.parseFrom(val, column.format).toFormat('MM/dd/yyyy HH:mm:ss');
|
|
660
660
|
}
|
|
661
661
|
if (item[column.field] && !Date.isDate(item[column.field])) {
|
|
662
662
|
validation.data[column.field].error = translate('Invalid date') + ": " + item[column.field];
|
|
663
|
-
|
|
663
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
664
664
|
return [2 /*return*/, "continue"];
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
|
-
if (!(!
|
|
667
|
+
if (!(!errors.length && column.errorValidation)) return [3 /*break*/, 3];
|
|
668
668
|
return [4 /*yield*/, column.errorValidation(item, item[column.field])];
|
|
669
669
|
case 2:
|
|
670
670
|
error = _f.sent();
|
|
671
671
|
if (error) {
|
|
672
672
|
validation.data[column.field].error = "" + error;
|
|
673
|
-
|
|
673
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
674
674
|
}
|
|
675
675
|
_f.label = 3;
|
|
676
676
|
case 3:
|
|
@@ -687,9 +687,11 @@
|
|
|
687
687
|
case 6:
|
|
688
688
|
ex_1 = _f.sent();
|
|
689
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');
|
|
690
|
-
|
|
690
|
+
errors.push("<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error);
|
|
691
691
|
return [3 /*break*/, 7];
|
|
692
|
-
case 7:
|
|
692
|
+
case 7:
|
|
693
|
+
validation.error = errors.join('<br>');
|
|
694
|
+
return [2 /*return*/];
|
|
693
695
|
}
|
|
694
696
|
});
|
|
695
697
|
};
|
|
@@ -720,9 +722,7 @@
|
|
|
720
722
|
}
|
|
721
723
|
finally { if (e_2) throw e_2.error; }
|
|
722
724
|
return [7 /*endfinally*/];
|
|
723
|
-
case 8:
|
|
724
|
-
item.validation = validation;
|
|
725
|
-
return [2 /*return*/];
|
|
725
|
+
case 8: return [2 /*return*/];
|
|
726
726
|
}
|
|
727
727
|
});
|
|
728
728
|
}); };
|
|
@@ -997,7 +997,7 @@
|
|
|
997
997
|
SdUploadExcel.decorators = [
|
|
998
998
|
{ type: core.Component, args: [{
|
|
999
999
|
selector: 'sd-upload-excel',
|
|
1000
|
-
template: "<sd-modal [title]=\"(option?.title || 'Import Excel')| sdTranslate\" #modal>\r\n <sd-modal-body background=\"#F0F8FF\">\r\n <div class=\"row mx-0 mb-10\">\r\n <sd-button *ngIf=\"items?.length\" class=\"mr-5\" (action)=\"view('ALL')\" icon=\"cached\"\r\n [title]=\"'View all' | sdTranslate\" size=\"sm\"></sd-button>\r\n <sd-button *ngIf=\"numberOfSuccess\" class=\"mr-5\" (action)=\"view('SUCCESS')\" icon=\"done\" [title]=\"numberOfSuccess\"\r\n [tooltip]=\"'Number of success rows' | sdTranslate\" size=\"sm\" color=\"success\"></sd-button>\r\n <sd-button *ngIf=\"numberOfWarning\" class=\"mr-5\" (action)=\"view('WARNING')\" icon=\"warning\"\r\n [title]=\"numberOfWarning\" [tooltip]=\"'Number of warning rows' | sdTranslate\" size=\"sm\"></sd-button>\r\n <sd-button *ngIf=\"numberOfError\" class=\"mr-5\" (action)=\"view('ERROR')\" icon=\"error\" [title]=\"numberOfError\"\r\n color=\"danger\" [tooltip]=\"'Number of error rows' | sdTranslate\" size=\"sm\"></sd-button>\r\n </div>\r\n <div class=\"sd-box\">\r\n <div class=\"sd-box-body p-0\">\r\n <div class=\"table-responsive\" style=\"position: relative; height:50vh\">\r\n <table class=\"table table-striped table-sm table-hover table-bordered\">\r\n <thead class=\"thead-light\">\r\n <tr>\r\n <th class=\"text-center position-sticky c-sticky-left\" style=\"width: 50px;vertical-align: middle;\">#</th>\r\n <th *ngIf=\"filteredItems?.length\" class=\"text-center\"\r\n style=\"min-width: 250px; width: 250px;vertical-align: middle;\">\r\n {{'Upload message' | sdTranslate}}</th>\r\n <ng-container *ngFor=\"let column of option.columns\">\r\n <th *ngIf=\"column | columnHidden\" [ngStyle]=\"{'min-width':column.width ? column.width : '300px'}\"\r\n [matTooltip]=\"column.title\">\r\n <span class=\"c-ellipsis\"\r\n [ngStyle]=\"{'min-width':column.width ? column.width : '300px', 'max-width':column.width ? column.width : '300px'}\">{{column.title}}</span>\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </thead>\r\n <tbody *ngIf=\"viewItems.length\">\r\n <tr *ngFor=\"let item of viewItems\">\r\n <td class=\"text-center position-sticky c-sticky-left\" style=\"width: 50px\">\r\n <span class=\"badge\"\r\n [ngClass]=\"{'badge-success':!item.validation?.warning && !item.validation?.error, 'badge-warning':item.validation?.warning && !item.validation?.error, 'badge-danger':item.validation?.error}\"\r\n style=\"width: 100%\">{{item.sd.excelIndex}}</span>\r\n </td>\r\n <td style=\"min-width: 250px; width: 250px\">\r\n <div\r\n [innerHtml]=\"item.sd.validation?.error || item.sd.validation?.warning || item.sd.validation?.success || ('Success' | sdTranslate)\">\r\n </div>\r\n </td>\r\n <ng-container *ngFor=\"let column of option.columns\">\r\n <td *ngIf=\"column | columnHidden\" class=\"align-middle\" [ngClass]=\"{'table-warning':item.sd.validation?.data[column.field]?.warning && !item.sd.validation?.data[column.field]?.error, \r\n 'table-danger':item.sd.validation?.data[column.field]?.error}\"\r\n [matTooltip]=\"item.sd.validation?.data[column.field]?.error || item.sd.validation?.data[column.field]?.warning\"\r\n [ngStyle]=\"{'min-width':column.width ? column.width : '300px'}\" matTooltipPosition=\"above\">\r\n <span class=\"c-ellipsis\">\r\n <div *ngIf=\"column.type !== 'array'\"\r\n [innerHtml]=\"item | columnTransform:column | async | safeHtml\"></div>\r\n <ng-container *ngIf=\"column.type === 'array'\">\r\n {{item.data[column.field]?.split(column.divideString)?.length}} {{column.unitString}}\r\n <button mat-button [matMenuTriggerFor]=\"menu\" class=\"c-mat-menu\">\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <div class=\"row mx-0\">\r\n <div class=\"col-6\" *ngFor=\"let itemArray of item.data[column.field]?.split(column.divideString)\"\r\n [innerHtml]=\"itemArray\">\r\n </div>\r\n </div>\r\n </mat-menu>\r\n </ng-container>\r\n </span>\r\n </td>\r\n </ng-container>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </div>\r\n </div>\r\n <div class=\"sd-box-footer clearfix\">\r\n <div style=\"display: flex; align-items: center; align-content: space-between;\">\r\n <div style=\"flex: 1;\" [innerHTML]=\"option?.note\">\r\n </div>\r\n <div style=\"flex: 1;\">\r\n <mat-paginator [length]=\"filteredItems?.length || 0\" hidePageSize>\r\n </mat-paginator>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </sd-modal-body>\r\n <sd-modal-footer *sdDesktop>\r\n <div class=\"mr-auto\">\r\n <sd-button class=\"mr-5\" (action)=\"upload()\" icon=\"file_upload\" [title]=\"'Upload' | sdTranslate\" size=\"sm\"\r\n color=\"info\" [loading]=\"uploading\"></sd-button>\r\n <sd-button class=\"mr-5\" (action)=\"downloadTemplate()\" icon=\"file_download\" [loading]=\"isDownloadTemplate\"\r\n [title]=\"'Download template' | sdTranslate\" color=\"info\" type=\"outline\" size=\"sm\">\r\n </sd-button>\r\n </div>\r\n <sd-button *ngIf=\"filteredItems?.length\" class=\"mr-5\" (action)=\"export()\" icon=\"get_app\"\r\n [title]=\"'Download result' | sdTranslate\" size=\"sm\" color=\"info\" type=\"outline\">\r\n </sd-button>\r\n <sd-button (action)=\"accept()\" [title]=\"'Accept' | sdTranslate\"\r\n [disabled]=\"numberOfSuccess === 0 || numberOfError > 0 || isUploaded\" color=\"primary\" type=\"fill\" size=\"sm\">\r\n </sd-button>\r\n </sd-modal-footer>\r\n <sd-modal-footer *sdMobileTablet>\r\n <sd-button style=\"flex: 1; padding-right: 5px;\" (action)=\"upload()\" icon=\"file_upload\"\r\n [title]=\"'Upload' | sdTranslate\" width=\"100%\" size=\"sm\" color=\"info\" [loading]=\"uploading\"></sd-button>\r\n <sd-button style=\"flex: 1; padding-left: 5px;\" (action)=\"accept()\" icon=\"check\" [title]=\"'Accept' | sdTranslate\"\r\n [disabled]=\"numberOfSuccess === 0 || numberOfError > 0\" color=\"success\" width=\"100%\" size=\"sm\"></sd-button>\r\n </sd-modal-footer>\r\n</sd-modal>",
|
|
1000
|
+
template: "<sd-modal [title]=\"(option?.title || 'Import Excel')| sdTranslate\" #modal>\r\n <sd-modal-body background=\"#F0F8FF\">\r\n <div class=\"row mx-0 mb-10\">\r\n <sd-button *ngIf=\"items?.length\" class=\"mr-5\" (action)=\"view('ALL')\" icon=\"cached\"\r\n [title]=\"'View all' | sdTranslate\" size=\"sm\"></sd-button>\r\n <sd-button *ngIf=\"numberOfSuccess\" class=\"mr-5\" (action)=\"view('SUCCESS')\" icon=\"done\" [title]=\"numberOfSuccess\"\r\n [tooltip]=\"'Number of success rows' | sdTranslate\" size=\"sm\" color=\"success\"></sd-button>\r\n <sd-button *ngIf=\"numberOfWarning\" class=\"mr-5\" (action)=\"view('WARNING')\" icon=\"warning\"\r\n [title]=\"numberOfWarning\" [tooltip]=\"'Number of warning rows' | sdTranslate\" size=\"sm\"></sd-button>\r\n <sd-button *ngIf=\"numberOfError\" class=\"mr-5\" (action)=\"view('ERROR')\" icon=\"error\" [title]=\"numberOfError\"\r\n color=\"danger\" [tooltip]=\"'Number of error rows' | sdTranslate\" size=\"sm\"></sd-button>\r\n </div>\r\n <div class=\"sd-box\">\r\n <div class=\"sd-box-body p-0\">\r\n <div class=\"table-responsive\" style=\"position: relative; height:50vh\">\r\n <table class=\"table table-striped table-sm table-hover table-bordered\">\r\n <thead class=\"thead-light\">\r\n <tr>\r\n <th class=\"text-center position-sticky c-sticky-left\" style=\"width: 50px;vertical-align: middle;\">#</th>\r\n <th *ngIf=\"filteredItems?.length\" class=\"text-center\"\r\n style=\"min-width: 250px; width: 250px;vertical-align: middle;\">\r\n {{'Upload message' | sdTranslate}}</th>\r\n <ng-container *ngFor=\"let column of option.columns\">\r\n <th *ngIf=\"column | columnHidden\" [ngStyle]=\"{'min-width':column.width ? column.width : '300px'}\"\r\n [matTooltip]=\"column.title\">\r\n <span class=\"c-ellipsis\"\r\n [ngStyle]=\"{'min-width':column.width ? column.width : '300px', 'max-width':column.width ? column.width : '300px'}\">{{column.title}}</span>\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </thead>\r\n <tbody *ngIf=\"viewItems.length\">\r\n <tr *ngFor=\"let item of viewItems\">\r\n <td class=\"text-center position-sticky c-sticky-left\" style=\"width: 50px\">\r\n <span class=\"badge\"\r\n [ngClass]=\"{'badge-success':!item.sd.validation?.warning && !item.sd.validation?.error, 'badge-warning':item.sd.validation?.warning && !item.sd.validation?.error, 'badge-danger':item.sd.validation?.error}\"\r\n style=\"width: 100%\">{{item.sd.excelIndex}}</span>\r\n </td>\r\n <td style=\"min-width: 250px; width: 250px\">\r\n <div\r\n [innerHtml]=\"item.sd.validation?.error || item.sd.validation?.warning || item.sd.validation?.success || ('Success' | sdTranslate)\">\r\n </div>\r\n </td>\r\n <ng-container *ngFor=\"let column of option.columns\">\r\n <td *ngIf=\"column | columnHidden\" class=\"align-middle\" [ngClass]=\"{'table-warning':item.sd.validation?.data[column.field]?.warning && !item.sd.validation?.data[column.field]?.error, \r\n 'table-danger':item.sd.validation?.data[column.field]?.error}\"\r\n [matTooltip]=\"item.sd.validation?.data[column.field]?.error || item.sd.validation?.data[column.field]?.warning\"\r\n [ngStyle]=\"{'min-width':column.width ? column.width : '300px'}\" matTooltipPosition=\"above\">\r\n <span class=\"c-ellipsis\">\r\n <div *ngIf=\"column.type !== 'array'\"\r\n [innerHtml]=\"item | columnTransform:column | async | safeHtml\"></div>\r\n <ng-container *ngIf=\"column.type === 'array'\">\r\n {{item.data[column.field]?.split(column.divideString)?.length}} {{column.unitString}}\r\n <button mat-button [matMenuTriggerFor]=\"menu\" class=\"c-mat-menu\">\r\n <mat-icon>open_in_new</mat-icon>\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <div class=\"row mx-0\">\r\n <div class=\"col-6\" *ngFor=\"let itemArray of item.data[column.field]?.split(column.divideString)\"\r\n [innerHtml]=\"itemArray\">\r\n </div>\r\n </div>\r\n </mat-menu>\r\n </ng-container>\r\n </span>\r\n </td>\r\n </ng-container>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </div>\r\n </div>\r\n <div class=\"sd-box-footer clearfix\">\r\n <div style=\"display: flex; align-items: center; align-content: space-between;\">\r\n <div style=\"flex: 1;\" [innerHTML]=\"option?.note\">\r\n </div>\r\n <div style=\"flex: 1;\">\r\n <mat-paginator [length]=\"filteredItems?.length || 0\" hidePageSize>\r\n </mat-paginator>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </sd-modal-body>\r\n <sd-modal-footer *sdDesktop>\r\n <div class=\"mr-auto\">\r\n <sd-button class=\"mr-5\" (action)=\"upload()\" icon=\"file_upload\" [title]=\"'Upload' | sdTranslate\" size=\"sm\"\r\n color=\"info\" [loading]=\"uploading\"></sd-button>\r\n <sd-button class=\"mr-5\" (action)=\"downloadTemplate()\" icon=\"file_download\" [loading]=\"isDownloadTemplate\"\r\n [title]=\"'Download template' | sdTranslate\" color=\"info\" type=\"outline\" size=\"sm\">\r\n </sd-button>\r\n </div>\r\n <sd-button *ngIf=\"filteredItems?.length\" class=\"mr-5\" (action)=\"export()\" icon=\"get_app\"\r\n [title]=\"'Download result' | sdTranslate\" size=\"sm\" color=\"info\" type=\"outline\">\r\n </sd-button>\r\n <sd-button (action)=\"accept()\" [title]=\"'Accept' | sdTranslate\"\r\n [disabled]=\"numberOfSuccess === 0 || numberOfError > 0 || isUploaded\" color=\"primary\" type=\"fill\" size=\"sm\">\r\n </sd-button>\r\n </sd-modal-footer>\r\n <sd-modal-footer *sdMobileTablet>\r\n <sd-button style=\"flex: 1; padding-right: 5px;\" (action)=\"upload()\" icon=\"file_upload\"\r\n [title]=\"'Upload' | sdTranslate\" width=\"100%\" size=\"sm\" color=\"info\" [loading]=\"uploading\"></sd-button>\r\n <sd-button style=\"flex: 1; padding-left: 5px;\" (action)=\"accept()\" icon=\"check\" [title]=\"'Accept' | sdTranslate\"\r\n [disabled]=\"numberOfSuccess === 0 || numberOfError > 0\" color=\"success\" width=\"100%\" size=\"sm\"></sd-button>\r\n </sd-modal-footer>\r\n</sd-modal>",
|
|
1001
1001
|
styles: [".table thead td,.table thead th{padding-bottom:5px;padding-top:5px}.table-striped tbody tr:nth-of-type(2n) .c-sticky-left{background-color:#fff}.table-striped tbody tr:nth-of-type(odd) .c-sticky-left{background-color:#f2f2f2}.c-sticky-left{border-left:none!important;border-right:none!important;left:0!important;z-index:20}.c-ellipsis{display:block;overflow:hidden!important;padding:.1rem;text-overflow:ellipsis;white-space:nowrap}.c-mat-menu{border:none}.c-mat-menu mat-icon{font-size:20px;vertical-align:middle}:host ::ng-deep .mat-paginator-container{height:32px;min-height:32px}:host ::ng-deep .mat-paginator-container .mat-icon-button{height:28px;line-height:28px;width:28px}"]
|
|
1002
1002
|
},] }
|
|
1003
1003
|
];
|
|
@@ -1020,17 +1020,17 @@
|
|
|
1020
1020
|
var _this = this;
|
|
1021
1021
|
this.decimalPipe = decimalPipe;
|
|
1022
1022
|
this.transform = function (rowData, column) { return __awaiter(_this, void 0, void 0, function () {
|
|
1023
|
-
var _a, _b, _c, _d, _e, value;
|
|
1024
|
-
return __generator(this, function (
|
|
1023
|
+
var _a, _b, _c, _d, _e, _f, value;
|
|
1024
|
+
return __generator(this, function (_g) {
|
|
1025
1025
|
value = rowData.data[column.field];
|
|
1026
1026
|
if ((_a = rowData.sd.validation.data[column.field]) === null || _a === void 0 ? void 0 : _a.error) {
|
|
1027
|
-
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 : ''];
|
|
1028
1028
|
}
|
|
1029
1029
|
if (column === null || column === void 0 ? void 0 : column.transform) {
|
|
1030
1030
|
return [2 /*return*/, column.transform(value, rowData.data)];
|
|
1031
1031
|
}
|
|
1032
1032
|
if (column.type === 'number') {
|
|
1033
|
-
return [2 /*return*/, (
|
|
1033
|
+
return [2 /*return*/, (_d = Number.toVNCurrency(value)) !== null && _d !== void 0 ? _d : ''];
|
|
1034
1034
|
}
|
|
1035
1035
|
if (column.type === 'bool') {
|
|
1036
1036
|
if (value === '1' || value === true) {
|
|
@@ -1040,6 +1040,12 @@
|
|
|
1040
1040
|
return [2 /*return*/, "<div class=\"text-center\"><input type=\"checkbox\" disabled></div>"];
|
|
1041
1041
|
}
|
|
1042
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
|
+
}
|
|
1043
1049
|
return [2 /*return*/, value !== null && value !== void 0 ? value : ''];
|
|
1044
1050
|
});
|
|
1045
1051
|
}); };
|