tnx-shared 5.3.185 → 5.3.187

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.
@@ -1116,6 +1116,7 @@
1116
1116
  this.disableViewWorkflowAttach = false;
1117
1117
  this.hiddenWorkflowCoreStatus = true;
1118
1118
  this.requiredVanBanDiAfterTrinhKy = false;
1119
+ this.disableLazyLoadCommonSearch = false;
1119
1120
  this.showExportAll = false;
1120
1121
  this.showExportSelectedItems = true;
1121
1122
  this.showExportWordSelectedItems = false;
@@ -1453,6 +1454,7 @@
1453
1454
  _this.enableCaching = false;
1454
1455
  _this.hasOperatorCanBo = false;
1455
1456
  _this.addToGridInfo = false;
1457
+ _this.isLazyLoad = false;
1456
1458
  for (var key in init) {
1457
1459
  _this[key] = init[key];
1458
1460
  }
@@ -18418,10 +18420,7 @@
18418
18420
  return __awaiter(this, void 0, void 0, function () {
18419
18421
  return __generator(this, function (_e) {
18420
18422
  switch (_e.label) {
18421
- case 0:
18422
- this.messageInsertSuccess = this._translateService.instant('MESSAGE.INSERT_DATA_SUCCESS');
18423
- this.messageUpdateSuccess = this._translateService.instant('MESSAGE.UPDATE_DATA_SUCCESS');
18424
- return [4 /*yield*/, this.__handleFormReady(formEvent)];
18423
+ case 0: return [4 /*yield*/, this.__handleFormReady(formEvent)];
18425
18424
  case 1:
18426
18425
  _e.sent();
18427
18426
  return [2 /*return*/];
@@ -31645,6 +31644,7 @@
31645
31644
  _this.lstBoolControl = [];
31646
31645
  _this.lstControlNotIn = [];
31647
31646
  _this.lstControlAddToGridInfo = [];
31647
+ _this.lstControlLazyLoad = [];
31648
31648
  _this.defaultValues = {};
31649
31649
  _this.isAddDefaultValues = false;
31650
31650
  _this.mapControlBindingFilter = new Map();
@@ -31652,6 +31652,7 @@
31652
31652
  _this.isOpenFull = false;
31653
31653
  _this.isCustomGenerateSearch = false;
31654
31654
  _this.isDisableOpenFull = false;
31655
+ _this._index = 1;
31655
31656
  return _this;
31656
31657
  }
31657
31658
  CommonSearchFormComponent.prototype.ngOnInit = function () {
@@ -31672,9 +31673,10 @@
31672
31673
  var lstTextSearchControl = columnFilters.filter(function (p) { return p.fullTextSearch; });
31673
31674
  this.lstTextControl = lstTextSearchControl.map(function (p) { return p.field; });
31674
31675
  this.searchBoxTooltip += "" + (lstTextSearchControl.map(function (x) { return x.label; })).join(', ');
31676
+ this._index = 2;
31675
31677
  }
31678
+ var totalControlPerRow = 12 / this.mdWidth;
31676
31679
  if (this.isCustomGenerateSearch) {
31677
- this.lstControlAddToGridInfo = this.parentSetting.commonSchemas.filter(function (p) { return p.addToGridInfo; }).map(function (p) { return p.field; });
31678
31680
  this.parentSetting.commonSchemas.forEach(function (column) {
31679
31681
  column.showLabel = false;
31680
31682
  column.mdWidth = _this.mdWidth;
@@ -31687,26 +31689,34 @@
31687
31689
  if (column instanceof NumberRangeControlSchema) {
31688
31690
  _this.lstNumberRangeControl.push(column.field);
31689
31691
  }
31692
+ if (column.hasOwnProperty('defaultValue') && (column instanceof DropdownControlSchema || column instanceof DateTimeControlSchema)) {
31693
+ _this.defaultValues[column.field] = column.defaultValue;
31694
+ }
31695
+ if (column.addToGridInfo) {
31696
+ _this.lstControlAddToGridInfo.push(column.field);
31697
+ }
31698
+ column.isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31699
+ && column instanceof DropdownControlSchema && !!column.baseService && !(column.baseService instanceof MasterDataService);
31700
+ if (column.isLazyLoad) {
31701
+ _this.lstControlLazyLoad.push(column.field);
31702
+ }
31703
+ _this._index++;
31690
31704
  });
31691
31705
  this.setting.schema = this.addSearchBox(this.parentSetting.commonSchemas.sort(function (prev, next) { return prev.order - next.order; }));
31692
- this.genFormSchema(this.parentSetting.commonSchemas);
31693
31706
  }
31694
31707
  else {
31695
31708
  this.setting.schema = this.genFormSchema(columnFilters);
31696
31709
  }
31697
31710
  this.isDisableOpenFull = this.setting.schema.length <= 4 && !this._commonService.isMobile();
31698
31711
  _super.prototype.ngOnInit.call(this);
31699
- var controlSetDefaultValue = this.setting.schema.filter(function (p) { return p.hasOwnProperty('defaultValue') && (p instanceof DropdownControlSchema || p instanceof DateTimeControlSchema); });
31700
- if (controlSetDefaultValue.length) {
31701
- controlSetDefaultValue.forEach(function (item) {
31702
- _this.defaultValues[item.field] = item.defaultValue;
31703
- });
31712
+ if (Object.keys(this.defaultValues).length) {
31704
31713
  this.handleSearch();
31705
31714
  }
31706
31715
  };
31707
31716
  CommonSearchFormComponent.prototype.genFormSchema = function (columns) {
31708
31717
  var _this = this;
31709
31718
  var result = [];
31719
+ var totalControlPerRow = 12 / this.mdWidth;
31710
31720
  columns.forEach(function (column) {
31711
31721
  var _a;
31712
31722
  if (!column.isInTable || !column.includeSelect) {
@@ -31726,7 +31736,12 @@
31726
31736
  });
31727
31737
  }
31728
31738
  if (column.baseService || (dataSource && dataSource.length > 0)) {
31729
- result.push(new DropdownControlSchema(Object.assign(Object.assign({}, column), { placeholder: (_a = column.placeholder) !== null && _a !== void 0 ? _a : "Ch\u1ECDn " + column.label, multiple: !column.single, dataSource: dataSource, mdWidth: _this.mdWidth, showLabel: false, loadOnInit: true, showClear: true, onChanged: function (evt) {
31739
+ var isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31740
+ && !!column.baseService && !(column.baseService instanceof MasterDataService);
31741
+ if (isLazyLoad) {
31742
+ _this.lstControlLazyLoad.push(column.field);
31743
+ }
31744
+ result.push(new DropdownControlSchema(Object.assign(Object.assign({}, column), { placeholder: (_a = column.placeholder) !== null && _a !== void 0 ? _a : "Ch\u1ECDn " + column.label, multiple: !column.single, dataSource: dataSource, mdWidth: _this.mdWidth, isLazyLoad: isLazyLoad, showLabel: false, showClear: true, onChanged: function (evt) {
31730
31745
  var _a;
31731
31746
  if (column.dataType == exports.DataType.boolean) {
31732
31747
  evt.parentModel[column.field] = column.single ? (_a = evt.value.id) !== null && _a !== void 0 ? _a : evt.value : evt.value.map(function (p) { return p.id; });
@@ -31743,6 +31758,7 @@
31743
31758
  }
31744
31759
  _this.handleSearch();
31745
31760
  } })));
31761
+ _this._index++;
31746
31762
  }
31747
31763
  }
31748
31764
  else {
@@ -31758,6 +31774,7 @@
31758
31774
  addColumn.showTime = column.dataType == exports.DataType.datetime;
31759
31775
  result.push(new DateTimeRangeControlSchema(addColumn));
31760
31776
  _this.lstDatetimeControl.push(column.field);
31777
+ _this._index++;
31761
31778
  break;
31762
31779
  case exports.DataType.int:
31763
31780
  case exports.DataType.intWithoutMask:
@@ -31770,6 +31787,7 @@
31770
31787
  };
31771
31788
  result.push(new NumberRangeControlSchema(addColumn));
31772
31789
  _this.lstNumberRangeControl.push(addColumn.field);
31790
+ _this._index++;
31773
31791
  break;
31774
31792
  default:
31775
31793
  break;
@@ -31787,7 +31805,7 @@
31787
31805
  label: 'Từ khóa',
31788
31806
  fullLabel: 'Từ khóa',
31789
31807
  showLabel: false,
31790
- mdWidth: this.mdWidth
31808
+ mdWidth: this.mdWidth,
31791
31809
  });
31792
31810
  var index = Number(12 / this.mdWidth) - 1;
31793
31811
  if (this._commonService.isMobile()) {
@@ -31884,8 +31902,29 @@
31884
31902
  };
31885
31903
  CommonSearchFormComponent.prototype.toggleMenuSearch = function () {
31886
31904
  this.isOpenFull = !this.isOpenFull;
31905
+ if (this.lstControlLazyLoad.length) {
31906
+ this.triggerLazyLoadDropdown();
31907
+ }
31887
31908
  this.onAfterToggleMenuSearch.emit(true);
31888
31909
  };
31910
+ CommonSearchFormComponent.prototype.triggerLazyLoadDropdown = function () {
31911
+ return __awaiter(this, void 0, void 0, function () {
31912
+ var promises;
31913
+ var _this = this;
31914
+ return __generator(this, function (_b) {
31915
+ switch (_b.label) {
31916
+ case 0:
31917
+ promises = [];
31918
+ this.lstControlLazyLoad.forEach(function (control) { return promises.push(_this.formControls[control]._component._getDataSource()); });
31919
+ return [4 /*yield*/, Promise.all(promises)];
31920
+ case 1:
31921
+ _b.sent();
31922
+ this.lstControlLazyLoad = [];
31923
+ return [2 /*return*/];
31924
+ }
31925
+ });
31926
+ });
31927
+ };
31889
31928
  CommonSearchFormComponent.prototype.onFormInitialized = function (formEvent) {
31890
31929
  return __awaiter(this, void 0, void 0, function () {
31891
31930
  return __generator(this, function (_b) {
@@ -32139,7 +32178,7 @@
32139
32178
  this.createFilterFunction();
32140
32179
  this.createSearchSubscription();
32141
32180
  }
32142
- if (this.control.loadOnInit) {
32181
+ if (this.control.loadOnInit && !this.control.isLazyLoad) {
32143
32182
  this._getData();
32144
32183
  }
32145
32184
  }