Lines 1-31
Link Here
|
1 |
/* keep tidy */ |
1 |
/* keep tidy */ |
2 |
$(document).ready(function() { |
2 |
$(document).ready(function () { |
3 |
$('#ticketDetailsModal').on('show.bs.modal', function(event) { |
3 |
$("#ticketDetailsModal").on("show.bs.modal", function (event) { |
4 |
let modal = $(this); |
4 |
let modal = $(this); |
5 |
let button = $(event.relatedTarget); |
5 |
let button = $(event.relatedTarget); |
6 |
let ticket_id = button.data('concern'); |
6 |
let ticket_id = button.data("concern"); |
7 |
let resolved = button.data('resolved'); |
7 |
let resolved = button.data("resolved"); |
8 |
modal.find('.modal-footer input').val(ticket_id); |
8 |
modal.find(".modal-footer input").val(ticket_id); |
9 |
|
9 |
|
10 |
if ( resolved ) { |
10 |
if (resolved) { |
11 |
$('#resolveTicket').hide(); |
11 |
$("#resolveTicket").hide(); |
12 |
} else { |
12 |
} else { |
13 |
$('#resolveTicket').show(); |
13 |
$("#resolveTicket").show(); |
14 |
} |
14 |
} |
15 |
|
15 |
|
16 |
let detail = $('#detail_' + ticket_id).text(); |
16 |
let detail = $("#detail_" + ticket_id).text(); |
17 |
|
17 |
|
18 |
// Display ticket details |
18 |
// Display ticket details |
19 |
let display = '<div class="list-group">'; |
19 |
let display = '<div class="list-group">'; |
20 |
display += '<div class="list-group-item">'; |
20 |
display += '<div class="list-group-item">'; |
21 |
display += '<span class="wrapfix">' + detail + '</span>'; |
21 |
display += '<span class="wrapfix">' + detail + "</span>"; |
22 |
display += '</div>'; |
22 |
display += "</div>"; |
23 |
display += '<div id="concern-updates" class="list-group-item">'; |
23 |
display += '<div id="concern-updates" class="list-group-item">'; |
24 |
display += '<span>' + __("Loading updates . . .") + '</span>'; |
24 |
display += "<span>" + __("Loading updates . . .") + "</span>"; |
25 |
display += '</div>'; |
25 |
display += "</div>"; |
26 |
display += '</div>'; |
26 |
display += "</div>"; |
27 |
|
27 |
|
28 |
let details = modal.find('#concern-details'); |
28 |
let details = modal.find("#concern-details"); |
29 |
details.html(display); |
29 |
details.html(display); |
30 |
|
30 |
|
31 |
// Load any existing updates |
31 |
// Load any existing updates |
Lines 33-121
$(document).ready(function() {
Link Here
|
33 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
33 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
34 |
method: "GET", |
34 |
method: "GET", |
35 |
headers: { |
35 |
headers: { |
36 |
"x-koha-embed": "user" |
36 |
"x-koha-embed": "user", |
37 |
}, |
37 |
}, |
38 |
}).success(function(data) { |
38 |
}) |
39 |
let updates_display = $('#concern-updates'); |
39 |
.success(function (data) { |
40 |
let updates = ''; |
40 |
let updates_display = $("#concern-updates"); |
41 |
data.forEach(function(item, index) { |
41 |
let updates = ""; |
42 |
if ( item.public ) { |
42 |
data.forEach(function (item, index) { |
43 |
updates += '<div class="list-group-item list-group-item-success">'; |
43 |
if (item.public) { |
44 |
updates += '<span class="pull-right">' + __("Public") + '</span>'; |
44 |
updates += |
45 |
} |
45 |
'<div class="list-group-item list-group-item-success">'; |
46 |
else { |
46 |
updates += |
47 |
updates += '<div class="list-group-item list-group-item-warning">'; |
47 |
'<span class="pull-right">' + |
48 |
updates += '<span class="pull-right">' + __("Private") + '</span>'; |
48 |
__("Public") + |
49 |
} |
49 |
"</span>"; |
50 |
updates += '<span class="wrapfix">' + item.message + '</span>'; |
50 |
} else { |
51 |
updates += '<span class="clearfix">' + $patron_to_html(item.user, { |
51 |
updates += |
52 |
display_cardnumber: false, |
52 |
'<div class="list-group-item list-group-item-warning">'; |
53 |
url: true |
53 |
updates += |
54 |
}) + ' (' + $datetime(item.date) + ')</span>'; |
54 |
'<span class="pull-right">' + |
55 |
updates += '</div>'; |
55 |
__("Private") + |
56 |
}); |
56 |
"</span>"; |
57 |
updates_display.html(updates); |
57 |
} |
58 |
}).error(function() { |
58 |
updates += |
59 |
|
59 |
'<span class="wrapfix">' + item.message + "</span>"; |
60 |
}); |
60 |
updates += |
|
|
61 |
'<span class="clearfix">' + |
62 |
$patron_to_html(item.user, { |
63 |
display_cardnumber: false, |
64 |
url: true, |
65 |
}) + |
66 |
" (" + |
67 |
$datetime(item.date) + |
68 |
")</span>"; |
69 |
updates += "</div>"; |
70 |
}); |
71 |
updates_display.html(updates); |
72 |
}) |
73 |
.error(function () {}); |
61 |
|
74 |
|
62 |
// Clear any previously entered update message |
75 |
// Clear any previously entered update message |
63 |
$('#update_message').val(''); |
76 |
$("#update_message").val(""); |
64 |
$('#public').prop( "checked", false ); |
77 |
$("#public").prop("checked", false); |
65 |
}); |
78 |
}); |
66 |
|
79 |
|
67 |
$('#ticketDetailsModal').on('click', '#updateTicket', function(e) { |
80 |
$("#ticketDetailsModal").on("click", "#updateTicket", function (e) { |
68 |
let ticket_id = $('#ticket_id').val(); |
81 |
let ticket_id = $("#ticket_id").val(); |
69 |
let params = { |
82 |
let params = { |
70 |
'public': $('#public').is(":checked"), |
83 |
public: $("#public").is(":checked"), |
71 |
message: $('#update_message').val(), |
84 |
message: $("#update_message").val(), |
72 |
user_id: logged_in_user_borrowernumber |
85 |
user_id: logged_in_user_borrowernumber, |
73 |
}; |
86 |
}; |
74 |
|
87 |
|
75 |
$('#comment-spinner').show(); |
88 |
$("#comment-spinner").show(); |
76 |
|
89 |
|
77 |
$.ajax({ |
90 |
$.ajax({ |
78 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
91 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
79 |
method: "POST", |
92 |
method: "POST", |
80 |
data: JSON.stringify(params), |
93 |
data: JSON.stringify(params), |
81 |
ontentType: "application/json; charset=utf-8" |
94 |
ontentType: "application/json; charset=utf-8", |
82 |
}).success(function() { |
95 |
}) |
83 |
$('#comment-spinner').hide(); |
96 |
.success(function () { |
84 |
$('#ticketDetailsModal').modal('hide'); |
97 |
$("#comment-spinner").hide(); |
85 |
$('#table_concerns').DataTable().ajax.reload(function(data) { |
98 |
$("#ticketDetailsModal").modal("hide"); |
86 |
$("#concern_action_result_dialog").hide(); |
99 |
$("#table_concerns") |
87 |
$("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); |
100 |
.DataTable() |
|
|
101 |
.ajax.reload(function (data) { |
102 |
$("#concern_action_result_dialog").hide(); |
103 |
$("#concern_delete_success") |
104 |
.html( |
105 |
__("Concern #%s updated successfully.").format( |
106 |
ticket_id, |
107 |
), |
108 |
) |
109 |
.show(); |
110 |
}); |
111 |
}) |
112 |
.error(function () { |
113 |
$("#concern_update_error") |
114 |
.html( |
115 |
__( |
116 |
"Error resolving concern #%s. Check the logs for details.", |
117 |
).format(ticket_id), |
118 |
) |
119 |
.show(); |
88 |
}); |
120 |
}); |
89 |
}).error(function() { |
|
|
90 |
$("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show(); |
91 |
}); |
92 |
}); |
121 |
}); |
93 |
|
122 |
|
94 |
$('#ticketDetailsModal').on('click', '#resolveTicket', function(e) { |
123 |
$("#ticketDetailsModal").on("click", "#resolveTicket", function (e) { |
95 |
let ticket_id = $('#ticket_id').val(); |
124 |
let ticket_id = $("#ticket_id").val(); |
96 |
let params = { |
125 |
let params = { |
97 |
'public': $('#public').is(":checked"), |
126 |
public: $("#public").is(":checked"), |
98 |
message: $('#update_message').val(), |
127 |
message: $("#update_message").val(), |
99 |
user_id: logged_in_user_borrowernumber, |
128 |
user_id: logged_in_user_borrowernumber, |
100 |
state: 'resolved' |
129 |
state: "resolved", |
101 |
}; |
130 |
}; |
102 |
|
131 |
|
103 |
$('#resolve-spinner').show(); |
132 |
$("#resolve-spinner").show(); |
104 |
|
133 |
|
105 |
$.ajax({ |
134 |
$.ajax({ |
106 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
135 |
url: "/api/v1/tickets/" + ticket_id + "/updates", |
107 |
method: "POST", |
136 |
method: "POST", |
108 |
data: JSON.stringify(params), |
137 |
data: JSON.stringify(params), |
109 |
ontentType: "application/json; charset=utf-8" |
138 |
ontentType: "application/json; charset=utf-8", |
110 |
}).success(function() { |
139 |
}) |
111 |
$('#resolve-spinner').hide(); |
140 |
.success(function () { |
112 |
$("#ticketDetailsModal").modal('hide'); |
141 |
$("#resolve-spinner").hide(); |
113 |
$('#table_concerns').DataTable().ajax.reload(function(data) { |
142 |
$("#ticketDetailsModal").modal("hide"); |
114 |
$("#concern_action_result_dialog").hide(); |
143 |
$("#table_concerns") |
115 |
$("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); |
144 |
.DataTable() |
|
|
145 |
.ajax.reload(function (data) { |
146 |
$("#concern_action_result_dialog").hide(); |
147 |
$("#concern_delete_success") |
148 |
.html( |
149 |
__("Concern #%s updated successfully.").format( |
150 |
ticket_id, |
151 |
), |
152 |
) |
153 |
.show(); |
154 |
}); |
155 |
}) |
156 |
.error(function () { |
157 |
$("#concern_update_error") |
158 |
.html( |
159 |
__( |
160 |
"Error resolving concern #%s. Check the logs for details.", |
161 |
).format(ticket_id), |
162 |
) |
163 |
.show(); |
116 |
}); |
164 |
}); |
117 |
}).error(function() { |
|
|
118 |
$("#concern_update_error").html(__("Error resolving concern #%s. Check the logs for details.").format(ticket_id)).show(); |
119 |
}); |
120 |
}); |
165 |
}); |
121 |
}); |
166 |
}); |
122 |
- |
|
|