partial fix
This commit is contained in:
@@ -35,8 +35,7 @@
|
|||||||
|
|
||||||
@can('update', $ticket)
|
@can('update', $ticket)
|
||||||
<details
|
<details
|
||||||
@if ($hasRunningTimer) wire:poll.1s @endif
|
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
|
||||||
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
|
|
||||||
data-helpdesk-ticket-controls>
|
data-helpdesk-ticket-controls>
|
||||||
<summary
|
<summary
|
||||||
class="-mx-4 -mt-4 mb-4 flex cursor-pointer list-none items-center justify-between gap-3 rounded-t-xl bg-indigo-700 px-4 py-4 text-white marker:hidden">
|
class="-mx-4 -mt-4 mb-4 flex cursor-pointer list-none items-center justify-between gap-3 rounded-t-xl bg-indigo-700 px-4 py-4 text-white marker:hidden">
|
||||||
@@ -238,14 +237,17 @@
|
|||||||
(() => {
|
(() => {
|
||||||
const root = document.querySelector('[data-helpdesk-ticket-controls]');
|
const root = document.querySelector('[data-helpdesk-ticket-controls]');
|
||||||
|
|
||||||
if (!root) {
|
if (!root || root.dataset.helpdeskTimerBadgeBound === 'true') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const badge = root.querySelector('[data-helpdesk-running-summary-badge]');
|
root.dataset.helpdeskTimerBadgeBound = 'true';
|
||||||
const elapsed = root.querySelector('[data-helpdesk-running-summary-elapsed]');
|
|
||||||
|
|
||||||
if (!badge || !elapsed) {
|
const badge = root.querySelector('[data-helpdesk-running-summary-badge]');
|
||||||
|
const summaryElapsed = root.querySelector('[data-helpdesk-running-summary-elapsed]');
|
||||||
|
const panelElapsed = root.querySelector('[data-dusk="ticket-running-elapsed-time"]');
|
||||||
|
|
||||||
|
if (!badge || !summaryElapsed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,11 +260,9 @@
|
|||||||
return date.toISOString().substring(11, 19);
|
return date.toISOString().substring(11, 19);
|
||||||
};
|
};
|
||||||
|
|
||||||
const readExistingElapsedSeconds = () => {
|
const readElapsedSeconds = () => {
|
||||||
const parts = String(elapsed.textContent || '00:00:00')
|
const value = String(panelElapsed?.textContent || summaryElapsed.textContent || '00:00:00').trim();
|
||||||
.trim()
|
const parts = value.split(':').map((part) => Number.parseInt(part, 10));
|
||||||
.split(':')
|
|
||||||
.map((part) => Number.parseInt(part, 10));
|
|
||||||
|
|
||||||
if (parts.length !== 3 || parts.some(Number.isNaN)) {
|
if (parts.length !== 3 || parts.some(Number.isNaN)) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
badge.classList.add('inline-flex');
|
badge.classList.add('inline-flex');
|
||||||
|
|
||||||
if (!startedAt) {
|
if (!startedAt) {
|
||||||
startedAt = Date.now() - (readExistingElapsedSeconds() * 1000);
|
startedAt = Date.now() - (readElapsedSeconds() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interval) {
|
if (interval) {
|
||||||
@@ -284,7 +284,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
elapsed.textContent = formatElapsed(Math.floor((Date.now() - startedAt) / 1000));
|
const display = formatElapsed(Math.floor((Date.now() - startedAt) / 1000));
|
||||||
|
|
||||||
|
summaryElapsed.textContent = display;
|
||||||
|
|
||||||
|
if (panelElapsed) {
|
||||||
|
panelElapsed.textContent = display;
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -300,11 +306,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const syncRunningState = () => {
|
const syncRunningState = () => {
|
||||||
const timerPanel = root.querySelector('[data-helpdesk-running-timer]');
|
const hasTimerPanel = Boolean(root.querySelector('[data-helpdesk-running-timer]'));
|
||||||
const timerText = root.textContent.toLowerCase();
|
const text = root.textContent.toLowerCase();
|
||||||
const isRunning = Boolean(timerPanel) || timerText.includes('timer started') || timerText.includes('running');
|
const running = hasTimerPanel || text.includes('timer started') || text.includes('running');
|
||||||
|
|
||||||
if (isRunning) {
|
if (running) {
|
||||||
showBadge();
|
showBadge();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user