@recursyve/nice-data-filter-kit 14.4.1 → 14.5.0

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.
@@ -5,7 +5,7 @@ import * as i5$1 from '@recursyve/nice-ui-kit.v2';
5
5
  import { isNullOrUndefined, ObjectUtils, FileUtils, ArrayUtils, ExportBottomSheetComponent, NiceLoadingSpinnerModule, NiceTypeaheadModule, NiceExportBottomSheetModule, NiceAsyncTypeaheadProvider, NICE_ASYNC_TYPEAHEAD_PROVIDER, NiceAsyncTypeaheadModule } from '@recursyve/nice-ui-kit.v2';
6
6
  import * as i0 from '@angular/core';
7
7
  import { Directive, Input, NgModule, Injectable, Inject, InjectionToken, Optional, Pipe, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, HostListener, forwardRef, TemplateRef, ContentChild, ContentChildren, QueryList, ViewChild } from '@angular/core';
8
- import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, QueryEntity, EntityActions } from '@datorama/akita';
8
+ import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, transaction, QueryEntity, EntityActions } from '@datorama/akita';
9
9
  import { combineLatest, Subject, firstValueFrom, of, lastValueFrom, startWith, tap, distinct, take } from 'rxjs';
10
10
  import { __decorate, __metadata } from 'tslib';
11
11
  import * as i2 from '@angular/router';
@@ -571,7 +571,8 @@ class FilterUtils {
571
571
  rules: filterParameters.rules ?? []
572
572
  },
573
573
  order: OrderUtils.combineOrders(filterParameters.order, filterParameters.fallbackOrder),
574
- data: filterParameters.data
574
+ data: filterParameters.data,
575
+ groupBy: filterParameters.groupBy
575
576
  };
576
577
  }
