diff --git a/src/editors/substation/eq-function-editor.ts b/src/editors/substation/eq-function-editor.ts
index f3c26a017..9a6c374da 100644
--- a/src/editors/substation/eq-function-editor.ts
+++ b/src/editors/substation/eq-function-editor.ts
@@ -8,8 +8,10 @@ import {
} from 'lit-element';
import '../../action-pane.js';
+import './eq-sub-function-editor.js';
+import { getChildElementsByTagName } from '../../foundation.js';
-/** Pane rendering `Function` element with its children */
+/** Pane rendering `EqFunction` element with its children */
@customElement('eq-function-editor')
export class EqFunctionEditor extends LitElement {
/** The edited `EqFunction` element */
@@ -24,12 +26,26 @@ export class EqFunctionEditor extends LitElement {
return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`;
}
+ renderEqSubFunctions(): TemplateResult {
+ const eqSubFunctions = getChildElementsByTagName(
+ this.element,
+ 'EqSubFunction'
+ );
+ return html` ${eqSubFunctions.map(
+ eqSubFunction =>
+ html``
+ )}`;
+ }
+
render(): TemplateResult {
return html``;
+ >${this.renderEqSubFunctions()}`;
}
}
diff --git a/src/editors/substation/eq-sub-function-editor.ts b/src/editors/substation/eq-sub-function-editor.ts
new file mode 100644
index 000000000..552734813
--- /dev/null
+++ b/src/editors/substation/eq-sub-function-editor.ts
@@ -0,0 +1,46 @@
+import {
+ html,
+ LitElement,
+ TemplateResult,
+ property,
+ customElement,
+ state,
+} from 'lit-element';
+
+import '../../action-pane.js';
+import { getChildElementsByTagName } from '../../foundation.js';
+
+/** Pane rendering `EqSubFunction` element with its children */
+@customElement('eq-sub-function-editor')
+export class EqSubFunctionEditor extends LitElement {
+ /** The edited `EqSubFunction` element */
+ @property({ attribute: false })
+ element!: Element;
+ @state()
+ get header(): string {
+ const name = this.element.getAttribute('name');
+ const desc = this.element.getAttribute('desc');
+ const type = this.element.getAttribute('type');
+
+ return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`;
+ }
+
+ renderEqSubFunctions(): TemplateResult {
+ const eqSubFunctions = getChildElementsByTagName(
+ this.element,
+ 'EqSubFunction'
+ );
+ return html` ${eqSubFunctions.map(
+ eqSubFunction =>
+ html``
+ )}`;
+ }
+
+ render(): TemplateResult {
+ return html`${this.renderEqSubFunctions()}`;
+ }
+}
diff --git a/test/testfiles/zeroline/functions.scd b/test/testfiles/zeroline/functions.scd
index 6beb81fb5..5e7054da2 100644
--- a/test/testfiles/zeroline/functions.scd
+++ b/test/testfiles/zeroline/functions.scd
@@ -35,7 +35,9 @@
-
+
+
+
diff --git a/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js
index 674815ab5..da906462c 100644
--- a/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js
+++ b/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js
@@ -9,6 +9,8 @@ snapshots["web component rendering EqFunction element with complete attribute se
secondary=""
tabindex="0"
>
+
+
`;
/* end snapshot web component rendering EqFunction element with complete attribute set and existing children looks like the latest snapshot */
@@ -21,6 +23,8 @@ snapshots["web component rendering EqFunction element with missing desc and type
secondary=""
tabindex="0"
>
+
+
`;
/* end snapshot web component rendering EqFunction element with missing desc and type attribute looks like the latest snapshot */
diff --git a/test/unit/editors/substation/__snapshots__/eq-sub-function-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/eq-sub-function-editor.test.snap.js
new file mode 100644
index 000000000..40b994952
--- /dev/null
+++ b/test/unit/editors/substation/__snapshots__/eq-sub-function-editor.test.snap.js
@@ -0,0 +1,27 @@
+/* @web/test-runner snapshot v1 */
+export const snapshots = {};
+
+snapshots["web component rendering EqSubFunction element with complete attribute set and existing children looks like the latest snapshot"] =
+`
+
+`;
+/* end snapshot web component rendering EqSubFunction element with complete attribute set and existing children looks like the latest snapshot */
+
+snapshots["web component rendering EqSubFunction element with missing desc and type attribute looks like the latest snapshot"] =
+`
+
+
+
+`;
+/* end snapshot web component rendering EqSubFunction element with missing desc and type attribute looks like the latest snapshot */
+
diff --git a/test/unit/editors/substation/eq-sub-function-editor.test.ts b/test/unit/editors/substation/eq-sub-function-editor.test.ts
new file mode 100644
index 000000000..1f52d4058
--- /dev/null
+++ b/test/unit/editors/substation/eq-sub-function-editor.test.ts
@@ -0,0 +1,45 @@
+import { fixture, html, expect } from '@open-wc/testing';
+
+import '../../../../src/editors/substation/eq-sub-function-editor.js';
+import { EqSubFunctionEditor } from '../../../../src/editors/substation/eq-sub-function-editor.js';
+
+describe('web component rendering EqSubFunction element', () => {
+ let element: EqSubFunctionEditor;
+ let doc: XMLDocument;
+
+ beforeEach(async () => {
+ doc = await fetch('/test/testfiles/zeroline/functions.scd')
+ .then(response => response.text())
+ .then(str => new DOMParser().parseFromString(str, 'application/xml'));
+ });
+
+ describe('with complete attribute set and existing children', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html` EqSubFunction')}
+ >`
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () =>
+ await expect(element).shadowDom.to.equalSnapshot());
+ });
+
+ describe('with missing desc and type attribute', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html``
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () =>
+ await expect(element).shadowDom.to.equalSnapshot());
+ });
+});