@sd-angular/core 1.2.59 → 1.2.62
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-input-number.umd.js +3 -2
- package/bundles/sd-angular-core-input-number.umd.js.map +1 -1
- package/bundles/sd-angular-core-input-number.umd.min.js +1 -1
- package/bundles/sd-angular-core-input-number.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.js +145 -101
- 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/input-number/src/lib/input-number.component.js +4 -3
- package/esm2015/upload-excel/src/lib/pipes/column-transform.pipe.js +16 -7
- package/esm2015/upload-excel/src/lib/upload-excel.component.js +77 -53
- package/esm2015/upload-excel/src/lib/upload-excel.model.js +1 -1
- package/fesm2015/sd-angular-core-input-number.js +3 -2
- package/fesm2015/sd-angular-core-input-number.js.map +1 -1
- package/fesm2015/sd-angular-core-upload-excel.js +91 -58
- package/fesm2015/sd-angular-core-upload-excel.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.2.59.tgz → sd-angular-core-1.2.62.tgz} +0 -0
- package/upload-excel/sd-angular-core-upload-excel.metadata.json +1 -1
- package/upload-excel/src/lib/pipes/column-transform.pipe.d.ts +2 -2
- package/upload-excel/src/lib/upload-excel.component.d.ts +5 -16
- package/upload-excel/src/lib/upload-excel.model.d.ts +9 -0
|
@@ -352,7 +352,7 @@
|
|
|
352
352
|
];
|
|
353
353
|
SdColumnHiddenPipe.ctorParameters = function () { return []; };
|
|
354
354
|
|
|
355
|
-
var _paginator, _subscription, _reset, _reload, _mapItem, _import, _isValidDate, _isValidTime, _isValidDateTime;
|
|
355
|
+
var _paginator, _subscription, _reset, _reload, _isError, _isWarning, _isSuccess, _parse, _mapItem, _import, _isValidDate, _isValidTime, _isValidDateTime;
|
|
356
356
|
var SdUploadExcel = /** @class */ (function () {
|
|
357
357
|
function SdUploadExcel(ref, exportService, translateService, notifyService, sdColumnHidden, loadingService) {
|
|
358
358
|
var _this = this;
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
this.loadingService = loadingService;
|
|
365
365
|
this.importId = 'I' + uuid.v4();
|
|
366
366
|
this.items = [];
|
|
367
|
-
|
|
367
|
+
// originItems: SdExcelItem[] = [];
|
|
368
368
|
this.hasDescription = false;
|
|
369
369
|
this.showing = 'ALL';
|
|
370
370
|
this.filteredItems = [];
|
|
@@ -383,7 +383,6 @@
|
|
|
383
383
|
_this.modal.close();
|
|
384
384
|
};
|
|
385
385
|
_reset.set(this, function () {
|
|
386
|
-
_this.originItems = [];
|
|
387
386
|
_this.items = [];
|
|
388
387
|
_this.filteredItems = [];
|
|
389
388
|
_this.viewItems = [];
|
|
@@ -396,36 +395,40 @@
|
|
|
396
395
|
var pageIndex = __classPrivateFieldGet(_this, _paginator).pageIndex;
|
|
397
396
|
var pageSize = __classPrivateFieldGet(_this, _paginator).pageSize;
|
|
398
397
|
_this.filteredItems = _this.items.filter(function (item) {
|
|
399
|
-
var
|
|
398
|
+
var validation = item.sd.validation;
|
|
400
399
|
if (_this.showing === 'SUCCESS') {
|
|
401
|
-
return !(
|
|
400
|
+
return !(validation === null || validation === void 0 ? void 0 : validation.error) && !(validation === null || validation === void 0 ? void 0 : validation.warning);
|
|
402
401
|
}
|
|
403
402
|
else if (_this.showing === 'WARNING') {
|
|
404
|
-
return !!(
|
|
403
|
+
return !!(validation === null || validation === void 0 ? void 0 : validation.warning) && !(validation === null || validation === void 0 ? void 0 : validation.error);
|
|
405
404
|
}
|
|
406
405
|
else if (_this.showing === 'ERROR') {
|
|
407
|
-
return !!(
|
|
406
|
+
return !!(validation === null || validation === void 0 ? void 0 : validation.error);
|
|
408
407
|
}
|
|
409
408
|
return true;
|
|
410
409
|
});
|
|
411
410
|
_this.viewItems = _this.filteredItems
|
|
412
411
|
.filter(function (item, index) { return index >= pageIndex * pageSize && index < (pageIndex + 1) * pageSize; });
|
|
413
|
-
_this.numberOfSuccess = _this.items.filter(
|
|
414
|
-
_this.numberOfError = _this.items.filter(
|
|
415
|
-
_this.numberOfWarning = _this.items.filter(
|
|
412
|
+
_this.numberOfSuccess = _this.items.filter(__classPrivateFieldGet(_this, _isSuccess)).length;
|
|
413
|
+
_this.numberOfError = _this.items.filter(__classPrivateFieldGet(_this, _isError)).length;
|
|
414
|
+
_this.numberOfWarning = _this.items.filter(__classPrivateFieldGet(_this, _isWarning)).length;
|
|
416
415
|
});
|
|
416
|
+
_isError.set(this, function (item) { return !!item.sd.validation.error; });
|
|
417
|
+
_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
|
+
_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); });
|
|
417
419
|
this.upload = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
418
|
-
var translate,
|
|
419
|
-
var e_1,
|
|
420
|
+
var _f, mappingItems, errorValidation, warningValidation, translate, _g, items, file, offset, mappedItems, _h, _j, _k, _l, idx, item, e_1_1, results, results, err_1;
|
|
421
|
+
var e_1, _m;
|
|
420
422
|
var _this = this;
|
|
421
|
-
return __generator(this, function (
|
|
422
|
-
switch (
|
|
423
|
+
return __generator(this, function (_o) {
|
|
424
|
+
switch (_o.label) {
|
|
423
425
|
case 0:
|
|
424
|
-
|
|
426
|
+
_o.trys.push([0, 17, 18, 19]);
|
|
427
|
+
_f = this.option, mappingItems = _f.mappingItems, errorValidation = _f.errorValidation, warningValidation = _f.warningValidation;
|
|
425
428
|
translate = this.translateService.translate;
|
|
426
429
|
return [4 /*yield*/, __classPrivateFieldGet(this, _import).call(this)];
|
|
427
430
|
case 1:
|
|
428
|
-
|
|
431
|
+
_g = _o.sent(), items = _g.items, file = _g.file;
|
|
429
432
|
if (this.option.columns.some(function (e) { return !!e.description; })) {
|
|
430
433
|
this.hasDescription = true;
|
|
431
434
|
}
|
|
@@ -443,97 +446,101 @@
|
|
|
443
446
|
return [2 /*return*/];
|
|
444
447
|
}
|
|
445
448
|
__classPrivateFieldGet(this, _reset).call(this);
|
|
446
|
-
this.originItems = items
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
// this.originItems = items.map(data => ({
|
|
450
|
+
// data,
|
|
451
|
+
// sd: {}
|
|
452
|
+
// }));
|
|
453
|
+
this.items = items.map(function (data, idx) { return ({
|
|
454
|
+
data: data,
|
|
455
|
+
sd: {
|
|
456
|
+
excelIndex: idx + (_this.hasDescription ? 4 : 3),
|
|
457
|
+
validation: {
|
|
458
|
+
data: {}
|
|
459
|
+
},
|
|
460
|
+
origin: Object.assign({}, data)
|
|
461
|
+
}
|
|
462
|
+
}); });
|
|
463
|
+
if (!mappingItems) return [3 /*break*/, 4];
|
|
464
|
+
mappedItems = mappingItems(this.items);
|
|
465
|
+
if (!(mappedItems instanceof Promise)) return [3 /*break*/, 3];
|
|
451
466
|
this.uploading = true;
|
|
452
|
-
|
|
453
|
-
return [4 /*yield*/,
|
|
467
|
+
_h = this;
|
|
468
|
+
return [4 /*yield*/, mappedItems.finally(function () { return _this.uploading = false; })];
|
|
454
469
|
case 2:
|
|
455
|
-
|
|
470
|
+
_h.items = (_o.sent());
|
|
456
471
|
return [3 /*break*/, 4];
|
|
457
472
|
case 3:
|
|
458
|
-
this.items =
|
|
459
|
-
|
|
460
|
-
case 4:
|
|
461
|
-
case 5:
|
|
462
|
-
this.items = items;
|
|
463
|
-
_m.label = 6;
|
|
464
|
-
case 6:
|
|
473
|
+
this.items = (mappedItems || this.items);
|
|
474
|
+
_o.label = 4;
|
|
475
|
+
case 4:
|
|
465
476
|
this.file = file;
|
|
466
477
|
this.loadingService.start();
|
|
467
|
-
|
|
478
|
+
_o.label = 5;
|
|
479
|
+
case 5:
|
|
480
|
+
_o.trys.push([5, 10, 11, 12]);
|
|
481
|
+
_j = __values(this.items.entries()), _k = _j.next();
|
|
482
|
+
_o.label = 6;
|
|
483
|
+
case 6:
|
|
484
|
+
if (!!_k.done) return [3 /*break*/, 9];
|
|
485
|
+
_l = __read(_k.value, 2), idx = _l[0], item = _l[1];
|
|
486
|
+
return [4 /*yield*/, this.validate(item)];
|
|
468
487
|
case 7:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
_m.label = 8;
|
|
488
|
+
_o.sent();
|
|
489
|
+
_o.label = 8;
|
|
472
490
|
case 8:
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
item.excelIndex = idx + (this.hasDescription ? 4 : 3);
|
|
477
|
-
return [4 /*yield*/, this.validate(item)];
|
|
478
|
-
case 9:
|
|
479
|
-
_m.sent();
|
|
480
|
-
_m.label = 10;
|
|
491
|
+
_k = _j.next();
|
|
492
|
+
return [3 /*break*/, 6];
|
|
493
|
+
case 9: return [3 /*break*/, 12];
|
|
481
494
|
case 10:
|
|
482
|
-
|
|
483
|
-
return [3 /*break*/, 8];
|
|
484
|
-
case 11: return [3 /*break*/, 14];
|
|
485
|
-
case 12:
|
|
486
|
-
e_1_1 = _m.sent();
|
|
495
|
+
e_1_1 = _o.sent();
|
|
487
496
|
e_1 = { error: e_1_1 };
|
|
488
|
-
return [3 /*break*/,
|
|
489
|
-
case
|
|
497
|
+
return [3 /*break*/, 12];
|
|
498
|
+
case 11:
|
|
490
499
|
try {
|
|
491
|
-
if (
|
|
500
|
+
if (_k && !_k.done && (_m = _j.return)) _m.call(_j);
|
|
492
501
|
}
|
|
493
502
|
finally { if (e_1) throw e_1.error; }
|
|
494
503
|
return [7 /*endfinally*/];
|
|
504
|
+
case 12:
|
|
505
|
+
if (!(!this.items.some(__classPrivateFieldGet(this, _isError)) && errorValidation)) return [3 /*break*/, 14];
|
|
506
|
+
return [4 /*yield*/, errorValidation(this.items)];
|
|
507
|
+
case 13:
|
|
508
|
+
results = _o.sent();
|
|
509
|
+
results.forEach(function (result) { return _this.items[result.idx].sd.validation.error = result.message; });
|
|
510
|
+
_o.label = 14;
|
|
495
511
|
case 14:
|
|
496
|
-
if (!(!this.items.some(
|
|
497
|
-
return [4 /*yield*/,
|
|
512
|
+
if (!(!this.items.some(__classPrivateFieldGet(this, _isWarning)) && warningValidation)) return [3 /*break*/, 16];
|
|
513
|
+
return [4 /*yield*/, warningValidation(this.items)];
|
|
498
514
|
case 15:
|
|
499
|
-
results =
|
|
500
|
-
results.forEach(function (result) { return _this.items[result.idx].validation.
|
|
501
|
-
|
|
515
|
+
results = _o.sent();
|
|
516
|
+
results.forEach(function (result) { return _this.items[result.idx].sd.validation.warning = result.message; });
|
|
517
|
+
_o.label = 16;
|
|
502
518
|
case 16:
|
|
503
|
-
if (!(!this.items.some(function (item) { return !!item.validation.warning; }) && this.option.warningValidation)) return [3 /*break*/, 18];
|
|
504
|
-
return [4 /*yield*/, this.option.warningValidation(this.items)];
|
|
505
|
-
case 17:
|
|
506
|
-
results = _m.sent();
|
|
507
|
-
results.forEach(function (result) { return _this.items[result.idx].validation.warning = result.message; });
|
|
508
|
-
_m.label = 18;
|
|
509
|
-
case 18:
|
|
510
519
|
__classPrivateFieldGet(this, _paginator).pageIndex = 0;
|
|
511
520
|
__classPrivateFieldGet(this, _reload).call(this);
|
|
512
521
|
this.ref.detectChanges();
|
|
513
522
|
this.isUploaded = false;
|
|
514
|
-
return [3 /*break*/,
|
|
515
|
-
case
|
|
516
|
-
err_1 =
|
|
523
|
+
return [3 /*break*/, 19];
|
|
524
|
+
case 17:
|
|
525
|
+
err_1 = _o.sent();
|
|
517
526
|
this.notifyService.handle.error(err_1);
|
|
518
|
-
return [3 /*break*/,
|
|
519
|
-
case
|
|
527
|
+
return [3 /*break*/, 19];
|
|
528
|
+
case 18:
|
|
520
529
|
this.loadingService.stop();
|
|
521
530
|
return [7 /*endfinally*/];
|
|
522
|
-
case
|
|
531
|
+
case 19: return [2 /*return*/];
|
|
523
532
|
}
|
|
524
533
|
});
|
|
525
534
|
}); };
|
|
526
|
-
this.validate = function (
|
|
527
|
-
var _a, validation, translate, _loop_1, this_1, _f, _g, column, e_2_1;
|
|
535
|
+
this.validate = function (excelItem) { return __awaiter(_this, void 0, void 0, function () {
|
|
536
|
+
var _a, item, validation, translate, _loop_1, this_1, _f, _g, column, e_2_1;
|
|
528
537
|
var e_2, _h;
|
|
529
538
|
return __generator(this, function (_j) {
|
|
530
539
|
switch (_j.label) {
|
|
531
540
|
case 0:
|
|
532
|
-
validation = {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
data: {}
|
|
536
|
-
};
|
|
541
|
+
excelItem.sd.validation = {};
|
|
542
|
+
item = excelItem.data;
|
|
543
|
+
validation = excelItem.sd.validation;
|
|
537
544
|
translate = this.translateService.translate;
|
|
538
545
|
_loop_1 = function (column) {
|
|
539
546
|
var value, value, value, type, format, val, error, warning, ex_1;
|
|
@@ -606,6 +613,11 @@
|
|
|
606
613
|
validation.data[column.field].error = "" + translate('Value shoud be 0 or 1');
|
|
607
614
|
validation.error += "<strong>[" + (column.title || column.field) + "]</strong> " + validation.data[column.field].error + "<br>";
|
|
608
615
|
}
|
|
616
|
+
else {
|
|
617
|
+
if (column.parseToBool) {
|
|
618
|
+
item[column.field] = item[column.field] === '1';
|
|
619
|
+
}
|
|
620
|
+
}
|
|
609
621
|
}
|
|
610
622
|
}
|
|
611
623
|
else if (column.type === 'values') {
|
|
@@ -714,24 +726,28 @@
|
|
|
714
726
|
}
|
|
715
727
|
});
|
|
716
728
|
}); };
|
|
729
|
+
_parse.set(this, function (item) {
|
|
730
|
+
var data = item.data;
|
|
731
|
+
return data;
|
|
732
|
+
});
|
|
717
733
|
_mapItem.set(this, function (item) {
|
|
718
|
-
var
|
|
719
|
-
return
|
|
734
|
+
var data = item.data;
|
|
735
|
+
return data;
|
|
720
736
|
});
|
|
721
737
|
this.accept = function () {
|
|
722
738
|
var _a;
|
|
723
|
-
var successItems = _this.items.filter(
|
|
724
|
-
var errorItems = _this.items.filter(
|
|
725
|
-
var warningItems = _this.items.filter(
|
|
739
|
+
var successItems = _this.items.filter(__classPrivateFieldGet(_this, _isSuccess)).map(__classPrivateFieldGet(_this, _mapItem));
|
|
740
|
+
var errorItems = _this.items.filter(__classPrivateFieldGet(_this, _isError)).map(__classPrivateFieldGet(_this, _mapItem));
|
|
741
|
+
var warningItems = _this.items.filter(__classPrivateFieldGet(_this, _isWarning)).map(__classPrivateFieldGet(_this, _mapItem));
|
|
726
742
|
(_a = _this.option) === null || _a === void 0 ? void 0 : _a.onAccept(_this.items.map(__classPrivateFieldGet(_this, _mapItem)), successItems, errorItems, warningItems, _this.file);
|
|
727
743
|
_this.isUploaded = true;
|
|
728
744
|
};
|
|
729
745
|
this.setValidation = function (validates) {
|
|
730
746
|
if (Array.isArray(validates)) {
|
|
731
747
|
validates.forEach(function (validate) {
|
|
732
|
-
_this.items[validate.idx].validation.error = validate.messageError;
|
|
733
|
-
_this.items[validate.idx].validation.warning = validate.messageWarning;
|
|
734
|
-
_this.items[validate.idx].validation.success = validate.messageSuccess;
|
|
748
|
+
_this.items[validate.idx].sd.validation.error = validate.messageError;
|
|
749
|
+
_this.items[validate.idx].sd.validation.warning = validate.messageWarning;
|
|
750
|
+
_this.items[validate.idx].sd.validation.success = validate.messageSuccess;
|
|
735
751
|
});
|
|
736
752
|
}
|
|
737
753
|
__classPrivateFieldGet(_this, _reload).call(_this);
|
|
@@ -822,21 +838,40 @@
|
|
|
822
838
|
});
|
|
823
839
|
}); };
|
|
824
840
|
this.export = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
841
|
+
var columns;
|
|
825
842
|
var _this = this;
|
|
826
843
|
return __generator(this, function (_f) {
|
|
827
844
|
switch (_f.label) {
|
|
828
845
|
case 0:
|
|
829
846
|
this.loadingService.start();
|
|
847
|
+
columns = __spread([{
|
|
848
|
+
field: 'sdMessage',
|
|
849
|
+
title: this.translateService.translate('Upload message'),
|
|
850
|
+
width: '250px',
|
|
851
|
+
required: false
|
|
852
|
+
}], this.option.columns.filter(function (column) { return _this.sdColumnHidden.transform(column); }));
|
|
830
853
|
return [4 /*yield*/, this.exportService.export({
|
|
831
|
-
columns:
|
|
832
|
-
field: 'sdMessage',
|
|
833
|
-
title: this.translateService.translate('Upload message'),
|
|
834
|
-
width: '250px',
|
|
835
|
-
required: false
|
|
836
|
-
}], this.option.columns.filter(function (column) { return _this.sdColumnHidden.transform(column); })),
|
|
854
|
+
columns: columns,
|
|
837
855
|
items: this.filteredItems.map(function (e) {
|
|
838
|
-
var
|
|
839
|
-
|
|
856
|
+
var e_4, _f, _g;
|
|
857
|
+
var _a, _b, _c, _d, _e;
|
|
858
|
+
var result = {
|
|
859
|
+
sdMessage: (_d = (((_a = e.sd.validation) === null || _a === void 0 ? void 0 : _a.error) || ((_b = e.sd.validation) === null || _b === void 0 ? void 0 : _b.warning) || ((_c = e.sd.validation) === null || _c === void 0 ? void 0 : _c.success))) === null || _d === void 0 ? void 0 : _d.replace(/<strong>/g, '').replace(/<\/strong>/g, '').replace(/<br>/g, '\n')
|
|
860
|
+
};
|
|
861
|
+
try {
|
|
862
|
+
for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
|
|
863
|
+
var column = columns_1_1.value;
|
|
864
|
+
result = Object.assign(Object.assign({}, result), (_g = {}, _g[column.field] = (_e = e.sd.origin) === null || _e === void 0 ? void 0 : _e[column.field], _g));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
868
|
+
finally {
|
|
869
|
+
try {
|
|
870
|
+
if (columns_1_1 && !columns_1_1.done && (_f = columns_1.return)) _f.call(columns_1);
|
|
871
|
+
}
|
|
872
|
+
finally { if (e_4) throw e_4.error; }
|
|
873
|
+
}
|
|
874
|
+
return result;
|
|
840
875
|
})
|
|
841
876
|
}).finally(this.loadingService.stop)];
|
|
842
877
|
case 1:
|
|
@@ -958,11 +993,11 @@
|
|
|
958
993
|
};
|
|
959
994
|
return SdUploadExcel;
|
|
960
995
|
}());
|
|
961
|
-
_paginator = new WeakMap(), _subscription = new WeakMap(), _reset = new WeakMap(), _reload = new WeakMap(), _mapItem = new WeakMap(), _import = new WeakMap(), _isValidDate = new WeakMap(), _isValidTime = new WeakMap(), _isValidDateTime = new WeakMap();
|
|
996
|
+
_paginator = new WeakMap(), _subscription = new WeakMap(), _reset = new WeakMap(), _reload = new WeakMap(), _isError = new WeakMap(), _isWarning = new WeakMap(), _isSuccess = new WeakMap(), _parse = new WeakMap(), _mapItem = new WeakMap(), _import = new WeakMap(), _isValidDate = new WeakMap(), _isValidTime = new WeakMap(), _isValidDateTime = new WeakMap();
|
|
962
997
|
SdUploadExcel.decorators = [
|
|
963
998
|
{ type: core.Component, args: [{
|
|
964
999
|
selector: 'sd-upload-excel',
|
|
965
|
-
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.excelIndex}}</span>\r\n </td>\r\n <td style=\"min-width: 250px; width: 250px\">\r\n <div\r\n [innerHtml]=\"item.validation?.error || item.validation?.warning || item.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\"
|
|
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>",
|
|
966
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}"]
|
|
967
1002
|
},] }
|
|
968
1003
|
];
|
|
@@ -984,19 +1019,28 @@
|
|
|
984
1019
|
function SdColumnTransformPipe(decimalPipe) {
|
|
985
1020
|
var _this = this;
|
|
986
1021
|
this.decimalPipe = decimalPipe;
|
|
987
|
-
this.transform = function (
|
|
988
|
-
var _a, _b, _c;
|
|
989
|
-
return __generator(this, function (
|
|
990
|
-
|
|
991
|
-
|
|
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 (_f) {
|
|
1025
|
+
value = rowData.data[column.field];
|
|
1026
|
+
if ((_a = rowData.sd.validation.data[column.field]) === null || _a === void 0 ? void 0 : _a.error) {
|
|
1027
|
+
return [2 /*return*/, (_d = (_c = (_b = rowData.sd.origin) === null || _b === void 0 ? void 0 : _b[column.field]) !== null && _c !== void 0 ? _c : value) !== null && _d !== void 0 ? _d : ''];
|
|
992
1028
|
}
|
|
993
1029
|
if (column === null || column === void 0 ? void 0 : column.transform) {
|
|
994
1030
|
return [2 /*return*/, column.transform(value, rowData)];
|
|
995
1031
|
}
|
|
996
1032
|
if (column.type === 'number') {
|
|
997
|
-
return [2 /*return*/, Number.toVNCurrency(value)
|
|
1033
|
+
return [2 /*return*/, (_e = Number.toVNCurrency(value)) !== null && _e !== void 0 ? _e : ''];
|
|
1034
|
+
}
|
|
1035
|
+
if (column.type === 'bool') {
|
|
1036
|
+
if (value === '1' || value === true) {
|
|
1037
|
+
return [2 /*return*/, "<div class=\"text-center\"><input type=\"checkbox\" checked disabled></div>"];
|
|
1038
|
+
}
|
|
1039
|
+
else if (value === '0' || value === false) {
|
|
1040
|
+
return [2 /*return*/, "<div class=\"text-center\"><input type=\"checkbox\" disabled></div>"];
|
|
1041
|
+
}
|
|
998
1042
|
}
|
|
999
|
-
return [2 /*return*/, value];
|
|
1043
|
+
return [2 /*return*/, value !== null && value !== void 0 ? value : ''];
|
|
1000
1044
|
});
|
|
1001
1045
|
}); };
|
|
1002
1046
|
}
|