Update cookcli-recipe-strategy.js

This commit is contained in:
TheThomaas 2026-09-16 16:47:01 +02:00
parent b134a5d257
commit 6e9a31e7af

View file

@ -415,51 +415,34 @@ class CookcliStrategyEditor extends HTMLElement {
const c = this._config || {}; const c = this._config || {};
// Remplacer temporairement ha-textfield par des inputs natifs
this.innerHTML = ` this.innerHTML = `
<div style="padding: 16px; display: flex; flex-direction: column; gap: 16px;"> <div style="padding: 16px; display: flex; flex-direction: column; gap: 16px;">
<ha-textfield <label>
label="Titre du dashboard" Titre du dashboard
value="${c.title || ""}" <input type="text" value="${c.title || ""}" data-config-key="title" style="width: 100%;" />
data-config-key="title" </label>
helper="Titre affiché dans l'onglet" <label>
style="width: 100%;" Entité minuteur
></ha-textfield> <input type="text" value="${c.timer_entity || ""}" data-config-key="timer_entity" style="width: 100%;" />
</label>
<ha-textfield <label>
label="Entité minuteur" Entité étape
value="${c.timer_entity || ""}" <input type="text" value="${c.step_entity || ""}" data-config-key="step_entity" style="width: 100%;" />
data-config-key="timer_entity" </label>
helper="Ex: timer.recette_en_cours" <label>
style="width: 100%;" Entry ID (optionnel)
></ha-textfield> <input type="text" value="${c.entry_id || ""}" data-config-key="entry_id" style="width: 100%;" />
</label>
<ha-textfield
label="Entité étape"
value="${c.step_entity || ""}"
data-config-key="step_entity"
helper="Ex: input_number.recette_etape"
style="width: 100%;"
></ha-textfield>
<ha-textfield
label="Entry ID (optionnel)"
value="${c.entry_id || ""}"
data-config-key="entry_id"
helper="Laisser vide si un seul serveur CookCLI"
style="width: 100%;"
></ha-textfield>
</div> </div>
`; `;
// On attache les écouteurs en JS natif, car la syntaxe @change de Lit // Écouteurs natifs (change au lieu de input pour éviter les re-rendus intempestifs)
// n'est pas interprétée dans un innerHTML classique.
this.querySelectorAll("[data-config-key]").forEach((champ) => { this.querySelectorAll("[data-config-key]").forEach((champ) => {
champ.addEventListener("change", (ev) => { champ.addEventListener("change", (ev) => {
const cle = ev.target.dataset.configKey; const cle = ev.target.dataset.configKey;
const nouvelleConfig = { ...this._config, [cle]: ev.target.value }; const nouvelleConfig = { ...this._config, [cle]: ev.target.value };
this._config = nouvelleConfig; this._config = nouvelleConfig;
// On notifie HA du changement : il met à jour la config du dashboard
this.dispatchEvent( this.dispatchEvent(
new CustomEvent("config-changed", { new CustomEvent("config-changed", {
bubbles: true, bubbles: true,