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.
@@ -674,6 +674,7 @@ class CrudListSetting {
674
674
  this.disableViewWorkflowAttach = false;
675
675
  this.hiddenWorkflowCoreStatus = true;
676
676
  this.requiredVanBanDiAfterTrinhKy = false;
677
+ this.disableLazyLoadCommonSearch = false;
677
678
  this.showExportAll = false;
678
679
  this.showExportSelectedItems = true;
679
680
  this.showExportWordSelectedItems = false;
@@ -966,6 +967,7 @@ class FormControlBase extends FormSchemaBase {
966
967
  this.enableCaching = false;
967
968
  this.hasOperatorCanBo = false;
968
969
  this.addToGridInfo = false;
970
+ this.isLazyLoad = false;
969
971
  for (const key in init) {
970
972
  this[key] = init[key];
971
973
  }
@@ -15494,8 +15496,6 @@ class DataFormBase extends ComponentBaseWithButton {
15494
15496
  }
15495
15497
  _handleFormReady(formEvent) {
15496
15498
  return __awaiter(this, void 0, void 0, function* () {
15497
- this.messageInsertSuccess = this._translateService.instant('MESSAGE.INSERT_DATA_SUCCESS');
15498
- this.messageUpdateSuccess = this._translateService.instant('MESSAGE.UPDATE_DATA_SUCCESS');
15499
15499
  yield this.__handleFormReady(formEvent);
15500
15500
  });
15501
15501
  }
@@ -21576,6 +21576,7 @@ class CommonSearchFormComponent extends DataFormBase {
21576
21576
  this.lstBoolControl = [];
21577
21577
  this.lstControlNotIn = [];
21578
21578
  this.lstControlAddToGridInfo = [];
21579
+ this.lstControlLazyLoad = [];
21579
21580
  this.defaultValues = {};
21580
21581
  this.isAddDefaultValues = false;
21581
21582
  this.mapControlBindingFilter = new Map();
@@ -21583,6 +21584,7 @@ class CommonSearchFormComponent extends DataFormBase {
21583
21584
  this.isOpenFull = false;
21584
21585
  this.isCustomGenerateSearch = false;
21585
21586
  this.isDisableOpenFull = false;
21587
+ this._index = 1;
21586
21588
  }
21587
21589
  ngOnInit() {
21588
21590
  this.mdWidth = this.parentSetting.mdWidthCommonSearch;
@@ -21601,9 +21603,10 @@ class CommonSearchFormComponent extends DataFormBase {
21601
21603
  const lstTextSearchControl = columnFilters.filter(p => p.fullTextSearch);
21602
21604
  this.lstTextControl = lstTextSearchControl.map(p => p.field);
21603
21605
  this.searchBoxTooltip += `${(lstTextSearchControl.map(x => x.label)).join(', ')}`;
21606
+ this._index = 2;
21604
21607
  }
21608
+ const totalControlPerRow = 12 / this.mdWidth;
21605
21609
  if (this.isCustomGenerateSearch) {
21606
- this.lstControlAddToGridInfo = this.parentSetting.commonSchemas.filter(p => p.addToGridInfo).map(p => p.field);
21607
21610
  this.parentSetting.commonSchemas.forEach(column => {
21608
21611
  column.showLabel = false;
21609
21612
  column.mdWidth = this.mdWidth;
@@ -21616,25 +21619,33 @@ class CommonSearchFormComponent extends DataFormBase {
21616
21619
  if (column instanceof NumberRangeControlSchema) {
21617
21620
  this.lstNumberRangeControl.push(column.field);
21618
21621
  }
21622
+ if (column.hasOwnProperty('defaultValue') && (column instanceof DropdownControlSchema || column instanceof DateTimeControlSchema)) {
21623
+ this.defaultValues[column.field] = column.defaultValue;
21624
+ }
21625
+ if (column.addToGridInfo) {
21626
+ this.lstControlAddToGridInfo.push(column.field);
21627
+ }
21628
+ column.isLazyLoad = !this.parentSetting.disableLazyLoadCommonSearch && this._index > totalControlPerRow
21629
+ && column instanceof DropdownControlSchema && !!column.baseService && !(column.baseService instanceof MasterDataService);
21630
+ if (column.isLazyLoad) {
21631
+ this.lstControlLazyLoad.push(column.field);
21632
+ }
21633
+ this._index++;
21619
21634
  });
21620
21635
  this.setting.schema = this.addSearchBox(this.parentSetting.commonSchemas.sort((prev, next) => prev.order - next.order));
21621
- this.genFormSchema(this.parentSetting.commonSchemas);
21622
21636
  }
21623
21637
  else {
21624
21638
  this.setting.schema = this.genFormSchema(columnFilters);
21625
21639
  }
21626
21640
  this.isDisableOpenFull = this.setting.schema.length <= 4 && !this._commonService.isMobile();
21627
21641
  super.ngOnInit();
21628
- const controlSetDefaultValue = this.setting.schema.filter(p => p.hasOwnProperty('defaultValue') && (p instanceof DropdownControlSchema || p instanceof DateTimeControlSchema));
21629
- if (controlSetDefaultValue.length) {
21630
- controlSetDefaultValue.forEach(item => {
21631
- this.defaultValues[item.field] = item.defaultValue;
21632
- });
21642
+ if (Object.keys(this.defaultValues).length) {
21633
21643
  this.handleSearch();
21634
21644
  }
21635
21645
  }
21636
21646
  genFormSchema(columns) {
21637
21647
  const result = [];
21648
+ const totalControlPerRow = 12 / this.mdWidth;
21638
21649
  columns.forEach(column => {
21639
21650
  var _a;
21640
21651
  if (!column.isInTable || !column.includeSelect) {
@@ -21654,7 +21665,12 @@ class CommonSearchFormComponent extends DataFormBase {
21654
21665
  });
21655
21666
  }
21656
21667
  if (column.baseService || (dataSource && dataSource.length > 0)) {
21657
- result.push(new DropdownControlSchema(Object.assign(Object.assign({}, column), { placeholder: (_a = column.placeholder) !== null && _a !== void 0 ? _a : `Chọn ${column.label}`, multiple: !column.single, dataSource: dataSource, mdWidth: this.mdWidth, showLabel: false, loadOnInit: true, showClear: true, onChanged: (evt) => {
21668
+ const isLazyLoad = !this.parentSetting.disableLazyLoadCommonSearch && this._index > totalControlPerRow
21669
+ && !!column.baseService && !(column.baseService instanceof MasterDataService);
21670
+ if (isLazyLoad) {
21671
+ this.lstControlLazyLoad.push(column.field);
21672
+ }
21673
+ result.push(new DropdownControlSchema(Object.assign(Object.assign({}, column), { placeholder: (_a = column.placeholder) !== null && _a !== void 0 ? _a : `Chọn ${column.label}`, multiple: !column.single, dataSource: dataSource, mdWidth: this.mdWidth, isLazyLoad: isLazyLoad, showLabel: false, showClear: true, onChanged: (evt) => {
21658
21674
  var _a;
21659
21675
  if (column.dataType == DataType.boolean) {
21660
21676
  evt.parentModel[column.field] = column.single ? (_a = evt.value.id) !== null && _a !== void 0 ? _a : evt.value : evt.value.map(p => p.id);
@@ -21671,6 +21687,7 @@ class CommonSearchFormComponent extends DataFormBase {
21671
21687
  }
21672
21688
  this.handleSearch();
21673
21689
  } })));
21690
+ this._index++;
21674
21691
  }
21675
21692
  }
21676
21693
  else {
@@ -21686,6 +21703,7 @@ class CommonSearchFormComponent extends DataFormBase {
21686
21703
  addColumn.showTime = column.dataType == DataType.datetime;
21687
21704
  result.push(new DateTimeRangeControlSchema(addColumn));
21688
21705
  this.lstDatetimeControl.push(column.field);
21706
+ this._index++;
21689
21707
  break;
21690
21708
  case DataType.int:
21691
21709
  case DataType.intWithoutMask:
@@ -21698,6 +21716,7 @@ class CommonSearchFormComponent extends DataFormBase {
21698
21716
  };
21699
21717
  result.push(new NumberRangeControlSchema(addColumn));
21700
21718
  this.lstNumberRangeControl.push(addColumn.field);
21719
+ this._index++;
21701
21720
  break;
21702
21721
  default:
21703
21722
  break;
@@ -21715,7 +21734,7 @@ class CommonSearchFormComponent extends DataFormBase {
21715
21734
  label: 'Từ khóa',
21716
21735
  fullLabel: 'Từ khóa',
21717
21736
  showLabel: false,
21718
- mdWidth: this.mdWidth
21737
+ mdWidth: this.mdWidth,
21719
21738
  });
21720
21739
  const index = Number(12 / this.mdWidth) - 1;
21721
21740
  if (this._commonService.isMobile()) {
@@ -21744,7 +21763,7 @@ class CommonSearchFormComponent extends DataFormBase {
21744
21763
  data = Object.assign(data, this.defaultValues);
21745
21764
  this.isAddDefaultValues = true;
21746
21765
  }
21747
- let lstFilters = this._crudService.getFilterFromTemplate(this.templateFilter, data);
21766
+ const lstFilters = this._crudService.getFilterFromTemplate(this.templateFilter, data);
21748
21767
  const lstFilterAddCustom = lstFilters.filter(p => this.lstControlAddToGridInfo.includes(p.field));
21749
21768
  if (this.isCustomGenerateSearch) {
21750
21769
  const rs = {
@@ -21814,8 +21833,19 @@ class CommonSearchFormComponent extends DataFormBase {
21814
21833
  }
21815
21834
  toggleMenuSearch() {
21816
21835
  this.isOpenFull = !this.isOpenFull;
21836
+ if (this.lstControlLazyLoad.length) {
21837
+ this.triggerLazyLoadDropdown();
21838
+ }
21817
21839
  this.onAfterToggleMenuSearch.emit(true);
21818
21840
  }
21841
+ triggerLazyLoadDropdown() {
21842
+ return __awaiter(this, void 0, void 0, function* () {
21843
+ const promises = [];
21844
+ this.lstControlLazyLoad.forEach(control => promises.push(this.formControls[control]._component._getDataSource()));
21845
+ yield Promise.all(promises);
21846
+ this.lstControlLazyLoad = [];
21847
+ });
21848
+ }
21819
21849
  onFormInitialized(formEvent) {
21820
21850
  return __awaiter(this, void 0, void 0, function* () {
21821
21851
  // tiền xử lý dữ liệu (ví dụ tổng hợp datasource), trước khi gọi api get detail
@@ -27609,7 +27639,7 @@ class DropdownComponent extends ComponentBase {
27609
27639
  this.createFilterFunction();
27610
27640
  this.createSearchSubscription();
27611
27641
  }
27612
- if (this.control.loadOnInit) {
27642
+ if (this.control.loadOnInit && !this.control.isLazyLoad) {
27613
27643
  this._getData();
27614
27644
  }
27615
27645
  }