From 640da8245dcd1053d2f285dbde7a7f21c6f7011e Mon Sep 17 00:00:00 2001 From: fs Date: Sun, 5 Apr 2026 22:19:15 +0200 Subject: [PATCH] feat(helpdesk): add refresh button to ticket detail titlebar Adds 'Refresh data' button that re-fetches the communication feed with ?refresh=1 to bypass the session cache. Shows loading skeleton during reload. Co-Authored-By: Claude Opus 4.6 (1M context) --- modules/helpdesk/pages/helpdesk/ticket(default).phtml | 9 ++++++++- modules/helpdesk/web/js/helpdesk-ticket.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/helpdesk/pages/helpdesk/ticket(default).phtml b/modules/helpdesk/pages/helpdesk/ticket(default).phtml index b9c6e16..6747149 100644 --- a/modules/helpdesk/pages/helpdesk/ticket(default).phtml +++ b/modules/helpdesk/pages/helpdesk/ticket(default).phtml @@ -31,7 +31,14 @@ $backUrl = $ticketCustomerNo !== '' ? lurl('helpdesk/debitor/' . rawurlencode($t 'title' => t('Ticket') . ' ' . $ticketNo, 'backHref' => $backUrl, 'backTitle' => t('Back'), - 'actions' => [], + 'actions' => $ticket !== null ? [ + [ + 'label' => t('Refresh data'), + 'type' => 'button', + 'name' => 'ticket-refresh', + 'class' => 'secondary outline', + ], + ] : [], ]; require templatePath('partials/app-details-titlebar.phtml'); ?> diff --git a/modules/helpdesk/web/js/helpdesk-ticket.js b/modules/helpdesk/web/js/helpdesk-ticket.js index 378b8f3..7902100 100644 --- a/modules/helpdesk/web/js/helpdesk-ticket.js +++ b/modules/helpdesk/web/js/helpdesk-ticket.js @@ -41,16 +41,18 @@ function init(container) { if (el) el.hidden = false; } - async function loadCommunication() { + async function loadCommunication(refresh = false) { const feedEl = document.getElementById('ticket-communication-feed'); const loadingEl = document.getElementById('ticket-communication-loading'); const contentEl = document.getElementById('ticket-communication-content'); if (!feedEl || !loadingEl || !contentEl) return; + if (contentEl) contentEl.hidden = true; showLoading('ticket-communication-loading'); try { const params = new URLSearchParams({ ticketNo }); + if (refresh) params.set('refresh', '1'); const response = await fetch(communicationUrl + '?' + params.toString(), { credentials: 'same-origin' }); const data = await response.json(); @@ -85,5 +87,10 @@ function init(container) { } } + const refreshButton = container.querySelector('button[name="ticket-refresh"]'); + if (refreshButton) { + refreshButton.addEventListener('click', () => loadCommunication(true)); + } + loadCommunication(); }