Skip to content

Commit 5c19822

Browse files
author
Rob Tjalma
authored
feat(Subscription): Add edit button or hyperlink to GSEControl dialog in the Subscription Editor
1 parent c6d5102 commit 5c19822

File tree

8 files changed

+206
-182
lines changed

8 files changed

+206
-182
lines changed

src/editors/subscription/goose-publisher-list.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ import '@material/mwc-icon';
1212
import '@material/mwc-list/mwc-list-item';
1313

1414
import '../../filtered-list.js';
15-
import { compareNames, getNameAttribute } from '../../foundation.js';
15+
import { compareNames, getNameAttribute, newWizardEvent } from '../../foundation.js';
1616
import { newGOOSESelectEvent, styles } from './foundation.js';
1717
import { gooseIcon } from '../../icons/icons.js';
18+
import { wizards } from '../../wizards/wizard-library.js';
19+
import { classMap } from 'lit-html/directives/class-map';
1820

19-
let selectedGooseMsg: Element | undefined;
21+
let selectedGseControl: Element | undefined;
2022
let selectedDataSet: Element | undefined | null;
2123

2224
function onOpenDocResetSelectedGooseMsg() {
23-
selectedGooseMsg = undefined;
25+
selectedGseControl = undefined;
2426
selectedDataSet = undefined;
2527
}
2628
addEventListener('open-doc', onOpenDocResetSelectedGooseMsg);
@@ -53,36 +55,54 @@ export class GoosePublisherList extends LitElement {
5355
}
5456

5557
private onGooseSelect(gseControl: Element): void {
58+
if (gseControl == selectedGseControl) return;
59+
5660
const ln = gseControl.parentElement;
5761
const dataset = ln?.querySelector(
5862
`DataSet[name=${gseControl.getAttribute('datSet')}]`
5963
);
6064

61-
selectedGooseMsg = gseControl;
65+
selectedGseControl = gseControl;
6266
selectedDataSet = dataset;
6367

6468
this.dispatchEvent(
6569
newGOOSESelectEvent(
66-
selectedGooseMsg,
70+
selectedGseControl,
6771
selectedDataSet!
6872
)
6973
);
74+
75+
this.requestUpdate();
7076
}
7177

7278
renderGoose(gseControl: Element): TemplateResult {
7379
return html`<mwc-list-item
7480
@click=${() => this.onGooseSelect(gseControl)}
7581
graphic="large"
82+
hasMeta
7683
>
77-
<span>${gseControl.getAttribute('name')}</span>
7884
<mwc-icon slot="graphic">${gooseIcon}</mwc-icon>
85+
<span>${gseControl.getAttribute('name')}</span>
86+
<mwc-icon-button
87+
class="${classMap({
88+
hidden: gseControl !== selectedGseControl,
89+
})}"
90+
slot="meta"
91+
icon="edit"
92+
@click=${() => this.openEditWizard(gseControl)}
93+
></mwc-icon-button>
7994
</mwc-list-item>`;
8095
}
96+
97+
private openEditWizard(gseControl: Element): void {
98+
const wizard = wizards['GSEControl'].edit(gseControl);
99+
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
100+
}
81101

82102
protected firstUpdated(): void {
83103
this.dispatchEvent(
84104
newGOOSESelectEvent(
85-
selectedGooseMsg,
105+
selectedGseControl,
86106
selectedDataSet ?? undefined
87107
)
88108
);
@@ -111,5 +131,13 @@ export class GoosePublisherList extends LitElement {
111131

112132
static styles = css`
113133
${styles}
134+
135+
mwc-list-item {
136+
--mdc-list-item-meta-size: 48px;
137+
}
138+
139+
mwc-icon-button.hidden {
140+
display: none;
141+
}
114142
`;
115143
}

src/editors/subscription/subscriber-list.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ export class SubscriberList extends LitElement {
279279
private async onViewChange(event: ViewEvent) {
280280
view = event.detail.view;
281281

282+
this.currentSelectedIed = undefined;
283+
this.currentSelectedGseControl = undefined;
284+
282285
this.resetElements();
283286
this.requestUpdate();
284287
}
@@ -483,16 +486,20 @@ export class SubscriberList extends LitElement {
483486
const gseControlName = this.currentSelectedGseControl?.getAttribute('name') ?? undefined;
484487

485488
return view == View.GOOSE_PUBLISHER
486-
? html`<h1>${translate('subscription.publisherGoose.subscriberTitle', {
487-
selected: gseControlName
488-
? this.currentGooseIEDName + ' > ' + gseControlName
489-
: 'GOOSE',
490-
})}</h1>`
491-
: html`<h1>${translate('subscription.subscriberGoose.publisherTitle', {
492-
selected: this.currentSelectedIed
493-
? this.currentSelectedIed.getAttribute('name')!
494-
: 'IED',
495-
})}</h1>`;
489+
? html`<h1>
490+
${translate('subscription.publisherGoose.subscriberTitle', {
491+
selected: gseControlName
492+
? this.currentGooseIEDName + ' > ' + gseControlName
493+
: 'GOOSE',
494+
})}
495+
</h1>`
496+
: html`<h1>
497+
${translate('subscription.subscriberGoose.publisherTitle', {
498+
selected: this.currentSelectedIed
499+
? this.currentSelectedIed.getAttribute('name')!
500+
: 'IED',
501+
})}
502+
</h1>`;
496503
}
497504

498505
render(): TemplateResult {

src/wizards/wizard-library.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { editIEDWizard } from './ied.js';
2121
import { editTrgOpsWizard } from './trgops.js';
2222
import { createDaWizard } from './da.js';
2323
import { editDAIWizard } from './dai.js';
24+
import { editGseControlWizard } from './gsecontrol.js';
2425

2526
type SclElementWizard = (element: Element, instanceElement?: Element) => Wizard | undefined;
2627

@@ -240,7 +241,7 @@ export const wizards: Record<
240241
create: emptyWizard,
241242
},
242243
GSEControl: {
243-
edit: emptyWizard,
244+
edit: editGseControlWizard,
244245
create: emptyWizard,
245246
},
246247
GSESettings: {

0 commit comments

Comments
 (0)