@recursyve/nice-data-filter-kit 14.1.1 → 14.1.3

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.
@@ -2752,6 +2752,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
2752
2752
  const EXPORTS_SETTINGS = new InjectionToken("exports_settings");
2753
2753
  const FILTER_VIEW_ICONS = new InjectionToken("filter_view_icons");
2754
2754
  const FILTER_VIEW_STATE = new InjectionToken("filter_view_state");
2755
+ const FILTER_VIEW_STORE = new InjectionToken("filter_view_store");
2755
2756
 
2756
2757
  const initialValue = {
2757
2758
  subStates: {},
@@ -2773,12 +2774,12 @@ const initialValue = {
2773
2774
  queryParams: null,
2774
2775
  resetResult: false
2775
2776
  };
2776
- let NiceFilterViewStore = class NiceFilterViewStore extends EntityStore {
2777
- constructor(state) {
2777
+ class NiceFilterViewStore extends EntityStore {
2778
+ constructor(state, store) {
2778
2779
  super({
2779
2780
  ...initialValue,
2780
2781
  ...state
2781
- });
2782
+ }, store);
2782
2783
  }
2783
2784
  setFilterConfigLoading(loading) {
2784
2785
  this.update({ filterConfigLoading: loading });
@@ -2806,11 +2807,11 @@ let NiceFilterViewStore = class NiceFilterViewStore extends EntityStore {
2806
2807
  filterResult
2807
2808
  });
2808
2809
  }
2809
- if (mode === "accumulated") {
2810
- this.add(filterResult.values);
2810
+ if (mode === "accumulated" && !resetResult) {
2811
+ this.add([...filterResult.values]);
2811
2812
  }
2812
2813
  else {
2813
- this.set(filterResult.values);
2814
+ this.set([...filterResult.values]);
2814
2815
  }
2815
2816
  }
2816
2817
  addValue(value, opts) {
@@ -2826,44 +2827,45 @@ let NiceFilterViewStore = class NiceFilterViewStore extends EntityStore {
2826
2827
  });
2827
2828
  this.add(value, opts);
2828
2829
  }
2829
- upsertValue(value, key = "id") {
2830
+ upsertValue(value, key) {
2830
2831
  const { filterResult } = this.getValue();
2831
2832
  if (!filterResult) {
2832
2833
  return;
2833
2834
  }
2835
+ const idKey = key ?? this.idKey;
2834
2836
  this.update({
2835
2837
  filterResult: {
2836
2838
  ...filterResult,
2837
- values: arrayUpsert(filterResult.values, value[key], value)
2839
+ values: arrayUpsert(filterResult.values, value[idKey], value, key)
2838
2840
  }
2839
2841
  });
2840
- this.upsert(value[key], value);
2842
+ this.upsert(value[idKey], value);
2841
2843
  }
2842
- removeValue(value, key = "id") {
2844
+ removeValue(value, key) {
2843
2845
  const { filterResult } = this.getValue();
2844
2846
  if (!filterResult) {
2845
2847
  return;
2846
2848
  }
2849
+ const idKey = key ?? this.idKey;
2847
2850
  this.update({
2848
2851
  filterResult: {
2849
2852
  ...filterResult,
2850
- values: arrayRemove(filterResult.values, value[key])
2853
+ values: arrayRemove(filterResult.values, value[idKey], key)
2851
2854
  }
2852
2855
  });
2853
- this.remove(value[key]);
2856
+ this.remove(value[idKey]);
2854
2857
  }
2855
- };
2856
- NiceFilterViewStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, deps: [{ token: FILTER_VIEW_STATE }], target: i0.ɵɵFactoryTarget.Injectable });
2858
+ }
2859
+ NiceFilterViewStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, deps: [{ token: FILTER_VIEW_STATE }, { token: FILTER_VIEW_STORE }], target: i0.ɵɵFactoryTarget.Injectable });
2857
2860
  NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore });
2858
- NiceFilterViewStore = __decorate([
2859
- StoreConfig({ name: "nice-filter-view", resettable: true }),
2860
- __metadata("design:paramtypes", [Object])
2861
- ], NiceFilterViewStore);
2862
2861
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, decorators: [{
2863
2862
  type: Injectable
2864
2863
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2865
2864
  type: Inject,
2866
2865
  args: [FILTER_VIEW_STATE]
2866
+ }] }, { type: undefined, decorators: [{
2867
+ type: Inject,
2868
+ args: [FILTER_VIEW_STORE]
2867
2869
  }] }]; } });
2868
2870
 
2869
2871
  class NiceFilterViewQuery extends QueryEntity {
@@ -3086,10 +3088,10 @@ class NiceFilterViewService {
3086
3088
  addValue(value, opts) {
3087
3089
  this.store.addValue(value, opts);
3088
3090
  }
3089
- upsertValue(value, key = "id") {
3091
+ upsertValue(value, key) {
3090
3092
  this.store.upsertValue(value, key);
3091
3093
  }
3092
- removeValue(value, key = "id") {
3094
+ removeValue(value, key) {
3093
3095
  this.store.removeValue(value, key);
3094
3096
  }
3095
3097
  resetResult(waitForNextFilter) {
@@ -3225,11 +3227,11 @@ class NiceFilterInfiniteScrollDataViewComponent {
3225
3227
  constructor(query, service) {
3226
3228
  this.query = query;
3227
3229
  this.service = service;
3228
- this.data$ = this.query.selectAll();
3230
+ this.data$ = this.query.selectAll().pipe(tap(x => console.log(x)));
3229
3231
  }
3230
3232
  async loadNextPage() {
3231
3233
  const { filterParameters } = this.query.getValue();
3232
- this.service.setMode("paginated");
3234
+ this.service.setMode("accumulated");
3233
3235
  await this.service.setParameters({
3234
3236
  ...filterParameters,
3235
3237
  start: filterParameters.start + filterParameters.length
@@ -3259,6 +3261,10 @@ class NiceFilterSearchComponent {
3259
3261
  ngOnInit() {
3260
3262
  this.searchText$
3261
3263
  .pipe(takeUntil(this.unsubscribeAll$), debounceTime(300), distinctUntilChanged(), tap((search) => {
3264
+ const { mode } = this.query.getValue();
3265
+ if (mode === "accumulated") {
3266
+ this.service.resetPaging();
3267
+ }
3262
3268
  const { filterParameters } = this.query.getValue();
3263
3269
  this.service.setParameters({
3264
3270
  ...filterParameters,
@@ -3602,6 +3608,10 @@ class NiceFilterViewModule {
3602
3608
  {
3603
3609
  provide: FILTER_VIEW_STATE,
3604
3610
  useValue: options.state ?? {}
3611
+ },
3612
+ {
3613
+ provide: FILTER_VIEW_STORE,
3614
+ useValue: options.store ?? { name: "nice-filter-view", resettable: true }
3605
3615
  }
3606
3616
  ].filter(x => !!x);
3607
3617
  }