Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor/substation/l-node-editor): add remove button #771

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/editors/substation/l-node-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'lit-element';

import '../../action-icon.js';
import { identity } from '../../foundation.js';
import { identity, newActionEvent } from '../../foundation.js';
import {
automationLogicalNode,
controlLogicalNode,
Expand Down Expand Up @@ -75,15 +75,30 @@ export class LNodeEditor extends LitElement {
return this.element.getAttribute('iedName') === 'None' ?? false;
}

private removeAction(): void {
JakobVogelsang marked this conversation as resolved.
Show resolved Hide resolved
if (this.element)
this.dispatchEvent(
newActionEvent({
old: {
parent: this.element.parentElement!,
element: this.element,
},
})
);
}

render(): TemplateResult {
return html`<action-icon
label="${this.header}"
?secondary=${this.missingIedReference}
?highlighted=${this.missingIedReference}
hideActions
><mwc-icon slot="icon"
>${getLNodeIcon(this.element)}</mwc-icon
></action-icon
>`;
><mwc-icon slot="icon">${getLNodeIcon(this.element)}</mwc-icon
><mwc-fab
slot="action"
mini
icon="delete"
@click="${() => this.removeAction()}}"
></mwc-fab
></action-icon>`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { fixture, html, expect } from '@open-wc/testing';

import '../../../mock-wizard-editor.js';
import { MockWizardEditor } from '../../../mock-wizard-editor.js';

import '../../../../src/editors/substation/l-node-editor.js';
import { LNodeEditor } from '../../../../src/editors/substation/l-node-editor.js';

describe('l-node-editor wizarding editing integration', () => {
let doc: XMLDocument;
let parent: MockWizardEditor;
let element: LNodeEditor | null;

beforeEach(async () => {
doc = await fetch('/test/testfiles/zeroline/functions.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));

parent = <MockWizardEditor>(
await fixture(
html`<mock-wizard-editor
><l-node-editor
.element=${doc.querySelector('Substation > LNode[lnClass="CSWI"]')}
></l-node-editor
></mock-wizard-editor>`
)
);

element = parent.querySelector('l-node-editor');
});

describe('has a delete icon button that', () => {
let deleteButton: HTMLElement;

beforeEach(async () => {
deleteButton = <HTMLElement>(
element?.shadowRoot?.querySelector('mwc-fab[icon="delete"]')
);
await parent.updateComplete;
});

it('removes the attached LNode element from the document', async () => {
expect(doc.querySelector('Substation > LNode[lnClass="CSWI"]')).to.exist;

await deleteButton.click();

expect(doc.querySelector('Substation > LNode[lnClass="CSWI"]')).to.not
.exist;
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@ export const snapshots = {};

snapshots["web component rendering LNode element as reference to a LN/LN0 within IED looks like the latest snapshot"] =
`<action-icon
hideactions=""
label="IED1 CircuitBreaker_CB1/ XCBR 1"
tabindex="0"
>
<mwc-icon slot="icon">
</mwc-icon>
<mwc-fab
icon="delete"
mini=""
slot="action"
>
</mwc-fab>
</action-icon>
`;
/* end snapshot web component rendering LNode element as reference to a LN/LN0 within IED looks like the latest snapshot */

snapshots["web component rendering LNode element as instance of a LNodeType only looks like the latest snapshot"] =
`<action-icon
hideactions=""
highlighted=""
label="DC XSWI 1"
secondary=""
tabindex="0"
>
<mwc-icon slot="icon">
</mwc-icon>
<mwc-fab
icon="delete"
mini=""
slot="action"
>
</mwc-fab>
</action-icon>
`;
/* end snapshot web component rendering LNode element as instance of a LNodeType only looks like the latest snapshot */
Expand Down