From a9c17d0703e4bdd390c6ecc7fb71ad11e7708bc0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jul 2026 19:18:17 +0000 Subject: [PATCH] fix: address remaining review findings - Fix detail.html to use assigned_technician_name (not .assigned_technician?.full_name) - Remove double error toast in submitNote() catch block - Replace wasteful API calls in CEO dashboard with units+data approach - Remove QR Code option from reported_via dropdown (excluded per scope) --- app/templates/dashboard/ceo.html | 21 ++++++++++++++------- app/templates/tickets/detail.html | 4 ++-- app/templates/tickets/new.html | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/templates/dashboard/ceo.html b/app/templates/dashboard/ceo.html index 4315a64..cc06113 100644 --- a/app/templates/dashboard/ceo.html +++ b/app/templates/dashboard/ceo.html @@ -218,15 +218,22 @@ }); this.charts.monthlyMax = Math.max(...this.charts.monthlyTrend.map(m => m.count), 1); - // By property + // By property — load units once and compute from ticket data const propData = { east: 0, west: 0 }; - all.forEach(t => { /* would need unit join — estimate from ticket IDs */ }); try { - const east = await app().apiGet('/api/tickets?property=East&page_size=1'); - const west = await app().apiGet('/api/tickets?property=West&page_size=1'); - propData.east = east?.total || 0; - propData.west = west?.total || 0; - } catch (e) { /* api may not support property filter directly */ } + const units = await app().apiGet('/api/tickets/units'); + if (units && units.length > 0) { + const unitPropertyMap = {}; + units.forEach(u => { unitPropertyMap[u.id] = u.property; }); + all.forEach(t => { + if (t.unit_id && unitPropertyMap[t.unit_id]) { + const p = unitPropertyMap[t.unit_id].toLowerCase(); + if (p === 'east') propData.east++; + else if (p === 'west') propData.west++; + } + }); + } + } catch (e) { console.error('Property stats error', e); } this.charts.byProperty = { east: propData.east, west: propData.west, max: Math.max(propData.east, propData.west, 1) }; // By category — use categories endpoint diff --git a/app/templates/tickets/detail.html b/app/templates/tickets/detail.html index c933a3a..b722ec5 100644 --- a/app/templates/tickets/detail.html +++ b/app/templates/tickets/detail.html @@ -115,7 +115,7 @@
Assigned To
-
+
Reporter
@@ -402,7 +402,7 @@ this.noteForm.note = ''; app().showToast('Note added', 'success'); } catch (e) { - app().showToast(e.message, 'error'); + // No need to show error here — api() base method already shows it } finally { this.noteSubmitting = false; } diff --git a/app/templates/tickets/new.html b/app/templates/tickets/new.html index ad060ca..dec3dee 100644 --- a/app/templates/tickets/new.html +++ b/app/templates/tickets/new.html @@ -104,7 +104,7 @@ - +