|
| 1 | +import { |
| 2 | + css, |
| 3 | + html, |
| 4 | + LitElement, |
| 5 | + property, |
| 6 | + state, |
| 7 | + TemplateResult, |
| 8 | +} from 'lit-element'; |
| 9 | +import { classMap } from 'lit-html/directives/class-map'; |
| 10 | + |
| 11 | +import '@material/mwc-formfield'; |
| 12 | +import '@material/mwc-radio'; |
| 13 | + |
| 14 | +import './publisher/report-control-editor.js'; |
| 15 | +import './publisher/gse-control-editor.js'; |
| 16 | +import './publisher/sampled-value-control-editor.js'; |
| 17 | +import './publisher/data-set-editor.js'; |
| 18 | + |
| 19 | +/** An editor [[`plugin`]] to configure `Report`, `GOOSE`, `SampledValue` control blocks and its `DataSet` */ |
| 20 | +export default class PublisherPlugin extends LitElement { |
| 21 | + /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ |
| 22 | + @property({ attribute: false }) |
| 23 | + doc!: XMLDocument; |
| 24 | + @state() |
| 25 | + private publisherType: 'Report' | 'GOOSE' | 'SampledValue' | 'DataSet' = |
| 26 | + 'GOOSE'; |
| 27 | + |
| 28 | + render(): TemplateResult { |
| 29 | + return html`<div class="publishertypeselector"> |
| 30 | + <mwc-formfield label="Report" |
| 31 | + ><mwc-radio |
| 32 | + value="Report" |
| 33 | + ?checked=${this.publisherType === 'Report'} |
| 34 | + @checked=${() => (this.publisherType = 'Report')} |
| 35 | + ></mwc-radio></mwc-formfield |
| 36 | + ><mwc-formfield label="GOOSE" |
| 37 | + ><mwc-radio |
| 38 | + value="GOOSE" |
| 39 | + ?checked=${this.publisherType === 'GOOSE'} |
| 40 | + @checked=${() => (this.publisherType = 'GOOSE')} |
| 41 | + ></mwc-radio></mwc-formfield |
| 42 | + ><mwc-formfield label="SampledValue" |
| 43 | + ><mwc-radio |
| 44 | + value="SampledValue" |
| 45 | + ?checked=${this.publisherType === 'SampledValue'} |
| 46 | + @checked=${() => (this.publisherType = 'SampledValue')} |
| 47 | + ></mwc-radio></mwc-formfield |
| 48 | + ><mwc-formfield label="DataSet" |
| 49 | + ><mwc-radio |
| 50 | + value="DataSet" |
| 51 | + ?checked=${this.publisherType === 'DataSet'} |
| 52 | + @checked=${() => (this.publisherType = 'DataSet')} |
| 53 | + ></mwc-radio |
| 54 | + ></mwc-formfield> |
| 55 | + </div> |
| 56 | + <report-control-editor |
| 57 | + .doc=${this.doc} |
| 58 | + class="${classMap({ |
| 59 | + hidden: this.publisherType !== 'Report', |
| 60 | + })}" |
| 61 | + ></report-control-editor |
| 62 | + ><gse-control-editor |
| 63 | + .doc=${this.doc} |
| 64 | + class="${classMap({ |
| 65 | + hidden: this.publisherType !== 'GOOSE', |
| 66 | + })}" |
| 67 | + ></gse-control-editor |
| 68 | + ><sampled-value-control-editor |
| 69 | + .doc=${this.doc} |
| 70 | + class="${classMap({ |
| 71 | + hidden: this.publisherType !== 'SampledValue', |
| 72 | + })}" |
| 73 | + ></sampled-value-control-editor |
| 74 | + ><data-set-editor |
| 75 | + .doc=${this.doc} |
| 76 | + class="${classMap({ |
| 77 | + hidden: this.publisherType !== 'DataSet', |
| 78 | + })}" |
| 79 | + ></data-set-editor>`; |
| 80 | + } |
| 81 | + |
| 82 | + static styles = css` |
| 83 | + .hidden { |
| 84 | + display: none; |
| 85 | + } |
| 86 | +
|
| 87 | + .publishertypeselector { |
| 88 | + margin: 4px 8px 16px; |
| 89 | + background-color: var(--mdc-theme-surface); |
| 90 | + width: calc(100% - 16px); |
| 91 | + justify-content: space-around; |
| 92 | + } |
| 93 | + `; |
| 94 | +} |
0 commit comments