1
1
/* eslint-disable import/no-extraneous-dependencies */
2
2
import { css , html , LitElement , TemplateResult } from 'lit' ;
3
- import {
4
- customElement ,
5
- property ,
6
- query ,
7
- queryAll ,
8
- state ,
9
- } from 'lit/decorators.js' ;
3
+ import { property , query , queryAll , state } from 'lit/decorators.js' ;
4
+
5
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js' ;
10
6
7
+ import {
8
+ ActionItem ,
9
+ ActionList ,
10
+ } from '@openenergytools/filterable-lists/dist/ActionList.js' ;
11
11
import { MdDialog } from '@scopedelement/material-web/dialog/MdDialog.js' ;
12
+ import { MdIcon } from '@scopedelement/material-web/icon/MdIcon.js' ;
12
13
import { MdTextButton } from '@scopedelement/material-web/button/MdTextButton.js' ;
13
- // import '@scopedelement/material-web/icon/icon.js'
14
+ import { SclTextField } from '@openenergytools/scl-text-field' ;
15
+ import { TreeGrid } from '@openenergytools/tree-grid' ;
14
16
15
17
import { newEditEvent } from '@openenergytools/open-scd-core' ;
16
- import type { TreeGrid } from '@openenergytools/tree-grid' ;
17
18
import {
18
19
canAddFCDA ,
19
20
find ,
@@ -22,15 +23,6 @@ import {
22
23
removeFCDA ,
23
24
updateDataSet ,
24
25
} from '@openenergytools/scl-lib' ;
25
- import '@openenergytools/filterable-lists/dist/action-list.js' ;
26
- // eslint-disable-next-line import/no-duplicates
27
- import '@openenergytools/scl-text-field' ;
28
- import type {
29
- ActionItem ,
30
- ActionList ,
31
- } from '@openenergytools/filterable-lists/dist/ActionList.js' ;
32
- // eslint-disable-next-line import/no-duplicates
33
- import { SclTextField } from '@openenergytools/scl-text-field' ;
34
26
35
27
import { addFCDAs , addFCDOs } from './foundation.js' ;
36
28
import { dataAttributeTree } from './dataAttributePicker.js' ;
@@ -83,8 +75,16 @@ function loadIcon(percent: number): string {
83
75
return 'stroke_full' ;
84
76
}
85
77
86
- @customElement ( 'data-set-element-editor' )
87
- export class DataSetElementEditor extends LitElement {
78
+ export class DataSetElementEditor extends ScopedElementsMixin ( LitElement ) {
79
+ static scopedElements = {
80
+ 'action-list' : ActionList ,
81
+ 'md-text-button' : MdTextButton ,
82
+ 'md-dialog' : MdDialog ,
83
+ 'md-icon' : MdIcon ,
84
+ 'tree-grid' : TreeGrid ,
85
+ 'scl-text-field' : SclTextField ,
86
+ } ;
87
+
88
88
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
89
89
@property ( { attribute : false } )
90
90
doc ! : XMLDocument ;
@@ -125,15 +125,15 @@ export class DataSetElementEditor extends LitElement {
125
125
126
126
@query ( '#dapicker' ) daPickerDialog ! : MdDialog ;
127
127
128
- @query ( '#dapicker > oscd- tree-grid' ) daPicker ! : TreeGrid ;
128
+ @query ( '#dapicker > tree-grid' ) daPicker ! : TreeGrid ;
129
129
130
130
@query ( '.da.picker.save' ) daPickerSaveButton ! : MdTextButton ;
131
131
132
132
@query ( '#dopickerbutton' ) doPickerButton ! : MdTextButton ;
133
133
134
134
@query ( '#dopicker' ) doPickerDialog ! : MdDialog ;
135
135
136
- @query ( '#dopicker > oscd- tree-grid' ) doPicker ! : TreeGrid ;
136
+ @query ( '#dopicker > tree-grid' ) doPicker ! : TreeGrid ;
137
137
138
138
@query ( '.do.picker.save' ) doPickerSaveButton ! : MdTextButton ;
139
139
@@ -147,7 +147,7 @@ export class DataSetElementEditor extends LitElement {
147
147
if ( input instanceof SclTextField ) input . reset ( ) ;
148
148
}
149
149
150
- private onInputChange ( ) : void {
150
+ onInputChange ( ) : void {
151
151
if ( ! this . element ) return ;
152
152
153
153
this . someDiffOnInputs = Array . from ( this . inputs ?? [ ] ) . some (
@@ -301,9 +301,7 @@ export class DataSetElementEditor extends LitElement {
301
301
> Add data object<md- icon slot= "icon" > playlist_add </ me-icon> </ md- text- butto n
302
302
> <md- dialog id= "dopicker" >
303
303
<div slot= "headline" > Add Data Objects </ div>
304
- <oscd- tree- grid slot= "content" .tree = ${ dataObjectTree (
305
- server
306
- ) } > </ oscd- tree- grid>
304
+ <tree- grid slot= "content" .tree = ${ dataObjectTree ( server ) } > </ tree- grid>
307
305
<div slot= "actions" >
308
306
<md- text- butto n
309
307
@click = ${ ( ) => this . doPickerDialog ?. close ( ) }
@@ -324,18 +322,23 @@ export class DataSetElementEditor extends LitElement {
324
322
icon = "playlist_add"
325
323
?dis abled= ${ ! canAddFCDA ( this . element ! ) }
326
324
@click = ${ ( ) => this . daPickerDialog . show ( ) }
327
- > Add data attribute <md- icon slot= "icon" > playlist_add </ me-icon> </ md- text- butto n
325
+ > Add data attribute<md- icon slot= "icon"
326
+ > playlist_add </ md- icon
327
+ > </ md- text- butto n
328
328
> <md- dialog id= "dapicker" >
329
329
<div slot= "headline" > Add Data Attributes </ div>
330
- <oscd- tree- grid slot= "content" .tree = "${ dataAttributeTree (
331
- server
332
- ) } "> </ oscd- tree- grid>
330
+ <tree- grid
331
+ slot= "content"
332
+ .tree = "${ dataAttributeTree ( server ) } "
333
+ > </ tree- grid>
333
334
<div slot= "actions" >
334
- <md- text- butto n @click = ${ ( ) =>
335
- this . daPickerDialog ?. close ( ) } > Close </ md- text- butto n>
336
- <md- text- butto n class= "da picker save" @click = ${
337
- this . saveDataAttributes
338
- } >
335
+ <md- text- butto n @click = ${ ( ) => this . daPickerDialog ?. close ( ) }
336
+ > Close</ md- text- butto n
337
+ >
338
+ <md- text- butto n
339
+ class= "da picker save"
340
+ @click = ${ this . saveDataAttributes }
341
+ >
339
342
Save
340
343
<md- icon slot= "icon" > Save </ md- icon>
341
344
</ md- text- butto n>
0 commit comments