tnx-shared 5.3.289 → 5.3.291

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.
@@ -27676,7 +27676,7 @@
27676
27676
  var resultValidate, flashShow;
27677
27677
  return __generator(this, function (_b) {
27678
27678
  switch (_b.label) {
27679
- case 0: return [4 /*yield*/, this.validateEdit()];
27679
+ case 0: return [4 /*yield*/, this.validateEdit(rowData)];
27680
27680
  case 1:
27681
27681
  resultValidate = _b.sent();
27682
27682
  if (!resultValidate) {
@@ -27702,7 +27702,7 @@
27702
27702
  });
27703
27703
  });
27704
27704
  };
27705
- ListBase.prototype.validateEdit = function () {
27705
+ ListBase.prototype.validateEdit = function (rowData) {
27706
27706
  return __awaiter(this, void 0, void 0, function () {
27707
27707
  return __generator(this, function (_b) {
27708
27708
  return [2 /*return*/, true];
@@ -27734,35 +27734,57 @@
27734
27734
  ListBase.prototype.getPromiseDeleteItem = function (rowData) {
27735
27735
  return this.setting.baseService.delete(rowData.id, this.deletePlusUrl);
27736
27736
  };
27737
+ ListBase.prototype.validateDelete = function (items) {
27738
+ return __awaiter(this, void 0, void 0, function () {
27739
+ return __generator(this, function (_b) {
27740
+ return [2 /*return*/, true];
27741
+ });
27742
+ });
27743
+ };
27737
27744
  ListBase.prototype._delete = function (rowData) {
27738
- var _this = this;
27739
- if (rowData.__disableDelete) {
27740
- return;
27741
- }
27742
- this._notifierService.showDeleteConfirm().then(function (rs) {
27743
- if (!rs) {
27744
- return;
27745
- }
27746
- if (_this.setting.baseService) {
27747
- _this.getPromiseDeleteItem(rowData)
27748
- .then(function (response) {
27749
- if (response.success) {
27750
- _this.beforeReloadAfterDelete([rowData.id]);
27751
- if (_this.setting.showVersionButton) {
27752
- _this.context.fireEvent(ComCtxConstants.COMMON.RELOAD_DATA_VERSION, {}, true);
27745
+ return __awaiter(this, void 0, void 0, function () {
27746
+ var resultValidate;
27747
+ var _this = this;
27748
+ return __generator(this, function (_b) {
27749
+ switch (_b.label) {
27750
+ case 0:
27751
+ if (rowData.__disableDelete) {
27752
+ return [2 /*return*/];
27753
27753
  }
27754
- else {
27755
- _this._triggerProcessData();
27754
+ return [4 /*yield*/, this.validateDelete([rowData])];
27755
+ case 1:
27756
+ resultValidate = _b.sent();
27757
+ if (!resultValidate) {
27758
+ return [2 /*return*/];
27756
27759
  }
27757
- _this._notifierService.showDeleteDataSuccess();
27758
- }
27759
- else {
27760
- _this._notifierService.showWarningByResponse(response);
27761
- }
27762
- }, function (error) {
27763
- _this._notifierService.showDeleteDataError();
27764
- });
27765
- }
27760
+ this._notifierService.showDeleteConfirm().then(function (rs) {
27761
+ if (!rs) {
27762
+ return;
27763
+ }
27764
+ if (_this.setting.baseService) {
27765
+ _this.getPromiseDeleteItem(rowData)
27766
+ .then(function (response) {
27767
+ if (response.success) {
27768
+ _this.beforeReloadAfterDelete([rowData.id]);
27769
+ if (_this.setting.showVersionButton) {
27770
+ _this.context.fireEvent(ComCtxConstants.COMMON.RELOAD_DATA_VERSION, {}, true);
27771
+ }
27772
+ else {
27773
+ _this._triggerProcessData();
27774
+ }
27775
+ _this._notifierService.showDeleteDataSuccess();
27776
+ }
27777
+ else {
27778
+ _this._notifierService.showWarningByResponse(response);
27779
+ }
27780
+ }, function (error) {
27781
+ _this._notifierService.showDeleteDataError();
27782
+ });
27783
+ }
27784
+ });
27785
+ return [2 /*return*/];
27786
+ }
27787
+ });
27766
27788
  });
27767
27789
  };
27768
27790
  ListBase.prototype.getPromiseDeleteItems = function (items) {
@@ -27770,23 +27792,37 @@
27770
27792
  return this.setting.baseService.deleteMany(ids, this.deleteManyPlusUrl);
27771
27793
  };
27772
27794
  ListBase.prototype._deleteMultiple = function (items) {
27773
- var _this = this;
27774
- this._notifierService.showDeleteConfirm('Bạn có chắc chắn muốn xóa bản ghi đã chọn (Và các bản ghi con tương ứng)?').then(function (rs) {
27775
- if (!rs) {
27776
- return;
27777
- }
27778
- if (_this.setting.baseService) {
27779
- _this.getPromiseDeleteItems(items).then(function (response) {
27780
- if (response.success) {
27781
- _this.beforeReloadAfterDelete(items.map(function (q) { return q.id; }));
27782
- _this._triggerProcessData();
27783
- _this._notifierService.showDeleteDataSuccess();
27784
- }
27785
- else {
27786
- _this._notifierService.showWarningByResponse(response);
27787
- }
27788
- });
27789
- }
27795
+ return __awaiter(this, void 0, void 0, function () {
27796
+ var resultValidate;
27797
+ var _this = this;
27798
+ return __generator(this, function (_b) {
27799
+ switch (_b.label) {
27800
+ case 0: return [4 /*yield*/, this.validateDelete(items)];
27801
+ case 1:
27802
+ resultValidate = _b.sent();
27803
+ if (!resultValidate) {
27804
+ return [2 /*return*/];
27805
+ }
27806
+ this._notifierService.showDeleteConfirm('Bạn có chắc chắn muốn xóa bản ghi đã chọn (Và các bản ghi con tương ứng)?').then(function (rs) {
27807
+ if (!rs) {
27808
+ return;
27809
+ }
27810
+ if (_this.setting.baseService) {
27811
+ _this.getPromiseDeleteItems(items).then(function (response) {
27812
+ if (response.success) {
27813
+ _this.beforeReloadAfterDelete(items.map(function (q) { return q.id; }));
27814
+ _this._triggerProcessData();
27815
+ _this._notifierService.showDeleteDataSuccess();
27816
+ }
27817
+ else {
27818
+ _this._notifierService.showWarningByResponse(response);
27819
+ }
27820
+ });
27821
+ }
27822
+ });
27823
+ return [2 /*return*/];
27824
+ }
27825
+ });
27790
27826
  });
27791
27827
  };
27792
27828
  ListBase.prototype.beforeReloadAfterDelete = function (ids) {
@@ -27810,36 +27846,33 @@
27810
27846
  ListBase.prototype._exportAllData = function (event) {
27811
27847
  var _a;
27812
27848
  return __awaiter(this, void 0, void 0, function () {
27813
- var lstData, lstVisibleField, lstHeader, printData;
27814
- var _this = this;
27849
+ var lstData, lstVisibleField, lstHeader, fieldSchemaMap, printData;
27815
27850
  return __generator(this, function (_b) {
27816
27851
  switch (_b.label) {
27817
27852
  case 0: return [4 /*yield*/, this.setting.baseService.getDataCustomRoute(this.plusUrl, this.currentGridInfo.filters, this.currentGridInfo.fields, this.currentGridInfo.sorts, -1, 1)];
27818
27853
  case 1:
27819
27854
  lstData = (_a = (_b.sent()).data) !== null && _a !== void 0 ? _a : [];
27820
- return [4 /*yield*/, this.beforeExportAllData(lstData)];
27855
+ lstVisibleField = this.setting.cols
27856
+ .filter(function (item) { return item.visible && item.dataType !== 'trangThaiV5'; })
27857
+ .map(function (item) { return item.field; });
27858
+ return [4 /*yield*/, this.beforeExportAllData(lstData, lstVisibleField)];
27821
27859
  case 2:
27822
27860
  _b.sent();
27823
27861
  return [4 /*yield*/, this._crudService.getRefDataInDatasource(lstData, this.setting.fieldNeedGetRef)];
27824
27862
  case 3:
27825
27863
  _b.sent();
27826
- lstVisibleField = this.setting.cols.filter(function (item) { return item.visible && item.dataType != 'trangThaiV5'; }).map(function (item) {
27827
- if (item.controlType == 'dropdown' && item.field.startsWith('str')) {
27828
- return item.field.slice(3);
27829
- }
27830
- return item.field;
27831
- });
27832
27864
  lstHeader = ['TT'];
27833
- lstVisibleField.forEach(function (item) {
27834
- var schema = _this.setting.modelSchemas.find(function (x) { return x.field == item; });
27835
- lstHeader.push((schema === null || schema === void 0 ? void 0 : schema.name) || "");
27865
+ fieldSchemaMap = new Map(this.setting.modelSchemas.map(function (schema) { return [schema.field, schema.name]; }));
27866
+ lstVisibleField.forEach(function (field) {
27867
+ var schemaName = fieldSchemaMap.get(field) || fieldSchemaMap.get(field.slice(3)) || "";
27868
+ lstHeader.push(schemaName);
27836
27869
  });
27837
27870
  printData = __spreadArray([
27838
27871
  lstHeader
27839
27872
  ], __read(lstData.map(function (item, index) {
27840
27873
  var row = [index + 1];
27841
- _this.setting.cols.filter(function (col) { return col.visible && col.dataType != 'trangThaiV5'; }).forEach(function (col) {
27842
- row.push(item[col.field]);
27874
+ lstVisibleField.forEach(function (field) {
27875
+ row.push(item[field]);
27843
27876
  });
27844
27877
  return row;
27845
27878
  })));
@@ -27849,7 +27882,7 @@
27849
27882
  });
27850
27883
  });
27851
27884
  };
27852
- ListBase.prototype.beforeExportAllData = function (dataSource) {
27885
+ ListBase.prototype.beforeExportAllData = function (dataSource, lstVisibleField) {
27853
27886
  return __awaiter(this, void 0, void 0, function () {
27854
27887
  return __generator(this, function (_b) {
27855
27888
  return [2 /*return*/];