@recursyve/nice-data-filter-kit 14.1.6 → 14.2.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.
- 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/providers/selectable-list-content.service.mjs +26 -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 +48 -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/public-api.mjs +2 -1
- package/fesm2015/recursyve-nice-data-filter-kit.mjs +525 -17
- package/fesm2015/recursyve-nice-data-filter-kit.mjs.map +1 -1
- package/fesm2020/recursyve-nice-data-filter-kit.mjs +500 -20
- 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/providers/selectable-list-content.service.d.ts +13 -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 +18 -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
|
@@ -4,8 +4,8 @@ import { HttpParams } from '@angular/common/http';
|
|
|
4
4
|
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
|
-
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';
|
|
7
|
+
import { Directive, Input, NgModule, Injectable, Inject, InjectionToken, Optional, Pipe, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, HostListener, forwardRef, TemplateRef, ContentChild, ContentChildren, ViewChild, QueryList } from '@angular/core';
|
|
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,6 +55,7 @@ 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) {
|
|
@@ -2859,6 +2860,20 @@ class NiceFilterViewStore extends EntityStore {
|
|
|
2859
2860
|
});
|
|
2860
2861
|
this.remove(value[idKey]);
|
|
2861
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
|
+
}
|
|
2862
2877
|
}
|
|
2863
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 });
|
|
2864
2879
|
NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore });
|
|
@@ -2889,6 +2904,9 @@ class NiceFilterViewQuery extends QueryEntity {
|
|
|
2889
2904
|
selectFilterResult() {
|
|
2890
2905
|
return this.select("filterResult");
|
|
2891
2906
|
}
|
|
2907
|
+
getParameters() {
|
|
2908
|
+
return this.store.getParameters(this.store.getValue().filterParameters);
|
|
2909
|
+
}
|
|
2892
2910
|
}
|
|
2893
2911
|
NiceFilterViewQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery, deps: [{ token: NiceFilterViewStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2894
2912
|
NiceFilterViewQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery });
|
|
@@ -2961,7 +2979,7 @@ class NiceFilterViewService {
|
|
|
2961
2979
|
}
|
|
2962
2980
|
try {
|
|
2963
2981
|
this.store.setLoading(true);
|
|
2964
|
-
const result = await firstValueFrom(this.filterService.filter(this.getParameters(filterParameters)));
|
|
2982
|
+
const result = await firstValueFrom(this.filterService.filter(this.store.getParameters(filterParameters)));
|
|
2965
2983
|
this.store.setResult(result);
|
|
2966
2984
|
}
|
|
2967
2985
|
catch (e) {
|
|
@@ -2978,7 +2996,7 @@ class NiceFilterViewService {
|
|
|
2978
2996
|
}
|
|
2979
2997
|
try {
|
|
2980
2998
|
this.store.setLoading(true);
|
|
2981
|
-
const result = await firstValueFrom(this.filterService.getFile(type, this.getParameters(filterParameters)));
|
|
2999
|
+
const result = await firstValueFrom(this.filterService.getFile(type, this.store.getParameters(filterParameters)));
|
|
2982
3000
|
FileUtils.downloadFile(`${downloadFileName}.${type}`, result);
|
|
2983
3001
|
}
|
|
2984
3002
|
catch (e) {
|
|
@@ -2995,7 +3013,7 @@ class NiceFilterViewService {
|
|
|
2995
3013
|
}
|
|
2996
3014
|
try {
|
|
2997
3015
|
this.store.setLoading(true);
|
|
2998
|
-
const result = await firstValueFrom(this.filterService.getPrintableHtml(this.getParameters(filterParameters)));
|
|
3016
|
+
const result = await firstValueFrom(this.filterService.getPrintableHtml(this.store.getParameters(filterParameters)));
|
|
2999
3017
|
FileUtils.openPrintableWindow(result);
|
|
3000
3018
|
}
|
|
3001
3019
|
catch (e) {
|
|
@@ -3110,20 +3128,6 @@ class NiceFilterViewService {
|
|
|
3110
3128
|
});
|
|
3111
3129
|
}
|
|
3112
3130
|
}
|
|
3113
|
-
getParameters(filterParameters) {
|
|
3114
|
-
const { baseRules } = this.store.getValue();
|
|
3115
|
-
const parameters = {
|
|
3116
|
-
...filterParameters,
|
|
3117
|
-
rules: filterParameters?.rules ? [...filterParameters.rules] : []
|
|
3118
|
-
};
|
|
3119
|
-
if (baseRules?.length) {
|
|
3120
|
-
parameters.rules.push({
|
|
3121
|
-
condition: "and",
|
|
3122
|
-
rules: baseRules
|
|
3123
|
-
});
|
|
3124
|
-
}
|
|
3125
|
-
return parameters;
|
|
3126
|
-
}
|
|
3127
3131
|
}
|
|
3128
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 });
|
|
3129
3133
|
NiceFilterViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService });
|
|
@@ -3703,6 +3707,482 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
|
|
|
3703
3707
|
}]
|
|
3704
3708
|
}] });
|
|
3705
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
|
+
class SelectableListContentService {
|
|
3945
|
+
constructor() {
|
|
3946
|
+
this._state = null;
|
|
3947
|
+
this._checkboxes = new QueryList();
|
|
3948
|
+
}
|
|
3949
|
+
get state() {
|
|
3950
|
+
return this._state;
|
|
3951
|
+
}
|
|
3952
|
+
get checkboxes() {
|
|
3953
|
+
return this._checkboxes;
|
|
3954
|
+
}
|
|
3955
|
+
setState(state) {
|
|
3956
|
+
this._state = state;
|
|
3957
|
+
}
|
|
3958
|
+
setCheckboxes(checkboxes) {
|
|
3959
|
+
this._checkboxes = checkboxes;
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
SelectableListContentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3963
|
+
SelectableListContentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService });
|
|
3964
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService, decorators: [{
|
|
3965
|
+
type: Injectable
|
|
3966
|
+
}] });
|
|
3967
|
+
|
|
3968
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
3969
|
+
class NiceSelectableListCheckboxDirective {
|
|
3970
|
+
constructor(checkbox, service, selectableListService) {
|
|
3971
|
+
this.checkbox = checkbox;
|
|
3972
|
+
this.service = service;
|
|
3973
|
+
this.selectableListService = selectableListService;
|
|
3974
|
+
this.unsubscribeAll$ = new Subject();
|
|
3975
|
+
}
|
|
3976
|
+
get currentId() {
|
|
3977
|
+
if (!this.selectableEntity || !this.selectableListStateService) {
|
|
3978
|
+
return null;
|
|
3979
|
+
}
|
|
3980
|
+
return this.selectableEntity[this.selectableListStateService.idKey];
|
|
3981
|
+
}
|
|
3982
|
+
ngOnInit() {
|
|
3983
|
+
this.selectableListStateService = this.selectableListService.withState(this.service.state);
|
|
3984
|
+
this.selectableListStateQuery = this.selectableListService.query(this.service.state);
|
|
3985
|
+
if (this.selectableEntity) {
|
|
3986
|
+
this.handleSelectableEntity();
|
|
3987
|
+
}
|
|
3988
|
+
if (this.selectPage) {
|
|
3989
|
+
this.handleSelectPage();
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
ngOnDestroy() {
|
|
3993
|
+
this.unsubscribeAll$.next();
|
|
3994
|
+
this.unsubscribeAll$.complete();
|
|
3995
|
+
}
|
|
3996
|
+
handleSelectableEntity() {
|
|
3997
|
+
if (this.checkbox.checked) {
|
|
3998
|
+
this.selectableListStateService.selectEntity(this.selectableEntity);
|
|
3999
|
+
}
|
|
4000
|
+
if (!this.checkbox.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4001
|
+
this.checkbox.checked = true;
|
|
4002
|
+
}
|
|
4003
|
+
this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
|
|
4004
|
+
if (value.checked && !this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4005
|
+
this.selectableListStateService.selectEntity(this.selectableEntity);
|
|
4006
|
+
}
|
|
4007
|
+
if (!value.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
|
|
4008
|
+
this.selectableListStateService.unselectEntity(this.selectableEntity);
|
|
4009
|
+
}
|
|
4010
|
+
});
|
|
4011
|
+
this.selectableListStateQuery.selectEntityAction([
|
|
4012
|
+
EntityActions.Add,
|
|
4013
|
+
EntityActions.Remove,
|
|
4014
|
+
EntityActions.Set
|
|
4015
|
+
]).pipe(takeUntil(this.unsubscribeAll$)).subscribe(({ ids, type }) => {
|
|
4016
|
+
const shouldTakeAction = ids.includes(this.currentId);
|
|
4017
|
+
if (!shouldTakeAction) {
|
|
4018
|
+
if (type === EntityActions.Set) {
|
|
4019
|
+
this.checkbox.checked = false;
|
|
4020
|
+
}
|
|
4021
|
+
return;
|
|
4022
|
+
}
|
|
4023
|
+
if (!this.checkbox.checked && (type === EntityActions.Add || type === EntityActions.Set)) {
|
|
4024
|
+
this.checkbox.checked = true;
|
|
4025
|
+
}
|
|
4026
|
+
if (this.checkbox.checked && type === EntityActions.Remove) {
|
|
4027
|
+
this.checkbox.checked = false;
|
|
4028
|
+
}
|
|
4029
|
+
});
|
|
4030
|
+
}
|
|
4031
|
+
handleSelectPage() {
|
|
4032
|
+
this.selectableListStateQuery.selectCount().subscribe(() => this.updateCheckboxState());
|
|
4033
|
+
this.service.checkboxes.changes.pipe(takeUntil(this.unsubscribeAll$)).subscribe(() => this.updateCheckboxState());
|
|
4034
|
+
this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
|
|
4035
|
+
for (const checkbox of this.service.checkboxes) {
|
|
4036
|
+
if (checkbox.selectPage) {
|
|
4037
|
+
continue;
|
|
4038
|
+
}
|
|
4039
|
+
checkbox.checkbox.checked = value.checked;
|
|
4040
|
+
checkbox.checkbox.change.emit({ checked: value.checked, source: checkbox.checkbox });
|
|
4041
|
+
}
|
|
4042
|
+
});
|
|
4043
|
+
}
|
|
4044
|
+
updateCheckboxState() {
|
|
4045
|
+
const checkboxes = this.service.checkboxes.filter((checkbox) => !checkbox.selectPage);
|
|
4046
|
+
if (!checkboxes.length) {
|
|
4047
|
+
return;
|
|
4048
|
+
}
|
|
4049
|
+
const count = this.selectableListStateQuery.getCount();
|
|
4050
|
+
if (!count) {
|
|
4051
|
+
this.checkbox.indeterminate = false;
|
|
4052
|
+
this.checkbox.checked = false;
|
|
4053
|
+
return;
|
|
4054
|
+
}
|
|
4055
|
+
if (count !== checkboxes.length) {
|
|
4056
|
+
this.checkbox.indeterminate = true;
|
|
4057
|
+
this.checkbox.checked = false;
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
if (count === checkboxes.length) {
|
|
4061
|
+
this.checkbox.checked = true;
|
|
4062
|
+
this.checkbox.indeterminate = false;
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
NiceSelectableListCheckboxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, deps: [{ token: i1$4.MatCheckbox }, { token: SelectableListContentService }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4067
|
+
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 });
|
|
4068
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, decorators: [{
|
|
4069
|
+
type: Directive,
|
|
4070
|
+
args: [{
|
|
4071
|
+
selector: "mat-checkbox[niceSelectableListCheckbox]"
|
|
4072
|
+
}]
|
|
4073
|
+
}], ctorParameters: function () { return [{ type: i1$4.MatCheckbox }, { type: SelectableListContentService }, { type: SelectableListService }]; }, propDecorators: { selectableEntity: [{
|
|
4074
|
+
type: Input
|
|
4075
|
+
}], selectPage: [{
|
|
4076
|
+
type: Input
|
|
4077
|
+
}] } });
|
|
4078
|
+
|
|
4079
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
4080
|
+
class NiceSelectableListSelectAllDirective {
|
|
4081
|
+
constructor(niceFilterViewQuery, service, selectableListService) {
|
|
4082
|
+
this.niceFilterViewQuery = niceFilterViewQuery;
|
|
4083
|
+
this.service = service;
|
|
4084
|
+
this.selectableListService = selectableListService;
|
|
4085
|
+
this.action = "select";
|
|
4086
|
+
}
|
|
4087
|
+
ngOnInit() {
|
|
4088
|
+
this.selectableListStateService = this.selectableListService.withState(this.service.state);
|
|
4089
|
+
this.selectableListStateQuery = this.selectableListService.query(this.service.state);
|
|
4090
|
+
}
|
|
4091
|
+
onClick() {
|
|
4092
|
+
if (this.action === "select") {
|
|
4093
|
+
const filterParameters = this.niceFilterViewQuery?.getParameters() ?? {};
|
|
4094
|
+
const query = filterParameters ? FilterUtils.parametersToRequest(filterParameters) : null;
|
|
4095
|
+
this.selectableListStateService.selectAll({ query });
|
|
4096
|
+
}
|
|
4097
|
+
else {
|
|
4098
|
+
this.selectableListStateService.unselectAll();
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
NiceSelectableListSelectAllDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, deps: [{ token: NiceFilterViewQuery, optional: true }, { token: SelectableListContentService }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4103
|
+
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 });
|
|
4104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, decorators: [{
|
|
4105
|
+
type: Directive,
|
|
4106
|
+
args: [{
|
|
4107
|
+
selector: "button[niceSelectableListSelectAll]"
|
|
4108
|
+
}]
|
|
4109
|
+
}], ctorParameters: function () { return [{ type: NiceFilterViewQuery, decorators: [{
|
|
4110
|
+
type: Optional
|
|
4111
|
+
}] }, { type: SelectableListContentService }, { type: SelectableListService }]; }, propDecorators: { action: [{
|
|
4112
|
+
type: Input
|
|
4113
|
+
}], onClick: [{
|
|
4114
|
+
type: HostListener,
|
|
4115
|
+
args: ["click"]
|
|
4116
|
+
}] } });
|
|
4117
|
+
|
|
4118
|
+
// tslint:disable-next-line:directive-class-suffix
|
|
4119
|
+
class NiceSelectableListDirective {
|
|
4120
|
+
constructor(service) {
|
|
4121
|
+
this.service = service;
|
|
4122
|
+
this.defaultOptions = { idKey: "id", preloadWindow: 2 };
|
|
4123
|
+
}
|
|
4124
|
+
ngOnInit() {
|
|
4125
|
+
if (!this.options) {
|
|
4126
|
+
this.options = { ...this.defaultOptions };
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
ngOnChanges(changes) {
|
|
4130
|
+
if ("options" in changes) {
|
|
4131
|
+
this.options = {
|
|
4132
|
+
...this.defaultOptions,
|
|
4133
|
+
...changes.options.currentValue
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4136
|
+
if ("state" in changes) {
|
|
4137
|
+
this.service.setState(this.state);
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
ngAfterContentInit() {
|
|
4141
|
+
this.service.setCheckboxes(this.checkboxes);
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
NiceSelectableListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, deps: [{ token: SelectableListContentService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4145
|
+
NiceSelectableListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListDirective, selector: "[niceSelectableList]", inputs: { state: "state", options: "options" }, providers: [SelectableListContentService], queries: [{ propertyName: "checkboxes", predicate: NiceSelectableListCheckboxDirective, descendants: true }], usesOnChanges: true, ngImport: i0 });
|
|
4146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, decorators: [{
|
|
4147
|
+
type: Directive,
|
|
4148
|
+
args: [{
|
|
4149
|
+
selector: "[niceSelectableList]",
|
|
4150
|
+
providers: [SelectableListContentService]
|
|
4151
|
+
}]
|
|
4152
|
+
}], ctorParameters: function () { return [{ type: SelectableListContentService }]; }, propDecorators: { state: [{
|
|
4153
|
+
type: Input
|
|
4154
|
+
}], options: [{
|
|
4155
|
+
type: Input
|
|
4156
|
+
}], checkboxes: [{
|
|
4157
|
+
type: ContentChildren,
|
|
4158
|
+
args: [NiceSelectableListCheckboxDirective, { descendants: true }]
|
|
4159
|
+
}] } });
|
|
4160
|
+
|
|
4161
|
+
class NiceSelectableListModule {
|
|
4162
|
+
static register(...providers) {
|
|
4163
|
+
return {
|
|
4164
|
+
ngModule: NiceSelectableListModule,
|
|
4165
|
+
providers: providers.map(x => ({
|
|
4166
|
+
provide: NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER,
|
|
4167
|
+
useClass: x,
|
|
4168
|
+
multi: true
|
|
4169
|
+
}))
|
|
4170
|
+
};
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
NiceSelectableListModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4174
|
+
NiceSelectableListModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective], exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective] });
|
|
4175
|
+
NiceSelectableListModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, providers: [SelectableListService] });
|
|
4176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, decorators: [{
|
|
4177
|
+
type: NgModule,
|
|
4178
|
+
args: [{
|
|
4179
|
+
imports: [],
|
|
4180
|
+
declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective],
|
|
4181
|
+
providers: [SelectableListService],
|
|
4182
|
+
exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective]
|
|
4183
|
+
}]
|
|
4184
|
+
}] });
|
|
4185
|
+
|
|
3706
4186
|
class StringUtils {
|
|
3707
4187
|
}
|
|
3708
4188
|
// tslint:disable-next-line:max-line-length
|
|
@@ -3719,5 +4199,5 @@ String.prototype.toTableColumn = function (sortableOrOptions, nullLast) {
|
|
|
3719
4199
|
* Generated bundle index. Do not edit.
|
|
3720
4200
|
*/
|
|
3721
4201
|
|
|
3722
|
-
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 };
|
|
4202
|
+
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 };
|
|
3723
4203
|
//# sourceMappingURL=recursyve-nice-data-filter-kit.mjs.map
|