mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 21:06:34 +00:00
Select one branch at a time in choose script graphs (#8812)
This commit is contained in:
parent
b501b7f47c
commit
4cf1e52ac0
@ -133,7 +133,7 @@ export class HatGraphNode extends LitElement {
|
|||||||
|
|
||||||
:host([nofocus]):host-context(.active),
|
:host([nofocus]):host-context(.active),
|
||||||
:host([nofocus]):host-context(:focus) {
|
:host([nofocus]):host-context(:focus) {
|
||||||
--stroke-clr: var(--active-clr);
|
--circle-clr: var(--active-clr);
|
||||||
--icon-clr: var(--default-icon-clr);
|
--icon-clr: var(--default-icon-clr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,12 +208,6 @@ export class HatGraph extends LitElement {
|
|||||||
:host([disabled]) path.line {
|
:host([disabled]) path.line {
|
||||||
stroke: var(--disabled-clr);
|
stroke: var(--disabled-clr);
|
||||||
}
|
}
|
||||||
:host(.active) #top path.line {
|
|
||||||
stroke: var(--active-clr);
|
|
||||||
}
|
|
||||||
:host(:focus) #top path.line {
|
|
||||||
stroke: var(--active-clr);
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import {
|
|||||||
mdiArrowUp,
|
mdiArrowUp,
|
||||||
mdiAsterisk,
|
mdiAsterisk,
|
||||||
mdiCallSplit,
|
mdiCallSplit,
|
||||||
mdiCheckboxBlankOutline,
|
|
||||||
mdiCheckBoxOutline,
|
mdiCheckBoxOutline,
|
||||||
mdiChevronDown,
|
mdiChevronDown,
|
||||||
mdiChevronRight,
|
mdiChevronRight,
|
||||||
@ -168,13 +167,19 @@ class HatScriptGraph extends LitElement {
|
|||||||
|
|
||||||
${config.choose.map((branch, i) => {
|
${config.choose.map((branch, i) => {
|
||||||
const branch_path = `${path}/choose/${i}`;
|
const branch_path = `${path}/choose/${i}`;
|
||||||
|
const track_this =
|
||||||
|
trace !== undefined && trace[0].result?.choice === i;
|
||||||
|
if (track_this) {
|
||||||
|
this.trackedNodes[branch_path] = { config, path: branch_path };
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<hat-graph>
|
<hat-graph>
|
||||||
<hat-graph-node
|
<hat-graph-node
|
||||||
.iconPath=${mdiCheckBoxOutline}
|
.iconPath=${mdiCheckBoxOutline}
|
||||||
nofocus
|
@focus=${this.selectNode(config, branch_path)}
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
track: trace !== undefined && trace[0].result?.choice === i,
|
active: this.selected === branch_path,
|
||||||
|
track: track_this,
|
||||||
})}
|
})}
|
||||||
></hat-graph-node>
|
></hat-graph-node>
|
||||||
${ensureArray(branch.sequence).map((action, j) =>
|
${ensureArray(branch.sequence).map((action, j) =>
|
||||||
@ -184,14 +189,6 @@ class HatScriptGraph extends LitElement {
|
|||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
<hat-graph>
|
<hat-graph>
|
||||||
<hat-graph-node
|
|
||||||
.iconPath=${mdiCheckboxBlankOutline}
|
|
||||||
nofocus
|
|
||||||
class=${classMap({
|
|
||||||
track:
|
|
||||||
trace !== undefined && trace[0].result?.choice === "default",
|
|
||||||
})}
|
|
||||||
></hat-graph-node>
|
|
||||||
${ensureArray(config.default)?.map((action, i) =>
|
${ensureArray(config.default)?.map((action, i) =>
|
||||||
this.render_node(action, `${path}/default/${i}`)
|
this.render_node(action, `${path}/default/${i}`)
|
||||||
)}
|
)}
|
||||||
@ -410,7 +407,6 @@ class HatScriptGraph extends LitElement {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
const paths = Object.keys(this.trackedNodes);
|
const paths = Object.keys(this.trackedNodes);
|
||||||
|
|
||||||
const manual_triggered = this.trace && "trigger" in this.trace.trace;
|
const manual_triggered = this.trace && "trigger" in this.trace.trace;
|
||||||
let track_path = manual_triggered ? undefined : [0];
|
let track_path = manual_triggered ? undefined : [0];
|
||||||
const trigger_nodes = ensureArray(this.trace.config.trigger).map(
|
const trigger_nodes = ensureArray(this.trace.config.trigger).map(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user