forked from openscd/open-scd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor/substation): read-only editor for SubEquipment element (o…
…penscd#1030) * Added sub-equipment to Sub-Station editor Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * Fixed review comments Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * Fixed formatting Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * Added new tests for parents of the SubEquipmentEditor Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * Added new tests for children of the SubEquipmentEditor Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * Fixed formatting Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> * reverted test files Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Signed-off-by: Pascal Wilbrink <pascal.wilbrink@alliander.com> Co-authored-by: Dennis Labordus <dennis.labordus@alliander.com>
- Loading branch information
1 parent
81da900
commit f6e96b5
Showing
14 changed files
with
761 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { | ||
css, | ||
customElement, | ||
html, | ||
LitElement, | ||
property, | ||
TemplateResult, | ||
} from 'lit-element'; | ||
|
||
import '@material/mwc-fab'; | ||
import '@material/mwc-icon'; | ||
import '@material/mwc-icon-button'; | ||
import '@material/mwc-menu'; | ||
|
||
import '../../action-icon.js'; | ||
import '../../action-pane.js'; | ||
|
||
import { styles } from './foundation.js'; | ||
import { getChildElementsByTagName } from '../../foundation.js'; | ||
|
||
/** [[`SubstationEditor`]] subeditor for a child-less `SubEquipment` element. */ | ||
@customElement('sub-equipment-editor') | ||
export class SubEquipmentEditor extends LitElement { | ||
/** The document being edited as provided to editor by [[`Zeroline`]]. */ | ||
@property({ attribute: false }) | ||
doc!: XMLDocument; | ||
/** SCL element SubEquipment */ | ||
@property({ attribute: false }) | ||
element!: Element; | ||
|
||
/** SubEquipment name attribute */ | ||
@property({ type: String }) | ||
get label(): string { | ||
const name = `${ | ||
this.element.hasAttribute('name') | ||
? `${this.element.getAttribute('name')}` | ||
: '' | ||
}`; | ||
|
||
const description = `${ | ||
this.element.hasAttribute('desc') | ||
? ` - ${this.element.getAttribute('desc')}` | ||
: '' | ||
}`; | ||
|
||
const phase = `${ | ||
this.element.hasAttribute('phase') | ||
? ` (${this.element.getAttribute('phase')})` | ||
: '' | ||
}`; | ||
|
||
return `${name}${description}${phase}`; | ||
} | ||
|
||
private renderLNodes(): TemplateResult { | ||
const lNodes = getChildElementsByTagName(this.element, 'LNode'); | ||
|
||
return lNodes.length | ||
? html`<div class="container lnode"> | ||
${lNodes.map( | ||
lNode => | ||
html`<l-node-editor | ||
.doc=${this.doc} | ||
.element=${lNode} | ||
></l-node-editor>` | ||
)} | ||
</div>` | ||
: html``; | ||
} | ||
|
||
private renderEqFunctions(): TemplateResult { | ||
const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction'); | ||
return eqFunctions.length | ||
? html` ${eqFunctions.map( | ||
eqFunction => | ||
html`<eq-function-editor | ||
.doc=${this.doc} | ||
.element=${eqFunction} | ||
></eq-function-editor>` | ||
)}` | ||
: html``; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html`<action-pane label="${this.label}"> | ||
${this.renderLNodes()} ${this.renderEqFunctions()} | ||
</action-pane> `; | ||
} | ||
|
||
static styles = css` | ||
${styles} | ||
:host(.moving) { | ||
opacity: 0.3; | ||
} | ||
abbr { | ||
text-decoration: none; | ||
border-bottom: none; | ||
} | ||
`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.