Added functionality to update the ticket's last updated time when changing the ticket status or severity
This commit is contained in:
parent
77c8605b49
commit
ab2c87ce3a
@ -19,9 +19,11 @@ handleSeverityClick = (e, msg = 'Set ticket severity:') ->
|
|||||||
url: editLink,
|
url: editLink,
|
||||||
data:
|
data:
|
||||||
severity: newSeverity,
|
severity: newSeverity,
|
||||||
success: (data) ->
|
dataType: 'json',
|
||||||
|
success: (result) ->
|
||||||
newSeverity = newSeverity.charAt(0).toUpperCase() + newSeverity.slice(1)
|
newSeverity = newSeverity.charAt(0).toUpperCase() + newSeverity.slice(1)
|
||||||
$('.ticket-severity > span').text(newSeverity)
|
$('.ticket-severity > span').text(newSeverity)
|
||||||
|
updateTicketModified(result.updated_at)
|
||||||
console.log('Ticket updated successfully.')
|
console.log('Ticket updated successfully.')
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
@ -39,16 +41,22 @@ handleStatusClick = (e, msg = 'Set ticket status:') ->
|
|||||||
console.log('Setting status to ' + newStatus)
|
console.log('Setting status to ' + newStatus)
|
||||||
editLink = $('#ticketEditLink').attr('href') + '/status'
|
editLink = $('#ticketEditLink').attr('href') + '/status'
|
||||||
console.log('Sending data to ' + editLink)
|
console.log('Sending data to ' + editLink)
|
||||||
$.ajax({
|
$.ajax(
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: editLink,
|
url: editLink,
|
||||||
data:
|
data:
|
||||||
status: newStatus,
|
status: newStatus,
|
||||||
success: (data) ->
|
dataType: 'json',
|
||||||
|
success: (result) ->
|
||||||
newStatus = newStatus.charAt(0).toUpperCase() + newStatus.slice(1)
|
newStatus = newStatus.charAt(0).toUpperCase() + newStatus.slice(1)
|
||||||
$('.ticket-status > span').text(newStatus)
|
$('.ticket-status > span').text(newStatus)
|
||||||
|
updateTicketModified(result.updated_at)
|
||||||
console.log('Ticket updated successfully.')
|
console.log('Ticket updated successfully.')
|
||||||
})
|
)
|
||||||
else
|
else
|
||||||
console.log('Invalid status entered')
|
console.log('Invalid status entered')
|
||||||
handleStatusClick(e, 'Invalid status; valid values are open, closed, and parked.')
|
handleStatusClick(e, 'Invalid status; valid values are open, closed, and parked.')
|
||||||
|
|
||||||
|
updateTicketModified = (date) ->
|
||||||
|
$('.ticket-updated > span').text(date)
|
||||||
|
console.log('Ticket update time is ' + date)
|
||||||
|
@ -82,7 +82,10 @@ class TicketController extends Controller {
|
|||||||
$ticket->save();
|
$ticket->save();
|
||||||
|
|
||||||
// return a response
|
// return a response
|
||||||
$response->getBody()->write(json_encode(['status' => 'success']));
|
$response->getBody()->write(json_encode([
|
||||||
|
'result' => 'success',
|
||||||
|
'updated_at' => $ticket->formatUpdatedAt(),
|
||||||
|
]));
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,4 +27,12 @@ class Ticket extends Model {
|
|||||||
return $this->hasMany(Comment::class);
|
return $this->hasMany(Comment::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function formatCreatedAt(): string {
|
||||||
|
return date_format(date_create($this->created_at), "F jS\\, Y \\a\\t g:i:s a");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formatUpdatedAt(): string {
|
||||||
|
return date_format(date_create($this->updated_at), "F jS\\, Y \\a\\t g:i:s a");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<div id="ticket-header" class="row">
|
<div id="ticket-header" class="row">
|
||||||
<div class="columns twelve">
|
<div class="columns twelve">
|
||||||
<h1 class="ticket-title">{{ ticket.title }}</h1>
|
<h1 class="ticket-title">{{ ticket.title }}</h1>
|
||||||
<h4 class="ticket-created">Created at {{ ticket.created_at }}</h4>
|
<h4 class="ticket-created">Created at: <span>{{ ticket.formatCreatedAt() }}</span></h4>
|
||||||
<h4 class="ticket-updated">Last updated at {{ ticket.updated_at }}</h4>
|
<h4 class="ticket-updated">Last updated at: <span>{{ ticket.formatUpdatedAt() }}</span></h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user