-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathserver-container.ts
70 lines (62 loc) · 2.07 KB
/
server-container.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
customElement,
html,
property,
PropertyValues,
state,
TemplateResult,
} from 'lit-element';
import { nothing } from 'lit-html';
import '@openscd/open-scd/src/action-pane.js';
import './ldevice-container.js';
import { serverIcon } from '@openscd/open-scd/src/icons/ied-icons.js';
import { getDescriptionAttribute } from '@openscd/open-scd/src/foundation.js';
import { Container } from './foundation.js';
/** [[`IED`]] plugin subeditor for editing `Server` element. */
@customElement('server-container')
export class ServerContainer extends Container {
@property()
selectedLNClasses: string[] = [];
private header(): TemplateResult {
const desc = getDescriptionAttribute(this.element);
return html`Server${desc ? html` — ${desc}` : nothing}`;
}
protected updated(_changedProperties: PropertyValues): void {
super.updated(_changedProperties);
// When the LN Classes filter is updated, we also want to trigger rendering for the LN Elements.
if (_changedProperties.has('selectedLNClasses')) {
this.requestUpdate('lDeviceElements');
}
}
@state()
private get lDeviceElements(): Element[] {
return Array.from(this.element.querySelectorAll(':scope > LDevice')).filter(
element => {
return (
Array.from(element.querySelectorAll(':scope > LN,LN0')).filter(
element => {
const lnClass = element.getAttribute('lnClass') ?? '';
return this.selectedLNClasses.includes(lnClass);
}
).length > 0
);
}
);
}
render(): TemplateResult {
return html`<action-pane .label="${this.header()}">
<mwc-icon slot="icon">${serverIcon}</mwc-icon>
${this.lDeviceElements.map(
server =>
html`<ldevice-container
.editCount=${this.editCount}
.doc=${this.doc}
.element=${server}
.nsdoc=${this.nsdoc}
.selectedLNClasses=${this.selectedLNClasses}
.ancestors=${[...this.ancestors, this.element]}
></ldevice-container>`
)}
</action-pane>`;
}
}