-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editors/ied): add DO elements to IED editor (#454)
* Added DO/SDO elements * Added DO/SDO/DOI/SDI * Added unit tests ln-container * Made methods private in ln-container * Added do-container snapshot tests * Added batch of do-container unit tests * Review comments Co-authored-by: Rob Tjalma <rob@tjalma.com>
- Loading branch information
Showing
20 changed files
with
1,006 additions
and
48 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,76 @@ | ||
import { | ||
css, | ||
customElement, | ||
html, | ||
LitElement, | ||
property, | ||
TemplateResult, | ||
} from 'lit-element'; | ||
import { nothing } from 'lit-html'; | ||
|
||
import '../../action-pane.js'; | ||
import { getDescriptionAttribute, getNameAttribute } from '../../foundation.js'; | ||
|
||
/** [[`IED`]] plugin subeditor for editing `DO` element. */ | ||
@customElement('do-container') | ||
export class DOContainer extends LitElement { | ||
/** | ||
* The DO itself. | ||
*/ | ||
@property({ attribute: false }) | ||
element!: Element; | ||
|
||
/** | ||
* The optional DOI of this DO. | ||
*/ | ||
@property({ attribute: false }) | ||
instanceElement!: Element; | ||
|
||
private header(): TemplateResult { | ||
const name = getNameAttribute(this.element); | ||
const desc = getDescriptionAttribute(this.element); | ||
|
||
if (this.instanceElement != null) { | ||
return html`<b>${name}${desc ? html` — ${desc}` : nothing}</b>`; | ||
} else { | ||
return html`${name}${desc ? html` — ${desc}` : nothing}`; | ||
} | ||
} | ||
|
||
/** | ||
* Get the nested SDO element(s). | ||
* @returns The nested SDO element(s) of this DO container. | ||
*/ | ||
private getDOElements(): Element[] { | ||
const type = this.element.getAttribute('type') ?? undefined; | ||
const doType = this.element.closest('SCL')!.querySelector(`:root > DataTypeTemplates > DOType[id="${type}"]`); | ||
if (doType != null) { | ||
return Array.from(doType!.querySelectorAll(':scope > SDO')) | ||
} | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the instance element (SDI) of a SDO element (if available) | ||
* @param sdo - The SDO object to search with. | ||
* @returns The optional SDI element. | ||
*/ | ||
private getInstanceElement(sdo: Element): Element | null { | ||
const sdoName = getNameAttribute(sdo); | ||
if (this.instanceElement) { | ||
return this.instanceElement.querySelector(`:scope > SDI[name="${sdoName}"]`) | ||
} | ||
return null; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html`<action-pane .label="${this.header()}" icon="${this.instanceElement != null ? 'done' : ''}"> | ||
${this.getDOElements().map(dO => | ||
html`<do-container | ||
.element=${dO} | ||
.instanceElement=${this.getInstanceElement(dO)}> | ||
</do-container>`)} | ||
</action-pane> | ||
`; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
11 changes: 0 additions & 11 deletions
11
test/integration/editors/ied/__snapshots__/IED.test.snap.js
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
Oops, something went wrong.