-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathsmv-editor.ts
68 lines (60 loc) · 1.56 KB
/
smv-editor.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
import {
LitElement,
TemplateResult,
html,
customElement,
property,
state,
} from 'lit-element';
import '@material/mwc-icon';
import '@openscd/open-scd/src/action-icon.js';
import { sizableSmvIcon } from '@openscd/open-scd/src/icons/icons.js';
import { newWizardEvent } from '@openscd/open-scd/src/foundation.js';
import { newActionEvent } from '@openscd/core/foundation/deprecated/editor.js';
import { editSMvWizard } from '../../wizards/smv.js';
@customElement('smv-editor')
export class SmvEditor extends LitElement {
@property({ attribute: false })
doc!: XMLDocument;
@property({ attribute: false })
element!: Element;
@state()
get label(): string {
return (
this.element.getAttribute('ldInst') +
'/' +
this.element.getAttribute('cbName')
);
}
private openEditWizard(): void {
this.dispatchEvent(newWizardEvent(editSMvWizard(this.element)));
}
remove(): void {
if (this.element)
this.dispatchEvent(
newActionEvent({
old: {
parent: this.element.parentElement!,
element: this.element,
reference: this.element.nextSibling,
},
})
);
}
render(): TemplateResult {
return html`<action-icon label="${this.label}" .icon="${sizableSmvIcon}"
><mwc-fab
slot="action"
mini
icon="edit"
@click="${() => this.openEditWizard()}"
></mwc-fab>
<mwc-fab
slot="action"
mini
icon="delete"
@click="${() => this.remove()}}"
></mwc-fab
></action-icon>`;
}
}