Show only changed fields (delta) in ticket activity timeline
Before: entire ticket data was logged and shown in the activity tab.
After: compare old vs new values before saving; log only fields that
actually changed as { field: { from: '...', to: '...' } } pairs.
- TicketController.php: fetch old ticket before update, compute delta
- api/update_ticket.php: same fix for the API endpoint (currentTicket
already fetched for auth, reuse it for delta comparison)
- TicketView.php: render delta format as "Field: old → new" with color;
truncate long values (description) at 60 chars; keep legacy flat format
as fallback for older log entries
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-2
@@ -180,9 +180,20 @@ try {
|
||||
$this->ticketModel->updateVisibility($id, $data['visibility'], $visibilityGroups, $this->userId);
|
||||
}
|
||||
|
||||
// Log ticket update to audit log
|
||||
// Log ticket update to audit log — only the changed fields (delta)
|
||||
if ($this->userId) {
|
||||
$this->auditLog->logTicketUpdate($this->userId, $id, $data);
|
||||
$trackFields = ['title', 'priority', 'status', 'description', 'category', 'type'];
|
||||
$delta = [];
|
||||
foreach ($trackFields as $field) {
|
||||
$oldVal = (string)($currentTicket[$field] ?? '');
|
||||
$newVal = (string)($updateData[$field] ?? '');
|
||||
if ($oldVal !== $newVal) {
|
||||
$delta[$field] = ['from' => $oldVal, 'to' => $newVal];
|
||||
}
|
||||
}
|
||||
if (!empty($delta)) {
|
||||
$this->auditLog->logTicketUpdate($this->userId, $id, $delta);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user