@@ -6,12 +6,21 @@ import {
6
6
property ,
7
7
TemplateResult ,
8
8
} from 'lit-element' ;
9
+ import { translate } from 'lit-translate' ;
9
10
10
11
import '@material/mwc-fab' ;
12
+ import '@material/mwc-icon' ;
13
+ import '@material/mwc-icon-button' ;
11
14
12
15
import '../../action-icon.js' ;
16
+ import '../../action-pane.js' ;
17
+ import './eq-function-editor.js' ;
13
18
import { startMove , getIcon } from './foundation.js' ;
14
- import { newActionEvent , newWizardEvent } from '../../foundation.js' ;
19
+ import {
20
+ getChildElementsByTagName ,
21
+ newActionEvent ,
22
+ newWizardEvent ,
23
+ } from '../../foundation.js' ;
15
24
import { BayEditor } from './bay-editor.js' ;
16
25
import { wizards } from '../../wizards/wizard-library.js' ;
17
26
@@ -26,6 +35,9 @@ export class ConductingEquipmentEditor extends LitElement {
26
35
get name ( ) : string {
27
36
return this . element . getAttribute ( 'name' ) ?? '' ;
28
37
}
38
+ /** Whether `EqFunction` and `SubEqFunction` are rendered */
39
+ @property ( { type : Boolean } )
40
+ showfunctions = false ;
29
41
30
42
private openEditWizard ( ) : void {
31
43
const wizard = wizards [ 'ConductingEquipment' ] . edit ( this . element ) ;
@@ -50,9 +62,57 @@ export class ConductingEquipmentEditor extends LitElement {
50
62
) ;
51
63
}
52
64
53
- render ( ) : TemplateResult {
54
- return html `<action- icon label= "${ this . name } " >
55
- <span slot= "icon" > ${ getIcon ( this . element ) } </ span>
65
+ renderEqFunctions ( ) : TemplateResult {
66
+ if ( ! this . showfunctions ) return html `` ;
67
+
68
+ const eqFunctions = getChildElementsByTagName ( this . element , 'EqFunction' ) ;
69
+ return html ` ${ eqFunctions . map (
70
+ eqFunction =>
71
+ html `<eq- function- edito r .element = ${ eqFunction } > </ eq- function- edito r> `
72
+ ) } `;
73
+ }
74
+
75
+ renderContentPane ( ) : TemplateResult {
76
+ return html `<mwc- icon slot= "icon" style = "width:24px;height:24px"
77
+ > ${ getIcon ( this . element ) } </ mwc- icon
78
+ >
79
+ <abbr slot= "action" title = "${ translate ( 'lnode.tooltip' ) } " >
80
+ <mwc- icon- butto n
81
+ slot= "action"
82
+ mini
83
+ @click = "${ ( ) => this . openLNodeWizard ( ) } "
84
+ icon=" account_tree"
85
+ ></mwc-icon-button>
86
+ </abbr>
87
+ <abbr slot=" action" title=" ${ translate ( 'edit' ) } ">
88
+ <mwc-icon-button
89
+ slot=" action"
90
+ mini
91
+ icon=" edit"
92
+ @click=" ${ ( ) => this . openEditWizard ( ) } }"
93
+ ></mwc-icon-button>
94
+ </abbr>
95
+ <abbr slot=" action" title=" ${ translate ( 'move' ) } ">
96
+ <mwc-icon-button
97
+ slot=" action"
98
+ mini
99
+ @click=" ${ ( ) =>
100
+ startMove ( this , ConductingEquipmentEditor , [ BayEditor ] ) } "
101
+ icon=" forward"
102
+ ></mwc-icon-button>
103
+ </abbr>
104
+ <abbr slot=" action" title=" ${ translate ( 'remove' ) } ">
105
+ <mwc-icon-button
106
+ slot=" action"
107
+ mini
108
+ icon=" delete"
109
+ @click=" ${ ( ) => this . remove ( ) } }"
110
+ ></mwc-icon-button>
111
+ </abbr> ` ;
112
+ }
113
+
114
+ renderContentIcon ( ) : TemplateResult {
115
+ return html `<mwc-icon slot=" icon">${ getIcon ( this . element ) } </mwc-icon>
56
116
<mwc-fab
57
117
slot=" action"
58
118
mini
@@ -77,13 +137,28 @@ export class ConductingEquipmentEditor extends LitElement {
77
137
mini
78
138
icon=" delete"
79
139
@click=" ${ ( ) => this . remove ( ) } }"
80
- ></mwc-fab>
81
- </action-icon>` ;
140
+ ></mwc-fab>` ;
141
+ }
142
+
143
+ render ( ) : TemplateResult {
144
+ if ( this . showfunctions )
145
+ return html `<action-pane label=" ${ this . name } "
146
+ >${ this . renderContentPane ( ) } ${ this . renderEqFunctions ( ) } </action-pane
147
+ >` ;
148
+
149
+ return html `<action-icon label=" ${ this . name } "
150
+ >${ this . renderContentIcon ( ) } </action-icon
151
+ >` ;
82
152
}
83
153
84
154
static styles = css `
85
155
:host(.moving) {
86
156
opacity: 0.3;
87
157
}
158
+
159
+ abbr {
160
+ text-decoration: none;
161
+ border-bottom: none;
162
+ }
88
163
` ;
89
164
}
0 commit comments