diff --git a/app/Domain/Tickets/Controllers/TicketHistoryController.php b/app/Domain/Tickets/Controllers/TicketHistoryController.php index cd2ea849fd..0f6f377000 100644 --- a/app/Domain/Tickets/Controllers/TicketHistoryController.php +++ b/app/Domain/Tickets/Controllers/TicketHistoryController.php @@ -29,7 +29,7 @@ public function logStatusChange(): JsonResponse { if (!$this->authService->loggedIn()) { return new JsonResponse([ - 'success' => false, + 'success' => false, 'error' => 'Unauthorized' ], 401); } @@ -44,7 +44,7 @@ public function logStatusChange(): JsonResponse if (!$ticketId) { return new JsonResponse([ - 'success' => false, + 'success' => false, 'error' => 'No ticket ID provided' ], 400); } @@ -68,7 +68,7 @@ public function logStatusChange(): JsonResponse ]); } else { return new JsonResponse([ - 'success' => false, + 'success' => false, 'error' => 'Failed to save status change' ], 500); } @@ -101,32 +101,50 @@ public function getStatusChanges(): Response $html = '
Error loading status changes: ' . htmlspecialchars($e->getMessage()) . '
', diff --git a/app/Domain/Tickets/Templates/submodules/ticketDetails.sub.php b/app/Domain/Tickets/Templates/submodules/ticketDetails.sub.php index 135e84d672..309df5eede 100644 --- a/app/Domain/Tickets/Templates/submodules/ticketDetails.sub.php +++ b/app/Domain/Tickets/Templates/submodules/ticketDetails.sub.php @@ -223,6 +223,49 @@ function loadStatusHistory(ticketId) { const ticketIdOnLoad = $('#status-change-log').data('ticket-id'); if (ticketIdOnLoad) { loadStatusHistory(ticketIdOnLoad); + } + window.initialTicketDescription = ''; + + if (typeof tinymce !== 'undefined') { + tinymce.on('AddEditor', function(e) { + if (e.editor.id === 'ticketDescription') { + e.editor.on('init', function() { + window.initialTicketDescription = e.editor.getContent(); + }); + + e.editor.off('SaveContent'); + + e.editor.on('SaveContent', function() { + const currentDescription = e.editor.getContent(); + + if (window.initialTicketDescription !== currentDescription) { + const ticketId = $('#status-change-log').data('ticket-id'); + const user = $('#status-select').data('user') || 'Unknown User'; + + $.ajax({ + url: '= BASE_URL ?>/tickets/ticketHistoryController/logStatusChange', + method: 'POST', + data: { + ticketId: ticketId, + oldStatus: '', + newStatus: '', + oldStatusText: window.initialTicketDescription, + newStatusText: currentDescription, + user: user, + detailsAttributeId: 'ticketDescription' + }, + success: function(response) { + window.initialTicketDescription = currentDescription; + loadStatusHistory(ticketId); + }, + error: function(xhr, status, error) { + console.error('Error logging description:', error); + } + }); + } + }); + } + }); } $('#status-select, #priority, #storypoints, #editorId, #deadline').on('change', function() { diff --git a/app/Domain/Tickets/Templates/submodules/timesheet.sub.php b/app/Domain/Tickets/Templates/submodules/timesheet.sub.php index 5e1da83eee..712087182d 100644 --- a/app/Domain/Tickets/Templates/submodules/timesheet.sub.php +++ b/app/Domain/Tickets/Templates/submodules/timesheet.sub.php @@ -45,7 +45,7 @@ -