@recursyve/nice-data-filter-kit 15.0.1 → 15.1.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.
- package/esm2020/lib/components/nice-filter-view/nice-base-filter-view.component.mjs +2 -1
- package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.service.mjs +20 -2
- package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.store.mjs +95 -4
- package/esm2020/lib/directive/selectable-list/model/selectable-list-options.model.mjs +1 -1
- package/esm2020/lib/directive/selectable-list/selectable-list.directive.mjs +5 -2
- package/esm2020/lib/directive/selectable-list/store/selectable-list-state.service.mjs +10 -5
- package/esm2020/lib/models/filter.model.mjs +1 -1
- package/esm2020/lib/utils/filter.utils.mjs +3 -2
- package/fesm2015/recursyve-nice-data-filter-kit.mjs +119 -10
- package/fesm2015/recursyve-nice-data-filter-kit.mjs.map +1 -1
- package/fesm2020/recursyve-nice-data-filter-kit.mjs +126 -10
- package/fesm2020/recursyve-nice-data-filter-kit.mjs.map +1 -1
- package/lib/components/nice-filter-view/nice-base-filter-view.component.d.ts +1 -0
- package/lib/components/nice-filter-view/store/nice-filter-view.service.d.ts +4 -1
- package/lib/components/nice-filter-view/store/nice-filter-view.store.d.ts +4 -0
- package/lib/directive/selectable-list/model/selectable-list-options.model.d.ts +1 -0
- package/lib/directive/selectable-list/store/selectable-list-state.service.d.ts +1 -0
- package/lib/models/filter.model.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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) {
|
|
@@ -2755,6 +2756,7 @@ const initialValue = {
|
|
|
2755
2756
|
mode: "paginated",
|
|
2756
2757
|
autoLoad: true,
|
|
2757
2758
|
disabled: false,
|
|
2759
|
+
initialLoadCompleted: false,
|
|
2758
2760
|
filterConfigLoading: false,
|
|
2759
2761
|
filterConfig: [],
|
|
2760
2762
|
filterResult: null,
|
|
@@ -2788,7 +2790,7 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2788
2790
|
this.update({ filterParameters });
|
|
2789
2791
|
}
|
|
2790
2792
|
setResult(filterResult) {
|
|
2791
|
-
const { mode, resetResult } = this.getValue();
|
|
2793
|
+
const { mode, resetResult, initialLoadCompleted } = this.getValue();
|
|
2792
2794
|
if (mode === "accumulated") {
|
|
2793
2795
|
this.update((state) => ({
|
|
2794
2796
|
filterResult: {
|
|
@@ -2813,6 +2815,9 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2813
2815
|
else {
|
|
2814
2816
|
this.set([...filterResult.values]);
|
|
2815
2817
|
}
|
|
2818
|
+
if (!initialLoadCompleted) {
|
|
2819
|
+
this.update({ initialLoadCompleted: true });
|
|
2820
|
+
}
|
|
2816
2821
|
}
|
|
2817
2822
|
addValue(value, opts) {
|
|
2818
2823
|
const { filterResult } = this.getValue();
|
|
@@ -2827,6 +2832,19 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2827
2832
|
});
|
|
2828
2833
|
this.add(value, opts);
|
|
2829
2834
|
}
|
|
2835
|
+
addValues(values, opts) {
|
|
2836
|
+
const { filterResult } = this.getValue();
|
|
2837
|
+
if (!filterResult) {
|
|
2838
|
+
return;
|
|
2839
|
+
}
|
|
2840
|
+
this.update({
|
|
2841
|
+
filterResult: {
|
|
2842
|
+
...filterResult,
|
|
2843
|
+
values: arrayAdd(filterResult.values, values, opts)
|
|
2844
|
+
}
|
|
2845
|
+
});
|
|
2846
|
+
this.add(values, opts);
|
|
2847
|
+
}
|
|
2830
2848
|
upsertValue(value, key) {
|
|
2831
2849
|
const { filterResult } = this.getValue();
|
|
2832
2850
|
if (!filterResult) {
|
|
@@ -2841,6 +2859,22 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2841
2859
|
});
|
|
2842
2860
|
this.upsert(value[idKey], value);
|
|
2843
2861
|
}
|
|
2862
|
+
upsertValues(values, key) {
|
|
2863
|
+
const { filterResult } = this.getValue();
|
|
2864
|
+
if (!filterResult) {
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
const idKey = key ?? this.idKey;
|
|
2868
|
+
for (const value of values) {
|
|
2869
|
+
this.update({
|
|
2870
|
+
filterResult: {
|
|
2871
|
+
...filterResult,
|
|
2872
|
+
values: arrayUpsert(filterResult.values, value[idKey], value, key)
|
|
2873
|
+
}
|
|
2874
|
+
});
|
|
2875
|
+
this.upsert(value[idKey], value);
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2844
2878
|
removeValue(value, key) {
|
|
2845
2879
|
const { filterResult } = this.getValue();
|
|
2846
2880
|
if (!filterResult) {
|
|
@@ -2855,6 +2889,21 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2855
2889
|
});
|
|
2856
2890
|
this.remove(value[idKey]);
|
|
2857
2891
|
}
|
|
2892
|
+
removeValues(values, key) {
|
|
2893
|
+
const { filterResult } = this.getValue();
|
|
2894
|
+
if (!filterResult) {
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2897
|
+
const idKey = key ?? this.idKey;
|
|
2898
|
+
const ids = values.map(value => value[idKey]);
|
|
2899
|
+
this.update({
|
|
2900
|
+
filterResult: {
|
|
2901
|
+
...filterResult,
|
|
2902
|
+
values: arrayRemove(filterResult.values, ids)
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
this.remove(ids);
|
|
2906
|
+
}
|
|
2858
2907
|
getParameters(filterParameters) {
|
|
2859
2908
|
const { baseRules } = this.getValue();
|
|
2860
2909
|
const parameters = {
|
|
@@ -2876,6 +2925,48 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2876
2925
|
}
|
|
2877
2926
|
NiceFilterViewStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewStore, deps: [{ token: FILTER_VIEW_STATE }, { token: FILTER_VIEW_STORE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2878
2927
|
NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewStore });
|
|
2928
|
+
__decorate([
|
|
2929
|
+
transaction(),
|
|
2930
|
+
__metadata("design:type", Function),
|
|
2931
|
+
__metadata("design:paramtypes", [Object]),
|
|
2932
|
+
__metadata("design:returntype", void 0)
|
|
2933
|
+
], NiceFilterViewStore.prototype, "setResult", null);
|
|
2934
|
+
__decorate([
|
|
2935
|
+
transaction(),
|
|
2936
|
+
__metadata("design:type", Function),
|
|
2937
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2938
|
+
__metadata("design:returntype", void 0)
|
|
2939
|
+
], NiceFilterViewStore.prototype, "addValue", null);
|
|
2940
|
+
__decorate([
|
|
2941
|
+
transaction(),
|
|
2942
|
+
__metadata("design:type", Function),
|
|
2943
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
2944
|
+
__metadata("design:returntype", void 0)
|
|
2945
|
+
], NiceFilterViewStore.prototype, "addValues", null);
|
|
2946
|
+
__decorate([
|
|
2947
|
+
transaction(),
|
|
2948
|
+
__metadata("design:type", Function),
|
|
2949
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2950
|
+
__metadata("design:returntype", void 0)
|
|
2951
|
+
], NiceFilterViewStore.prototype, "upsertValue", null);
|
|
2952
|
+
__decorate([
|
|
2953
|
+
transaction(),
|
|
2954
|
+
__metadata("design:type", Function),
|
|
2955
|
+
__metadata("design:paramtypes", [Array, String]),
|
|
2956
|
+
__metadata("design:returntype", void 0)
|
|
2957
|
+
], NiceFilterViewStore.prototype, "upsertValues", null);
|
|
2958
|
+
__decorate([
|
|
2959
|
+
transaction(),
|
|
2960
|
+
__metadata("design:type", Function),
|
|
2961
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2962
|
+
__metadata("design:returntype", void 0)
|
|
2963
|
+
], NiceFilterViewStore.prototype, "removeValue", null);
|
|
2964
|
+
__decorate([
|
|
2965
|
+
transaction(),
|
|
2966
|
+
__metadata("design:type", Function),
|
|
2967
|
+
__metadata("design:paramtypes", [Array, String]),
|
|
2968
|
+
__metadata("design:returntype", void 0)
|
|
2969
|
+
], NiceFilterViewStore.prototype, "removeValues", null);
|
|
2879
2970
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewStore, decorators: [{
|
|
2880
2971
|
type: Injectable
|
|
2881
2972
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
@@ -2884,7 +2975,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2884
2975
|
}] }, { type: undefined, decorators: [{
|
|
2885
2976
|
type: Inject,
|
|
2886
2977
|
args: [FILTER_VIEW_STORE]
|
|
2887
|
-
}] }]; } });
|
|
2978
|
+
}] }]; }, propDecorators: { setResult: [], addValue: [], addValues: [], upsertValue: [], upsertValues: [], removeValue: [], removeValues: [] } });
|
|
2888
2979
|
|
|
2889
2980
|
class NiceFilterViewQuery extends QueryEntity {
|
|
2890
2981
|
constructor(store) {
|
|
@@ -3127,17 +3218,27 @@ class NiceFilterViewService {
|
|
|
3127
3218
|
addValue(value, opts) {
|
|
3128
3219
|
this.store.addValue(value, opts);
|
|
3129
3220
|
}
|
|
3221
|
+
addValues(value, opts) {
|
|
3222
|
+
this.store.addValues(value, opts);
|
|
3223
|
+
}
|
|
3130
3224
|
upsertValue(value, key) {
|
|
3131
3225
|
this.store.upsertValue(value, key);
|
|
3132
3226
|
}
|
|
3227
|
+
upsertValues(values, key) {
|
|
3228
|
+
this.store.upsertValues(values, key);
|
|
3229
|
+
}
|
|
3133
3230
|
removeValue(value, key) {
|
|
3134
3231
|
this.store.removeValue(value, key);
|
|
3135
3232
|
}
|
|
3233
|
+
removeValues(values, key) {
|
|
3234
|
+
this.store.removeValues(values, key);
|
|
3235
|
+
}
|
|
3136
3236
|
resetResult(waitForNextFilter) {
|
|
3137
3237
|
if (!waitForNextFilter) {
|
|
3138
3238
|
this.store.update({
|
|
3139
3239
|
filterResult: null
|
|
3140
3240
|
});
|
|
3241
|
+
this.store.set([]);
|
|
3141
3242
|
}
|
|
3142
3243
|
else {
|
|
3143
3244
|
this.store.update({
|
|
@@ -3148,12 +3249,18 @@ class NiceFilterViewService {
|
|
|
3148
3249
|
}
|
|
3149
3250
|
NiceFilterViewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewService, deps: [{ token: NiceFilterViewStore }, { token: NiceFilterService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3150
3251
|
NiceFilterViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewService });
|
|
3252
|
+
__decorate([
|
|
3253
|
+
transaction(),
|
|
3254
|
+
__metadata("design:type", Function),
|
|
3255
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
3256
|
+
__metadata("design:returntype", void 0)
|
|
3257
|
+
], NiceFilterViewService.prototype, "resetResult", null);
|
|
3151
3258
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NiceFilterViewService, decorators: [{
|
|
3152
3259
|
type: Injectable
|
|
3153
3260
|
}], ctorParameters: function () { return [{ type: NiceFilterViewStore }, { type: undefined, decorators: [{
|
|
3154
3261
|
type: Inject,
|
|
3155
3262
|
args: [NiceFilterService]
|
|
3156
|
-
}] }]; } });
|
|
3263
|
+
}] }]; }, propDecorators: { resetResult: [] } });
|
|
3157
3264
|
|
|
3158
3265
|
class AdvancedFiltersUtils {
|
|
3159
3266
|
static isSingleInput(filterOperator) {
|
|
@@ -4030,6 +4137,9 @@ class NiceSelectableListStateService {
|
|
|
4030
4137
|
get preloadedWindow() {
|
|
4031
4138
|
return this.options?.preloadWindow ?? 2;
|
|
4032
4139
|
}
|
|
4140
|
+
get queryParamsDisabled() {
|
|
4141
|
+
return this.options?.disableQueryParams ?? false;
|
|
4142
|
+
}
|
|
4033
4143
|
constructor(store, route, router, preloadService, options) {
|
|
4034
4144
|
this.store = store;
|
|
4035
4145
|
this.route = route;
|
|
@@ -4225,10 +4335,12 @@ class NiceSelectableListStateService {
|
|
|
4225
4335
|
};
|
|
4226
4336
|
}
|
|
4227
4337
|
setQueryParams() {
|
|
4228
|
-
this.
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4338
|
+
if (!this.queryParamsDisabled) {
|
|
4339
|
+
this.router.navigate([], {
|
|
4340
|
+
queryParams: this.generateQueryParams(),
|
|
4341
|
+
queryParamsHandling: "merge"
|
|
4342
|
+
});
|
|
4343
|
+
}
|
|
4232
4344
|
}
|
|
4233
4345
|
}
|
|
4234
4346
|
|
|
@@ -4858,6 +4970,9 @@ class NiceSelectableListDirective {
|
|
|
4858
4970
|
this.unsubscribeQuerySub$ = new Subject();
|
|
4859
4971
|
}
|
|
4860
4972
|
ngOnInit() {
|
|
4973
|
+
if (this.options?.disableQueryParams) {
|
|
4974
|
+
return;
|
|
4975
|
+
}
|
|
4861
4976
|
combineLatest([
|
|
4862
4977
|
this.route.queryParams.pipe(map((params) => params.selection), distinct()),
|
|
4863
4978
|
this.route.queryParams.pipe(map((params) => params.selected), distinct())
|
|
@@ -4890,7 +5005,7 @@ class NiceSelectableListDirective {
|
|
|
4890
5005
|
}
|
|
4891
5006
|
if ("state" in changes) {
|
|
4892
5007
|
this.service.setState(this.state);
|
|
4893
|
-
this.stateService = this.selectableListService.withState(this.state);
|
|
5008
|
+
this.stateService = this.selectableListService.withState(this.state, this.options);
|
|
4894
5009
|
this.stateQuery = this.selectableListService.query(this.state);
|
|
4895
5010
|
this.listenOnStateChanges();
|
|
4896
5011
|
}
|
|
@@ -4935,6 +5050,7 @@ class NiceBaseFilterViewComponent {
|
|
|
4935
5050
|
this.autoLoad(autoLoad);
|
|
4936
5051
|
this.loadConfig(loadConfig, configQueryParams);
|
|
4937
5052
|
this.filterViewLoading$ = this.filterViewQuery.selectLoading();
|
|
5053
|
+
this.filterViewCount$ = this.filterViewQuery.selectCount();
|
|
4938
5054
|
if (this.selectableListDirective) {
|
|
4939
5055
|
this.filterViewService.updateSubState("selectable", { stateName: this.selectableListDirective.state });
|
|
4940
5056
|
}
|