@sd-angular/core 1.2.61 → 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.
@@ -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
- this.originItems = [];
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 _a, _b, _c, _d, _e;
398
+ var validation = item.sd.validation;
400
399
  if (_this.showing === 'SUCCESS') {
401
- return !((_a = item.validation) === null || _a === void 0 ? void 0 : _a.error) && !((_b = item.validation) === null || _b === void 0 ? void 0 : _b.warning);
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 !!((_c = item.validation) === null || _c === void 0 ? void 0 : _c.warning) && !((_d = item.validation) === null || _d === void 0 ? void 0 : _d.error);
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 !!((_e = item.validation) === null || _e === void 0 ? void 0 : _e.error);
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(function (item) { var _a, _b; return !((_a = item.validation) === null || _a === void 0 ? void 0 : _a.error) && !((_b = item.validation) === null || _b === void 0 ? void 0 : _b.warning); }).length;
414
- _this.numberOfError = _this.items.filter(function (item) { var _a; return (_a = item.validation) === null || _a === void 0 ? void 0 : _a.error; }).length;
415
- _this.numberOfWarning = _this.items.filter(function (item) { var _a, _b; return ((_a = item.validation) === null || _a === void 0 ? void 0 : _a.warning) && !((_b = item.validation) === null || _b === void 0 ? void 0 : _b.error); }).length;
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, _f, items, file, offset, mappingItems, data, _g, _h, _j, _k, idx, item, e_1_1, results, results, err_1;
419
- var e_1, _l;
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 (_m) {
422
- switch (_m.label) {
423
+ return __generator(this, function (_o) {
424
+ switch (_o.label) {
423
425
  case 0:
424
- _m.trys.push([0, 19, 20, 21]);
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
- _f = _m.sent(), items = _f.items, file = _f.file;
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
- mappingItems = this.option.mappingItems;
448
- if (!mappingItems) return [3 /*break*/, 5];
449
- data = mappingItems(items);
450
- if (!(data instanceof Promise)) return [3 /*break*/, 3];
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
- _g = this;
453
- return [4 /*yield*/, data.finally(function () { return _this.uploading = false; })];
467
+ _h = this;
468
+ return [4 /*yield*/, mappedItems.finally(function () { return _this.uploading = false; })];
454
469
  case 2:
455
- _g.items = _m.sent();
470
+ _h.items = (_o.sent());
456
471
  return [3 /*break*/, 4];
457
472
  case 3:
458
- this.items = data || items;
459
- _m.label = 4;
460
- case 4: return [3 /*break*/, 6];
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
- _m.label = 7;
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
- _m.trys.push([7, 12, 13, 14]);
470
- _h = __values(this.items.entries()), _j = _h.next();
471
- _m.label = 8;
488
+ _o.sent();
489
+ _o.label = 8;
472
490
  case 8:
473
- if (!!_j.done) return [3 /*break*/, 11];
474
- _k = __read(_j.value, 2), idx = _k[0], item = _k[1];
475
- item.sdOrigin = Object.assign({}, item);
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
- _j = _h.next();
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*/, 14];
489
- case 13:
497
+ return [3 /*break*/, 12];
498
+ case 11:
490
499
  try {
491
- if (_j && !_j.done && (_l = _h.return)) _l.call(_h);
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(function (item) { return !!item.validation.error; }) && this.option.errorValidation)) return [3 /*break*/, 16];
497
- return [4 /*yield*/, this.option.errorValidation(this.items)];
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 = _m.sent();
500
- results.forEach(function (result) { return _this.items[result.idx].validation.error = result.message; });
501
- _m.label = 16;
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*/, 21];
515
- case 19:
516
- err_1 = _m.sent();
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*/, 21];
519
- case 20:
527
+ return [3 /*break*/, 19];
528
+ case 18:
520
529
  this.loadingService.stop();
521
530
  return [7 /*endfinally*/];
522
- case 21: return [2 /*return*/];
531
+ case 19: return [2 /*return*/];
523
532
  }
524
533
  });
525
534
  }); };
