Added ability to change the ticket status
This commit is contained in:
@ -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')
|
||||
|
Reference in New Issue
Block a user