429 files
This commit is contained in:
1 parent
472c19bceb
commit
963cce81a7
566 files changed
+50311
-47616
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { LitElement, html, css, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators.js";
|
||||
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
||||
import { live } from "lit/directives/live.js";
|
||||
import type { HomeAssistant, AdvancedFeatures, BudgetStatus, HAUser } from "../types";
|
||||
import { t, langOf } from "../styles";
|
||||
import { signApiPath } from "../helpers/document-url";
|
||||
@@ -36,6 +37,8 @@ interface SettingsResponse {
|
||||
// so the picker matches the options-flow dropdown exactly. Optional for
|
||||
// backward-compat with an older backend that didn't send it.
|
||||
notify_targets?: string[];
|
||||
/** v2.67: todo.* entity the buy-task shopping sync mirrors into ("" = off). */
|
||||
shopping_list_entity?: string;
|
||||
panel_enabled: boolean;
|
||||
panel_title: string;
|
||||
/** Opt-in copy of the shipped Assist sentences into the config dir. */
|
||||
@@ -249,6 +252,11 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
this.dispatchEvent(new CustomEvent("settings-changed"));
|
||||
} catch {
|
||||
this._showToast(t("action_error", this._lang));
|
||||
// The control already shows the rejected value (the browser changed it
|
||||
// before we asked the server). `_settings` is unchanged, so a plain
|
||||
// re-render would not touch the DOM — the selects bind their value
|
||||
// through `live()` precisely so this re-render snaps them back.
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,15 +587,16 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
<h3>${t("settings_general", L)}</h3>
|
||||
<label class="setting-row">
|
||||
<span class="setting-label">${t("settings_default_warning", L)}</span>
|
||||
<input type="number" min="1" max="365" .value=${String(g.default_warning_days)}
|
||||
<input type="number" min="0" max="365" .value=${String(g.default_warning_days)}
|
||||
@change=${(e: Event) => {
|
||||
const v = parseInt((e.target as HTMLInputElement).value, 10);
|
||||
if (v >= 1 && v <= 365) this._updateSetting("default_warning_days", v);
|
||||
// 0 = no warning window (due soon only on the due date) — #145.
|
||||
if (v >= 0 && v <= 365) this._updateSetting("default_warning_days", v);
|
||||
}} />
|
||||
</label>
|
||||
<label class="setting-row">
|
||||
<span class="setting-label">${t("settings_currency", L)}</span>
|
||||
<select @change=${(e: Event) => this._updateSetting("budget_currency", (e.target as HTMLSelectElement).value)}>
|
||||
<select .value=${live(b.currency)} @change=${(e: Event) => this._updateSetting("budget_currency", (e.target as HTMLSelectElement).value)}>
|
||||
${CURRENCIES.map((c) => html`<option value=${c} ?selected=${b.currency === c}>${c}</option>`)}
|
||||
</select>
|
||||
</label>
|
||||
@@ -652,10 +661,29 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
</div>
|
||||
` : nothing}
|
||||
` : nothing}
|
||||
|
||||
<label class="setting-row">
|
||||
<span class="setting-label" title=${t("settings_shopping_list_help", L)}>${t("settings_shopping_list", L)}</span>
|
||||
<select .value=${live(g.shopping_list_entity || "")}
|
||||
@change=${(e: Event) => this._updateSetting("shopping_list_entity", (e.target as HTMLSelectElement).value)}>
|
||||
<option value="" ?selected=${!g.shopping_list_entity}>${t("shopping_list_none", L)}</option>
|
||||
${this._todoEntities(g.shopping_list_entity || "").map((id) => html`
|
||||
<option value=${id} ?selected=${g.shopping_list_entity === id}>${id}</option>
|
||||
`)}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
/** All todo.* entities, plus the saved value even when its integration
|
||||
* hasn't loaded (so an offline pick isn't silently dropped from the UI). */
|
||||
private _todoEntities(current: string): string[] {
|
||||
const ids = Object.keys(this.hass?.states || {}).filter((id) => id.startsWith("todo.")).sort();
|
||||
if (current && !ids.includes(current)) ids.unshift(current);
|
||||
return ids;
|
||||
}
|
||||
|
||||
// --- Section: Notifications ---
|
||||
|
||||
private _renderNotifications(L: string) {
|
||||
@@ -762,7 +790,7 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
<label class="setting-row">
|
||||
<span class="setting-label">${t("settings_notify_scope", L)}</span>
|
||||
<select
|
||||
.value=${n.scope_view_id || ""}
|
||||
.value=${live(n.scope_view_id || "")}
|
||||
@change=${(e: Event) => this._updateSetting("notify_scope_view_id", (e.target as HTMLSelectElement).value)}
|
||||
>
|
||||
<option value="" ?selected=${!n.scope_view_id}>${t("settings_notify_scope_all", L)}</option>
|
||||
|
||||
Reference in new issue
Block a user