@@ -25,25 +25,35 @@ export const AnnotationStatistics = function () {
25
25
const renamingsSize = countNonRepeatableAnnotation ( annotations . renamings , matchedIds ) ;
26
26
const requiredsSize = countNonRepeatableAnnotation ( annotations . requireds , matchedIds ) ;
27
27
const todoSize = countNonRepeatableAnnotation ( annotations . todos , matchedIds ) ;
28
+ const sum =
29
+ attributesSize +
30
+ boundariesSize +
31
+ calledAftersSize +
32
+ constantsSize +
33
+ descriptionSize +
34
+ enumsSize +
35
+ groupsSize +
36
+ optionalsSize +
37
+ movesSize +
38
+ puresSize +
39
+ removesSize +
40
+ renamingsSize +
41
+ requiredsSize +
42
+ todoSize ;
28
43
29
44
const filterString = useAppSelector ( selectFilterString ) ;
30
45
31
- const filterAction = ( annotation : string ) => {
32
- const annotationFilterPrefix = 'annotation:@' ;
33
- const annotationFilterString = annotationFilterPrefix + annotation ;
46
+ const filterAction = ( newAnnotationFilterString : string ) => {
47
+ const annotationFilterPrefix = 'annotation:' ;
34
48
35
- //Remove existing annotation filter
36
- const filterList = filterString . split ( ' ' ) ;
37
- let newFilter = '' ;
38
- for ( const element of filterList ) {
39
- if ( ! element . startsWith ( annotationFilterPrefix ) ) {
40
- newFilter += element ;
41
- newFilter += ' ' ;
42
- }
43
- }
49
+ const newFilterString = [
50
+ ...filterString . split ( ' ' ) . filter ( ( it ) => ! it . startsWith ( annotationFilterPrefix ) ) ,
51
+ newAnnotationFilterString ,
52
+ ]
53
+ . filter ( ( it ) => it . length > 0 )
54
+ . join ( ' ' ) ;
44
55
45
- newFilter += annotationFilterString ;
46
- dispatch ( setFilterString ( newFilter ) ) ;
56
+ dispatch ( setFilterString ( newFilterString ) ) ;
47
57
} ;
48
58
49
59
return (
@@ -52,26 +62,27 @@ export const AnnotationStatistics = function () {
52
62
Annotations on Matched Elements
53
63
</ Heading >
54
64
< SimpleGrid columns = { 2 } spacing = { 2 } >
55
- < Button onClick = { ( ) => filterAction ( 'attribute' ) } children = { 'Attributes: ' + attributesSize } > </ Button >
56
- < Button onClick = { ( ) => filterAction ( 'boundary' ) } children = { 'Boundaries: ' + boundariesSize } > </ Button >
57
- < Button
58
- onClick = { ( ) => filterAction ( 'calledAfter' ) }
59
- children = { 'CalledAfter: ' + calledAftersSize }
60
- > </ Button >
61
- < Button onClick = { ( ) => filterAction ( 'constant' ) } children = { 'Constants: ' + constantsSize } > </ Button >
62
- < Button
63
- onClick = { ( ) => filterAction ( 'description' ) }
64
- children = { 'Descriptions: ' + descriptionSize }
65
- > </ Button >
66
- < Button onClick = { ( ) => filterAction ( 'enum' ) } children = { 'Enums: ' + enumsSize } > </ Button >
67
- < Button onClick = { ( ) => filterAction ( 'group' ) } children = { 'Groups: ' + groupsSize } > </ Button >
68
- < Button onClick = { ( ) => filterAction ( 'move' ) } children = { 'Move: ' + movesSize } > </ Button >
69
- < Button onClick = { ( ) => filterAction ( 'optional' ) } children = { 'Optionals: ' + optionalsSize } > </ Button >
70
- < Button onClick = { ( ) => filterAction ( 'pure' ) } children = { 'Pures: ' + puresSize } > </ Button >
71
- < Button onClick = { ( ) => filterAction ( 'remove' ) } children = { 'Removes: ' + removesSize } > </ Button >
72
- < Button onClick = { ( ) => filterAction ( 'rename' ) } children = { 'Renaming: ' + renamingsSize } > </ Button >
73
- < Button onClick = { ( ) => filterAction ( 'required' ) } children = { 'Requireds: ' + requiredsSize } > </ Button >
74
- < Button onClick = { ( ) => filterAction ( 'todo' ) } children = { 'Todos: ' + todoSize } > </ Button >
65
+ < Button onClick = { ( ) => filterAction ( '' ) } > Clear Filter</ Button >
66
+ < Button onClick = { ( ) => filterAction ( 'annotation:any' ) } > { 'Any: ' + sum } </ Button >
67
+
68
+ < Button onClick = { ( ) => filterAction ( 'annotation:@attribute' ) } > { '@Attribute: ' + attributesSize } </ Button >
69
+ < Button onClick = { ( ) => filterAction ( 'annotation:@boundary' ) } > { '@Boundary: ' + boundariesSize } </ Button >
70
+ < Button onClick = { ( ) => filterAction ( 'annotation:@calledAfter' ) } >
71
+ { '@CalledAfter: ' + calledAftersSize }
72
+ </ Button >
73
+ < Button onClick = { ( ) => filterAction ( 'annotation:@constant' ) } > { '@Constant: ' + constantsSize } </ Button >
74
+ < Button onClick = { ( ) => filterAction ( 'annotation:@description' ) } >
75
+ { '@Description: ' + descriptionSize }
76
+ </ Button >
77
+ < Button onClick = { ( ) => filterAction ( 'annotation:@enum' ) } > { '@Enum: ' + enumsSize } </ Button >
78
+ < Button onClick = { ( ) => filterAction ( 'annotation:@group' ) } > { '@Group: ' + groupsSize } </ Button >
79
+ < Button onClick = { ( ) => filterAction ( 'annotation:@move' ) } > { '@Move: ' + movesSize } </ Button >
80
+ < Button onClick = { ( ) => filterAction ( 'annotation:@optional' ) } > { '@Optional: ' + optionalsSize } </ Button >
81
+ < Button onClick = { ( ) => filterAction ( 'annotation:@pure' ) } > { '@Pure: ' + puresSize } </ Button >
82
+ < Button onClick = { ( ) => filterAction ( 'annotation:@remove' ) } > { '@Remove: ' + removesSize } </ Button >
83
+ < Button onClick = { ( ) => filterAction ( 'annotation:@rename' ) } > { '@Rename: ' + renamingsSize } </ Button >
84
+ < Button onClick = { ( ) => filterAction ( 'annotation:@required' ) } > { '@Required: ' + requiredsSize } </ Button >
85
+ < Button onClick = { ( ) => filterAction ( 'annotation:@todo' ) } > { '@Todo: ' + todoSize } </ Button >
75
86
</ SimpleGrid >
76
87
</ >
77
88
) ;
0 commit comments