@@ -6,17 +6,25 @@ import {
6
6
TemplateResult ,
7
7
} from 'lit-element' ;
8
8
import { nothing } from 'lit-html' ;
9
+ import { translate } from 'lit-translate' ;
9
10
10
11
import '@material/mwc-icon-button-toggle' ;
11
12
import { IconButtonToggle } from '@material/mwc-icon-button-toggle' ;
12
13
13
14
import '../../action-pane.js' ;
14
15
import './da-container.js' ;
15
- import { getDescriptionAttribute , getNameAttribute , newWizardEvent } from '../../foundation.js' ;
16
- import { translate } from 'lit-translate' ;
17
- import { Nsdoc } from '../../foundation/nsdoc.js' ;
18
- import { createDoInfoWizard } from "./do-wizard.js" ;
19
- import { Container , findDOTypeElement , getInstanceDAElement } from "./foundation.js" ;
16
+
17
+ import {
18
+ getDescriptionAttribute ,
19
+ getNameAttribute ,
20
+ newWizardEvent ,
21
+ } from '../../foundation.js' ;
22
+ import { createDoInfoWizard } from './do-wizard.js' ;
23
+ import {
24
+ Container ,
25
+ findDOTypeElement ,
26
+ getInstanceDAElement ,
27
+ } from './foundation.js' ;
20
28
21
29
/** [[`IED`]] plugin subeditor for editing `DO` element. */
22
30
@customElement ( 'do-container' )
@@ -27,9 +35,6 @@ export class DOContainer extends Container {
27
35
@property ( { attribute : false } )
28
36
instanceElement ! : Element ;
29
37
30
- @property ( )
31
- nsdoc ! : Nsdoc ;
32
-
33
38
@query ( '#toggleButton' ) toggleButton : IconButtonToggle | undefined ;
34
39
35
40
private header ( ) : TemplateResult {
@@ -50,7 +55,7 @@ export class DOContainer extends Container {
50
55
private getDOElements ( ) : Element [ ] {
51
56
const doType = findDOTypeElement ( this . element ) ;
52
57
if ( doType != null ) {
53
- return Array . from ( doType . querySelectorAll ( ':scope > SDO' ) )
58
+ return Array . from ( doType . querySelectorAll ( ':scope > SDO' ) ) ;
54
59
}
55
60
return [ ] ;
56
61
}
@@ -61,9 +66,11 @@ export class DOContainer extends Container {
61
66
*/
62
67
private getDAElements ( ) : Element [ ] {
63
68
const type = this . element . getAttribute ( 'type' ) ?? undefined ;
64
- const doType = this . element . closest ( 'SCL' ) ! . querySelector ( `:root > DataTypeTemplates > DOType[id="${ type } "]` ) ;
69
+ const doType = this . element
70
+ . closest ( 'SCL' ) !
71
+ . querySelector ( `:root > DataTypeTemplates > DOType[id="${ type } "]` ) ;
65
72
if ( doType != null ) {
66
- return Array . from ( doType ! . querySelectorAll ( ':scope > DA' ) )
73
+ return Array . from ( doType ! . querySelectorAll ( ':scope > DA' ) ) ;
67
74
}
68
75
return [ ] ;
69
76
}
@@ -76,7 +83,9 @@ export class DOContainer extends Container {
76
83
private getInstanceDOElement ( dO : Element ) : Element | null {
77
84
const sdoName = getNameAttribute ( dO ) ;
78
85
if ( this . instanceElement ) {
79
- return this . instanceElement . querySelector ( `:scope > SDI[name="${ sdoName } "]` )
86
+ return this . instanceElement . querySelector (
87
+ `:scope > SDI[name="${ sdoName } "]`
88
+ ) ;
80
89
}
81
90
return null ;
82
91
}
@@ -85,39 +94,67 @@ export class DOContainer extends Container {
85
94
const daElements = this . getDAElements ( ) ;
86
95
const doElements = this . getDOElements ( ) ;
87
96
88
- return html `< action-pane .label ="${ this . header ( ) } " icon ="${ this . instanceElement != null ? 'done' : '' } ">
97
+ return html `< action-pane
98
+ .label ="${ this . header ( ) } "
99
+ icon ="${ this . instanceElement != null ? 'done' : '' } "
100
+ >
89
101
< abbr slot ="action ">
90
102
< mwc-icon-button
91
103
title =${ this . nsdoc . getDataDescription ( this . element ) . label }
92
104
icon ="info"
93
- @click=${ ( ) => this . dispatchEvent ( newWizardEvent (
94
- createDoInfoWizard ( this . element , this . instanceElement , this . ancestors , this . nsdoc ) ) ) }
105
+ @click=${ ( ) =>
106
+ this . dispatchEvent (
107
+ newWizardEvent (
108
+ createDoInfoWizard (
109
+ this . element ,
110
+ this . instanceElement ,
111
+ this . ancestors ,
112
+ this . nsdoc
113
+ )
114
+ )
115
+ ) }
95
116
> </ mwc-icon-button >
96
117
</ abbr >
97
- ${ daElements . length > 0 || doElements . length > 0 ?
98
- html `< abbr slot ="action " title ="${ translate ( 'iededitor.toggleChildElements' ) } ">
99
- < mwc-icon-button-toggle
100
- id ="toggleButton "
101
- onIcon ="keyboard_arrow_up "
102
- offIcon ="keyboard_arrow_down "
103
- @click =${ ( ) => this . requestUpdate ( ) }
104
- > </ mwc-icon-button-toggle >
105
- </ abbr > ` : nothing }
106
- ${ this . toggleButton ?. on ? daElements . map ( daElement =>
107
- html `< da-container
108
- .element =${ daElement }
109
- .instanceElement =${ getInstanceDAElement ( this . instanceElement , daElement ) }
110
- .nsdoc=${ this . nsdoc }
111
- .ancestors=${ [ ...this . ancestors , this . element ] }
112
- > </ da-container > ` ) : nothing }
113
- ${ this . toggleButton ?. on ? doElements . map ( doElement =>
114
- html `< do-container
115
- .element =${ doElement }
116
- .instanceElement =${ this . getInstanceDOElement ( doElement ) }
117
- .nsdoc=${ this . nsdoc }
118
- .ancestors=${ [ ...this . ancestors , this . element ] }
119
- > </ do-container > ` ) : nothing }
120
- </ action-pane >
121
- ` ;
118
+ ${ daElements . length > 0 || doElements . length > 0
119
+ ? html `< abbr
120
+ slot ="action "
121
+ title ="${ translate ( 'iededitor.toggleChildElements' ) } "
122
+ >
123
+ < mwc-icon-button-toggle
124
+ id ="toggleButton "
125
+ onIcon ="keyboard_arrow_up "
126
+ offIcon ="keyboard_arrow_down "
127
+ @click =${ ( ) => this . requestUpdate ( ) }
128
+ > </ mwc-icon-button-toggle >
129
+ </ abbr > `
130
+ : nothing }
131
+ ${ this . toggleButton ?. on
132
+ ? daElements . map (
133
+ daElement =>
134
+ html `< da-container
135
+ .doc =${ this . doc }
136
+ .element =${ daElement }
137
+ .instanceElement=${ getInstanceDAElement (
138
+ this . instanceElement ,
139
+ daElement
140
+ ) }
141
+ .nsdoc=${ this . nsdoc }
142
+ .ancestors=${ [ ...this . ancestors , this . element ] }
143
+ > </ da-container > `
144
+ )
145
+ : nothing }
146
+ ${ this . toggleButton ?. on
147
+ ? doElements . map (
148
+ doElement =>
149
+ html `< do-container
150
+ .doc =${ this . doc }
151
+ .element =${ doElement }
152
+ .instanceElement=${ this . getInstanceDOElement ( doElement ) }
153
+ .nsdoc=${ this . nsdoc }
154
+ .ancestors=${ [ ...this . ancestors , this . element ] }
155
+ > </ do-container > `
156
+ )
157
+ : nothing }
158
+ </ action-pane > ` ;
122
159
}
123
160
}
0 commit comments