577
578
  static filterChangeNeedsRefresh(currentFilters, newFilters) {
@@ -2756,6 +2757,7 @@ const initialValue = {
2756
2757
  mode: "paginated",
2757
2758
  autoLoad: true,
2758
2759
  disabled: false,
2760
+ initialLoadCompleted: false,
2759
2761
  filterConfigLoading: false,
2760
2762
  filterConfig: [],
2761
2763
  filterResult: null,
@@ -2789,7 +2791,7 @@ class NiceFilterViewStore extends EntityStore {
2789
2791
  this.update({ filterParameters });
2790
2792
  }
2791
2793
  setResult(filterResult) {
2792
- const { mode, resetResult } = this.getValue();
2794
+ const { mode, resetResult, initialLoadCompleted } = this.getValue();
2793
2795
  if (mode === "accumulated") {
2794
2796
  this.update((state) => ({
2795
2797
  filterResult: {
@@ -2814,6 +2816,9 @@ class NiceFilterViewStore extends EntityStore {
2814
2816
  else {
2815
2817
  this.set([...filterResult.values]);
2816
2818
  }
2819
+ if (!initialLoadCompleted) {
2820
+ this.update({ initialLoadCompleted: true });
2821
+ }
2817
2822
  }
2818
2823
  addValue(value, opts) {
2819
2824
  const { filterResult } = this.getValue();
@@ -2828,6 +2833,19 @@ class NiceFilterViewStore extends EntityStore {
2828
2833
  });
2829
2834
  this.add(value, opts);
2830
2835
  }
2836
+ addValues(values, opts) {
2837
+ const { filterResult } = this.getValue();
2838
+ if (!filterResult) {
2839
+ return;
2840
+ }
2841
+ this.update({
2842
+ filterResult: {
2843
+ ...filterResult,
2844
+ values: arrayAdd(filterResult.values, values, opts)
2845
+ }
2846
+ });
2847
+ this.add(values, opts);
2848
+ }
2831
2849
  upsertValue(value, key) {
2832
2850
  const { filterResult } = this.getValue();
2833
2851
  if (!filterResult) {
@@ -2842,6 +2860,22 @@ class NiceFilterViewStore extends EntityStore {
2842
2860
  });
2843
2861
  this.upsert(value[idKey], value);
2844
2862
  }
2863
+ upsertValues(values, key) {
2864
+ const { filterResult } = this.getValue();
2865
+ if (!filterResult) {
2866
+ return;
2867
+ }
2868
+ const idKey = key ?? this.idKey;
2869
+ for (const value of values) {
2870
+ this.update({
2871
+ filterResult: {
2872
+ ...filterResult,
2873
+ values: arrayUpsert(filterResult.values, value[idKey], value, key)
2874
+ }
2875
+ });
2876
+ this.upsert(value[idKey], value);
2877
+ }
2878
+ }
2845
2879
  removeValue(value, key) {
2846
2880
  const { filterResult } = this.getValue();
2847
2881
  if (!filterResult) {
@@ -2856,6 +2890,21 @@ class NiceFilterViewStore extends EntityStore {
2856
2890
  });
2857
2891
  this.remove(value[idKey]);
2858
2892
  }
2893
+ removeValues(values, key) {
2894
+ const { filterResult } = this.getValue();
2895
+ if (!filterResult) {
2896
+ return;
2897
+ }
2898
+ const idKey = key ?? this.idKey;
2899
+ const ids = values.map(value => value[idKey]);
2900
+ this.update({
2901
+ filterResult: {
2902
+ ...filterResult,
2903
+ values: arrayRemove(filterResult.values, ids)
2904
+ }
2905
+ });
2906
+ this.remove(ids);
2907
+ }
2859
2908
  getParameters(filterParameters) {
2860
2909
  const { baseRules } = this.getValue();
2861
2910
  const parameters = {
@@ -2877,6 +2926,48 @@ class NiceFilterViewStore extends EntityStore {
2877
2926
  }
2878
2927
  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 });
2879
2928
  NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore });
2929
+ __decorate([
2930
+ transaction(),
2931
+ __metadata("design:type", Function),
2932
+ __metadata("design:paramtypes", [Object]),
2933
+ __metadata("design:returntype", void 0)
2934
+ ], NiceFilterViewStore.prototype, "setResult", null);
2935
+ __decorate([
2936
+ transaction(),
2937
+ __metadata("design:type", Function),
2938
+ __metadata("design:paramtypes", [Object, Object]),
2939
+ __metadata("design:returntype", void 0)
2940
+ ], NiceFilterViewStore.prototype, "addValue", null);
2941
+ __decorate([
2942
+ transaction(),
2943
+ __metadata("design:type", Function),
2944
+ __metadata("design:paramtypes", [Array, Object]),
2945
+ __metadata("design:returntype", void 0)
2946
+ ], NiceFilterViewStore.prototype, "addValues", null);
2947
+ __decorate([
2948
+ transaction(),
2949
+ __metadata("design:type", Function),
2950
+ __metadata("design:paramtypes", [Object, String]),
2951
+ __metadata("design:returntype", void 0)
2952
+ ], NiceFilterViewStore.prototype, "upsertValue", null);
2953
+ __decorate([
2954
+ transaction(),
2955
+ __metadata("design:type", Function),
2956
+ __metadata("design:paramtypes", [Array, String]),
2957
+ __metadata("design:returntype", void 0)
2958
+ ], NiceFilterViewStore.prototype, "upsertValues", null);
2959
+ __decorate([
2960
+ transaction(),
2961
+ __metadata("design:type", Function),
2962
+ __metadata("design:paramtypes", [Object, String]),
2963
+ __metadata("design:returntype", void 0)
2964
+ ], NiceFilterViewStore.prototype, "removeValue", null);
2965
+ __decorate([
2966
+ transaction(),
2967
+ __metadata("design:type", Function),
2968
+ __metadata("design:paramtypes", [Array, String]),
2969
+ __metadata("design:returntype", void 0)
2970
+ ], NiceFilterViewStore.prototype, "removeValues", null);
2880
2971
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, decorators: [{
2881
2972
  type: Injectable
2882
2973
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
@@ -2885,7 +2976,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
2885
2976
  }] }, { type: undefined, decorators: [{
2886
2977
  type: Inject,
2887
2978
  args: [FILTER_VIEW_STORE]
2888
- }] }]; } });
2979
+ }] }]; }, propDecorators: { setResult: [], addValue: [], addValues: [], upsertValue: [], upsertValues: [], removeValue: [], removeValues: [] } });
2889
2980
 
2890
2981
  class NiceFilterViewQuery extends QueryEntity {
2891
2982
  constructor(store) {
@@ -3128,12 +3219,21 @@ class NiceFilterViewService {
3128
3219
  addValue(value, opts) {
3129
3220
  this.store.addValue(value, opts);
3130
3221
  }
3222
+ addValues(value, opts) {
3223
+ this.store.addValues(value, opts);
3224
+ }
3131
3225
  upsertValue(value, key) {
3132
3226
  this.store.upsertValue(value, key);
3133
3227
  }
3228
+ upsertValues(values, key) {
3229
+ this.store.upsertValues(values, key);
3230
+ }
3134
3231
  removeValue(value, key) {
3135
3232
  this.store.removeValue(value, key);
3136
3233
  }
3234
+ removeValues(values, key) {
3235
+ this.store.removeValues(values, key);
3236
+ }
3137
3237
  resetResult(waitForNextFilter) {
3138
3238
  if (!waitForNextFilter) {
3139
3239
  this.store.update({
@@ -4937,6 +5037,7 @@ class NiceBaseFilterViewComponent {
4937
5037
  this.autoLoad(autoLoad);
4938
5038
  this.loadConfig(loadConfig, configQueryParams);
4939
5039
  this.filterViewLoading$ = this.filterViewQuery.selectLoading();
5040
+ this.filterViewCount$ = this.filterViewQuery.selectCount();
4940
5041
  if (this.selectableListDirective) {
4941
5042
  this.filterViewService.updateSubState("selectable", { stateName: this.selectableListDirective.state });
4942
5043
  }