tnx-shared 5.3.185 → 5.3.186

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
  }
@@ -31645,6 +31647,7 @@
31645
31647
  _this.lstBoolControl = [];
31646
31648
  _this.lstControlNotIn = [];
31647
31649
  _this.lstControlAddToGridInfo = [];
31650
+ _this.lstControlLazyLoad = [];
31648
31651
  _this.defaultValues = {};
31649
31652
  _this.isAddDefaultValues = false;
31650
31653
  _this.mapControlBindingFilter = new Map();
@@ -31652,6 +31655,7 @@
31652
31655
  _this.isOpenFull = false;
31653
31656
  _this.isCustomGenerateSearch = false;
31654
31657
  _this.isDisableOpenFull = false;
31658
+ _this._index = 1;
31655
31659
  return _this;
31656
31660
  }
31657
31661
  CommonSearchFormComponent.prototype.ngOnInit = function () {
@@ -31672,9 +31676,10 @@
31672
31676
  var lstTextSearchControl = columnFilters.filter(function (p) { return p.fullTextSearch; });
31673
31677
  this.lstTextControl = lstTextSearchControl.map(function (p) { return p.field; });
31674
31678
  this.searchBoxTooltip += "" + (lstTextSearchControl.map(function (x) { return x.label; })).join(', ');
31679
+ this._index = 2;
31675
31680
  }
31681
+ var totalControlPerRow = 12 / this.mdWidth;
31676
31682
  if (this.isCustomGenerateSearch) {
31677
- this.lstControlAddToGridInfo = this.parentSetting.commonSchemas.filter(function (p) { return p.addToGridInfo; }).map(function (p) { return p.field; });
31678
31683
  this.parentSetting.commonSchemas.forEach(function (column) {
31679
31684
  column.showLabel = false;
31680
31685
  column.mdWidth = _this.mdWidth;
@@ -31687,26 +31692,34 @@
31687
31692
  if (column instanceof NumberRangeControlSchema) {
31688
31693
  _this.lstNumberRangeControl.push(column.field);
31689
31694
  }
31695
+ if (column.hasOwnProperty('defaultValue') && (column instanceof DropdownControlSchema || column instanceof DateTimeControlSchema)) {
31696
+ _this.defaultValues[column.field] = column.defaultValue;
31697
+ }
31698
+ if (column.addToGridInfo) {
31699
+ _this.lstControlAddToGridInfo.push(column.field);
31700
+ }
31701
+ column.isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31702
+ && column instanceof DropdownControlSchema && !!column.baseService && !(column.baseService instanceof MasterDataService);
31703
+ if (column.isLazyLoad) {
31704
+ _this.lstControlLazyLoad.push(column.field);
31705
+ }
31706
+ _this._index++;
31690
31707
  });
31691
31708
  this.setting.schema = this.addSearchBox(this.parentSetting.commonSchemas.sort(function (prev, next) { return prev.order - next.order; }));
31692
- this.genFormSchema(this.parentSetting.commonSchemas);
31693
31709
  }
31694
31710
  else {
31695
31711
  this.setting.schema = this.genFormSchema(columnFilters);
31696
31712
  }
31697
31713
  this.isDisableOpenFull = this.setting.schema.length <= 4 && !this._commonService.isMobile();
31698
31714
  _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
- });
31715
+ if (Object.keys(this.defaultValues).length) {
31704
31716
  this.handleSearch();
31705
31717
  }
31706
31718
  };
31707
31719
  CommonSearchFormComponent.prototype.genFormSchema = function (columns) {
31708
31720
  var _this = this;
31709
31721
  var result = [];
31722
+ var totalControlPerRow = 12 / this.mdWidth;
31710
31723
  columns.forEach(function (column) {
31711
31724
  var _a;
31712
31725
  if (!column.isInTable || !column.includeSelect) {
@@ -31726,7 +31739,12 @@
31726
31739
  });
31727
31740
  }
31728
31741
  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) {
31742
+ var isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31743
+ && !!column.baseService && !(column.baseService instanceof MasterDataService);
31744
+ if (isLazyLoad) {
31745
+ _this.lstControlLazyLoad.push(column.field);
31746
+ }
31747
+ 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
31748
  var _a;
31731
31749
  if (column.dataType == exports.DataType.boolean) {
31732
31750
  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 +31761,7 @@
31743
31761
  }
31744
31762
  _this.handleSearch();
31745
31763
  } })));
31764
+ _this._index++;
31746
31765
  }
31747
31766
  }
31748
31767
  else {
@@ -31758,6 +31777,7 @@
31758
31777
  addColumn.showTime = column.dataType == exports.DataType.datetime;
31759
31778
  result.push(new DateTimeRangeControlSchema(addColumn));
31760
31779
  _this.lstDatetimeControl.push(column.field);
31780
+ _this._index++;
31761
31781
  break;
31762
31782
  case exports.DataType.int:
31763
31783
  case exports.DataType.intWithoutMask:
@@ -31770,6 +31790,7 @@
31770
31790
  };
31771
31791
  result.push(new NumberRangeControlSchema(addColumn));
31772
31792
  _this.lstNumberRangeControl.push(addColumn.field);
31793
+ _this._index++;
31773
31794
  break;
31774
31795
  default:
31775
31796
  break;
@@ -31787,7 +31808,7 @@
31787
31808
  label: 'Từ khóa',
31788
31809
  fullLabel: 'Từ khóa',
31789
31810
  showLabel: false,
31790
- mdWidth: this.mdWidth
31811
+ mdWidth: this.mdWidth,
31791
31812
  });
31792
31813
  var index = Number(12 / this.mdWidth) - 1;
31793
31814
  if (this._commonService.isMobile()) {
@@ -31884,8 +31905,29 @@
31884
31905
  };
31885
31906
  CommonSearchFormComponent.prototype.toggleMenuSearch = function () {
31886
31907
  this.isOpenFull = !this.isOpenFull;
31908
+ if (this.lstControlLazyLoad.length) {
31909
+ this.triggerLazyLoadDropdown();
31910
+ }
31887
31911
  this.onAfterToggleMenuSearch.emit(true);
31888
31912
  };
31913
+ CommonSearchFormComponent.prototype.triggerLazyLoadDropdown = function () {
31914
+ return __awaiter(this, void 0, void 0, function () {
31915
+ var promises;
31916
+ var _this = this;
31917
+ return __generator(this, function (_b) {
31918
+ switch (_b.label) {
31919
+ case 0:
31920
+ promises = [];
31921
+ this.lstControlLazyLoad.forEach(function (control) { return promises.push(_this.formControls[control]._component._getDataSource()); });
31922
+ return [4 /*yield*/, Promise.all(promises)];
31923
+ case 1:
31924
+ _b.sent();
31925
+ this.lstControlLazyLoad = [];
31926
+ return [2 /*return*/];
31927
+ }
31928
+ });
31929
+ });
31930
+ };
31889
31931
  CommonSearchFormComponent.prototype.onFormInitialized = function (formEvent) {
31890
31932
  return __awaiter(this, void 0, void 0, function () {
31891
31933
  return __generator(this, function (_b) {
@@ -32139,7 +32181,7 @@
32139
32181
  this.createFilterFunction();
32140
32182
  this.createSearchSubscription();
32141
32183
  }
32142
- if (this.control.loadOnInit) {
32184
+ if (this.control.loadOnInit && !this.control.isLazyLoad) {
32143
32185
  this._getData();
32144
32186
  }
32145
32187
  }