@sdcorejs/angular 22.2.9 → 22.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.
@@ -4785,6 +4785,7 @@ class SdTable {
4785
4785
  #optionRevision = 0;
4786
4786
  #configurationRevision = 0;
4787
4787
  #configurationReady = false;
4788
+ #preparingFilterRequest;
4788
4789
  #hydration;
4789
4790
  #retryConfiguration;
4790
4791
  #pendingReload;
@@ -4970,6 +4971,10 @@ class SdTable {
4970
4971
  #requestReload = (force, delay = 200, source = 'read') => {
4971
4972
  if (this.#destroyed || !this.#configurationReady)
4972
4973
  return;
4974
+ if (this.#preparingFilterRequest) {
4975
+ Object.assign(this.#preparingFilterRequest, this.getFilterRequest());
4976
+ return;
4977
+ }
4973
4978
  this.#read.invalidate();
4974
4979
  this.#failedRead = undefined;
4975
4980
  this.loading.set(false);
@@ -5116,9 +5121,13 @@ class SdTable {
5116
5121
  this.quickSearchValue.set(value.quickSearch || { term: '', filters: {} });
5117
5122
  this.columnOperator = value.columnOperator || {};
5118
5123
  this.#syncColumnFilterInPlace(value.columnFilter || {});
5119
- // 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.
5124
+ // 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.
5120
5125
  if (!this.#configurationReady)
5121
5126
  return;
5127
+ if (this.#preparingFilterRequest) {
5128
+ Object.assign(this.#preparingFilterRequest, this.getFilterRequest());
5129
+ return;
5130
+ }
5122
5131
  if (value.notReload) {
5123
5132
  if (this.#pendingReload?.source === 'filter' && !this.#pendingReload.force)
5124
5133
  this.#cancelReload();
@@ -5221,22 +5230,34 @@ class SdTable {
5221
5230
  this.#ref.detectChanges();
5222
5231
  this.#checkFilter(filterReq);
5223
5232
  const opt = this.tableOption();
5224
- const validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5233
+ let validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5225
5234
  if (opt.type === 'local' && !validQuickSearch) {
5226
5235
  this.loading.set(false);
5227
5236
  return { items: [], total: 0 };
5228
5237
  }
5229
5238
  if (opt.type === 'server') {
5230
5239
  const { items, onFilter } = opt;
5240
+ this.#preparingFilterRequest = filterReq;
5231
5241
  try {
5232
- onFilter?.(filterReq, {
5233
- externalFilterValid: !this.externalFilter()?.form?.invalid,
5234
- quickSearchValid: validQuickSearch,
5235
- });
5242
+ try {
5243
+ onFilter?.(filterReq, {
5244
+ externalFilterValid: !this.externalFilter()?.form?.invalid,
5245
+ quickSearchValid: validQuickSearch,
5246
+ });
5247
+ }
5248
+ catch (err) {
5249
+ console.error(err);
5250
+ }
5251
+ // 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.
5252
+ if (onFilter)
5253
+ this.#ref.detectChanges();
5236
5254
  }
5237
- catch (err) {
5238
- console.error(err);
5255
+ finally {
5256
+ this.#preparingFilterRequest = undefined;
5239
5257
  }
5258
+ // why: onFilter có thể hydrate tenant/filter từ URL trước khi chụp snapshot; kiểm tra giá trị đã áp dụng.
5259
+ validQuickSearch = quickSearchValid(this.quickSearchOption(), filterReq.quickSearch);
5260
+ this.#checkFilter(filterReq);
5240
5261
  if (this.externalFilter()?.form?.invalid || !validQuickSearch) {
5241
5262
  this.#read.invalidate();
5242
5263
  this.#failedRead = undefined;