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

973 remove tapchanger #1174

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.29.0](https://github.com/openscd/open-scd/compare/v0.28.0...v0.29.0) (2023-02-08)


### Features

* **editors/later-binding:** Improve supervision visibility and remove clutter ([#1141](https://github.com/openscd/open-scd/issues/1141)) ([845d1a5](https://github.com/openscd/open-scd/commits/845d1a5200e54b1d7e2a470604b553c519d5f6dd)), closes [#1024](https://github.com/openscd/open-scd/issues/1024) [#1037](https://github.com/openscd/open-scd/issues/1037)
* **editors/laterbinding:** Filter later binding GOOSE/SMV by serviceType (closes [#1150](https://github.com/openscd/open-scd/issues/1150)) ([#1151](https://github.com/openscd/open-scd/issues/1151)) ([ea59f70](https://github.com/openscd/open-scd/commits/ea59f702546f1b9186054d77ec61f4ca57de5b10))
* **editors/substation/transformerwinding:** add remove button ([#1157](https://github.com/openscd/open-scd/issues/1157)) ([a01e0ed](https://github.com/openscd/open-scd/commits/a01e0ed5f1e34cc93a041c57400ae306db5228e4))
* **general-equipment-editor:** add remove button ([#1107](https://github.com/openscd/open-scd/issues/1107)) ([b3def87](https://github.com/openscd/open-scd/commits/b3def87e33d9a47a9bfb8872b35161e59ded4a80))
* **substation/transformerwinding:** add create wizard ([#1154](https://github.com/openscd/open-scd/issues/1154)) ([51e19a7](https://github.com/openscd/open-scd/commits/51e19a75d3cadaf9c61969a54e0a67d9e9fd1fda))
* **wizards/generalequipment:** Add_create_wizard_GeneralEquipment_and_test ([#1102](https://github.com/openscd/open-scd/issues/1102)) ([2d1464f](https://github.com/openscd/open-scd/commits/2d1464fa3446d459aa411f82080241ebf0ff379a))
* **wizards/transformerwinding:** add edit wizard ([#1137](https://github.com/openscd/open-scd/issues/1137)) ([cf65a50](https://github.com/openscd/open-scd/commits/cf65a50366cb0659c3a510e3664ea4226c4c26d4))


### Bug Fixes

* add missing code editor to edit wizards ([#1136](https://github.com/openscd/open-scd/issues/1136)) ([2171569](https://github.com/openscd/open-scd/commits/2171569a9885cd105804cf342906799e678f8009))
* close menu after open project ([#1111](https://github.com/openscd/open-scd/issues/1111)) ([0e047a3](https://github.com/openscd/open-scd/commits/0e047a377f0eedd81996da24c5da80c9b67cbee3))
* **editors/cleanup:** quote input in selector of control blocks cleanup editor, closes [#1145](https://github.com/openscd/open-scd/issues/1145) ([ae26764](https://github.com/openscd/open-scd/commits/ae26764c5be29667114e35fb6ac1e16f5e3704a4))
* **ieds-import:** multiple IEDs import ([#1103](https://github.com/openscd/open-scd/issues/1103)) ([af0f5a3](https://github.com/openscd/open-scd/commits/af0f5a3f4c2648a9538ce7c7e6eca5a73746b784))
* opened menu cut off ([#1125](https://github.com/openscd/open-scd/issues/1125)) ([0c3bd0c](https://github.com/openscd/open-scd/commits/0c3bd0c838c75a6ef9ca575894bbc410a40ac36f))
* styling issue with SubEquipment editor ([#1130](https://github.com/openscd/open-scd/issues/1130)) ([d0e9657](https://github.com/openscd/open-scd/commits/d0e96572f3d57c84674f12d2eeeca93afbe667ad))

## [0.28.0](https://github.com/openscd/open-scd/compare/v0.27.0...v0.28.0) (2022-11-30)


Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"purpose": "maskable"
}
],
"version": "0.28.0"
"version": "0.29.0"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-scd",
"version": "0.28.0",
"version": "0.29.0",
"repository": "https://github.com/openscd/open-scd.git",
"description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",
"keywords": [
Expand Down
123 changes: 109 additions & 14 deletions src/editors/substation/tapchanger-editor.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
import {
css,
customElement,
html,
LitElement,
TemplateResult,
property,
state,
query,
} from 'lit-element';

import { translate } from 'lit-translate';

import '@material/mwc-icon';
import '@material/mwc-icon-button';
import '@material/mwc-menu';
import { IconButton } from '@material/mwc-icon-button';
import { ListItem } from '@material/mwc-list/mwc-list-item';
import { Menu } from '@material/mwc-menu';

import '../../action-pane.js';
import './eq-function-editor.js';
import './l-node-editor.js';
import './sub-equipment-editor.js';
import { getChildElementsByTagName, newWizardEvent } from '../../foundation.js';
import { wizards } from '../../wizards/wizard-library.js';

import { styles } from './foundation.js';
import {
getChildElementsByTagName,
newActionEvent,
newWizardEvent,
SCLTag,
tags,
} from '../../foundation.js';
import { emptyWizard, wizards } from '../../wizards/wizard-library.js';

function childTags(element: Element | null | undefined): SCLTag[] {
if (!element) return [];

return tags[<SCLTag>element.tagName].children.filter(
child => wizards[child].create !== emptyWizard
);
}

@customElement('tapchanger-editor')
export class TapChangerEditor extends LitElement {
Expand All @@ -39,6 +61,36 @@ export class TapChangerEditor extends LitElement {
return `TapChanger.${name} ${desc ? `—TapChanger.${desc}` : ''}`;
}

@query('mwc-menu') addMenu!: Menu;
@query('mwc-icon-button[icon="playlist_add"]') addButton!: IconButton;

openEditWizard(): void {
const wizard = wizards['TapChanger'].edit(this.element);
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

private openCreateWizard(tagName: string): void {
const wizard = wizards[<SCLTag>tagName].create(this.element!);

if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

updated(): void {
if (this.addMenu && this.addButton)
this.addMenu.anchor = <HTMLElement>this.addButton;
}

remove(): void {
if (this.element.parentElement)
this.dispatchEvent(
newActionEvent({
old: {
parent: this.element.parentElement,
element: this.element,
},
})
);
}
private renderLNodes(): TemplateResult {
const lNodes = getChildElementsByTagName(this.element, 'LNode');

Expand All @@ -55,12 +107,7 @@ export class TapChangerEditor extends LitElement {
: html``;
}

openEditWizard(): void {
const wizard = wizards['TapChanger'].edit(this.element);
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

renderEqFunctions(): TemplateResult {
private renderEqFunctions(): TemplateResult {
if (!this.showfunctions) return html``;

const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction');
Expand Down Expand Up @@ -90,15 +137,63 @@ export class TapChangerEditor extends LitElement {
)}`;
}

private renderAddButtons(): TemplateResult[] {
return childTags(this.element).map(
child =>
html`<mwc-list-item value="${child}"
><span>${child}</span></mwc-list-item
>`
);
}

render(): TemplateResult {
return html`<action-pane label=${this.header}>
<abbr slot="action" title="${translate('edit')}">
<mwc-icon-button
icon="edit"
@click=${() => this.openEditWizard()}
></mwc-icon-button>
</abbr>
<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"
style="position:relative;"
title="${translate('add')}"
>
<mwc-icon-button
icon="playlist_add"
@click=${() => (this.addMenu.open = true)}
></mwc-icon-button
><mwc-menu
corner="BOTTOM_RIGHT"
menuCorner="END"
@action=${(e: Event) => {
const tagName = (<ListItem>(<Menu>e.target).selected).value;
this.openCreateWizard(tagName);
}}
>${this.renderAddButtons()}</mwc-menu
></abbr
>
${this.renderLNodes()}
${this.renderEqFunctions()} ${this.renderSubEquipments()}</action-icon>`;
${this.renderEqFunctions()} ${this.renderSubEquipments()}
</action-icon>`;
}

static styles = css`
${styles}

:host(.moving) {
opacity: 0.3;
}

abbr {
text-decoration: none;
border-bottom: none;
}
`;
}
2 changes: 1 addition & 1 deletion src/wizards/tapchanger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function contentTapChangerWizard(
export function createTapChangerWizard(parent: Element): Wizard {
const name = '';
const desc = null;
const type = null;
const type = 'LTC';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcvanraalte I changed the default type from null to LTC as suggested.

const virtual = null;
const reservedNames = Array.from(parent.querySelectorAll('TapChanger')).map(
TapChanger => TapChanger.getAttribute('name')!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@ import { WizardTextField } from '../../../../src/wizard-textfield.js';
import { WizardCheckbox } from '../../../../src/wizard-checkbox.js';
import { MenuBase } from '@material/mwc-menu/mwc-menu-base.js';

const openAndCancelMenu: (
parent: MockWizardEditor,
element: TapChangerEditor
) => Promise<void> = (
parent: MockWizardEditor,
element: TapChangerEditor
): Promise<void> =>
new Promise(async resolve => {
expect(parent.wizardUI.dialog).to.be.undefined;

element?.shadowRoot
?.querySelector<MenuBase>("mwc-icon-button[icon='playlist_add']")!
.click();
const lnodMenuItem: ListItemBase =
element?.shadowRoot?.querySelector<ListItemBase>(
`mwc-list-item[value='LNode']`
)!;
lnodMenuItem.click();
await new Promise(resolve => setTimeout(resolve, 100)); // await animation

expect(parent.wizardUI.dialog).to.exist;

const secondaryAction: HTMLElement = <HTMLElement>(
parent.wizardUI.dialog?.querySelector(
'mwc-button[slot="secondaryAction"][dialogaction="close"]'
)
);

secondaryAction.click();
await new Promise(resolve => setTimeout(resolve, 100)); // await animation

expect(parent.wizardUI.dialog).to.be.undefined;

return resolve();
});

describe('tapchanger-editor wizarding editing integration', () => {
let doc: XMLDocument;
let parent: MockWizardEditor;
Expand Down Expand Up @@ -108,5 +144,63 @@ describe('tapchanger-editor wizarding editing integration', () => {
?.getAttribute('virtual')
).to.equal('false');
});

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

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

it('removes the attached TapChanger element from the document', async () => {
expect(
doc.querySelector(
'TransformerWinding[name="withTapChanger1"] > TapChanger[name="tapChComplet"]'
)
).to.exist;

await deleteButton.click();

expect(
doc.querySelector(
'TransformerWinding[name="withTapChanger1"] > TapChanger[name="tapChComplet"]'
)
).to.not.exist;
});
});
});
describe('Open add wizard', () => {
let doc: XMLDocument;
let parent: MockWizardEditor;
let element: TapChangerEditor | null;

beforeEach(async () => {
doc = await fetch('/test/testfiles/editors/substation/TapChanger.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
parent = <MockWizardEditor>(
await fixture(
html`<mock-wizard-editor
><tapchanger-editor
.element=${doc.querySelector(
'TransformerWinding[name="withTapChanger1"] > TapChanger[name="tapChComplet"]'
)}
></tapchanger-editor
></mock-wizard-editor>`
)
);

element = parent.querySelector('tapchanger-editor');

await parent.updateComplete;
});

it('Should open the same wizard for the second time', async () => {
await openAndCancelMenu(parent, element!);
await openAndCancelMenu(parent, element!);
});
});
});
Loading