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(editors/substation): add read-only l-node-editor (openscd#730)
* feat(editors/substation): add read-only l-node-editor * feat(editors/subtation): add l-node-editor to ConductingEquipment * feat(editors/subtation): add l-node-editor to PowerTransformer * feat(editors/subtation): add l-node-editor to EqSubFunction * feat(editors/subtation): add l-node-editor to EqFunction * feat(editors/subtation): add l-node-editor to SubFunction * feat(editors/subtation): add l-node-editor to Function * feat(editors/subtation): add l-node-editor to Bay * feat(editors/subtation): add l-node-editor to VoltageLevel * feat(editors/subtation): add l-node-editor to Substation * merge with first * style(action-icon): propper highlight of focused secondary items * fix(editors/substation): unify rendering of LNode container * feat(action-icon): add hideActions property (openscd#752) * feat(action-icon): add noaction property * test(editors/substation/l-node-editor): update snapshot * refactor(action-icon): resolve review comments
- Loading branch information
1 parent
8f89f27
commit ecfeb5d
Showing
33 changed files
with
1,663 additions
and
42 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
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,89 @@ | ||
import { | ||
html, | ||
LitElement, | ||
TemplateResult, | ||
property, | ||
customElement, | ||
state, | ||
} from 'lit-element'; | ||
|
||
import '../../action-icon.js'; | ||
import { identity } from '../../foundation.js'; | ||
import { | ||
automationLogicalNode, | ||
controlLogicalNode, | ||
functionalLogicalNode, | ||
furtherPowerSystemEquipmentLogicalNode, | ||
generalLogicalNode, | ||
interfacingLogicalNode, | ||
measurementLogicalNode, | ||
nonElectricalLogicalNode, | ||
powerTransformerLogicalNode, | ||
protectionLogicalNode, | ||
protectionRelatedLogicalNode, | ||
qualityLogicalNode, | ||
supervisionLogicalNode, | ||
switchgearLogicalNode, | ||
systemLogicalNode, | ||
transformerLogicalNode, | ||
} from '../../icons/lnode.js'; | ||
|
||
export function getLNodeIcon(lNode: Element): TemplateResult { | ||
const lnClassGroup = lNode.getAttribute('lnClass')?.charAt(0) ?? ''; | ||
return lnClassIcons[lnClassGroup] ?? systemLogicalNode; | ||
} | ||
|
||
const lnClassIcons: Partial<Record<string, TemplateResult>> = { | ||
L: systemLogicalNode, | ||
A: automationLogicalNode, | ||
C: controlLogicalNode, | ||
F: functionalLogicalNode, | ||
G: generalLogicalNode, | ||
I: interfacingLogicalNode, | ||
K: nonElectricalLogicalNode, | ||
M: measurementLogicalNode, | ||
P: protectionLogicalNode, | ||
Q: qualityLogicalNode, | ||
R: protectionRelatedLogicalNode, | ||
S: supervisionLogicalNode, | ||
T: transformerLogicalNode, | ||
X: switchgearLogicalNode, | ||
Y: powerTransformerLogicalNode, | ||
Z: furtherPowerSystemEquipmentLogicalNode, | ||
}; | ||
|
||
/** Pane rendering `LNode` element with its children */ | ||
@customElement('l-node-editor') | ||
export class LNodeEditor extends LitElement { | ||
/** The edited `LNode` element */ | ||
@property({ attribute: false }) | ||
element!: Element; | ||
@state() | ||
private get header(): string { | ||
const prefix = this.element.getAttribute('prefix') ?? ''; | ||
const lnClass = this.element.getAttribute('lnClass'); | ||
const lnInst = this.element.getAttribute('lnInst'); | ||
|
||
const header = this.missingIedReference | ||
? `${prefix} ${lnClass} ${lnInst}` | ||
: identity(this.element); | ||
|
||
return typeof header === 'string' ? header : ''; | ||
} | ||
@state() | ||
private get missingIedReference(): boolean { | ||
return this.element.getAttribute('iedName') === 'None' ?? false; | ||
} | ||
|
||
render(): TemplateResult { | ||
return html`<action-icon | ||
label="${this.header}" | ||
?secondary=${this.missingIedReference} | ||
?highlighted=${this.missingIedReference} | ||
hideActions | ||
><mwc-icon slot="icon" | ||
>${getLNodeIcon(this.element)}</mwc-icon | ||
></action-icon | ||
>`; | ||
} | ||
} |
Oops, something went wrong.