From 1fe06114532357b41adce14d92cd3ecd31155bae Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 5 May 2026 07:03:03 +0200 Subject: [PATCH] fix: show phone and mobile in sag v3 add-contact search results --- VERSION | 2 +- app/modules/sag/templates/detail_v3.html | 6 +++++ app/modules/search/backend/router.py | 34 +++++++++++++++++------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 1a848c1..0a58e8e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.91 +2.2.92 diff --git a/app/modules/sag/templates/detail_v3.html b/app/modules/sag/templates/detail_v3.html index 2326b9a..6bb73f3 100644 --- a/app/modules/sag/templates/detail_v3.html +++ b/app/modules/sag/templates/detail_v3.html @@ -5267,6 +5267,12 @@ onclick="addContact(${caseId}, ${c.id}, '${(c.first_name + ' ' + c.last_name).replace(/'/g, "\\'")}')"> ${c.first_name} ${c.last_name}
${c.email || ''} ${c.user_company ? '(' + c.user_company + ')' : ''}
+
+ ${Array.from(new Set([ + c.mobile ? `Mobil: ${c.mobile}` : '', + c.phone ? `Telefon: ${c.phone}` : '' + ].filter(Boolean))).join(' ยท ') || 'Intet telefonnummer'} +
`).join(''); } diff --git a/app/modules/search/backend/router.py b/app/modules/search/backend/router.py index 0caa92e..9c49f16 100644 --- a/app/modules/search/backend/router.py +++ b/app/modules/search/backend/router.py @@ -26,20 +26,34 @@ async def search_customers(q: str = Query(..., min_length=2)): async def search_contacts(q: str = Query(..., min_length=2)): """ Autocomplete search for contacts. - Returns list of {id, first_name, last_name, email} + Returns list of {id, first_name, last_name, email, phone, mobile, user_company} Supports: first name, last name, email, combined "Fornavn Efternavn", phone, mobile. """ sql = """ - SELECT id, first_name, last_name, email - FROM contacts + SELECT + c.id, + c.first_name, + c.last_name, + c.email, + c.phone, + c.mobile, + ( + SELECT cu.name + FROM contact_companies cc + JOIN customers cu ON cu.id = cc.customer_id + WHERE cc.contact_id = c.id + ORDER BY cc.is_primary DESC NULLS LAST, cc.id ASC + LIMIT 1 + ) AS user_company + FROM contacts c WHERE - first_name ILIKE %s - OR last_name ILIKE %s - OR email ILIKE %s - OR CONCAT(first_name, ' ', last_name) ILIKE %s - OR phone ILIKE %s - OR mobile ILIKE %s - ORDER BY first_name ASC, last_name ASC + c.first_name ILIKE %s + OR c.last_name ILIKE %s + OR c.email ILIKE %s + OR CONCAT(c.first_name, ' ', c.last_name) ILIKE %s + OR c.phone ILIKE %s + OR c.mobile ILIKE %s + ORDER BY c.first_name ASC, c.last_name ASC LIMIT 20 """ term = f"%{q}%"