diff --git a/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php b/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php index 75a5da05..fc7ed905 100644 --- a/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php +++ b/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php @@ -103,7 +103,7 @@ Expand all - @@ -234,9 +234,10 @@ const expandButton = event.target.closest('[data-helpdesk-expand-comments]'); if (expandButton) { - document.querySelectorAll('[data-helpdesk-comments-shell], [data-helpdesk-comment-card]').forEach((card) => { + document.querySelectorAll('[data-helpdesk-comment-card]').forEach((card) => { card.open = true; }); + updateCommentToggleButtons(); return; } @@ -246,6 +247,7 @@ document.querySelectorAll('[data-helpdesk-comment-card]').forEach((card) => { card.open = false; }); + updateCommentToggleButtons(); return; } @@ -293,6 +295,24 @@ } }); + function updateCommentToggleButtons() { + const commentCards = Array.from(document.querySelectorAll('[data-helpdesk-comment-card]')); + const expandButton = document.querySelector('[data-helpdesk-expand-comments]'); + const collapseButton = document.querySelector('[data-helpdesk-collapse-comments]'); + + if (! expandButton || ! collapseButton) { + return; + } + + const hasExpandableComments = commentCards.some((card) => ! card.open); + const hasExpandedComments = commentCards.some((card) => card.open); + + expandButton.classList.toggle('hidden', ! hasExpandableComments); + expandButton.classList.toggle('inline-flex', hasExpandableComments); + collapseButton.classList.toggle('hidden', ! hasExpandedComments || hasExpandableComments); + collapseButton.classList.toggle('inline-flex', hasExpandedComments && ! hasExpandableComments); + } + function decodeHtmlEntities(value) { const textarea = document.createElement('textarea'); textarea.innerHTML = value;