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) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 22:19:15 +02:00
parent 66be390fa9
commit 640da8245d
2 changed files with 16 additions and 2 deletions

View File

@@ -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');
?>

View File

@@ -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();
}