Lines 63-99
Link Here
|
63 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
63 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
64 |
</div> <!-- /.row --> |
64 |
</div> <!-- /.row --> |
65 |
|
65 |
|
66 |
<!-- Display updates concern modal --> |
66 |
[% INCLUDE 'modals/display_ticket.inc' %] |
67 |
<div class="modal" id="ticketDetailsModal" tabindex="-1" role="dialog" aria-labelledby="ticketDetailsLabel"> |
|
|
68 |
<div class="modal-dialog modal-lg" role="document"> |
69 |
<div class="modal-content"> |
70 |
<div class="modal-header"> |
71 |
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
72 |
<h4 class="modal-title" id="displayUpdateLabel">Ticket details</h4> |
73 |
</div> |
74 |
<div class="modal-body"> |
75 |
<div id="concern-details"></div> |
76 |
<fieldset class="rows"> |
77 |
<ol> |
78 |
<li> |
79 |
<label for="message">Update: </label> |
80 |
<textarea id="update_message" name="message"></textarea> |
81 |
</li> |
82 |
<li> |
83 |
<label for="public">Notify: </label> |
84 |
<input type="checkbox" name="public" id="public"> |
85 |
</li> |
86 |
</ol> |
87 |
</fieldset> |
88 |
</div> <!-- /.modal-body --> |
89 |
<div class="modal-footer"> |
90 |
<input type="hidden" name="ticket_id" id="ticket_id"> |
91 |
<button type="button" class="btn btn-default" id="resolveTicket">Resolve</button> |
92 |
<button type="submit" class="btn btn-primary" id="updateTicket">Comment</button> |
93 |
</div> <!-- /.modal-footer --> |
94 |
</div> <!-- /.modal-content --> |
95 |
</div> <!-- /.modal-dialog --> |
96 |
</div> <!-- /#displayUpdateModal --> |
97 |
|
67 |
|
98 |
[% MACRO jsinclude BLOCK %] |
68 |
[% MACRO jsinclude BLOCK %] |
99 |
[% INCLUDE 'datatables.inc' %] |
69 |
[% INCLUDE 'datatables.inc' %] |
Lines 104-110
Link Here
|
104 |
<script> |
74 |
<script> |
105 |
$(document).ready(function() { |
75 |
$(document).ready(function() { |
106 |
|
76 |
|
107 |
var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; |
77 |
logged_in_user_borrowernumber = [% logged_in_user.borrowernumber | html %]; |
108 |
|
78 |
|
109 |
var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %]; |
79 |
var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %]; |
110 |
|
80 |
|
Lines 149-157
Link Here
|
149 |
{ |
119 |
{ |
150 |
"data": "title:body", |
120 |
"data": "title:body", |
151 |
"render": function(data, type, row, meta) { |
121 |
"render": function(data, type, row, meta) { |
152 |
let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '">' + row.title + '</a>'; |
122 |
let resolved = ( row.resolved_date ) ? true : false; |
|
|
123 |
let result = '<a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'">' + row.title + '</a>'; |
153 |
if (row.updates_count) { |
124 |
if (row.updates_count) { |
154 |
result += '<span class="pull-right"><a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-comment" aria-hidden="true"></i> ' + row.updates_count + '</a></span>'; |
125 |
result += '<span class="pull-right"><a role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'"><i class="fa fa-comment" aria-hidden="true"></i> ' + row.updates_count + '</a></span>'; |
155 |
} |
126 |
} |
156 |
result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>'; |
127 |
result += '<div id="detail_' + row.ticket_id + '" class="hidden">' + row.body + '</div>'; |
157 |
return result; |
128 |
return result; |
Lines 189-195
Link Here
|
189 |
}, |
160 |
}, |
190 |
{ |
161 |
{ |
191 |
"data": function(row, type, val, meta) { |
162 |
"data": function(row, type, val, meta) { |
192 |
let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '"><i class="fa fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>'; |
163 |
let resolved = ( row.resolved_date ) ? true : false; |
|
|
164 |
let result = '<a class="btn btn-default btn-xs" role="button" href="#" data-toggle="modal" data-target="#ticketDetailsModal" data-concern="' + encodeURIComponent(row.ticket_id) + '" data-resolved="'+resolved+'"><i class="fa fa-eye" aria-hidden="true"></i> ' + _("Details") + '</a>'; |
193 |
return result; |
165 |
return result; |
194 |
}, |
166 |
}, |
195 |
"searchable": false, |
167 |
"searchable": false, |
Lines 206-306
Link Here
|
206 |
$('#showAll').on("click", function() { |
178 |
$('#showAll').on("click", function() { |
207 |
tickets.DataTable().columns('3').search('').draw(); |
179 |
tickets.DataTable().columns('3').search('').draw(); |
208 |
}); |
180 |
}); |
209 |
|
|
|
210 |
$('#ticketDetailsModal').on('show.bs.modal', function(event) { |
211 |
let modal = $(this); |
212 |
let button = $(event.relatedTarget); |
213 |
let ticket_id = button.data('concern'); |
214 |
modal.find('.modal-footer input').val(ticket_id); |
215 |
|
216 |
let detail = $('#detail_' + ticket_id).text(); |
217 |
|
218 |
let display = '<div class="list-group">'; |
219 |
display += '<div class="list-group-item">'; |
220 |
display += '<span class="wrapfix">' + detail + '</span>'; |
221 |
display += '</div>'; |
222 |
display += '<div id="concern-updates" class="list-group-item">'; |
223 |
display += '<span>Loading updates . . .</span>'; |
224 |
display += '</div>'; |
225 |
display += '</div>'; |
226 |
|
227 |
let details = modal.find('#concern-details'); |
228 |
details.html(display); |
229 |
|
230 |
$.ajax({ |
231 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
232 |
method: "GET", |
233 |
headers: { |
234 |
"x-koha-embed": "user" |
235 |
}, |
236 |
}).success(function(data) { |
237 |
let updates_display = $('#concern-updates'); |
238 |
let updates = ''; |
239 |
data.forEach(function(item, index) { |
240 |
updates += '<div class="list-group-item">'; |
241 |
updates += '<span class="wrapfix">' + item.message + '</span>'; |
242 |
updates += '<span class="clearfix">' + $patron_to_html(item.user, { |
243 |
display_cardnumber: false, |
244 |
url: true |
245 |
}) + ' (' + $datetime(item.date) + ')</span>'; |
246 |
updates += '</div>'; |
247 |
}); |
248 |
updates_display.html(updates); |
249 |
}).error(function() { |
250 |
|
251 |
}); |
252 |
}); |
253 |
|
254 |
$('#ticketDetailsModal').on('click', '#updateTicket', function(e) { |
255 |
let ticket_id = $('#ticket_id').val(); |
256 |
let params = { |
257 |
'public': $('#public').is(":checked"), |
258 |
message: $('#update_message').val(), |
259 |
user_id: logged_in_user_borrowernumber |
260 |
}; |
261 |
|
262 |
$.ajax({ |
263 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
264 |
method: "POST", |
265 |
data: JSON.stringify(params), |
266 |
ontentType: "application/json; charset=utf-8" |
267 |
}).success(function() { |
268 |
$("#ticketDetailsModal").modal('hide'); |
269 |
tickets.DataTable().ajax.reload(function(data) { |
270 |
$("#concern_action_result_dialog").hide(); |
271 |
$("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show(); |
272 |
}); |
273 |
}).error(function() { |
274 |
$("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show(); |
275 |
}); |
276 |
}); |
277 |
|
278 |
$('#ticketDetailsModal').on('click', '#resolveTicket', function(e) { |
279 |
let ticket_id = $('#ticket_id').val(); |
280 |
let params = { |
281 |
'public': $('#public').is(":checked"), |
282 |
message: $('#update_message').val(), |
283 |
user_id: logged_in_user_borrowernumber, |
284 |
state: 'resolved' |
285 |
}; |
286 |
|
287 |
$.ajax({ |
288 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
289 |
method: "POST", |
290 |
data: JSON.stringify(params), |
291 |
ontentType: "application/json; charset=utf-8" |
292 |
}).success(function() { |
293 |
$("#ticketDetailsModal").modal('hide'); |
294 |
tickets.DataTable().ajax.reload(function(data) { |
295 |
$("#concern_action_result_dialog").hide(); |
296 |
$("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show(); |
297 |
}); |
298 |
}).error(function() { |
299 |
$("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show(); |
300 |
}); |
301 |
}); |
302 |
|
303 |
}); |
181 |
}); |
304 |
</script> |
182 |
</script> |
|
|
183 |
[% Asset.js("js/modals/display_ticket.js") | $raw %] |
305 |
[% END %] |
184 |
[% END %] |
306 |
[% INCLUDE 'intranet-bottom.inc' %] |
185 |
[% INCLUDE 'intranet-bottom.inc' %] |