@@ -10,6 +10,7 @@ import {
10
10
query ,
11
11
queryAll ,
12
12
} from 'lit-element' ;
13
+ import { classMap } from 'lit-html/directives/class-map' ;
13
14
import { translate } from 'lit-translate' ;
14
15
15
16
import '@material/mwc-button' ;
@@ -76,7 +77,7 @@ function getCommAddress(controlBlock: Element): Element | null | undefined {
76
77
@customElement ( 'cleanup-control-blocks' )
77
78
export class CleanupControlBlocks extends LitElement {
78
79
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
79
- @property ( )
80
+ @property ( { attribute : false } )
80
81
doc ! : XMLDocument ;
81
82
82
83
@property ( { type : Boolean } )
@@ -85,7 +86,7 @@ export class CleanupControlBlocks extends LitElement {
85
86
@property ( { type : Array } )
86
87
unreferencedControls : Element [ ] = [ ] ;
87
88
88
- @property ( )
89
+ @property ( { attribute : false } )
89
90
selectedControlItems : MWCListIndex | [ ] = [ ] ;
90
91
91
92
@query ( '.deleteButton' )
@@ -118,7 +119,9 @@ export class CleanupControlBlocks extends LitElement {
118
119
*/
119
120
private toggleHiddenClass ( selectorType : string ) {
120
121
this . cleanupList ! . querySelectorAll ( `.${ selectorType } ` ) . forEach ( element => {
121
- element . classList . toggle ( 'hidden' ) ;
122
+ element . classList . toggle ( 'hiddenontypefilter' ) ;
123
+ if ( element . hasAttribute ( 'disabled' ) ) element . removeAttribute ( 'disabled' ) ;
124
+ else element . setAttribute ( 'disabled' , 'true' ) ;
122
125
} ) ;
123
126
}
124
127
@@ -164,7 +167,13 @@ export class CleanupControlBlocks extends LitElement {
164
167
private renderListItem ( controlBlock : Element ) : TemplateResult {
165
168
return html `<mwc- check- lis t- item
166
169
twoline
167
- class= "cleanupListItem t${ controlBlock . tagName } "
170
+ class= "${ classMap ( {
171
+ cleanupListItem : true ,
172
+ tReportControl : controlBlock . tagName === 'ReportControl' ,
173
+ tLogControl : controlBlock . tagName === 'LogControl' ,
174
+ tGSEControl : controlBlock . tagName === 'GSEControl' ,
175
+ tSampledValueControl : controlBlock . tagName === 'SampledValueControl' ,
176
+ } ) } "
168
177
value = "${ identity ( controlBlock ) } "
169
178
graphic= "large"
170
179
> <span class= "unreferencedControl"
@@ -228,13 +237,15 @@ export class CleanupControlBlocks extends LitElement {
228
237
* @returns html for the Delete Button of this container.
229
238
*/
230
239
private renderDeleteButton ( ) : TemplateResult {
240
+ const sizeSelectedItems = ( < Set < number > > this . selectedControlItems ) . size ;
241
+
231
242
return html `<mwc- butto n
232
243
outlined
233
244
icon= "delete"
234
245
class = "deleteButto n"
235
- label= "${ translate ( 'cleanup.unreferencedControls.deleteButton' ) } ( ${ ( <
236
- Set < number >
237
- > this . selectedControlItems ) . size || '0' } )"
246
+ label= "${ translate (
247
+ 'cleanup.unreferencedControls.deleteButton'
248
+ ) } ( ${ sizeSelectedItems || '0' } )"
238
249
?dis abled= ${ ( < Set < number > > this . selectedControlItems ) . size === 0 ||
239
250
( Array . isArray ( this . selectedControlItems ) &&
240
251
! this . selectedControlItems . length ) }
@@ -399,22 +410,12 @@ export class CleanupControlBlocks extends LitElement {
399
410
opacity : 1 ;
400
411
}
401
412
402
- /* items are disabled if the filter is deselected */
403
- .tGSEControl ,
404
- .tSampledValueControl ,
405
- .tLogControl ,
406
- .tReportControl {
413
+ /* Make sure to type filter here
414
+ .hidden is set on string filter in filtered-list and must always filter*/
415
+ .cleanupListItem .hiddenontypefilter : not (.hidden ) {
407
416
display : none;
408
417
}
409
418
410
- /* items enabled if filter is selected */
411
- .tGSEControlFilter [on ] ~ .cleanupList > .tGSEControl ,
412
- .tSampledValueControlFilter [on ] ~ .cleanupList > .tSampledValueControl ,
413
- .tLogControlFilter [on ] ~ .cleanupList > .tLogControl ,
414
- .tReportControlFilter [on ] ~ .cleanupList > .tReportControl {
415
- display : flex;
416
- }
417
-
418
419
/* filter disabled, Material Design guidelines for opacity */
419
420
.tGSEControlFilter ,
420
421
.tSampledValueControlFilter ,
0 commit comments