-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(substation): read only Function and SubFunction container (#700)
* feat(zeroline): add showfunctions toggle button * feat(zeroline): write toggle buttons state to localhost * feat(zeroline/function-editor): add function-editor web-component * feat(zeroline): add function-editor to zeroline * refactor: linter format * test(zeroline): add snapshot tests * refactor(zeroline): pass showfunction though properties * feat(zeroline): add read-only subfuction-editor (#706)
- Loading branch information
1 parent
865f7ab
commit 3d7b2ef
Showing
22 changed files
with
771 additions
and
41 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
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,46 @@ | ||
import { | ||
html, | ||
LitElement, | ||
TemplateResult, | ||
property, | ||
customElement, | ||
state, | ||
} from 'lit-element'; | ||
|
||
import '../action-pane.js'; | ||
import './subfunction-editor.js'; | ||
import { getChildElementsByTagName } from '../foundation.js'; | ||
|
||
/** Pane rendering `Function` element with its children */ | ||
@customElement('function-editor') | ||
export class FunctionEditor extends LitElement { | ||
/** The edited `Function` element */ | ||
@property({ attribute: false }) | ||
element!: Element; | ||
@state() | ||
get header(): string { | ||
const name = this.element.getAttribute('name'); | ||
const desc = this.element.getAttribute('desc'); | ||
const type = this.element.getAttribute('type'); | ||
|
||
return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`; | ||
} | ||
|
||
renderSubFunctions(): TemplateResult { | ||
const subfunctions = getChildElementsByTagName(this.element, 'SubFunction'); | ||
return html` ${subfunctions.map( | ||
subFunction => | ||
html`<subfunction-editor .element=${subFunction}></subfunction-editor>` | ||
)}`; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html`<action-pane | ||
label="${this.header}" | ||
icon="functions" | ||
secondary | ||
highlighted | ||
>${this.renderSubFunctions()}</action-pane | ||
>`; | ||
} | ||
} |
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,42 @@ | ||
import { | ||
html, | ||
LitElement, | ||
TemplateResult, | ||
property, | ||
customElement, | ||
state, | ||
} from 'lit-element'; | ||
|
||
import '../action-pane.js'; | ||
import './subfunction-editor.js'; | ||
import { getChildElementsByTagName } from '../foundation.js'; | ||
|
||
/** Pane rendering `SubFunction` element with its children */ | ||
@customElement('subfunction-editor') | ||
export class SubFunctionEditor extends LitElement { | ||
/** The edited `SubFunction` element */ | ||
@property({ attribute: false }) | ||
element!: Element; | ||
@state() | ||
get header(): string { | ||
const name = this.element.getAttribute('name'); | ||
const desc = this.element.getAttribute('desc'); | ||
const type = this.element.getAttribute('type'); | ||
|
||
return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`; | ||
} | ||
|
||
renderSubFunctions(): TemplateResult { | ||
const subfunctions = getChildElementsByTagName(this.element, 'SubFunction'); | ||
return html` ${subfunctions.map( | ||
subFunction => | ||
html`<subfunction-editor .element=${subFunction}></subfunction-editor>` | ||
)}`; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html`<action-pane label="${this.header}" icon="functions" secondary | ||
>${this.renderSubFunctions()}</action-pane | ||
>`; | ||
} | ||
} |
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.