forked from JakobVogelsang/oscd-publisher
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoscd-publisher.ts
122 lines (112 loc) · 3.87 KB
/
oscd-publisher.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { css, html, LitElement } from 'lit';
import { property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import '@material/mwc-radio';
import '@material/mwc-formfield';
import './editors/report/report-control-editor.js';
import './editors/gsecontrol/gse-control-editor.js';
import './editors/dataset/data-set-editor.js';
import './editors/sampledvalue/sampled-value-control-editor.js';
/** An editor [[`plugin`]] to configure `Report`, `GOOSE`, `SampledValue` control blocks and its `DataSet` */
export default class PublisherPlugin extends LitElement {
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
@property({ attribute: false })
doc!: XMLDocument;
/** SCL change indicator */
@property({ type: Number })
editCount = 0;
@state()
private publisherType: 'Report' | 'GOOSE' | 'SampledValue' | 'DataSet' =
'GOOSE';
render() {
return html`<div class="publishertypeselector">
<mwc-formfield label="Report"
><mwc-radio
value="Report"
?checked=${this.publisherType === 'Report'}
eslint-disable-next-line
no-return-assign
@checked=${() => {
this.publisherType = 'Report';
}}
></mwc-radio></mwc-formfield
><mwc-formfield label="GOOSE"
><mwc-radio
value="GOOSE"
?checked=${this.publisherType === 'GOOSE'}
@checked=${() => {
this.publisherType = 'GOOSE';
}}
></mwc-radio></mwc-formfield
><mwc-formfield label="SampledValue"
><mwc-radio
value="SampledValue"
?checked=${this.publisherType === 'SampledValue'}
@checked=${() => {
this.publisherType = 'SampledValue';
}}
></mwc-radio></mwc-formfield
><mwc-formfield label="DataSet"
><mwc-radio
value="DataSet"
?checked=${this.publisherType === 'DataSet'}
@checked=${() => {
this.publisherType = 'DataSet';
}}
></mwc-radio
></mwc-formfield>
</div>
<report-control-editor
.doc=${this.doc}
editCount="${this.editCount}"
class="${classMap({
hidden: this.publisherType !== 'Report',
})}"
></report-control-editor
><gse-control-editor
.doc=${this.doc}
editCount="${this.editCount}"
class="${classMap({
hidden: this.publisherType !== 'GOOSE',
})}"
></gse-control-editor
><sampled-value-control-editor
.doc=${this.doc}
editCount="${this.editCount}"
class="${classMap({
hidden: this.publisherType !== 'SampledValue',
})}"
></sampled-value-control-editor
><data-set-editor
.doc=${this.doc}
editCount="${this.editCount}"
class="${classMap({
hidden: this.publisherType !== 'DataSet',
})}"
></data-set-editor>`;
}
static styles = css`
* {
--md-sys-color-primary: var(--oscd-primary);
--md-sys-color-secondary: var(--oscd-secondary);
--md-sys-typescale-body-large-font: var(--oscd-theme-text-font);
--md-outlined-text-field-input-text-color: var(--oscd-base01);
--md-sys-color-surface: var(--oscd-base3);
--md-sys-color-on-surface: var(--oscd-base00);
--md-sys-color-on-primary: var(--oscd-base2);
--md-sys-color-on-surface-variant: var(--oscd-base00);
--md-menu-container-color: var(--oscd-base3);
font-family: var(--oscd-theme-text-font);
--md-sys-color-surface-container-highest: var(--oscd-base2);
}
.hidden {
display: none;
}
.publishertypeselector {
margin: 4px 8px 8px;
background-color: var(--mdc-theme-surface);
width: calc(100% - 16px);
justify-content: space-around;
}
`;
}