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

refactor(editor/communication): move wizards to wizard library #489

Merged
merged 13 commits into from
Feb 8, 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
30 changes: 19 additions & 11 deletions src/editors/Communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
newActionEvent,
createElement,
} from '../foundation.js';
import { selectors, styles } from './communication/foundation.js';
import { selectors } from './communication/foundation.js';
import './communication/subnetwork-editor.js';
import { subNetworkWizard } from '../wizards/subnetwork.js';

Expand Down Expand Up @@ -60,24 +60,32 @@ export default class CommunicationPlugin extends LitElement {
icon="add"
label="${get('subnetwork.wizard.title.add')}"
@click=${() => this.openCreateSubNetworkWizard()}
></mwc-fab
>${Array.from(this.doc.querySelectorAll(selectors.SubNetwork) ?? []).map(
subnetwork =>
html`<subnetwork-editor .element=${subnetwork}></subnetwork-editor>`
)}`;
></mwc-fab>
<section>
${Array.from(this.doc.querySelectorAll(selectors.SubNetwork) ?? []).map(
subnetwork =>
html`<subnetwork-editor .element=${subnetwork}></subnetwork-editor>`
)}
</section> `;
}

static styles = css`
${styles}
:host {
width: 100vw;
}
section {
outline: none;
padding: 8px 12px 16px;
}

subnetwork-editor {
margin: 8px 12px 16px;
}

mwc-fab {
position: fixed;
bottom: 32px;
right: 32px;
}

:host {
width: 100vw;
}
`;
}
53 changes: 23 additions & 30 deletions src/editors/communication/subnetwork-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,8 @@ export class SubNetworkEditor extends LitElement {
}

private renderHeader(): TemplateResult {
return html`<h1>
${this.name} ${this.desc === null ? '' : html`&mdash;`} ${this.desc}
${this.renderSubNetworkSpecs()}
<abbr title="${translate('add')}">
<mwc-icon-button
icon="playlist_add"
@click="${() => this.openConnectedAPwizard()}"
></mwc-icon-button>
</abbr>
<nav>
<abbr title="${translate('edit')}">
<mwc-icon-button
icon="edit"
@click=${() => this.openEditWizard()}
></mwc-icon-button>
</abbr>
<abbr title="${translate('remove')}">
<mwc-icon-button
icon="delete"
@click=${() => this.remove()}
></mwc-icon-button>
</abbr>
</nav>
</h1>`;
return html` ${this.name} ${this.desc === null ? '' : html`&mdash;`}
${this.desc} ${this.renderSubNetworkSpecs()}`;
}

private renderIedContainer(): TemplateResult[] {
Expand All @@ -116,8 +94,7 @@ export class SubNetworkEditor extends LitElement {
.filter((v, i, a) => a.indexOf(v) === i)
.sort(compareNames)
.map(
iedName => html` <section id="iedSection" tabindex="0">
<h3>${iedName}</h3>
iedName => html` <action-pane id="iedSection" label="${iedName}">
<div id="connApContainer">
${Array.from(
this.element.ownerDocument.querySelectorAll(
Expand All @@ -133,15 +110,31 @@ export class SubNetworkEditor extends LitElement {
></connectedap-editor>`
)}
</div>
</section>`
</action-pane>`
);
}

render(): TemplateResult {
return html`<section tabindex="0">
${this.renderHeader()}
return html`<action-pane .label="${this.renderHeader()}">
<abbr slot="action" title="${translate('edit')}">
<mwc-icon-button
icon="edit"
@click=${() => this.openEditWizard()}
></mwc-icon-button>
</abbr>
<abbr slot="action" title="${translate('remove')}">
<mwc-icon-button
icon="delete"
@click=${() => this.remove()}
></mwc-icon-button> </abbr
><abbr slot="action" title="${translate('add')}">
<mwc-icon-button
icon="playlist_add"
@click="${() => this.openConnectedAPwizard()}"
></mwc-icon-button>
</abbr>
<div id="connAPContainer">${this.renderIedContainer()}</div>
</section>`;
</action-pane> `;
}

static styles = css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@
export const snapshots = {};

snapshots["subnetwork-editor looks like the latest snapshot"] =
`<section tabindex="0">
<h1>
StationBus — desc
(8-MMS—100.0b/s)
<abbr title="[add]">
<mwc-icon-button icon="playlist_add">
</mwc-icon-button>
</abbr>
<nav>
<abbr title="[edit]">
<mwc-icon-button icon="edit">
</mwc-icon-button>
</abbr>
<abbr title="[remove]">
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
</nav>
</h1>
`<action-pane>
<abbr
slot="action"
title="[edit]"
>
<mwc-icon-button icon="edit">
</mwc-icon-button>
</abbr>
<abbr
slot="action"
title="[remove]"
>
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<abbr
slot="action"
title="[add]"
>
<mwc-icon-button icon="playlist_add">
</mwc-icon-button>
</abbr>
<div id="connAPContainer">
<section
<action-pane
id="iedSection"
tabindex="0"
label="IED1"
>
<h3>
IED1
</h3>
<div id="connApContainer">
<connectedap-editor>
</connectedap-editor>
</div>
</section>
</action-pane>
</div>
</section>
</action-pane>
`;
/* end snapshot subnetwork-editor looks like the latest snapshot */