@sdcorejs/angular 21.2.9 → 21.2.10

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.
@@ -4609,6 +4609,7 @@ class SdTable {
4609
4609
  #optionRevision = 0;
4610
4610
  #configurationRevision = 0;
4611
4611
  #configurationReady = false;
4612
+ #preparingFilterRequest;
4612
4613
  #hydration;
4613
4614
  #retryConfiguration;
4614
4615
  #pendingReload;
@@ -4792,6 +4793,10 @@ class SdTable {
4792
4793
  #requestReload = (force, delay = 200, source = 'read') => {
4793
4794
  if (this.#destroyed || !this.#configurationReady)
4794
4795
  return;
4796
+ if (this.#preparingFilterRequest) {
4797
+ Object.assign(this.#preparingFilterRequest, this.getFilterRequest());
4798
+ return;
4799
+ }
4795
4800
  this.#read.invalidate();
4796
4801
  this.#failedRead = undefined;
4797
4802
  this.loading.set(false);
@@ -4938,9 +4943,13 @@ class SdTable {
4938
4943
  this.quickSearchValue.set(value.quickSearch || { term: '', filters: {} });
4939
4944
  this.columnOperator = value.columnOperator || {};
4940
4945
  this.#syncColumnFilterInPlace(value.columnFilter || {});
4941
- // why: snapshot ban đầu chỉ hydrate state; cấu hình sở hữu initial read sau khi lookup và form sẵn sàng.
4946
+ // why: hydrate ban đầu và onFilter chuẩn bị chính request hiện tại; không phát lịch đọc tự hủy nhánh đang chờ render.
4942
4947
  if (!this.#configurationReady)
4943
4948
  return;
4949
+ if (this.#preparingFilterRequest) {
4950
+ Object.assign(this.#preparingFilterRequest, this.getFilterRequest());
4951
+ return;
4952
+ }
4944
4953
  if (value.notReload) {
4945
4954
  if (this.#pendingReload?.source === 'filter' && !this.#pendingReload.force)
4946
4955
  this.#cancelReload();
@@ -5043,22 +5052,34 @@ class SdTable {
5043
5052
  this.#ref.detectChanges();
5044
5053
  this.#checkFilter(filterReq);
5045
5054
  const opt = this.tableOption();
5046
- const validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5055
+ let validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5047
5056
  if (opt.type === 'local' && !validQuickSearch) {
5048
5057
  this.loading.set(false);
5049
5058
  return { items: [], total: 0 };
5050
5059
  }
5051
5060
  if (opt.type === 'server') {
5052
5061
  const { items, onFilter } = opt;
5062
+ this.#preparingFilterRequest = filterReq;
5053
5063
  try {
5054
- onFilter?.(filterReq, {
5055
- externalFilterValid: !this.externalFilter()?.form?.invalid,
5056
- quickSearchValid: validQuickSearch,
5057
- });
5064
+ try {
5065
+ onFilter?.(filterReq, {
5066
+ externalFilterValid: !this.externalFilter()?.form?.invalid,
5067
+ quickSearchValid: validQuickSearch,
5068
+ });
5069
+ }
5070
+ catch (err) {
5071
+ console.error(err);
5072
+ }
5073
+ // why: form phải nhận model vừa hydrate trước khi kiểm tra required; emission từ control vẫn thuộc request này.
5074
+ if (onFilter)
5075
+ this.#ref.detectChanges();
5058
5076
  }
5059
- catch (err) {
5060
- console.error(err);
5077
+ finally {
5078
+ this.#preparingFilterRequest = undefined;
5061
5079
  }
5080
+ // why: onFilter có thể hydrate tenant/filter từ URL trước khi chụp snapshot; kiểm tra giá trị đã áp dụng.
5081
+ validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5082
+ this.#checkFilter(filterReq);
5062
5083
  if (this.externalFilter()?.form?.invalid || !validQuickSearch) {
5063
5084
  this.#read.invalidate();
5064
5085
  this.#failedRead = undefined;