Skip to content

Commit 7af5b5c

Browse files
fix(editors/substation): update on action (openscd#852)
1 parent dc59736 commit 7af5b5c

12 files changed

+134
-22
lines changed

src/editors/substation/bay-editor.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
4141
/** [[`SubstationEditor`]] subeditor for a `Bay` element. */
4242
@customElement('bay-editor')
4343
export class BayEditor extends LitElement {
44+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
45+
@property({ attribute: false })
46+
doc!: XMLDocument;
4447
@property({ attribute: false })
4548
element!: Element;
4649
@property({ type: Boolean })
@@ -107,7 +110,11 @@ export class BayEditor extends LitElement {
107110
return lNodes.length
108111
? html`<div class="container lnode">
109112
${lNodes.map(
110-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
113+
lNode =>
114+
html`<l-node-editor
115+
.doc=${this.doc}
116+
.element=${lNode}
117+
></l-node-editor>`
111118
)}
112119
</div>`
113120
: html``;
@@ -118,15 +125,22 @@ export class BayEditor extends LitElement {
118125

119126
const functions = getChildElementsByTagName(this.element, 'Function');
120127
return html` ${functions.map(
121-
fUnction => html`<function-editor .element=${fUnction}></function-editor>`
128+
fUnction =>
129+
html`<function-editor
130+
.doc=${this.doc}
131+
.element=${fUnction}
132+
></function-editor>`
122133
)}`;
123134
}
124135

125136
renderIedContainer(): TemplateResult {
126137
const ieds = this.getAttachedIeds?.(this.element) ?? [];
127138
return ieds?.length
128139
? html`<div id="iedcontainer">
129-
${ieds.map(ied => html`<ied-editor .element=${ied}></ied-editor>`)}
140+
${ieds.map(
141+
ied =>
142+
html`<ied-editor .doc=${this.doc} .element=${ied}></ied-editor>`
143+
)}
130144
</div>`
131145
: html``;
132146
}
@@ -203,6 +217,7 @@ export class BayEditor extends LitElement {
203217
).map(
204218
pwt =>
205219
html`<powertransformer-editor
220+
.doc=${this.doc}
206221
.element=${pwt}
207222
?showfunctions=${this.showfunctions}
208223
></powertransformer-editor>`
@@ -212,6 +227,7 @@ export class BayEditor extends LitElement {
212227
).map(
213228
voltageLevel =>
214229
html`<conducting-equipment-editor
230+
.doc=${this.doc}
215231
.element=${voltageLevel}
216232
?readonly=${this.readonly}
217233
?showfunctions=${this.showfunctions}

src/editors/substation/conducting-equipment-editor.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
4343
/** [[`SubstationEditor`]] subeditor for a `ConductingEquipment` element. */
4444
@customElement('conducting-equipment-editor')
4545
export class ConductingEquipmentEditor extends LitElement {
46+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
47+
@property({ attribute: false })
48+
doc!: XMLDocument;
4649
/** SCL element ConductingEquipment */
4750
@property({ attribute: false })
4851
element!: Element;
@@ -98,7 +101,11 @@ export class ConductingEquipmentEditor extends LitElement {
98101
return lNodes.length
99102
? html`<div class="container lnode">
100103
${lNodes.map(
101-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
104+
lNode =>
105+
html`<l-node-editor
106+
.doc=${this.doc}
107+
.element=${lNode}
108+
></l-node-editor>`
102109
)}
103110
</div>`
104111
: html``;
@@ -110,7 +117,10 @@ export class ConductingEquipmentEditor extends LitElement {
110117
const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction');
111118
return html` ${eqFunctions.map(
112119
eqFunction =>
113-
html`<eq-function-editor .element=${eqFunction}></eq-function-editor>`
120+
html`<eq-function-editor
121+
.doc=${this.doc}
122+
.element=${eqFunction}
123+
></eq-function-editor>`
114124
)}`;
115125
}
116126

src/editors/substation/eq-function-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
3939
/** Pane rendering `EqFunction` element with its children */
4040
@customElement('eq-function-editor')
4141
export class EqFunctionEditor extends LitElement {
42+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
43+
@property({ attribute: false })
44+
doc!: XMLDocument;
4245
/** The edited `EqFunction` element */
4346
@property({ attribute: false })
4447
element!: Element;
@@ -87,7 +90,11 @@ export class EqFunctionEditor extends LitElement {
8790
return lNodes.length
8891
? html`<div class="container lnode">
8992
${lNodes.map(
90-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
93+
lNode =>
94+
html`<l-node-editor
95+
.doc=${this.doc}
96+
.element=${lNode}
97+
></l-node-editor>`
9198
)}
9299
</div>`
93100
: html``;
@@ -101,6 +108,7 @@ export class EqFunctionEditor extends LitElement {
101108
return html` ${eqSubFunctions.map(
102109
eqSubFunction =>
103110
html`<eq-sub-function-editor
111+
.doc=${this.doc}
104112
.element=${eqSubFunction}
105113
></eq-sub-function-editor>`
106114
)}`;

src/editors/substation/eq-sub-function-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
3838
/** Pane rendering `EqSubFunction` element with its children */
3939
@customElement('eq-sub-function-editor')
4040
export class EqSubFunctionEditor extends LitElement {
41+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
42+
@property({ attribute: false })
43+
doc!: XMLDocument;
4144
/** The edited `EqSubFunction` element */
4245
@property({ attribute: false })
4346
element!: Element;
@@ -86,7 +89,11 @@ export class EqSubFunctionEditor extends LitElement {
8689
return lNodes.length
8790
? html`<div class="container lnode">
8891
${lNodes.map(
89-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
92+
lNode =>
93+
html`<l-node-editor
94+
.doc=${this.doc}
95+
.element=${lNode}
96+
></l-node-editor>`
9097
)}
9198
</div>`
9299
: html``;
@@ -100,6 +107,7 @@ export class EqSubFunctionEditor extends LitElement {
100107
return html` ${eqSubFunctions.map(
101108
eqSubFunction =>
102109
html`<eq-sub-function-editor
110+
.doc=${this.doc}
103111
.element=${eqSubFunction}
104112
></eq-sub-function-editor>`
105113
)}`;

src/editors/substation/function-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
3535
/** Pane rendering `Function` element with its children */
3636
@customElement('function-editor')
3737
export class FunctionEditor extends LitElement {
38+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
39+
@property({ attribute: false })
40+
doc!: XMLDocument;
3841
/** The edited `Function` element */
3942
@property({ attribute: false })
4043
element!: Element;
@@ -83,7 +86,11 @@ export class FunctionEditor extends LitElement {
8386
return lNodes.length
8487
? html`<div class="container lnode">
8588
${lNodes.map(
86-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
89+
lNode =>
90+
html`<l-node-editor
91+
.doc=${this.doc}
92+
.element=${lNode}
93+
></l-node-editor>`
8794
)}
8895
</div>`
8996
: html``;
@@ -94,6 +101,7 @@ export class FunctionEditor extends LitElement {
94101
return html` ${subfunctions.map(
95102
subFunction =>
96103
html`<sub-function-editor
104+
.doc=${this.doc}
97105
.element=${subFunction}
98106
></sub-function-editor>`
99107
)}`;

src/editors/substation/ied-editor.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ import { newActionEvent, newWizardEvent } from '../../foundation.js';
1919
import { selectGseControlWizard } from '../../wizards/gsecontrol.js';
2020
import { selectSampledValueControlWizard } from '../../wizards/sampledvaluecontrol.js';
2121
import { selectReportControlWizard } from '../../wizards/reportcontrol.js';
22-
import { removeIEDWizard } from "../../wizards/ied.js";
22+
import { removeIEDWizard } from '../../wizards/ied.js';
2323

2424
/** [[`SubstationEditor`]] subeditor for a child-less `IED` element. */
2525
@customElement('ied-editor')
2626
export class IedEditor extends LitElement {
27+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
28+
@property({ attribute: false })
29+
doc!: XMLDocument;
2730
/** SCL element IED */
2831
@property({ attribute: false })
2932
element!: Element;
@@ -72,7 +75,11 @@ export class IedEditor extends LitElement {
7275
this.dispatchEvent(newWizardEvent(() => wizard));
7376
} else {
7477
// If no Wizard is needed, just remove the element.
75-
this.dispatchEvent(newActionEvent({ old: { parent: this.element.parentElement!, element: this.element } }));
78+
this.dispatchEvent(
79+
newActionEvent({
80+
old: { parent: this.element.parentElement!, element: this.element },
81+
})
82+
);
7683
}
7784
}
7885

@@ -89,7 +96,7 @@ export class IedEditor extends LitElement {
8996
slot="action"
9097
class="delete"
9198
mini
92-
@click="${() => this.removeIED() }"
99+
@click="${() => this.removeIED()}"
93100
icon="delete"
94101
></mwc-fab
95102
><mwc-fab
@@ -116,7 +123,8 @@ export class IedEditor extends LitElement {
116123
class="selectgse"
117124
mini
118125
@click="${() => this.openGseControlSelection()}"
119-
><mwc-icon slot="icon">${gooseIcon}</mwc-icon></mwc-fab
120-
></action-icon> `;
126+
><mwc-icon slot="icon">${gooseIcon}</mwc-icon></mwc-fab
127+
></action-icon
128+
> `;
121129
}
122130
}

src/editors/substation/l-node-editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const lnClassIcons: Partial<Record<string, TemplateResult>> = {
6262
/** Pane rendering `LNode` element with its children */
6363
@customElement('l-node-editor')
6464
export class LNodeEditor extends LitElement {
65+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
66+
@property({ attribute: false })
67+
doc!: XMLDocument;
6568
/** The edited `LNode` element */
6669
@property({ attribute: false })
6770
element!: Element;

src/editors/substation/powertransformer-editor.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
4444
/** [[`SubstationEditor`]] subeditor for a child-less `PowerTransformer` element. */
4545
@customElement('powertransformer-editor')
4646
export class PowerTransformerEditor extends LitElement {
47+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
48+
@property({ attribute: false })
49+
doc!: XMLDocument;
4750
/** SCL element PowerTransformer */
4851
@property({ attribute: false })
4952
element!: Element;
@@ -100,7 +103,11 @@ export class PowerTransformerEditor extends LitElement {
100103
return lNodes.length
101104
? html`<div class="container lnode">
102105
${lNodes.map(
103-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
106+
lNode =>
107+
html`<l-node-editor
108+
.doc=${this.doc}
109+
.element=${lNode}
110+
></l-node-editor>`
104111
)}
105112
</div>`
106113
: html``;
@@ -112,7 +119,10 @@ export class PowerTransformerEditor extends LitElement {
112119
const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction');
113120
return html` ${eqFunctions.map(
114121
eqFunction =>
115-
html`<eq-function-editor .element=${eqFunction}></eq-function-editor>`
122+
html`<eq-function-editor
123+
.doc=${this.doc}
124+
.element=${eqFunction}
125+
></eq-function-editor>`
116126
)}`;
117127
}
118128

src/editors/substation/sub-function-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
3939
/** Pane rendering `SubFunction` element with its children */
4040
@customElement('sub-function-editor')
4141
export class SubFunctionEditor extends LitElement {
42+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
43+
@property({ attribute: false })
44+
doc!: XMLDocument;
4245
/** The edited `SubFunction` element */
4346
@property({ attribute: false })
4447
element!: Element;
@@ -87,7 +90,11 @@ export class SubFunctionEditor extends LitElement {
8790
return lNodes.length
8891
? html`<div class="container lnode">
8992
${lNodes.map(
90-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
93+
lNode =>
94+
html`<l-node-editor
95+
.doc=${this.doc}
96+
.element=${lNode}
97+
></l-node-editor>`
9198
)}
9299
</div>`
93100
: html``;
@@ -98,6 +105,7 @@ export class SubFunctionEditor extends LitElement {
98105
return html` ${subfunctions.map(
99106
subFunction =>
100107
html`<sub-function-editor
108+
.doc=${this.doc}
101109
.element=${subFunction}
102110
></sub-function-editor>`
103111
)}`;

src/editors/substation/substation-editor.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function childTags(element: Element | null | undefined): SCLTag[] {
4545
/** [[`Substation`]] plugin subeditor for editing `Substation` sections. */
4646
@customElement('substation-editor')
4747
export class SubstationEditor extends LitElement {
48+
/** The document being edited as provided to editor by [[`Zeroline`]]. */
49+
@property({ attribute: false })
50+
doc!: XMLDocument;
4851
/** The edited `Element`, a common property of all Substation subeditors. */
4952
@property({ attribute: false })
5053
element!: Element;
@@ -113,7 +116,11 @@ export class SubstationEditor extends LitElement {
113116
return lNodes.length
114117
? html`<div class="container lnode">
115118
${lNodes.map(
116-
lNode => html`<l-node-editor .element=${lNode}></l-node-editor>`
119+
lNode =>
120+
html`<l-node-editor
121+
.doc=${this.doc}
122+
.element=${lNode}
123+
></l-node-editor>`
117124
)}
118125
</div>`
119126
: html``;
@@ -124,15 +131,22 @@ export class SubstationEditor extends LitElement {
124131

125132
const functions = getChildElementsByTagName(this.element, 'Function');
126133
return html` ${functions.map(
127-
fUnction => html`<function-editor .element=${fUnction}></function-editor>`
134+
fUnction =>
135+
html`<function-editor
136+
.doc=${this.doc}
137+
.element=${fUnction}
138+
></function-editor>`
128139
)}`;
129140
}
130141

131142
renderIedContainer(): TemplateResult {
132143
const ieds = this.getAttachedIeds?.(this.element) ?? [];
133144
return ieds?.length
134145
? html`<div id="iedcontainer">
135-
${ieds.map(ied => html`<ied-editor .element=${ied}></ied-editor>`)}
146+
${ieds.map(
147+
ied =>
148+
html`<ied-editor .doc=${this.doc} .element=${ied}></ied-editor>`
149+
)}
136150
</div>`
137151
: html``;
138152
}
@@ -153,6 +167,7 @@ export class SubstationEditor extends LitElement {
153167
${pwts.map(
154168
pwt =>
155169
html`<powertransformer-editor
170+
.doc=${this.doc}
156171
.element=${pwt}
157172
?showfunctions=${this.showfunctions}
158173
></powertransformer-editor>`
@@ -226,6 +241,7 @@ export class SubstationEditor extends LitElement {
226241
${Array.from(this.element.querySelectorAll(selectors.VoltageLevel)).map(
227242
voltageLevel =>
228243
html`<voltage-level-editor
244+
.doc=${this.doc}
229245
.element=${voltageLevel}
230246
.getAttachedIeds=${this.getAttachedIeds}
231247
?readonly=${this.readonly}

0 commit comments

Comments
 (0)