@recursyve/nice-data-filter-kit 14.4.2 → 14.5.1

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';
@@ -2757,6 +2757,7 @@ const initialValue = {
2757
2757
  mode: "paginated",
2758
2758
  autoLoad: true,
2759
2759
  disabled: false,
2760
+ initialLoadCompleted: false,
2760
2761
  filterConfigLoading: false,
2761
2762
  filterConfig: [],
2762
2763
  filterResult: null,
@@ -2790,7 +2791,7 @@ class NiceFilterViewStore extends EntityStore {
2790
2791
  this.update({ filterParameters });
2791
2792
  }
2792
2793
  setResult(filterResult) {
2793
- const { mode, resetResult } = this.getValue();
2794
+ const { mode, resetResult, initialLoadCompleted } = this.getValue();
2794
2795
  if (mode === "accumulated") {
2795
2796
  this.update((state) => ({
2796
2797
  filterResult: {
@@ -2815,6 +2816,9 @@ class NiceFilterViewStore extends EntityStore {
2815
2816
  else {
2816
2817
  this.set([...filterResult.values]);
2817
2818
  }
2819
+ if (!initialLoadCompleted) {
2820
+ this.update({ initialLoadCompleted: true });
2821
+ }
2818
2822
  }
2819
2823
  addValue(value, opts) {
2820
2824
  const { filterResult } = this.getValue();
@@ -2829,6 +2833,19 @@ class NiceFilterViewStore extends EntityStore {
2829
2833
  });
2830
2834
  this.add(value, opts);
2831
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
+ }
2832
2849
  upsertValue(value, key) {
2833
2850
  const { filterResult } = this.getValue();
2834
2851
  if (!filterResult) {
@@ -2843,6 +2860,22 @@ class NiceFilterViewStore extends EntityStore {
2843
2860
  });
2844
2861
  this.upsert(value[idKey], value);
2845
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
+ }
2846
2879
  removeValue(value, key) {
2847
2880
  const { filterResult } = this.getValue();
2848
2881
  if (!filterResult) {
@@ -2857,6 +2890,21 @@ class NiceFilterViewStore extends EntityStore {
2857
2890
  });
2858
2891
  this.remove(value[idKey]);
2859
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
+ }
2860
2908
  getParameters(filterParameters) {
2861
2909
  const { baseRules } = this.getValue();
2862
2910
  const parameters = {
@@ -2878,6 +2926,48 @@ class NiceFilterViewStore extends EntityStore {
2878
2926
  }
2879
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 });
2880
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);
2881
2971
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, decorators: [{
2882
2972
  type: Injectable
2883
2973
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
@@ -2886,7 +2976,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
2886
2976
  }] }, { type: undefined, decorators: [{
2887
2977
  type: Inject,
2888
2978
  args: [FILTER_VIEW_STORE]
2889
- }] }]; } });
2979
+ }] }]; }, propDecorators: { setResult: [], addValue: [], addValues: [], upsertValue: [], upsertValues: [], removeValue: [], removeValues: [] } });
2890
2980
 
