Skip to content

Commit 41a0a4b

Browse files
author
Rob Tjalma
authored
Merge pull request openscd#827 from openscd/104-refresh-issue
fix(104): Temporary fix to refresh components.
2 parents 748e2e5 + 806a6a2 commit 41a0a4b

File tree

7 files changed

+52
-58
lines changed

7 files changed

+52
-58
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LitElement, property } from 'lit-element';
2+
3+
export class Base104Container extends LitElement {
4+
@property()
5+
doc!: XMLDocument;
6+
}

src/editors/protocol104/connectedap-editor.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import {
2-
LitElement,
3-
TemplateResult,
4-
customElement,
5-
html,
6-
property,
7-
} from 'lit-element';
1+
import { customElement, html, property, TemplateResult } from 'lit-element';
82

93
import '@material/mwc-fab';
104

115
import '../../action-icon.js';
12-
import { newWizardEvent, newActionEvent } from '../../foundation.js';
6+
import { newActionEvent, newWizardEvent } from '../../foundation.js';
137
import { editConnectedApWizard } from './wizards/connectedap.js';
8+
import { Base104Container } from './base-container.js';
149

1510
/** [[`104`]] subeditor for a `ConnectedAP` element. */
1611
@customElement('connectedap-104-editor')
17-
export class ConnectedAP104Editor extends LitElement {
12+
export class ConnectedAP104Editor extends Base104Container {
1813
/** SCL element ConnectedAP */
1914
@property({ attribute: false })
2015
element!: Element;
@@ -45,7 +40,9 @@ export class ConnectedAP104Editor extends LitElement {
4540

4641
render(): TemplateResult {
4742
return html`
48-
<action-icon label="${this.element.getAttribute('apName') ?? 'UNDEFINED'}" icon="settings_input_hdmi"
43+
<action-icon
44+
label="${this.element.getAttribute('apName') ?? 'UNDEFINED'}"
45+
icon="settings_input_hdmi"
4946
><mwc-fab
5047
slot="action"
5148
mini

src/editors/protocol104/doi-container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
css,
33
customElement,
44
html,
5-
LitElement,
65
property,
76
query,
87
TemplateResult,
@@ -30,13 +29,14 @@ import {
3029
import { editAddressWizard } from './wizards/address.js';
3130
import { showDOIInfoWizard } from './wizards/doi.js';
3231
import { PROTOCOL_104_PRIVATE } from './foundation/private.js';
32+
import { Base104Container } from './base-container.js';
3333

3434
/**
3535
* Container showing all the DAI Elements, related to the 104 Protocol, of the passed DOI Element in a list.
3636
* The DAI Element can be edited by pressing the Edit button at the end of the line.
3737
*/
3838
@customElement('doi-104-container')
39-
export class Doi104Container extends LitElement {
39+
export class Doi104Container extends Base104Container {
4040
@property()
4141
element!: Element;
4242

src/editors/protocol104/ied-container.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
css,
33
customElement,
44
html,
5-
LitElement,
65
property,
76
query,
87
TemplateResult,
@@ -23,12 +22,13 @@ import { getFullPath } from './foundation/foundation.js';
2322

2423
import './doi-container.js';
2524
import { PROTOCOL_104_PRIVATE } from './foundation/private.js';
25+
import { Base104Container } from './base-container.js';
2626

2727
/**
2828
* Container showing all the DOI Elements, related to the 104 Protocol, of the passed IED Element in a container.
2929
*/
3030
@customElement('ied-104-container')
31-
export class Ied104Container extends LitElement {
31+
export class Ied104Container extends Base104Container {
3232
@property()
3333
element!: Element;
3434

@@ -65,7 +65,8 @@ export class Ied104Container extends LitElement {
6565
const dois = this.doiElements;
6666
return html`${dois.map(doiElement => {
6767
return html`
68-
<doi-104-container .element="${doiElement}"></doi-104-container>
68+
<doi-104-container .doc="${this.doc}" .element="${doiElement}">
69+
</doi-104-container>
6970
`;
7071
})}`;
7172
}

src/editors/protocol104/network-container.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
import { get } from "lit-translate";
2-
import {
3-
css,
4-
customElement,
5-
html,
6-
LitElement,
7-
property,
8-
TemplateResult
9-
} from "lit-element";
1+
import { get } from 'lit-translate';
2+
import { css, customElement, html, TemplateResult } from 'lit-element';
103

114
import './subnetwork-container.js';
125
import {
136
compareNames,
147
createElement,
158
newActionEvent,
16-
newWizardEvent
17-
} from "../../foundation.js";
18-
import { createSubNetworkWizard } from "./wizards/subnetwork.js";
9+
newWizardEvent,
10+
} from '../../foundation.js';
11+
import { createSubNetworkWizard } from './wizards/subnetwork.js';
12+
import { Base104Container } from './base-container.js';
1913

2014
@customElement('network-104-container')
21-
export class Network104Container extends LitElement {
22-
@property()
23-
doc!: XMLDocument;
24-
15+
export class Network104Container extends Base104Container {
2516
private getSubNetworkElements(): Element[] {
26-
return Array.from(this.doc.querySelectorAll('Communication > SubNetwork') ?? [])
17+
return Array.from(
18+
this.doc.querySelectorAll('Communication > SubNetwork') ?? []
19+
)
2720
.filter(network => network.getAttribute('type') === '104')
28-
.sort((a,b) => compareNames(a,b));
21+
.sort((a, b) => compareNames(a, b));
2922
}
3023

3124
/** Opens a [[`WizardDialog`]] for creating a new `SubNetwork` element. */
@@ -46,27 +39,27 @@ export class Network104Container extends LitElement {
4639

4740
render(): TemplateResult {
4841
return html`<mwc-fab
49-
extended
50-
icon="add"
51-
label="${get('subnetwork.wizard.title.add')}"
52-
@click=${() => this.openCreateSubNetworkWizard()}
53-
></mwc-fab>
54-
<section>
55-
${this.getSubNetworkElements()
56-
.map(
42+
extended
43+
icon="add"
44+
label="${get('subnetwork.wizard.title.add')}"
45+
@click=${() => this.openCreateSubNetworkWizard()}
46+
></mwc-fab>
47+
<section>
48+
${this.getSubNetworkElements().map(
5749
subnetwork =>
5850
html`<subnetwork-104-container
59-
.element=${subnetwork}
60-
></subnetwork-104-container>`
51+
.doc="${this.doc}"
52+
.element=${subnetwork}
53+
></subnetwork-104-container>`
6154
)}
62-
</section>`;
55+
</section>`;
6356
}
6457

6558
static styles = css`
6659
:host {
6760
width: 100vw;
6861
}
69-
62+
7063
mwc-fab {
7164
position: fixed;
7265
bottom: 32px;

src/editors/protocol104/subnetwork-container.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import {
2-
LitElement,
3-
TemplateResult,
2+
css,
43
customElement,
54
html,
65
property,
7-
css,
6+
TemplateResult,
87
} from 'lit-element';
98

109
import '@material/mwc-icon-button';
@@ -13,14 +12,15 @@ import './connectedap-editor.js';
1312
import { compareNames, newWizardEvent } from '../../foundation.js';
1413
import { translate } from 'lit-translate';
1514
import { createConnectedApWizard } from './wizards/connectedap.js';
15+
import { Base104Container } from './base-container.js';
1616

1717
/** [[`104`]] subeditor for a `SubNetwork` element. */
1818
@customElement('subnetwork-104-container')
19-
export class SubNetwork104Container extends LitElement {
19+
export class SubNetwork104Container extends Base104Container {
2020
/** SCL element SubNetwork */
2121
@property({ attribute: false })
2222
element!: Element;
23-
23+
2424
get bitrate(): string | null {
2525
const bitRate = this.element.querySelector('BitRate');
2626
if (bitRate === null) return null;
@@ -51,6 +51,7 @@ export class SubNetwork104Container extends LitElement {
5151
class="${connectedAP.parentElement !== this.element
5252
? 'disabled'
5353
: ''}"
54+
.doc="${this.doc}"
5455
.element=${connectedAP}
5556
></connectedap-104-editor>`
5657
)}
@@ -63,9 +64,7 @@ export class SubNetwork104Container extends LitElement {
6364

6465
if (!type && !this.bitrate) return '';
6566

66-
return `(${type}${
67-
type && this.bitrate ? ` — ${this.bitrate}` : ``
68-
})`;
67+
return `(${type}${type && this.bitrate ? ` — ${this.bitrate}` : ``})`;
6968
}
7069

7170
private header(): string {

src/editors/protocol104/values-container.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
css,
33
customElement,
44
html,
5-
LitElement,
65
property,
76
TemplateResult,
87
} from 'lit-element';
@@ -14,16 +13,14 @@ import './ied-container.js';
1413

1514
import { selectDoWizard } from './wizards/selectDo.js';
1615
import { PROTOCOL_104_PRIVATE } from './foundation/private.js';
16+
import { Base104Container } from './base-container.js';
1717

1818
/**
1919
* Container that will render an 'ied-104-container' for every IED which contains DAI Elements related to the
2020
* 104 Protocol.
2121
*/
2222
@customElement('values-104-container')
23-
export class Values104Container extends LitElement {
24-
@property()
25-
doc!: XMLDocument;
26-
23+
export class Values104Container extends Base104Container {
2724
@property()
2825
get iedElements(): Element[] {
2926
return Array.from(this.doc.querySelectorAll('IED'))
@@ -59,6 +56,7 @@ export class Values104Container extends LitElement {
5956
return html`
6057
${ieds.map(iedElement => {
6158
return html`<ied-104-container
59+
.doc="${this.doc}"
6260
.element="${iedElement}"
6361
></ied-104-container>`;
6462
})}

0 commit comments

Comments
 (0)