File tree Expand file tree Collapse file tree 5 files changed +31
-56
lines changed Expand file tree Collapse file tree 5 files changed +31
-56
lines changed Original file line number Diff line number Diff line change 1
- import { Field } from './Field' ;
2
- import type { FilterOrErrorMessage } from './Filter' ;
3
- import { FilterInstructions } from './FilterInstructions' ;
1
+ import { FilterInstructionsBasedField } from './FilterInstructionsBasedField' ;
4
2
5
3
/**
6
4
* Implements 'exclude sub-items' filter
7
5
*/
8
- export class ExcludeSubItemsField extends Field {
9
- private readonly _filters = new FilterInstructions ( ) ;
10
-
6
+ export class ExcludeSubItemsField extends FilterInstructionsBasedField {
11
7
constructor ( ) {
12
8
super ( ) ;
13
9
@@ -17,19 +13,7 @@ export class ExcludeSubItemsField extends Field {
17
13
) ;
18
14
}
19
15
20
- public canCreateFilterForLine ( line : string ) : boolean {
21
- return this . _filters . canCreateFilterForLine ( line ) ;
22
- }
23
-
24
- public createFilterOrErrorMessage ( line : string ) : FilterOrErrorMessage {
25
- return this . _filters . createFilterOrErrorMessage ( line ) ;
26
- }
27
-
28
16
protected fieldName ( ) : string {
29
17
return 'exclude' ;
30
18
}
31
-
32
- protected filterRegexp ( ) : RegExp | null {
33
- return null ;
34
- }
35
19
}
Original file line number Diff line number Diff line change
1
+ import { Field } from './Field' ;
2
+ import { FilterInstructions } from './FilterInstructions' ;
3
+ import type { FilterOrErrorMessage } from './Filter' ;
4
+
5
+ /**
6
+ * This class is an implementation for implements of {@link Field}
7
+ *
8
+ * The named of the class is weak. It is based solely on the fact that the
9
+ * class is entirely implemented via the {@link FilterInstructions} class.
10
+ */
11
+ export abstract class FilterInstructionsBasedField extends Field {
12
+ protected readonly _filters = new FilterInstructions ( ) ;
13
+
14
+ public canCreateFilterForLine ( line : string ) : boolean {
15
+ return this . _filters . canCreateFilterForLine ( line ) ;
16
+ }
17
+
18
+ public createFilterOrErrorMessage ( line : string ) : FilterOrErrorMessage {
19
+ return this . _filters . createFilterOrErrorMessage ( line ) ;
20
+ }
21
+
22
+ protected filterRegexp ( ) : RegExp | null {
23
+ return null ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change 1
- import { Field } from './Field' ;
2
- import type { FilterOrErrorMessage } from './Filter' ;
3
- import { FilterInstructions } from './FilterInstructions' ;
4
-
5
- export class RecurringField extends Field {
6
- private readonly _filters = new FilterInstructions ( ) ;
1
+ import { FilterInstructionsBasedField } from './FilterInstructionsBasedField' ;
7
2
3
+ export class RecurringField extends FilterInstructionsBasedField {
8
4
constructor ( ) {
9
5
super ( ) ;
10
6
this . _filters . add ( 'is recurring' , ( task ) => task . recurrence !== null ) ;
@@ -14,19 +10,7 @@ export class RecurringField extends Field {
14
10
) ;
15
11
}
16
12
17
- public canCreateFilterForLine ( line : string ) : boolean {
18
- return this . _filters . canCreateFilterForLine ( line ) ;
19
- }
20
-
21
- public createFilterOrErrorMessage ( line : string ) : FilterOrErrorMessage {
22
- return this . _filters . createFilterOrErrorMessage ( line ) ;
23
- }
24
-
25
13
protected fieldName ( ) : string {
26
14
return 'recurring' ;
27
15
}
28
-
29
- protected filterRegexp ( ) : RegExp | null {
30
- return null ;
31
- }
32
16
}
Original file line number Diff line number Diff line change 1
1
import { Status , Task } from '../../Task' ;
2
- import { Field } from './Field' ;
3
- import type { FilterOrErrorMessage } from './Filter' ;
4
- import { FilterInstructions } from './FilterInstructions' ;
5
-
6
- export class StatusField extends Field {
7
- private readonly _filters = new FilterInstructions ( ) ;
2
+ import { FilterInstructionsBasedField } from './FilterInstructionsBasedField' ;
8
3
4
+ export class StatusField extends FilterInstructionsBasedField {
9
5
constructor ( ) {
10
6
super ( ) ;
11
7
@@ -16,19 +12,7 @@ export class StatusField extends Field {
16
12
) ;
17
13
}
18
14
19
- public canCreateFilterForLine ( line : string ) : boolean {
20
- return this . _filters . canCreateFilterForLine ( line ) ;
21
- }
22
-
23
- public createFilterOrErrorMessage ( line : string ) : FilterOrErrorMessage {
24
- return this . _filters . createFilterOrErrorMessage ( line ) ;
25
- }
26
-
27
15
protected fieldName ( ) : string {
28
16
return 'status' ;
29
17
}
30
-
31
- protected filterRegexp ( ) : RegExp | null {
32
- return null ;
33
- }
34
18
}
Original file line number Diff line number Diff line change 1
- // 'exclude sub-items'
2
-
3
1
import { testTaskFilter } from '../../TestingTools/FilterTestHelpers' ;
4
2
import { fromLine } from '../../TestHelpers' ;
5
3
import { ExcludeSubItemsField } from '../../../src/Query/Filter/ExcludeSubItemsField' ;
You can’t perform that action at this time.
0 commit comments