2891
2981
  class NiceFilterViewQuery extends QueryEntity {
2892
2982
  constructor(store) {
@@ -3129,17 +3219,27 @@ class NiceFilterViewService {
3129
3219
  addValue(value, opts) {
3130
3220
  this.store.addValue(value, opts);
3131
3221
  }
3222
+ addValues(value, opts) {
3223
+ this.store.addValues(value, opts);
3224
+ }
3132
3225
  upsertValue(value, key) {
3133
3226
  this.store.upsertValue(value, key);
3134
3227
  }
3228
+ upsertValues(values, key) {
3229
+ this.store.upsertValues(values, key);
3230
+ }
3135
3231
  removeValue(value, key) {
3136
3232
  this.store.removeValue(value, key);
3137
3233
  }
3234
+ removeValues(values, key) {
3235
+ this.store.removeValues(values, key);
3236
+ }
3138
3237
  resetResult(waitForNextFilter) {
3139
3238
  if (!waitForNextFilter) {
3140
3239
  this.store.update({
3141
3240
  filterResult: null
3142
3241
  });
3242
+ this.store.set([]);
3143
3243
  }
3144
3244
  else {
3145
3245
  this.store.update({
@@ -3150,12 +3250,18 @@ class NiceFilterViewService {
3150
3250
  }
3151
3251
  NiceFilterViewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService, deps: [{ token: NiceFilterViewStore }, { token: NiceFilterService }], target: i0.ɵɵFactoryTarget.Injectable });
3152
3252
  NiceFilterViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService });
3253
+ __decorate([
3254
+ transaction(),
3255
+ __metadata("design:type", Function),
3256
+ __metadata("design:paramtypes", [Boolean]),
3257
+ __metadata("design:returntype", void 0)
3258
+ ], NiceFilterViewService.prototype, "resetResult", null);
3153
3259
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService, decorators: [{
3154
3260
  type: Injectable
3155
3261
  }], ctorParameters: function () { return [{ type: NiceFilterViewStore }, { type: undefined, decorators: [{
3156
3262
  type: Inject,
3157
3263
  args: [NiceFilterService]
3158
- }] }]; } });
3264
+ }] }]; }, propDecorators: { resetResult: [] } });
3159
3265
 
3160
3266
  class AdvancedFiltersUtils {
3161
3267
  static isSingleInput(filterOperator) {
@@ -4040,6 +4146,9 @@ class NiceSelectableListStateService {
4040
4146
  get preloadedWindow() {
4041
4147
  return this.options?.preloadWindow ?? 2;
4042
4148
  }
4149
+ get queryParamsDisabled() {
4150
+ return this.options?.disableQueryParams ?? false;
4151
+ }
4043
4152
  setActive(entity) {
4044
4153
  this.store.setActive(entity[this.idKey]);
4045
4154
  }
@@ -4228,10 +4337,12 @@ class NiceSelectableListStateService {
4228
4337
  };
4229
4338
  }
4230
4339
  setQueryParams() {
4231
- this.router.navigate([], {
4232
- queryParams: this.generateQueryParams(),
4233
- queryParamsHandling: "merge"
4234
- });
4340
+ if (!this.queryParamsDisabled) {
4341
+ this.router.navigate([], {
4342
+ queryParams: this.generateQueryParams(),
4343
+ queryParamsHandling: "merge"
4344
+ });
4345
+ }
4235
4346
  }
4236
4347
  }
4237
4348
 
@@ -4861,6 +4972,9 @@ class NiceSelectableListDirective {
4861
4972
  this.unsubscribeQuerySub$ = new Subject();
4862
4973
  }
4863
4974
  ngOnInit() {
4975
+ if (this.options?.disableQueryParams) {
4976
+ return;
4977
+ }
4864
4978
  combineLatest([
4865
4979
  this.route.queryParams.pipe(map((params) => params.selection), distinct()),
4866
4980
  this.route.queryParams.pipe(map((params) => params.selected), distinct())
@@ -4893,7 +5007,7 @@ class NiceSelectableListDirective {
4893
5007
  }
4894
5008
  if ("state" in changes) {
4895
5009
  this.service.setState(this.state);
4896
- this.stateService = this.selectableListService.withState(this.state);
5010
+ this.stateService = this.selectableListService.withState(this.state, this.options);
4897
5011
  this.stateQuery = this.selectableListService.query(this.state);
4898
5012
  this.listenOnStateChanges();
4899
5013
  }
@@ -4938,6 +5052,7 @@ class NiceBaseFilterViewComponent {
4938
5052
  this.autoLoad(autoLoad);
4939
5053
  this.loadConfig(loadConfig, configQueryParams);
4940
5054
  this.filterViewLoading$ = this.filterViewQuery.selectLoading();
5055
+ this.filterViewCount$ = this.filterViewQuery.selectCount();
4941
5056
  if (this.selectableListDirective) {
4942
5057
  this.filterViewService.updateSubState("selectable", { stateName: this.selectableListDirective.state });
4943
5058
  }