Added a ticket queues object to organize tickets; added ability to change a ticket's queue
This commit is contained in:
@ -1,12 +1,41 @@
|
||||
$(document).ready ->
|
||||
console.log('Hello, world!')
|
||||
|
||||
$('.ticket-severity').on('click', handleAttributeClick('severity'))
|
||||
$('.ticket-status').on('click', handleAttributeClick('status'))
|
||||
$('.ticket-queue').on('click', (e) ->
|
||||
handleQueueClick(e)
|
||||
)
|
||||
$('.ticket-severity').on('click', (e) ->
|
||||
handleAttributeClick(e, 'severity')
|
||||
)
|
||||
$('.ticket-status').on('click', (e) ->
|
||||
handleAttributeClick(e, 'status')
|
||||
)
|
||||
|
||||
validOptions =
|
||||
'severity' = ['low', 'medium', 'high'],
|
||||
'status' = ['open', 'closed', 'parked']
|
||||
'severity': ['low', 'medium', 'high'],
|
||||
'status': ['open', 'closed', 'parked']
|
||||
|
||||
handleQueueClick = (e, fail = false) ->
|
||||
newQueueId = prompt('Set queue ID:', $('.ticket-queue').data('id'))
|
||||
|
||||
if (newQueueId != null) and (newQueueId != '')
|
||||
if (true)
|
||||
console.log('Setting queue ID to ' + newQueueId)
|
||||
editLink = $('#ticketEditLink').attr('href') + '/queue_id'
|
||||
console.log('Sending data to ' + editLink)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: editLink,
|
||||
data:
|
||||
'queue_id': newQueueId,
|
||||
dataType: 'json',
|
||||
success: (result) ->
|
||||
$('.ticket-queue').data('id', newQueueId)
|
||||
$('.ticket-queue > span').text(result.queue_name)
|
||||
updateTicketModified(result.updated_at)
|
||||
console.log('Ticket updated successfully.')
|
||||
})
|
||||
else
|
||||
console.log('Invalid queue ID entered')
|
||||
handleQueueClick(e, 'Invalid queue ID entered; you must enter a number.')
|
||||
|
||||
handleAttributeClick = (e, attr, fail = false) ->
|
||||
newValue = prompt('Set ticket ' + attr + ':', $('.ticket-' + attr + ' > span').text())
|
||||
@ -16,12 +45,13 @@ handleAttributeClick = (e, attr, fail = false) ->
|
||||
if (newValue in validOptions[attr])
|
||||
console.log('Setting ' + attr + ' to ' + newValue)
|
||||
editLink = $('#ticketEditLink').attr('href') + '/' + attr
|
||||
postData = {}
|
||||
postData[attr] = newValue
|
||||
console.log('Sending data to ' + editLink)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: editLink,
|
||||
data:
|
||||
attr: newValue,
|
||||
data: postData,
|
||||
dataType: 'json',
|
||||
success: (result) ->
|
||||
newValue = newValue.charAt(0).toUpperCase() + newValue.slice(1)
|
||||
|
@ -81,12 +81,16 @@ input[type="submit"].button-primary
|
||||
height: 250px
|
||||
min-height: 100px
|
||||
|
||||
#queue-header,
|
||||
#ticket-header
|
||||
margin-bottom: 15px
|
||||
|
||||
.queue-title,
|
||||
.ticket-title
|
||||
margin-bottom: 5px
|
||||
|
||||
.queue-created,
|
||||
.queue-updated,
|
||||
.ticket-created,
|
||||
.ticket-updated
|
||||
margin-bottom: 3px
|
||||
@ -94,6 +98,7 @@ input[type="submit"].button-primary
|
||||
font-size: 1.5rem
|
||||
font-style: italic
|
||||
|
||||
#queue-description,
|
||||
#ticket-body
|
||||
p:last-child
|
||||
margin-bottom: 5px
|
||||
@ -141,6 +146,7 @@ input[type="submit"].button-primary
|
||||
margin-right: 5px
|
||||
font-size: 2rem
|
||||
|
||||
.ticket-queue,
|
||||
.ticket-severity,
|
||||
.ticket-status
|
||||
transition: all 230ms ease-in-out
|
||||
|
Reference in New Issue
Block a user