@theseam/ui-common 1.0.2-beta.63 → 1.0.2-beta.67

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.
@@ -6,6 +6,7 @@ import { isDevMode, InjectionToken, Optional, Inject, Injectable, EventEmitter }
6
6
  import { hasProperty, notNullOrUndefined, isNullOrUndefined, withoutProperty, wrapIntoObservable, withoutProperties } from '@theseam/ui-common/utils';
7
7
  import { Observable, EMPTY, from, defer, of, combineLatest, Subscription, Subject, BehaviorSubject, isObservable } from 'rxjs';
8
8
  import { switchMap, tap, take, concatMap, filter, toArray, map, auditTime, distinctUntilChanged, finalize, catchError, shareReplay, startWith, skip } from 'rxjs/operators';
9
+ import { outputToObservable } from '@angular/core/rxjs-interop';
9
10
  import * as i1 from 'apollo-angular';
10
11
  import { gql, provideApollo } from 'apollo-angular';
11
12
  import { THESEAM_COLUMNS_DATA_FILTER_DATE_TEXT_SEARCH_TYPES, getFormattedDateForComparison, THESEAM_COLUMNS_DATA_FILTER_DATE_RANGE_SEARCH_TYPES, THESEAM_COLUMNS_DATA_FILTER_NUMERIC_TEXT_SEARCH_TYPES, THESEAM_COLUMNS_DATA_FILTER_NUMERIC_RANGE_SEARCH_TYPES, THESEAM_COLUMNS_DATA_FILTER_TEXT_TEXT_SEARCH_TYPES } from '@theseam/ui-common/datatable';
@@ -879,16 +880,12 @@ function observeRowsWithGqlInputsHandling(queryRef, rows, datatable, extraVariab
879
880
  });
880
881
  }));
881
882
  return defer(() => {
882
- // Observe the optional refresh-button patch attached externally to the
883
- // datatable instance. When the user triggers a refresh, refetch the data.
883
+ // Observe the datatable's refreshRequested output. When the user clicks the
884
+ // refresh button (or any other consumer triggers DatatableRefreshService),
885
+ // refetch the data.
884
886
  let refreshBtnSub = Subscription.EMPTY;
885
887
  refreshBtnSub = datatable$
886
- .pipe(switchMap((dt) => {
887
- if (!dt || !dt.__refreshPatch) {
888
- return EMPTY;
889
- }
890
- return dt.__refreshPatch.refreshTriggered.pipe(tap(() => queryRef.refetch(undefined, true)));
891
- }))
888
+ .pipe(switchMap((dt) => dt ? outputToObservable(dt.refreshRequested) : EMPTY), tap(() => queryRef.refetch(undefined, true)))
892
889
  .subscribe();
893
890
  // Bridge query-input changes to row emissions via a Subject so that the
894
891
  // rows observable is only subscribed once (on the first input change) and
@@ -2061,6 +2058,20 @@ class MockDatatable {
2061
2058
  _columnsSubject = new BehaviorSubject([]);
2062
2059
  columns$ = this._columnsSubject.asObservable();
2063
2060
  _filterStatesSubject = new BehaviorSubject([]);
2061
+ _refreshSubject = new Subject();
2062
+ // Hand-rolled OutputRef so MockDatatable can be constructed outside an
2063
+ // injection context (outputFromObservable requires one). outputToObservable
2064
+ // tolerates a missing destroyRef via an optional chain.
2065
+ refreshRequested = {
2066
+ subscribe: (cb) => {
2067
+ const sub = this._refreshSubject.subscribe(() => cb(undefined));
2068
+ return { unsubscribe: () => sub.unsubscribe() };
2069
+ },
2070
+ };
2071
+ /** Test helper: simulate the refresh button being clicked. */
2072
+ triggerRefresh() {
2073
+ this._refreshSubject.next();
2074
+ }
2064
2075
  _sorts = [];
2065
2076
  _rows = [];
2066
2077
  _offset = 0;