Added ability to change the ticket status

This commit is contained in:
2022-12-04 15:00:26 -05:00
parent f3ac8a6965
commit 5d5265ef38
5 changed files with 55 additions and 5 deletions

View File

@ -1,2 +1,28 @@
$(document).ready ->
console.log('Hello, world!')
$('.ticket-status').on('click', handleStatusClick)
handleStatusClick = (e, msg = 'Set ticket status:') ->
validStatus = ['open', 'closed', 'parked']
newStatus = prompt(msg, $('.ticket-status > span').text())
newStatus = newStatus.toLowerCase()
if (newStatus != null) and (newStatus != '')
if (newStatus in validStatus)
console.log('Setting status to ' + newStatus)
editLink = $('#ticketEditLink').attr('href') + '/status'
console.log('Sending data to ' + editLink)
$.ajax({
type: "POST",
url: editLink,
data:
status: newStatus,
success: (data) ->
newStatus = newStatus.charAt(0).toUpperCase() + newStatus.slice(1)
$('.ticket-status > span').text(newStatus)
console.log('Ticket updated successfully.')
})
else
console.log('Invalid status entered')
handleStatusClick(e, 'Invalid status; valid values are open, closed, and parked')