429 files

This commit is contained in:
Home Assistant Version Control committed 2026-08-30 02:43:31 +00:00
1 parent 472c19bceb
commit 963cce81a7
566 files changed
+50311 -47616

No files matched your search

@@ -43,6 +43,15 @@ export class MaintenanceCompleteDialog extends LitElement {
/** #139: "2/4 · Flip blades" — which phase of the cycle this completion
* records. Purely informative; the backend advances the cursor itself. */
@property() public phaseLabel = "";
/** Proof of presence: the task completes only via NFC/QR scan — the
* dialog says so up front instead of relaying the server's refusal. */
@property({ type: Boolean }) public requireTagScan = false;
/** This open is the fallback of a QR/NFC scan (quick-complete refused for
* missing defaults/details): the completion carries `via_tag_scan` so the
* tag-scan gate counts the scan that got the user here, and the "scan
* required" note stays hidden — they just did. Set by open(); never
* survives into the next open. */
@property({ type: Boolean }) public viaTagScan = false;
@state() private _open = false;
@state() private _notes = "";
@state() private _cost = "";
@@ -66,9 +75,12 @@ export class MaintenanceCompleteDialog extends LitElement {
* prefill the dialog so nobody re-ticks what is already done. */
@property({ attribute: false }) public checklistPrefill: Record<string, boolean> = {};
public open(): void {
public open(opts: { viaTagScan?: boolean } = {}): void {
if (this._open) return;
this._open = true;
// Reset on every open — a plain open after a scan fallback must not
// keep claiming proof of presence.
this.viaTagScan = !!opts.viaTagScan;
this._notes = "";
this._cost = "";
this._duration = "";
@@ -173,6 +185,12 @@ export class MaintenanceCompleteDialog extends LitElement {
if (this._photoDocId) {
data.photo_doc_id = this._photoDocId;
}
// Scan fallback: the backend accepts via_tag_scan on task/complete so a
// require_tag_scan task can still be finished from the dialog the scan
// opened. Only ever sent when a scan actually happened.
if (this.viaTagScan) {
data.via_tag_scan = true;
}
if (this._completedAt) {
// Client-side guard mirrors the backend rule — a picked future moment
// fails fast with a localized message instead of a WS roundtrip.
@@ -290,6 +308,7 @@ export class MaintenanceCompleteDialog extends LitElement {
<ha-dialog open @closed=${this._close}>
<div class="dialog-title">${t("complete_title", L)}${this.taskName}</div>
${this.phaseLabel ? html`<div class="phase-line">${t("phase_current", L)}: ${this.phaseLabel}</div>` : nothing}
${this.requireTagScan && !this.viaTagScan ? html`<div class="scan-required-note">${t("require_tag_scan_hint", L)}</div>` : nothing}
<div class="content">
${this._error ? html`<div class="error">${this._error}</div>` : nothing}
${this.checklist.length > 0 ? html`
@@ -477,6 +496,14 @@ export class MaintenanceCompleteDialog extends LitElement {
font-weight: 500;
padding-bottom: 12px;
}
.scan-required-note {
margin: -4px 0 12px;
padding: 8px 10px;
border-radius: 6px;
background: rgba(255, 152, 0, 0.12);
color: var(--primary-text-color);
font-size: 13px;
}
.phase-line {
margin-top: -8px;
padding-bottom: 12px;