import { css , customElement , html , LitElement , property , TemplateResult , } from 'lit-element' ; import '@material/mwc-fab' ; import '../action-icon.js' ; import { startMove , getIcon } from './foundation.js' ; import { newActionEvent , newWizardEvent } from '../foundation.js' ; import { BayEditor } from './bay-editor.js' ; import { wizards } from '../wizards/wizard-library.js' ; /** [[`SubstationEditor`]] subeditor for a `ConductingEquipment` element. */ @ customElement ( 'conducting-equipment-editor' ) export class ConductingEquipmentEditor extends LitElement { /** SCL element ConductingEquipment */ @ property ( { attribute : false } ) element ! : Element ; /** ConductingEquipment name attribute */ @ property ( { type : String } ) get name ( ) : string { return this . element . getAttribute ( 'name' ) ?? '' ; } private openEditWizard ( ) { const wizard = wizards [ 'ConductingEquipment' ] . edit ( this . element ) ; if ( wizard ) this . dispatchEvent ( newWizardEvent ( wizard ) ) ; } private openLNodeWizard ( ) { const wizard = wizards [ 'LNode' ] . edit ( this . element ) ; if ( wizard ) this . dispatchEvent ( newWizardEvent ( wizard ) ) ; } remove ( ) { if ( this . element ) this . dispatchEvent ( newActionEvent ( { old : { parent : this . element . parentElement ! , element : this . element , reference : this . element . nextSibling , } , } ) ) ; } render ( ) { return html `<action-icon label="${ this . name }">
      <span slot="icon">${ getIcon ( this . element ) }</span>
      <mwc-fab
        slot="action"
        mini
        @click="${ ( ) => this . openLNodeWizard ( ) }"
        icon="account_tree"
      ></mwc-fab>
      <mwc-fab
        slot="action"
        mini
        icon="edit"
        @click="${ ( ) => this . openEditWizard ( ) }}"
      ></mwc-fab>
      <mwc-fab
        slot="action"
        mini
        @click="${ ( ) => startMove ( this , ConductingEquipmentEditor , BayEditor ) }"
        icon="forward"
      ></mwc-fab>
      <mwc-fab
        slot="action"
        mini
        icon="delete"
        @click="${ ( ) => this . remove ( ) }}"
      ></mwc-fab>
    </action-icon>` ; } static styles = css `
    :host(.moving) {
      opacity: 0.3;
    }
  ` ; }