Compare commits
2 Commits
f3ac8a6965
...
77c8605b49
Author | SHA1 | Date | |
---|---|---|---|
77c8605b49 | |||
5d5265ef38 |
@ -1,2 +1,54 @@
|
||||
$(document).ready ->
|
||||
console.log('Hello, world!')
|
||||
|
||||
$('.ticket-severity').on('click', handleSeverityClick)
|
||||
$('.ticket-status').on('click', handleStatusClick)
|
||||
|
||||
handleSeverityClick = (e, msg = 'Set ticket severity:') ->
|
||||
validSeverity = ['low', 'medium', 'high']
|
||||
newSeverity = prompt(msg, $('.ticket-severity > span').text())
|
||||
newSeverity = newSeverity.toLowerCase()
|
||||
|
||||
if (newSeverity != null) and (newSeverity != '')
|
||||
if (newSeverity in validSeverity)
|
||||
console.log('Setting severity to ' + newSeverity)
|
||||
editLink = $('#ticketEditLink').attr('href') + '/severity'
|
||||
console.log('Sending data to ' + editLink)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: editLink,
|
||||
data:
|
||||
severity: newSeverity,
|
||||
success: (data) ->
|
||||
newSeverity = newSeverity.charAt(0).toUpperCase() + newSeverity.slice(1)
|
||||
$('.ticket-severity > span').text(newSeverity)
|
||||
console.log('Ticket updated successfully.')
|
||||
})
|
||||
else
|
||||
console.log('Invalid severity entered')
|
||||
handleSeverityClick(e, 'Invalid severity; valid values are low, medium, and high.')
|
||||
|
||||
|
||||
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.')
|
||||
|
@ -98,7 +98,7 @@ input[type="submit"].button-primary
|
||||
p:last-child
|
||||
margin-bottom: 5px
|
||||
|
||||
.ticket-status
|
||||
.ticket-attributes
|
||||
list-style: none
|
||||
margin: 0
|
||||
border: 1px solid #bbb
|
||||
@ -141,6 +141,13 @@ input[type="submit"].button-primary
|
||||
margin-right: 5px
|
||||
font-size: 2rem
|
||||
|
||||
.ticket-severity,
|
||||
.ticket-status
|
||||
transition: all 230ms ease-in-out
|
||||
&:hover
|
||||
background: rgba(0, 0, 0, .1)
|
||||
cursor: pointer
|
||||
|
||||
#comment-form
|
||||
textarea
|
||||
height: 150px
|
||||
|
@ -69,6 +69,23 @@ class TicketController extends Controller {
|
||||
->withStatus(302);
|
||||
}
|
||||
|
||||
public function postEditAttr(Request $request, Response $response, array $args): Response {
|
||||
// grab ticket from database
|
||||
$ticket = Ticket::where('id', $args['ticket_id'])->first();
|
||||
|
||||
// edit the specified attribute
|
||||
$params = (array)$request->getParsedBody();
|
||||
$attr = $args['attr'];
|
||||
$ticket->$attr = $params[$attr];
|
||||
|
||||
// save updated ticket
|
||||
$ticket->save();
|
||||
|
||||
// return a response
|
||||
$response->getBody()->write(json_encode(['status' => 'success']));
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getDelete(Request $request, Response $response, array $args): Response {
|
||||
$ticket = Ticket::where('id', $args['ticket_id'])->first();
|
||||
|
||||
|
@ -14,6 +14,7 @@ $app->post('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketControlle
|
||||
// /ticket/edit routes - update a ticket!
|
||||
$app->get('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getEdit')->setName('ticket.edit');
|
||||
$app->post('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postEdit')->setName('ticket.edit');
|
||||
$app->post('/ticket/{ticket_id}/edit/{attr}', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postEditAttr')->setName('ticket.edit.attr');
|
||||
|
||||
// ticket deletion route
|
||||
$app->get('/ticket/{ticket_id}/delete', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getDelete')->setName('ticket.delete');
|
||||
|
@ -23,17 +23,17 @@
|
||||
|
||||
<!-- ticket status column -->
|
||||
<div class="three columns">
|
||||
<ul class="ticket-status">
|
||||
<ul class="ticket-attributes">
|
||||
<li class="ticket-actions">
|
||||
<ul>
|
||||
<li><a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i>Edit</a></li><li><a href="{{ url_for('ticket.delete', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-trash"></i>Delete</a></li>
|
||||
<li><a id="ticketEditLink" href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i>Edit</a></li><li><a href="{{ url_for('ticket.delete', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-trash"></i>Delete</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
Severity {{ ticket.severity | capitalize }}
|
||||
<li class="ticket-severity">
|
||||
Severity: <span>{{ ticket.severity | capitalize }}</span>
|
||||
</li>
|
||||
<li>
|
||||
Status: {{ ticket.status | capitalize }}
|
||||
<li class="ticket-status">
|
||||
Status: <span>{{ ticket.status | capitalize }}</span>
|
||||
</li>
|
||||
<li>
|
||||
Assignee(s): N/a
|
||||
|
Loading…
Reference in New Issue
Block a user