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

bugfix: Refactor filters in the S-IED creation #1603

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions packages/openscd/src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const de: Translations = {
wizard: {
nameHelper: 'Name des IED',
descHelper: 'Beschreibung des IED',
noDescWarning: "Warnung! Einige S-IEDs können nicht angezeigt werden, da sie kein „des“-Attribut haben. Klicke hier, um das Attribut manuell hinzuzufügen.",
title: {
edit: 'IED bearbeiten',
delete: 'IED mit Abhängigkeiten entfernen',
Expand Down
1 change: 1 addition & 0 deletions packages/openscd/src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export const en = {
wizard: {
nameHelper: 'IED name',
descHelper: 'IED description',
noDescWarning: "Warning! Some S-IEDs cannot be displayed because they do not have a “desc” attribute. Click here to add the attribute manually.",
title: {
edit: 'Edit IED',
delete: 'Remove IED with references',
Expand Down
47 changes: 47 additions & 0 deletions packages/plugins/src/editors/IED.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import {
compareNames,
getDescriptionAttribute,
getNameAttribute,
newWizardEvent,
} from '@openscd/open-scd/src/foundation.js';
import { Nsdoc } from '@openscd/open-scd/src/foundation/nsdoc.js';
import { getIcon } from '@openscd/open-scd/src/icons/icons.js';
import { wizards } from '../wizards/wizard-library.js';

/** An editor [[`plugin`]] for editing the `IED` section. */
export default class IedPlugin extends LitElement {
Expand Down Expand Up @@ -99,6 +101,11 @@ export default class IedPlugin extends LitElement {
return undefined;
}

@state()
private get iedsWithoutDesc(): Element[] {
return this.iedList.filter(ied => !ied.hasAttribute('desc'));
}

lNClassListOpenedOnce = false;

protected updated(_changedProperties: PropertyValues): void {
Expand Down Expand Up @@ -147,10 +154,31 @@ export default class IedPlugin extends LitElement {
return selectedLNClasses;
}

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

render(): TemplateResult {
const iedList = this.iedList;
if (iedList.length > 0) {
return html`<section>
${
this.iedsWithoutDesc.length > 0
? html`
<div
slot="action"
class="missing-desc-banner"
mini
@click="${() => this.openEditWizard(this.iedsWithoutDesc[0])}"
icon="edit"
>
<span>${get('ied.wizard.noDescWarning')}</span>
<mwc-icon>edit</mwc-icon>
</div>
`
: nothing
}
<div class="header">
<h1>${get('filters')}:</h1>

Expand All @@ -175,6 +203,13 @@ export default class IedPlugin extends LitElement {
return;
}

// const selectedIedNames = e.detail.selectedItems.map(item => {
// const [name] = item.split('__');
// return name;
// });

// console.log("HERE: ", selectedIedNames)

this.lNClassListOpenedOnce = false;
this.selectedIEDs = e.detail.selectedItems;
this.selectedLNClasses = [];
Expand Down Expand Up @@ -252,6 +287,18 @@ export default class IedPlugin extends LitElement {
display: flex;
}

.missing-desc-banner {
margin-bottom: 16px;
background-color: #ffcc00;
padding: 8px 16px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
border-radius: 4px;
transition: opacity 0.2s ease-in-out;
}

h1 {
color: var(--mdc-theme-on-surface);
font-family: 'Roboto', sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/menu/VirtualTemplateIED.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default class VirtualTemplateIED extends LitElement {
<wizard-textfield
label="desc"
.maybeValue=${null}
nullable
required
></wizard-textfield>
<wizard-textfield
label="AccessPoint name"
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/src/wizards/ied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
WizardInputElement,
WizardMenuActor,
} from '@openscd/open-scd/src/foundation.js';
import {
import {
ComplexAction,
Delete,
EditorAction,
Expand Down Expand Up @@ -60,7 +60,7 @@ export function renderIEDWizard(
html`<wizard-textfield
label="desc"
.maybeValue=${desc}
nullable
required
helper="${get('ied.wizard.descHelper')}"
pattern="${patterns.normalizedString}"
></wizard-textfield>`,
Expand Down
Loading