1
1
import { MinimalCFDimension } from '../core/types.js' ;
2
2
import { FilterStorageHelper , IFilterStorageConf } from './filter-storage-helper.js' ;
3
+ import { cfHelper } from './cf-helper.js' ;
4
+ import { ICFHelper } from './i-c-f-helper.js' ;
3
5
4
6
export interface ICFFilterHandlerConf extends IFilterStorageConf {
5
7
dimension ?: MinimalCFDimension ;
@@ -8,6 +10,7 @@ export interface ICFFilterHandlerConf extends IFilterStorageConf {
8
10
9
11
export class CFFilterHandler extends FilterStorageHelper {
10
12
protected _conf : ICFFilterHandlerConf ;
13
+ protected helper : ICFHelper = cfHelper ;
11
14
12
15
constructor ( conf : ICFFilterHandlerConf = { } ) {
13
16
super ( {
@@ -24,40 +27,10 @@ export class CFFilterHandler extends FilterStorageHelper {
24
27
}
25
28
26
29
protected _storageKey ( ) : any {
27
- if ( this . _conf . shareFilters ) {
28
- return this . _conf . dimension ;
29
- } else {
30
- return this ;
31
- }
30
+ return this . helper . storageKey ( this ) ;
32
31
}
33
32
34
33
public applyFilters ( ) {
35
- if ( ! ( this . _conf . dimension && this . _conf . dimension . filter ) ) {
36
- return ;
37
- }
38
-
39
- if ( this . filters . length === 0 ) {
40
- this . _conf . dimension . filter ( null ) ;
41
- } else if ( this . filters . length === 1 && ! this . filters [ 0 ] . isFiltered ) {
42
- // single value and not a function-based filter
43
- this . _conf . dimension . filterExact ( this . filters [ 0 ] ) ;
44
- } else if ( this . filters . length === 1 && this . filters [ 0 ] . filterType === 'RangedFilter' ) {
45
- // single range-based filter
46
- this . _conf . dimension . filterRange ( this . filters [ 0 ] ) ;
47
- } else {
48
- this . _conf . dimension . filterFunction ( d => {
49
- for ( let i = 0 ; i < this . filters . length ; i ++ ) {
50
- const filter = this . filters [ i ] ;
51
- if ( filter . isFiltered ) {
52
- if ( filter . isFiltered ( d ) ) {
53
- return true ;
54
- }
55
- } else if ( filter <= d && filter >= d ) {
56
- return true ;
57
- }
58
- }
59
- return false ;
60
- } ) ;
61
- }
34
+ this . helper . applyFilters ( this . _conf . dimension , this . filters ) ;
62
35
}
63
36
}
0 commit comments