526
- this.validate = function (item) { return __awaiter(_this, void 0, void 0, 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
- error: '',
534
- warning: '',
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 validation = item.validation, sdOrigin = item.sdOrigin, excelIndex = item.excelIndex, remain = __rest(item, ["validation", "sdOrigin", "excelIndex"]);
719
- return remain;
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(function (item) { return !item.validation.error && !item.validation.warning; }).map(__classPrivateFieldGet(_this, _mapItem));
724
- var errorItems = _this.items.filter(function (item) { return item.validation.error; }).map(__classPrivateFieldGet(_this, _mapItem));
725
- var warningItems = _this.items.filter(function (item) { return !item.validation.error && item.validation.warning; }).map(__classPrivateFieldGet(_this, _mapItem));
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);
@@ -840,12 +856,12 @@
840
856
  var e_4, _f, _g;
841
857
  var _a, _b, _c, _d, _e;
842
858
  var result = {
843
- sdMessage: (_d = (((_a = e.validation) === null || _a === void 0 ? void 0 : _a.error) || ((_b = e.validation) === null || _b === void 0 ? void 0 : _b.warning) || ((_c = e.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')
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')
844
860
  };
845
861
  try {
846
862
  for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
847
863
  var column = columns_1_1.value;
848
- result = Object.assign(Object.assign({}, result), (_g = {}, _g[column.field] = (_e = e.sdOrigin) === null || _e === void 0 ? void 0 : _e[column.field], _g));
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));
849
865
  }
850
866
  }
851
867
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
@@ -977,11 +993,11 @@
977
993
  };
978
994
  return SdUploadExcel;
979
995
  }());
980
- _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();
981
997
  SdUploadExcel.decorators = [
982
998
  { type: core.Component, args: [{
983
999
  selector: 'sd-upload-excel',
984
- 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\"\r\n [ngClass]=\"{'table-warning':item.validation?.data[column.field]?.warning && !item.validation?.data[column.field]?.error, 'table-danger':item.validation?.data[column.field]?.error}\"\r\n [matTooltip]=\"item.validation?.data[column.field]?.error || item.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 <ng-container *ngIf=\"(column.type === 'date' || column.type === 'datetime') && item.sdOrigin\">\r\n <div\r\n [innerHtml]=\"(item.sdOrigin[column.field] | columnTransform:item:column | async) | safeHtml\">\r\n </div>\r\n </ng-container>\r\n <ng-container *ngIf=\"column.type === 'number'\">\r\n <div [innerHtml]=\"item[column.field] | columnTransform:item:column | async | safeHtml\"></div>\r\n </ng-container>\r\n <ng-container *ngIf=\"column.type === 'array'\">\r\n {{item[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[column.field]?.split(column.divideString)\"\r\n [innerHtml]=\"(itemArray | columnTransform:item:column | async) | safeHtml\">\r\n </div>\r\n </div>\r\n </mat-menu>\r\n </ng-container>\r\n <ng-container\r\n *ngIf=\"column.type !== 'date' && column.type !== 'datetime' && column.type !== 'number' && column.type !== 'array'\">\r\n <!-- {{item[column.field]}} -->\r\n <div [innerHtml]=\"(item[column.field] | columnTransform:item:column | async) | safeHtml\"></div>\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.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>",
985
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}"]
986
1002
  },] }
987
1003
  ];
@@ -1003,17 +1019,26 @@
1003
1019
  function SdColumnTransformPipe(decimalPipe) {
1004
1020
  var _this = this;
1005
1021
  this.decimalPipe = decimalPipe;
1006
- this.transform = function (value, rowData, column) { return __awaiter(_this, void 0, void 0, function () {
1007
- var _a, _b, _c, _d, _e, _f;
1008
- return __generator(this, function (_g) {
1009
- if ((_b = (_a = rowData.validation) === null || _a === void 0 ? void 0 : _a.data[column.field]) === null || _b === void 0 ? void 0 : _b.error) {
1010
- return [2 /*return*/, (_e = (_d = (_c = rowData.sdOrigin) === null || _c === void 0 ? void 0 : _c[column.field]) !== null && _d !== void 0 ? _d : value) !== null && _e !== void 0 ? _e : ''];
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 : ''];
1011
1028
  }
1012
1029
  if (column === null || column === void 0 ? void 0 : column.transform) {
1013
1030
  return [2 /*return*/, column.transform(value, rowData)];
1014
1031
  }
1015
1032
  if (column.type === 'number') {
1016
- return [2 /*return*/, (_f = Number.toVNCurrency(value)) !== null && _f !== void 0 ? _f : ''];
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
+ }
1017
1042
  }
1018
1043
  return [2 /*return*/, value !== null && value !== void 0 ? value : ''];
1019
1044
  });