@@ -8,15 +8,18 @@ import {
88 TemplateResult ,
99} from 'lit-element' ;
1010import { nothing } from 'lit-html' ;
11- import { get } from 'lit-translate' ;
11+ import { get , translate } from 'lit-translate' ;
1212
1313import {
1414 getDescriptionAttribute ,
1515 getNameAttribute ,
1616 newWizardEvent ,
1717} from '@openscd/open-scd/src/foundation.js' ;
1818import { accessPointIcon } from '@openscd/open-scd/src/icons/ied-icons.js' ;
19+ import { newActionEvent } from '@openscd/core/foundation/deprecated/editor.js' ;
20+ import { wizards } from '../../wizards/wizard-library.js' ;
1921import { editServicesWizard } from '../../wizards/services.js' ;
22+ import { removeAccessPointWizard } from '../../wizards/accesspoint.js' ;
2023
2124import '@openscd/open-scd/src/action-pane.js' ;
2225import './server-container.js' ;
@@ -29,6 +32,16 @@ export class AccessPointContainer extends Container {
2932 @property ( )
3033 selectedLNClasses : string [ ] = [ ] ;
3134
35+ @state ( )
36+ private get lnElements ( ) : Element [ ] {
37+ return Array . from ( this . element . querySelectorAll ( ':scope > LN' ) ) . filter (
38+ element => {
39+ const lnClass = element . getAttribute ( 'lnClass' ) ?? '' ;
40+ return this . selectedLNClasses . includes ( lnClass ) ;
41+ }
42+ ) ;
43+ }
44+
3245 protected updated ( _changedProperties : PropertyValues ) : void {
3346 super . updated ( _changedProperties ) ;
3447
@@ -45,27 +58,22 @@ export class AccessPointContainer extends Container {
4558 return html `` ;
4659 }
4760
48- return html ` <abbr slot = "action" title = " ${ get ( 'iededitor.settings' ) } " >
49- <mwc - icon - but to n
50- icon= "settings"
51- @click = ${ ( ) => this . openSettingsWizard ( services ) }
52- > < / mwc - icon - but to n >
53- < / abbr > ` ;
61+ return html ` <mwc - icon - but to n
62+ slot = "action"
63+ icon = "settings"
64+ title = " ${ get ( 'iededitor.settings' ) } "
65+ @click = ${ ( ) => this . openSettingsWizard ( services ) }
66+ > < / mwc - icon - but to n > ` ;
5467 }
5568
56- private openSettingsWizard ( services : Element ) : void {
57- const wizard = editServicesWizard ( services ) ;
69+ private openEditWizard ( ) : void {
70+ const wizard = wizards [ 'AccessPoint' ] . edit ( this . element ) ;
5871 if ( wizard ) this . dispatchEvent ( newWizardEvent ( wizard ) ) ;
5972 }
6073
61- @state ( )
62- private get lnElements ( ) : Element [ ] {
63- return Array . from ( this . element . querySelectorAll ( ':scope > LN' ) ) . filter (
64- element => {
65- const lnClass = element . getAttribute ( 'lnClass' ) ?? '' ;
66- return this . selectedLNClasses . includes ( lnClass ) ;
67- }
68- ) ;
74+ private openSettingsWizard ( services : Element ) : void {
75+ const wizard = editServicesWizard ( services ) ;
76+ if ( wizard ) this . dispatchEvent ( newWizardEvent ( wizard ) ) ;
6977 }
7078
7179 private header ( ) : TemplateResult {
@@ -75,11 +83,37 @@ export class AccessPointContainer extends Container {
7583 return html `${ name } ${ desc ? html ` & mdash; ${ desc } ` : nothing } ` ;
7684 }
7785
86+ private removeAccessPoint ( ) : void {
87+ const wizard = removeAccessPointWizard ( this . element ) ;
88+ if ( wizard ) {
89+ this . dispatchEvent ( newWizardEvent ( ( ) => wizard ) ) ;
90+ } else {
91+ // If no Wizard is needed, just remove the element.
92+ this . dispatchEvent (
93+ newActionEvent ( {
94+ old : { parent : this . element . parentElement ! , element : this . element } ,
95+ } )
96+ ) ;
97+ }
98+ }
99+
78100 render ( ) : TemplateResult {
79101 const lnElements = this . lnElements ;
80102
81103 return html `<action- pane .label = "${ this . header ( ) } ">
82104 <mwc- icon slot= "icon" > ${ accessPointIcon } </ mwc- icon>
105+ <mwc- icon- butto n
106+ slot= "action"
107+ icon = "delete"
108+ title= "${ translate ( 'remove' ) } "
109+ @click = ${ ( ) => this . removeAccessPoint ( ) }
110+ > </ mwc- icon- butto n>
111+ <mwc- icon- butto n
112+ slot= "action"
113+ icon = "edit"
114+ title= "${ translate ( 'edit' ) } "
115+ @click = ${ ( ) => this . openEditWizard ( ) }
116+ > </ mwc- icon- butto n>
83117 ${ this . renderServicesIcon ( ) }
84118 ${ Array . from ( this . element . querySelectorAll ( ':scope > Server' ) ) . map (
85119 server =>
0 commit comments