@recursyve/nice-data-filter-kit 14.1.5 → 14.2.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/components/infinite-scroll-data-view/infinite-scroll-data-view.component.mjs +2 -3
- package/esm2020/lib/components/nice-filter-view/directives/mat-paginator.mjs +2 -2
- package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.query.mjs +4 -1
- package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.service.mjs +4 -18
- package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.store.mjs +15 -1
- package/esm2020/lib/directive/public-api.mjs +2 -0
- package/esm2020/lib/directive/selectable-list/model/load-all-entities-options.model.mjs +2 -0
- package/esm2020/lib/directive/selectable-list/model/selectable-list-options.model.mjs +2 -0
- package/esm2020/lib/directive/selectable-list/providers/preload-selected-entities.provider.mjs +10 -0
- package/esm2020/lib/directive/selectable-list/public-api.mjs +10 -0
- package/esm2020/lib/directive/selectable-list/selectable-list-checkbox.directive.mjs +122 -0
- package/esm2020/lib/directive/selectable-list/selectable-list-select-all.directive.mjs +48 -0
- package/esm2020/lib/directive/selectable-list/selectable-list.constant.mjs +3 -0
- package/esm2020/lib/directive/selectable-list/selectable-list.directive.mjs +38 -0
- package/esm2020/lib/directive/selectable-list/selectable-list.module.mjs +32 -0
- package/esm2020/lib/directive/selectable-list/store/selectable-list-state.service.mjs +181 -0
- package/esm2020/lib/directive/selectable-list/store/selectable-list.service.mjs +49 -0
- package/esm2020/lib/directive/selectable-list/store/selectable-list.state.mjs +2 -0
- package/esm2020/lib/utils/query-params.utils.mjs +2 -16
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/recursyve-nice-data-filter-kit.mjs +495 -33
- package/fesm2015/recursyve-nice-data-filter-kit.mjs.map +1 -1
- package/fesm2020/recursyve-nice-data-filter-kit.mjs +470 -36
- package/fesm2020/recursyve-nice-data-filter-kit.mjs.map +1 -1
- package/lib/components/nice-filter-view/store/nice-filter-view.query.d.ts +1 -0
- package/lib/components/nice-filter-view/store/nice-filter-view.service.d.ts +0 -1
- package/lib/components/nice-filter-view/store/nice-filter-view.store.d.ts +1 -0
- package/lib/directive/public-api.d.ts +1 -0
- package/lib/directive/selectable-list/model/load-all-entities-options.model.d.ts +4 -0
- package/lib/directive/selectable-list/model/selectable-list-options.model.d.ts +4 -0
- package/lib/directive/selectable-list/providers/preload-selected-entities.provider.d.ts +12 -0
- package/lib/directive/selectable-list/public-api.d.ts +9 -0
- package/lib/directive/selectable-list/selectable-list-checkbox.directive.d.ts +24 -0
- package/lib/directive/selectable-list/selectable-list-select-all.directive.d.ts +18 -0
- package/lib/directive/selectable-list/selectable-list.constant.d.ts +2 -0
- package/lib/directive/selectable-list/selectable-list.directive.d.ts +14 -0
- package/lib/directive/selectable-list/selectable-list.module.d.ts +12 -0
- package/lib/directive/selectable-list/store/selectable-list-state.service.d.ts +32 -0
- package/lib/directive/selectable-list/store/selectable-list.service.d.ts +23 -0
- package/lib/directive/selectable-list/store/selectable-list.state.d.ts +8 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -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 } 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, ViewChild } from '@angular/core';
|
|
8
|
-
import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, QueryEntity } from '@datorama/akita';
|
|
8
|
+
import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, QueryEntity, EntityActions } from '@datorama/akita';
|
|
9
9
|
import { combineLatest, Subject, firstValueFrom, of, tap } from 'rxjs';
|
|
10
10
|
import { __decorate, __metadata } from 'tslib';
|
|
11
11
|
import * as i2 from '@angular/router';
|
|
@@ -55,10 +55,11 @@ import * as i1$2 from '@ngx-translate/core';
|
|
|
55
55
|
import { TranslateModule } from '@ngx-translate/core';
|
|
56
56
|
import * as i18 from '@angular/material/badge';
|
|
57
57
|
import { MatBadgeModule } from '@angular/material/badge';
|
|
58
|
+
import * as i1$4 from '@angular/material/checkbox';
|
|
58
59
|
|
|
59
60
|
class QueryParamsUtils {
|
|
60
61
|
static hasFilterParameters(params) {
|
|
61
|
-
const keys = ["start", "length", "order", "
|
|
62
|
+
const keys = ["start", "length", "order", "search", "rules"];
|
|
62
63
|
return Object.keys(params).some(key => keys.includes(key));
|
|
63
64
|
}
|
|
64
65
|
static extractFilterParameters(params) {
|
|
@@ -77,14 +78,6 @@ class QueryParamsUtils {
|
|
|
77
78
|
delete filters.order;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
if (!isNullOrUndefined(params.fallbackOrder)) {
|
|
81
|
-
try {
|
|
82
|
-
filters.fallbackOrder = JSON.parse(params.fallbackOrder);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
delete filters.fallbackOrder;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
81
|
if (!isNullOrUndefined(params.search)) {
|
|
89
82
|
filters.search = params.search;
|
|
90
83
|
}
|
|
@@ -112,12 +105,6 @@ class QueryParamsUtils {
|
|
|
112
105
|
else {
|
|
113
106
|
params.order = null;
|
|
114
107
|
}
|
|
115
|
-
if (!isNullOrUndefined(filterParameters.fallbackOrder)) {
|
|
116
|
-
params.fallbackOrder = JSON.stringify(filterParameters.fallbackOrder);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
params.fallbackOrder = null;
|
|
120
|
-
}
|
|
121
108
|
if (!isNullOrUndefined(filterParameters.search)) {
|
|
122
109
|
params.search = filterParameters.search;
|
|
123
110
|
}
|
|
@@ -2873,6 +2860,20 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2873
2860
|
});
|
|
2874
2861
|
this.remove(value[idKey]);
|
|
2875
2862
|
}
|
|
2863
|
+
getParameters(filterParameters) {
|
|
2864
|
+
const { baseRules } = this.getValue();
|
|
2865
|
+
const parameters = {
|
|
2866
|
+
...filterParameters,
|
|
2867
|
+
rules: filterParameters?.rules ? [...filterParameters.rules] : []
|
|
2868
|
+
};
|
|
2869
|
+
if (baseRules?.length) {
|
|
2870
|
+
parameters.rules.push({
|
|
2871
|
+
condition: "and",
|
|
2872
|
+
rules: baseRules
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
return parameters;
|
|
2876
|
+
}
|
|
2876
2877
|
}
|
|
2877
2878
|
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 });
|
|
2878
2879
|
NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore });
|
|
@@ -2903,6 +2904,9 @@ class NiceFilterViewQuery extends QueryEntity {
|
|
|
2903
2904
|
selectFilterResult() {
|
|
2904
2905
|
return this.select("filterResult");
|
|
2905
2906
|
}
|
|
2907
|
+
getParameters() {
|
|
2908
|
+
return this.store.getParameters(this.store.getValue().filterParameters);
|
|
2909
|
+
}
|
|
2906
2910
|
}
|
|
2907
2911
|
NiceFilterViewQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery, deps: [{ token: NiceFilterViewStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2908
2912
|
NiceFilterViewQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery });
|
|
@@ -2975,7 +2979,7 @@ class NiceFilterViewService {
|
|
|
2975
2979
|
}
|
|
2976
2980
|
try {
|
|
2977
2981
|
this.store.setLoading(true);
|
|
2978
|
-
const result = await firstValueFrom(this.filterService.filter(this.getParameters(filterParameters)));
|
|
2982
|
+
const result = await firstValueFrom(this.filterService.filter(this.store.getParameters(filterParameters)));
|
|
2979
2983
|
this.store.setResult(result);
|
|
2980
2984
|
}
|
|
2981
2985
|
catch (e) {
|
|
@@ -2992,7 +2996,7 @@ class NiceFilterViewService {
|
|
|
2992
2996
|
}
|
|
2993
2997
|
try {
|
|
2994
2998
|
this.store.setLoading(true);
|
|
2995
|
-
const result = await firstValueFrom(this.filterService.getFile(type, this.getParameters(filterParameters)));
|
|
2999
|
+
const result = await firstValueFrom(this.filterService.getFile(type, this.store.getParameters(filterParameters)));
|
|
2996
3000
|
FileUtils.downloadFile(`${downloadFileName}.${type}`, result);
|
|
2997
3001
|
}
|
|
2998
3002
|
catch (e) {
|
|
@@ -3009,7 +3013,7 @@ class NiceFilterViewService {
|
|
|
3009
3013
|
}
|
|
3010
3014
|
try {
|
|
3011
3015
|
this.store.setLoading(true);
|
|
3012
|
-
const result = await firstValueFrom(this.filterService.getPrintableHtml(this.getParameters(filterParameters)));
|
|
3016
|
+
const result = await firstValueFrom(this.filterService.getPrintableHtml(this.store.getParameters(filterParameters)));
|
|
3013
3017
|
FileUtils.openPrintableWindow(result);
|
|
3014
3018
|
}
|
|
3015
3019
|
catch (e) {
|
|
@@ -3124,20 +3128,6 @@ class NiceFilterViewService {
|
|
|
3124
3128
|
});
|
|
3125
3129
|
}
|
|
3126
3130
|
}
|
|
3127
|
-
getParameters(filterParameters) {
|
|
3128
|
-
const { baseRules } = this.store.getValue();
|
|
3129
|
-
const parameters = {
|
|
3130
|
-
...filterParameters,
|
|
3131
|
-
rules: filterParameters?.rules ? [...filterParameters.rules] : []
|
|
3132
|
-
};
|
|
3133
|
-
if (baseRules?.length) {
|
|
3134
|
-
parameters.rules.push({
|
|
3135
|
-
condition: "and",
|
|
3136
|
-
rules: baseRules
|
|
3137
|
-
});
|
|
3138
|
-
}
|
|
3139
|
-
return parameters;
|
|
3140
|
-
}
|
|
3141
3131
|
}
|
|
3142
3132
|
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 });
|
|
3143
3133
|
NiceFilterViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService });
|
|
@@ -3245,7 +3235,7 @@ class NiceFilterInfiniteScrollDataViewComponent {
|
|
|
3245
3235
|
constructor(query, service) {
|
|
3246
3236
|
this.query = query;
|
|
3247
3237
|
this.service = service;
|
|
3248
|
-
this.data$ = this.query.selectAll()
|
|
3238
|
+
this.data$ = this.query.selectAll();
|
|
3249
3239
|
}
|
|
3250
3240
|
async loadNextPage() {
|
|
3251
3241
|
const { filterParameters } = this.query.getValue();
|
|
@@ -3332,7 +3322,7 @@ class NiceFilterMatPaginatorPaginationDirective {
|
|
|
3332
3322
|
const { filterParameters } = this.query.getValue();
|
|
3333
3323
|
this.service.setParameters({
|
|
3334
3324
|
...filterParameters,
|
|
3335
|
-
start: page.pageIndex,
|
|
3325
|
+
start: page.pageIndex * page.pageSize,
|
|
3336
3326
|
length: page.pageSize
|
|
3337
3327
|
}, true);
|
|
3338
3328
|
});
|
|
@@ -3717,6 +3707,450 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
|
|
|
3717
3707
|
}]
|
|
3718
3708
|
}] });
|
|
3719
3709
|
|
|
3710
|
+
class NicePreloadSelectedEntitiesProvider {
|
|
3711
|
+
}
|
|
3712
|
+
NicePreloadSelectedEntitiesProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3713
|
+
NicePreloadSelectedEntitiesProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider });
|
|
3714
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider, decorators: [{
|
|
3715
|
+
type: Injectable
|
|
3716
|
+
}] });
|
|
3717
|
+
|
|
3718
|
+
const NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER = new InjectionToken("nice_preload_selected_entities_provider");
|
|
3719
|
+
|
|
3720
|
+
class SelectableListStateService {
|
|
3721
|
+
constructor(store, preloadService, options) {
|
|
3722
|
+
this.store = store;
|
|
3723
|
+
this.preloadService = preloadService;
|
|
3724
|
+
this.options = options;
|
|
3725
|
+
}
|
|
3726
|
+
get idKey() {
|
|
3727
|
+
return this.options?.idKey ?? "id";
|
|
3728
|
+
}
|
|
3729
|
+
get preloadedWindow() {
|
|
3730
|
+
return this.options?.preloadWindow ?? 2;
|
|
3731
|
+
}
|
|
3732
|
+
setActive(entity) {
|
|
3733
|
+
this.store.setActive(entity[this.idKey]);
|
|
3734
|
+
}
|
|
3735
|
+
getIndex(identifier) {
|
|
3736
|
+
const { ids } = this.store.getValue();
|
|
3737
|
+
const index = ids.indexOf(identifier);
|
|
3738
|
+
return index + 1;
|
|
3739
|
+
}
|
|
3740
|
+
async selectAll(options) {
|
|
3741
|
+
if (!this.preloadService) {
|
|
3742
|
+
return this.store.update({
|
|
3743
|
+
allSelected: true
|
|
3744
|
+
});
|
|
3745
|
+
}
|
|
3746
|
+
const ids = await this.preloadService.loadAllEntities(options);
|
|
3747
|
+
this.store.set(ids.map((id) => ({
|
|
3748
|
+
[this.idKey]: id,
|
|
3749
|
+
loaded: false
|
|
3750
|
+
})));
|
|
3751
|
+
return this.store.update({
|
|
3752
|
+
allSelected: true
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
async select(id) {
|
|
3756
|
+
this.store.update((state) => ({
|
|
3757
|
+
unselectedEntity: arrayRemove(state.unselectedEntity, id)
|
|
3758
|
+
}));
|
|
3759
|
+
if (!this.preloadService) {
|
|
3760
|
+
this.store.add({
|
|
3761
|
+
[this.idKey]: id,
|
|
3762
|
+
loaded: false
|
|
3763
|
+
});
|
|
3764
|
+
}
|
|
3765
|
+
const entity = await this.preloadService.loadEntityById(id);
|
|
3766
|
+
return this.store.add({
|
|
3767
|
+
...entity,
|
|
3768
|
+
loaded: true
|
|
3769
|
+
});
|
|
3770
|
+
}
|
|
3771
|
+
async selectEntity(entity) {
|
|
3772
|
+
this.store.update((state) => ({
|
|
3773
|
+
unselectedEntity: arrayRemove(state.unselectedEntity, entity[this.idKey])
|
|
3774
|
+
}));
|
|
3775
|
+
if (!this.preloadService) {
|
|
3776
|
+
return this.store.upsert(entity[this.idKey], { ...entity, loaded: true });
|
|
3777
|
+
}
|
|
3778
|
+
const preloadedEntity = await this.preloadService.reloadEntity(entity);
|
|
3779
|
+
return this.store.upsert(preloadedEntity[this.idKey], { ...preloadedEntity, loaded: true });
|
|
3780
|
+
}
|
|
3781
|
+
async selectManyEntities(entities) {
|
|
3782
|
+
if (!this.preloadService) {
|
|
3783
|
+
return this.store.upsertMany(entities.map((entity) => ({ ...entity, loaded: true })));
|
|
3784
|
+
}
|
|
3785
|
+
const preloadedEntities = await this.preloadService.reloadEntities(entities);
|
|
3786
|
+
return this.store.upsertMany(preloadedEntities.map((preloadedEntity) => ({ ...preloadedEntity, loaded: true })));
|
|
3787
|
+
}
|
|
3788
|
+
unselectAll() {
|
|
3789
|
+
this.store.set([]);
|
|
3790
|
+
return this.store.update({
|
|
3791
|
+
allSelected: false,
|
|
3792
|
+
unselectedEntity: []
|
|
3793
|
+
});
|
|
3794
|
+
}
|
|
3795
|
+
unselect(id) {
|
|
3796
|
+
this.store.update((state) => ({
|
|
3797
|
+
unselectedEntity: arrayAdd(state.unselectedEntity, id)
|
|
3798
|
+
}));
|
|
3799
|
+
this.store.remove(id);
|
|
3800
|
+
}
|
|
3801
|
+
unselectEntity(entity) {
|
|
3802
|
+
this.store.update((state) => ({
|
|
3803
|
+
unselectedEntity: arrayAdd(state.unselectedEntity, entity[this.idKey])
|
|
3804
|
+
}));
|
|
3805
|
+
this.store.remove(entity[this.idKey]);
|
|
3806
|
+
}
|
|
3807
|
+
unselectManyEntities(entities) {
|
|
3808
|
+
this.store.remove(entities.map((entity) => entity[this.idKey]));
|
|
3809
|
+
}
|
|
3810
|
+
async setEntities(ids, activeId) {
|
|
3811
|
+
this.store.update({
|
|
3812
|
+
unselectedEntity: [],
|
|
3813
|
+
allSelected: false
|
|
3814
|
+
});
|
|
3815
|
+
this.store.set(ids.map((id) => ({
|
|
3816
|
+
[this.idKey]: id,
|
|
3817
|
+
loaded: false
|
|
3818
|
+
})));
|
|
3819
|
+
if (activeId) {
|
|
3820
|
+
this.store.setActive(activeId);
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
async next() {
|
|
3824
|
+
const { ids, active } = this.store.getValue();
|
|
3825
|
+
const index = ids.indexOf(active);
|
|
3826
|
+
await this.loadActiveEntity(ids[index + 1], 1);
|
|
3827
|
+
}
|
|
3828
|
+
async previous() {
|
|
3829
|
+
const { ids, active } = this.store.getValue();
|
|
3830
|
+
const index = ids.indexOf(active);
|
|
3831
|
+
await this.loadActiveEntity(ids[index - 1], -1);
|
|
3832
|
+
}
|
|
3833
|
+
async first() {
|
|
3834
|
+
const { ids } = this.store.getValue();
|
|
3835
|
+
await this.loadActiveEntity(ids[0], 1);
|
|
3836
|
+
}
|
|
3837
|
+
async last() {
|
|
3838
|
+
const { ids } = this.store.getValue();
|
|
3839
|
+
await this.loadActiveEntity(ids[ids.length - 1], -1);
|
|
3840
|
+
}
|
|
3841
|
+
async removeActive() {
|
|
3842
|
+
const { active, ids } = this.store.getValue();
|
|
3843
|
+
const index = ids.indexOf(active);
|
|
3844
|
+
this.store.remove(active);
|
|
3845
|
+
if (index === (ids.length - 1)) {
|
|
3846
|
+
await this.loadActiveEntity(ids[index - 1], -1);
|
|
3847
|
+
}
|
|
3848
|
+
else {
|
|
3849
|
+
await this.loadActiveEntity(ids[index + 1], 1);
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
async loadActiveEntity(id, direction) {
|
|
3853
|
+
try {
|
|
3854
|
+
this.store.setActive(id);
|
|
3855
|
+
const { entities } = this.store.getValue();
|
|
3856
|
+
if (!entities[+id + direction * this.preloadedWindow]?.loaded) {
|
|
3857
|
+
await this.loadEntities(false);
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
catch (e) {
|
|
3861
|
+
this.store.setError(e);
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
async loadEntities(loadExtremity) {
|
|
3865
|
+
if (!this.preloadService) {
|
|
3866
|
+
return;
|
|
3867
|
+
}
|
|
3868
|
+
const toLoad = this.getListIdToLoad(loadExtremity);
|
|
3869
|
+
if (!toLoad.length) {
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
const entities = await this.preloadService.loadEntitiesById(toLoad);
|
|
3873
|
+
this.store.upsertMany(entities.map((entity) => ({ ...entity, loaded: true })));
|
|
3874
|
+
}
|
|
3875
|
+
getListIdToLoad(loadExtremity) {
|
|
3876
|
+
const { active, ids, entities } = this.store.getValue();
|
|
3877
|
+
const from = ids.indexOf(active) - this.preloadedWindow > 0 ? ids.indexOf(active) - this.preloadedWindow : 0;
|
|
3878
|
+
const to = ids.indexOf(active) + this.preloadedWindow < ids.length - 1
|
|
3879
|
+
? ids.indexOf(active) + this.preloadedWindow
|
|
3880
|
+
: ids.length - 1;
|
|
3881
|
+
const toLoad = [];
|
|
3882
|
+
if (loadExtremity) {
|
|
3883
|
+
if (ids.length <= 2) {
|
|
3884
|
+
return ids;
|
|
3885
|
+
}
|
|
3886
|
+
toLoad.push(ids[0], ids[ids.length - 1]);
|
|
3887
|
+
}
|
|
3888
|
+
for (let i = from; i <= to; i++) {
|
|
3889
|
+
if (ids[i] === null || ids[0] === undefined) {
|
|
3890
|
+
continue;
|
|
3891
|
+
}
|
|
3892
|
+
if (!toLoad.includes(ids[i]) && !entities[ids[i]]?.loaded) {
|
|
3893
|
+
toLoad.push(ids[i]);
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
return toLoad;
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
class SelectableListService {
|
|
3901
|
+
constructor(providers) {
|
|
3902
|
+
this.providers = providers;
|
|
3903
|
+
this.stores = new Map();
|
|
3904
|
+
}
|
|
3905
|
+
createState(name, options) {
|
|
3906
|
+
const store = new EntityStore({ allSelected: false, unselectedEntity: [] }, { name, idKey: options?.idKey });
|
|
3907
|
+
const query = new QueryEntity(store);
|
|
3908
|
+
const state = { store, query };
|
|
3909
|
+
this.stores.set(name, state);
|
|
3910
|
+
return state;
|
|
3911
|
+
}
|
|
3912
|
+
getState(name) {
|
|
3913
|
+
return this.stores.get(name);
|
|
3914
|
+
}
|
|
3915
|
+
withState(stateName, options) {
|
|
3916
|
+
const provider = this.providers?.find((p) => p.state === stateName);
|
|
3917
|
+
const state = this.getState(stateName);
|
|
3918
|
+
if (state) {
|
|
3919
|
+
return new SelectableListStateService(state.store, provider, options);
|
|
3920
|
+
}
|
|
3921
|
+
const newState = this.createState(stateName, options);
|
|
3922
|
+
return new SelectableListStateService(newState.store, provider, options);
|
|
3923
|
+
}
|
|
3924
|
+
query(stateName) {
|
|
3925
|
+
const state = this.getState(stateName);
|
|
3926
|
+
if (!state) {
|
|
3927
|
+
throw new Error("No state found");
|
|
3928
|
+
}
|
|
3929
|
+
return state.query;
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
SelectableListService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, deps: [{ token: NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3933
|
+
SelectableListService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, providedIn: "root" });
|
|
3934
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, decorators: [{
|
|
3935
|
+
type: Injectable,
|
|
3936
|
+
args: [{ providedIn: "root" }]
|
|
3937
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
3938
|
+
type: Optional
|
|
3939
|
+
}, {
|
|
3940
|
+
type: Inject,
|
|
3941
|
+
args: [NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER]
|
|
3942
|
+
}] }]; } });
|
|
3943
|
+
|
|
3944
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
3945
|
+
class NiceSelectableListDirective {
|
|
3946
|
+
constructor() {
|
|
3947
|
+
this.defaultOptions = { idKey: "id", preloadWindow: 2 };
|
|
3948
|
+
}
|
|
3949
|
+
ngOnInit() {
|
|
3950
|
+
if (!this.options) {
|
|
3951
|
+
this.options = { ...this.defaultOptions };
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
ngOnChanges(changes) {
|
|
3955
|
+
if ("options" in changes) {
|
|
3956
|
+
this.options = {
|
|
3957
|
+
...this.defaultOptions,
|
|
3958
|
+
...changes.options.currentValue
|
|
3959
|
+
};
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
NiceSelectableListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3964
|
+
NiceSelectableListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListDirective, selector: "[niceSelectableList]", inputs: { state: "state", options: "options" }, queries: [{ propertyName: "checkboxes", predicate: NiceSelectableListCheckboxDirective, descendants: true }], usesOnChanges: true, ngImport: i0 });
|
|
3965
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, decorators: [{
|
|
3966
|
+
type: Directive,
|
|
3967
|
+
args: [{
|
|
3968
|
+
selector: "[niceSelectableList]"
|
|
3969
|
+
}]
|
|
3970
|
+
}], propDecorators: { state: [{
|
|
3971
|
+
type: Input
|
|
3972
|
+
}], options: [{
|
|
3973
|
+
type: Input
|
|
3974
|
+
}], checkboxes: [{
|
|
3975
|
+
type: ContentChildren,
|
|
3976
|
+
args: [NiceSelectableListCheckboxDirective, { descendants: true }]
|
|
3977
|
+
}] } });
|
|
3978
|
+
|
|
3979
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
3980
|
+
class NiceSelectableListCheckboxDirective {
|
|
3981
|
+
constructor(checkbox, selectableList, selectableListService) {
|
|
3982
|
+
this.checkbox = checkbox;
|
|
3983
|
+
this.selectableList = selectableList;
|
|
3984
|
+
this.selectableListService = selectableListService;
|
|
3985
|
+
this.unsubscribeAll$ = new Subject();
|
|
3986
|
+
}
|
|
3987
|
+
get currentId() {
|
|
3988
|
+
if (!this.selectableEntity || !this.selectableListStateService) {
|
|
3989
|
+
return null;
|
|
3990
|
+
}
|
|
3991
|
+
return this.selectableEntity[this.selectableListStateService.idKey];
|
|
3992
|
+
}
|
|
3993
|
+
ngOnInit() {
|
|
3994
|
+
this.selectableListStateService = this.selectableListService.withState(this.selectableList.state);
|
|
3995
|
+
this.selectableListStateQuery = this.selectableListService.query(this.selectableList.state);
|
|
3996
|
+
if (this.selectableEntity) {
|
|
3997
|
+
this.handleSelectableEntity();
|
|
3998
|
+
}
|
|
3999
|
+
if (this.selectPage) {
|
|
4000
|
+
this.handleSelectPage();
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
ngOnDestroy() {
|
|
4004
|
+
this.unsubscribeAll$.next();
|
|
4005
|
+
this.unsubscribeAll$.complete();
|
|
4006
|
+
}
|
|
4007
|
+
handleSelectableEntity() {
|
|
4008
|
+
if (this.checkbox.checked) {
|
|
4009
|
+
this.selectableListStateService.selectEntity(this.selectableEntity);
|
|
4010
|
+
}
|
|
4011
|
+
if (!this.checkbox.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4012
|
+
this.checkbox.checked = true;
|
|
4013
|
+
}
|
|
4014
|
+
this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
|
|
4015
|
+
if (value.checked && !this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4016
|
+
this.selectableListStateService.selectEntity(this.selectableEntity);
|
|
4017
|
+
}
|
|
4018
|
+
if (!value.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4019
|
+
this.selectableListStateService.unselectEntity(this.selectableEntity);
|
|
4020
|
+
}
|
|
4021
|
+
});
|
|
4022
|
+
this.selectableListStateQuery.selectEntityAction([
|
|
4023
|
+
EntityActions.Add,
|
|
4024
|
+
EntityActions.Remove,
|
|
4025
|
+
EntityActions.Set
|
|
4026
|
+
]).pipe(takeUntil(this.unsubscribeAll$)).subscribe(({ ids, type }) => {
|
|
4027
|
+
const shouldTakeAction = ids.includes(this.currentId);
|
|
4028
|
+
if (!shouldTakeAction) {
|
|
4029
|
+
if (type === EntityActions.Set) {
|
|
4030
|
+
this.checkbox.checked = false;
|
|
4031
|
+
}
|
|
4032
|
+
return;
|
|
4033
|
+
}
|
|
4034
|
+
if (!this.checkbox.checked && (type === EntityActions.Add || type === EntityActions.Set)) {
|
|
4035
|
+
this.checkbox.checked = true;
|
|
4036
|
+
}
|
|
4037
|
+
if (this.checkbox.checked && type === EntityActions.Remove) {
|
|
4038
|
+
this.checkbox.checked = false;
|
|
4039
|
+
}
|
|
4040
|
+
});
|
|
4041
|
+
}
|
|
4042
|
+
handleSelectPage() {
|
|
4043
|
+
this.selectableListStateQuery.selectCount().subscribe(() => this.updateCheckboxState());
|
|
4044
|
+
this.selectableList.checkboxes.changes.pipe(takeUntil(this.unsubscribeAll$)).subscribe(() => this.updateCheckboxState());
|
|
4045
|
+
this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
|
|
4046
|
+
for (const checkbox of this.selectableList.checkboxes) {
|
|
4047
|
+
if (checkbox.selectPage) {
|
|
4048
|
+
continue;
|
|
4049
|
+
}
|
|
4050
|
+
checkbox.checkbox.checked = value.checked;
|
|
4051
|
+
checkbox.checkbox.change.emit({ checked: value.checked, source: checkbox.checkbox });
|
|
4052
|
+
}
|
|
4053
|
+
});
|
|
4054
|
+
}
|
|
4055
|
+
updateCheckboxState() {
|
|
4056
|
+
const checkboxes = this.selectableList.checkboxes.filter((checkbox) => !checkbox.selectPage);
|
|
4057
|
+
if (!checkboxes.length) {
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
const count = this.selectableListStateQuery.getCount();
|
|
4061
|
+
if (!count) {
|
|
4062
|
+
this.checkbox.indeterminate = false;
|
|
4063
|
+
this.checkbox.checked = false;
|
|
4064
|
+
return;
|
|
4065
|
+
}
|
|
4066
|
+
if (count !== checkboxes.length) {
|
|
4067
|
+
this.checkbox.indeterminate = true;
|
|
4068
|
+
this.checkbox.checked = false;
|
|
4069
|
+
return;
|
|
4070
|
+
}
|
|
4071
|
+
if (count === checkboxes.length) {
|
|
4072
|
+
this.checkbox.checked = true;
|
|
4073
|
+
this.checkbox.indeterminate = false;
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
NiceSelectableListCheckboxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, deps: [{ token: i1$4.MatCheckbox }, { token: NiceSelectableListDirective }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4078
|
+
NiceSelectableListCheckboxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListCheckboxDirective, selector: "mat-checkbox[niceSelectableListCheckbox]", inputs: { selectableEntity: "selectableEntity", selectPage: "selectPage" }, ngImport: i0 });
|
|
4079
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, decorators: [{
|
|
4080
|
+
type: Directive,
|
|
4081
|
+
args: [{
|
|
4082
|
+
selector: "mat-checkbox[niceSelectableListCheckbox]"
|
|
4083
|
+
}]
|
|
4084
|
+
}], ctorParameters: function () { return [{ type: i1$4.MatCheckbox }, { type: NiceSelectableListDirective }, { type: SelectableListService }]; }, propDecorators: { selectableEntity: [{
|
|
4085
|
+
type: Input
|
|
4086
|
+
}], selectPage: [{
|
|
4087
|
+
type: Input
|
|
4088
|
+
}] } });
|
|
4089
|
+
|
|
4090
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
4091
|
+
class NiceSelectableListSelectAllDirective {
|
|
4092
|
+
constructor(niceFilterViewQuery, selectableList, selectableListService) {
|
|
4093
|
+
this.niceFilterViewQuery = niceFilterViewQuery;
|
|
4094
|
+
this.selectableList = selectableList;
|
|
4095
|
+
this.selectableListService = selectableListService;
|
|
4096
|
+
this.action = "select";
|
|
4097
|
+
}
|
|
4098
|
+
ngOnInit() {
|
|
4099
|
+
this.selectableListStateService = this.selectableListService.withState(this.selectableList.state);
|
|
4100
|
+
this.selectableListStateQuery = this.selectableListService.query(this.selectableList.state);
|
|
4101
|
+
}
|
|
4102
|
+
onClick() {
|
|
4103
|
+
if (this.action === "select") {
|
|
4104
|
+
const filterParameters = this.niceFilterViewQuery?.getParameters() ?? {};
|
|
4105
|
+
const query = filterParameters ? FilterUtils.parametersToRequest(filterParameters) : null;
|
|
4106
|
+
this.selectableListStateService.selectAll({ query });
|
|
4107
|
+
}
|
|
4108
|
+
else {
|
|
4109
|
+
this.selectableListStateService.unselectAll();
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
NiceSelectableListSelectAllDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, deps: [{ token: NiceFilterViewQuery, optional: true }, { token: NiceSelectableListDirective }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4114
|
+
NiceSelectableListSelectAllDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListSelectAllDirective, selector: "button[niceSelectableListSelectAll]", inputs: { action: "action" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
|
|
4115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, decorators: [{
|
|
4116
|
+
type: Directive,
|
|
4117
|
+
args: [{
|
|
4118
|
+
selector: "button[niceSelectableListSelectAll]"
|
|
4119
|
+
}]
|
|
4120
|
+
}], ctorParameters: function () { return [{ type: NiceFilterViewQuery, decorators: [{
|
|
4121
|
+
type: Optional
|
|
4122
|
+
}] }, { type: NiceSelectableListDirective }, { type: SelectableListService }]; }, propDecorators: { action: [{
|
|
4123
|
+
type: Input
|
|
4124
|
+
}], onClick: [{
|
|
4125
|
+
type: HostListener,
|
|
4126
|
+
args: ["click"]
|
|
4127
|
+
}] } });
|
|
4128
|
+
|
|
4129
|
+
class NiceSelectableListModule {
|
|
4130
|
+
static register(...providers) {
|
|
4131
|
+
return {
|
|
4132
|
+
ngModule: NiceSelectableListModule,
|
|
4133
|
+
providers: providers.map(x => ({
|
|
4134
|
+
provide: NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER,
|
|
4135
|
+
useClass: x,
|
|
4136
|
+
multi: true
|
|
4137
|
+
}))
|
|
4138
|
+
};
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
NiceSelectableListModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4142
|
+
NiceSelectableListModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective], exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective] });
|
|
4143
|
+
NiceSelectableListModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, providers: [SelectableListService] });
|
|
4144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, decorators: [{
|
|
4145
|
+
type: NgModule,
|
|
4146
|
+
args: [{
|
|
4147
|
+
imports: [],
|
|
4148
|
+
declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective],
|
|
4149
|
+
providers: [SelectableListService],
|
|
4150
|
+
exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective]
|
|
4151
|
+
}]
|
|
4152
|
+
}] });
|
|
4153
|
+
|
|
3720
4154
|
class StringUtils {
|
|
3721
4155
|
}
|
|
3722
4156
|
// tslint:disable-next-line:max-line-length
|
|
@@ -3733,5 +4167,5 @@ String.prototype.toTableColumn = function (sortableOrOptions, nullLast) {
|
|
|
3733
4167
|
* Generated bundle index. Do not edit.
|
|
3734
4168
|
*/
|
|
3735
4169
|
|
|
3736
|
-
export { DateFilterComponent, FilterComponent, FilterGroupIconPipe, FilterOperatorTypes, FilterSelectionComponent, FilterType, FilterUtils, LayoutContent, NiceBaseFilterViewComponent, NiceBaseListButtonsDirective, NiceBaseListCardsDirective, NiceBaseListComponent, NiceBaseListCustomContentDirective, NiceBaseListDirectiveModule, NiceBaseListEmptySearchResultStateDirective, NiceBaseListEmptyStateDirective, NiceBaseListFiltersDirective, NiceBaseListModule, NiceBaseListQuery, NiceBaseListService, NiceBaseListStore, NiceBaseListTableDirective, NiceBaseListTitleDirective, NiceCustomDateAdapter, NiceFilterApi, NiceFilterCustomDataViewComponent, NiceFilterDataDirective, NiceFilterExportButtonsComponent, NiceFilterExportDirective, NiceFilterGroupService, NiceFilterInfiniteScrollDataViewComponent, NiceFilterMatPaginatorPaginationDirective, NiceFilterMatSortSortingDirective, NiceFilterMatTableViewDirective, NiceFilterQueryParamsDirective, NiceFilterSearchComponent, NiceFilterService, NiceFilterViewComponent, NiceFilterViewModule, NiceFilterViewQuery, NiceFilterViewService, NiceListState, NiceMultiStateFilterService, NiceMultiStateListComponent, NiceMultiStateListModule, NiceMultiStateListQuery, NiceMultiStateListService, NiceMultiStateListStore, NiceQueryBuilderComponent, NiceQueryBuilderModule, NiceSavedReportService, NumberFilterComponent, OrderUtils, QBFilterUtils, QueryBuilderTriggerDirective, RadioFilterComponent, RuleComponent, SelectFilterComponent, StringUtils, TableColumns, TextFilterComponent, defaultLayout, initialBaseListState, initialValue$1 as initialValue, mixinNiceFilterApi };
|
|
4170
|
+
export { DateFilterComponent, FilterComponent, FilterGroupIconPipe, FilterOperatorTypes, FilterSelectionComponent, FilterType, FilterUtils, LayoutContent, NiceBaseFilterViewComponent, NiceBaseListButtonsDirective, NiceBaseListCardsDirective, NiceBaseListComponent, NiceBaseListCustomContentDirective, NiceBaseListDirectiveModule, NiceBaseListEmptySearchResultStateDirective, NiceBaseListEmptyStateDirective, NiceBaseListFiltersDirective, NiceBaseListModule, NiceBaseListQuery, NiceBaseListService, NiceBaseListStore, NiceBaseListTableDirective, NiceBaseListTitleDirective, NiceCustomDateAdapter, NiceFilterApi, NiceFilterCustomDataViewComponent, NiceFilterDataDirective, NiceFilterExportButtonsComponent, NiceFilterExportDirective, NiceFilterGroupService, NiceFilterInfiniteScrollDataViewComponent, NiceFilterMatPaginatorPaginationDirective, NiceFilterMatSortSortingDirective, NiceFilterMatTableViewDirective, NiceFilterQueryParamsDirective, NiceFilterSearchComponent, NiceFilterService, NiceFilterViewComponent, NiceFilterViewModule, NiceFilterViewQuery, NiceFilterViewService, NiceListState, NiceMultiStateFilterService, NiceMultiStateListComponent, NiceMultiStateListModule, NiceMultiStateListQuery, NiceMultiStateListService, NiceMultiStateListStore, NicePreloadSelectedEntitiesProvider, NiceQueryBuilderComponent, NiceQueryBuilderModule, NiceSavedReportService, NiceSelectableListCheckboxDirective, NiceSelectableListDirective, NiceSelectableListModule, NiceSelectableListSelectAllDirective, NumberFilterComponent, OrderUtils, QBFilterUtils, QueryBuilderTriggerDirective, RadioFilterComponent, RuleComponent, SelectFilterComponent, SelectableListService, SelectableListStateService, StringUtils, TableColumns, TextFilterComponent, defaultLayout, initialBaseListState, initialValue$1 as initialValue, mixinNiceFilterApi };
|
|
3737
4171
|
//# sourceMappingURL=recursyve-nice-data-filter-kit.mjs.map
|