@@ -3,9 +3,9 @@ import { property, query, queryAll, state } from 'lit/decorators.js';
33import { classMap } from 'lit/directives/class-map.js' ;
44
55import { styles } from './foundation.js' ;
6- import { EditV2 , Transactor } from '@omicronenergy/oscd-api' ;
6+ import { EditV2 } from '@omicronenergy/oscd-api' ;
77import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js' ;
8- import { MdOutlinedButton } from '@scopedelement/material-web/button/MdOutlinedButton .js' ;
8+ import { MdTextButton } from '@scopedelement/material-web/button/MdTextButton .js' ;
99import { MdFilledIconButton } from '@scopedelement/material-web/iconbutton/MdFilledIconButton.js' ;
1010import { MdIcon } from '@scopedelement/material-web/icon/MdIcon.js' ;
1111import { OscdEditorTemplateTextfield } from './components/OscdEditorTemplateTextfield.js' ;
@@ -15,21 +15,20 @@ import type {
1515 CreateWizard ,
1616 EditWizard ,
1717} from '@omicronenergy/oscd-edit-dialog/OscdEditDialog.js' ;
18+ import { newEditEventV2 } from '@omicronenergy/oscd-api/utils.js' ;
1819
1920/** An editor [[`plugin`]] for editing the `DataTypeTemplates` section. */
2021export default class OscdEditorTemplate extends ScopedElementsMixin (
2122 LitElement ,
2223) {
2324 static scopedElements = {
24- 'md-outline -button' : MdOutlinedButton ,
25+ 'md-text -button' : MdTextButton ,
2526 'md-filled-icon-button' : MdFilledIconButton ,
2627 'md-icon' : MdIcon ,
2728 'action-list' : ActionList ,
2829 'oscd-editor-template-textfield' : OscdEditorTemplateTextfield ,
2930 'oscd-edit-dialog' : OscdEditDialog ,
3031 } ;
31- @property ( { type : Object } )
32- editor ! : Transactor < EditV2 > ;
3332
3433 /** The document being edited as provided to plugins by [[`OpenSCD`]]. */
3534 @property ( { attribute : false } )
@@ -39,10 +38,7 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
3938 docName ! : string ;
4039
4140 @property ( { attribute : false } )
42- docs ! : Record < string , XMLDocument > ;
43-
44- @property ( { attribute : false } )
45- editCount ! : unknown ;
41+ docVersion ! : unknown ;
4642
4743 @state ( )
4844 selectedLNodeType : Element | null | undefined = undefined ;
@@ -129,7 +125,7 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
129125 ) ;
130126 }
131127
132- this . editor . commit ( actions ) ;
128+ this . dispatchEvent ( newEditEventV2 ( actions ) ) ;
133129 this . onLNodeTypeInputChange ( ) ;
134130 }
135131
@@ -181,7 +177,7 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
181177 ) ;
182178 }
183179
184- this . editor . commit ( actions ) ;
180+ this . dispatchEvent ( newEditEventV2 ( actions ) ) ;
185181 this . onDOTypeInputChange ( ) ;
186182 }
187183
@@ -233,7 +229,7 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
233229 ) ;
234230 }
235231
236- this . editor . commit ( actions ) ;
232+ this . dispatchEvent ( newEditEventV2 ( actions ) ) ;
237233 this . onDATypeInputChange ( ) ;
238234 }
239235
@@ -285,22 +281,22 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
285281 ) ;
286282 }
287283
288- this . editor . commit ( actions ) ;
284+ this . dispatchEvent ( newEditEventV2 ( actions ) ) ;
289285 this . onEnumTypeInputChange ( ) ;
290286 }
291287
292288 async handleCreateElement ( createWizard : CreateWizard ) {
293289 const edits = await this . editDialog ?. create ( createWizard ) ;
294290 if ( edits ) {
295- this . editor . commit ( edits ) ;
291+ this . dispatchEvent ( newEditEventV2 ( edits ) ) ;
296292 this . requestUpdate ( ) ;
297293 }
298294 }
299295
300296 async handleEditElement ( editWizard : EditWizard ) {
301297 const edits = await this . editDialog ?. edit ( editWizard ) ;
302298 if ( edits ) {
303- this . editor . commit ( edits ) ;
299+ this . dispatchEvent ( newEditEventV2 ( edits ) ) ;
304300 this . requestUpdate ( ) ;
305301 }
306302 }
@@ -399,24 +395,23 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
399395 @input = "${ this . onEnumTypeInputChange } "
400396 > </ oscd- edito r- template-textfield>
401397 <div class= "save" >
402- <md- butto n
403- icon= "save"
404- label = "Save"
398+ <md- text- butto n
405399 ?dis abled= ${ ! this . enumTypeDiff }
406400 @click = "${ this . onSaveEnumType } "
407- > </ md- butto n>
401+ > <md- icon slot= "icon" > save </ md- icon> Save </ md- text- butto n
402+ >
408403 </ div>
409404 <hr color = "lightgrey" / >
410405 <div class= "add" >
411- <md- butto n
412- icon= "playlist_add"
413- label = "Add EnumVal"
406+ <md- text- butto n
414407 @click = ${ ( ) =>
415408 this . handleCreateElement ( {
416409 parent : this . selectedEnumType ! ,
417410 tagName : 'EnumVal' ,
418411 } ) }
419- > </ md- butto n>
412+ > <md- icon slot= "icon" > playlist_add </ md- icon> Add
413+ EnumVal </ md- text- butto n
414+ >
420415 </ div>
421416 <action- lis t
422417 .items = ${ items }
@@ -532,24 +527,23 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
532527 @input = "${ this . onDATypeInputChange } "
533528 > </ oscd- edito r- template-textfield>
534529 <div class= "save" >
535- <md- butto n
536- icon= "save"
537- label = "Save"
530+ <md- text- butto n
538531 ?dis abled= ${ ! this . daTypeDiff }
539532 @click = "${ this . onSaveDAType } "
540- > </ md- butto n>
533+ > <md- icon slot= "icon" > save </ md- icon> Save </ md- text- butto n
534+ >
541535 </ div>
542536 <hr color = "lightgrey" / >
543537 <div class= "add" >
544- <md- butto n
545- icon= "playlist_add"
546- label = "Add Data Attribute"
538+ <md- text- butto n
547539 @click = ${ ( ) =>
548540 this . handleCreateElement ( {
549541 parent : this . selectedDAType ! ,
550542 tagName : 'BDA' ,
551543 } ) }
552- > </ md- butto n>
544+ > <md- icon slot= "icon" > playlist_add </ md- icon> Add Data
545+ Attribute </ md- text- butto n
546+ >
553547 </ div>
554548 <action- lis t
555549 .items = ${ items }
@@ -675,33 +669,34 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
675669 @input = "${ this . onDOTypeInputChange } "
676670 > </ oscd- edito r- template-textfield>
677671 <div class= "save" >
678- <md- butto n
679- icon= "save"
680- label = "Save"
672+ <md- text- butto n
681673 ?dis abled= ${ ! this . doTypeDiff }
682674 @click = "${ this . onSaveDOType } "
683- > </ md- butto n>
675+ > <md- icon slot= "icon" > save </ md- icon> Save </ md- text- butto n
676+ >
684677 </ div>
685678 <hr color = "lightgrey" / >
686679 <div class= "add" >
687- <md- butto n
680+ <md- text - butto n
688681 icon= "playlist_add"
689682 label = "Add Data Object"
690683 @click = "${ ( ) =>
691684 this . handleCreateElement ( {
692685 parent : this . selectedDOType ! ,
693686 tagName : 'SDO' ,
694687 } ) } "
695- > < / md- but to n >
696- <md - butto n
697- icon = "playlist_add"
698- label = "Add Data Attribute"
688+ > <md - icon slot = "icon" > playlist_add < / md- icon > Add Data
689+ Object < / md - text - butto n
690+ >
691+ <md - text - but to n
699692 @click = "${ ( ) =>
700693 this . handleCreateElement ( {
701694 parent : this . selectedDOType ! ,
702695 tagName : 'DA' ,
703696 } ) } "
704- > </ md- butto n>
697+ > <md- icon slot= "icon" > playlist_add </ md- icon> Add Data
698+ Attribute </ md- text- butto n
699+ >
705700 </ div>
706701 <action- lis t
707702 .items = ${ items }
@@ -822,24 +817,23 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
822817 @input = "${ this . onLNodeTypeInputChange } "
823818 > </ oscd- edito r- template-textfield>
824819 <div class= "save" >
825- <md- butto n
826- icon= "save"
827- label = "Save"
820+ <md- text- butto n
828821 ?dis abled= ${ ! this . lNodeTypeDiff }
829822 @click = "${ this . onSaveLNodeType } "
830- > </ md- butto n>
823+ > <md- icon slot= "icon" > save </ md- icon> Save </ md- text- butto n
824+ >
831825 </ div>
832826 <hr color = "lightgrey" / >
833827 <div class= "add" >
834- <md- butto n
835- icon= "playlist_add"
836- label = "Add Data Object"
828+ <md- text- butto n
837829 @click = ${ ( ) =>
838830 this . handleCreateElement ( {
839831 parent : this . selectedLNodeType ! ,
840832 tagName : 'DO' ,
841833 } ) }
842- > </ md- butto n>
834+ > <md- icon slot= "icon" > playlist_add </ md- icon> Add Data
835+ Object </ md- text- butto n
836+ >
843837 </ div>
844838 <action- lis t
845839 .items = ${ items }
@@ -960,7 +954,7 @@ export default class OscdEditorTemplate extends ScopedElementsMixin(
960954 justify-content : flex-end;
961955 }
962956
963- div .save > md-button {
957+ div .save > md-text- button {
964958 margin : 10px ;
965959 }
966960
0 commit comments