Lines 67-82
$(document).ready(function() {
Link Here
|
67 |
// Clear any previously entered update message |
67 |
// Clear any previously entered update message |
68 |
$('#update_message').val(''); |
68 |
$('#update_message').val(''); |
69 |
$('#public').prop( "checked", false ); |
69 |
$('#public').prop( "checked", false ); |
|
|
70 |
|
71 |
// Patron select2 |
72 |
$("#assignee_id").kohaSelect({ |
73 |
dropdownParent: $(".modal-content", "#ticketDetailsModal"), |
74 |
width: '50%', |
75 |
dropdownAutoWidth: true, |
76 |
allowClear: true, |
77 |
minimumInputLength: 3, |
78 |
ajax: { |
79 |
url: '/api/v1/patrons', |
80 |
delay: 250, |
81 |
dataType: 'json', |
82 |
headers: { |
83 |
"x-koha-embed": "library" |
84 |
}, |
85 |
data: function(params) { |
86 |
let q = buildPatronSearchQuery(params.term); |
87 |
let query = { |
88 |
'q': JSON.stringify(q), |
89 |
'_page': params.page, |
90 |
'_order_by': '+me.surname,+me.firstname', |
91 |
}; |
92 |
return query; |
93 |
}, |
94 |
processResults: function(data, params) { |
95 |
let results = []; |
96 |
data.results.forEach(function(patron) { |
97 |
patron.id = patron.patron_id; |
98 |
results.push(patron); |
99 |
}); |
100 |
return { |
101 |
"results": results, "pagination": { "more": data.pagination.more } |
102 |
}; |
103 |
}, |
104 |
}, |
105 |
templateResult: function (patron) { |
106 |
if (patron.library_id == loggedInLibrary) { |
107 |
loggedInClass = "ac-currentlibrary"; |
108 |
} else { |
109 |
loggedInClass = ""; |
110 |
} |
111 |
|
112 |
let $patron = $("<span></span>") |
113 |
.append( |
114 |
"" + |
115 |
(patron.surname |
116 |
? escape_str(patron.surname) + ", " |
117 |
: "") + |
118 |
(patron.firstname |
119 |
? escape_str(patron.firstname) + " " |
120 |
: "") + |
121 |
(patron.cardnumber |
122 |
? " (" + escape_str(patron.cardnumber) + ")" |
123 |
: "") + |
124 |
"<small>" + |
125 |
(patron.date_of_birth |
126 |
? ' <span class="age_years">' + |
127 |
$get_age(patron.date_of_birth) + |
128 |
" " + |
129 |
__("years") + |
130 |
"</span>" |
131 |
: "") + |
132 |
(patron.library ? |
133 |
" <span class=\"ac-library\">" + |
134 |
escape_str(patron.library.name) + |
135 |
"</span>" |
136 |
: "") + |
137 |
"</small>" |
138 |
) |
139 |
.addClass(loggedInClass); |
140 |
return $patron; |
141 |
}, |
142 |
templateSelection: function (patron) { |
143 |
if (!patron.surname) { |
144 |
return patron.text; |
145 |
} |
146 |
return ( |
147 |
escape_str(patron.surname) + ", " + escape_str(patron.firstname) |
148 |
); |
149 |
}, |
150 |
placeholder: "Search for a patron" |
151 |
}); |
70 |
}); |
152 |
}); |
71 |
|
153 |
|
72 |
$('#ticketDetailsModal').on('click', '.updateSubmit', function(e) { |
154 |
$('#ticketDetailsModal').on('click', '.updateSubmit', function(e) { |
73 |
let clicked = $(this); |
155 |
let clicked = $(this); |
74 |
let ticket_id = $('#ticket_id').val(); |
156 |
let ticket_id = $('#ticket_id').val(); |
|
|
157 |
let assignee_id = $('#assignee_id').val(); |
75 |
let params = { |
158 |
let params = { |
76 |
'public': $('#public').is(":checked"), |
159 |
'public': $('#public').is(":checked"), |
77 |
'message': $('#update_message').val(), |
160 |
'message': $('#update_message').val(), |
78 |
'user_id': logged_in_user_borrowernumber, |
161 |
'user_id': logged_in_user_borrowernumber, |
79 |
'status': clicked.data('status') |
162 |
'status': clicked.data('status'), |
|
|
163 |
'assignee_id': assignee_id |
80 |
}; |
164 |
}; |
81 |
|
165 |
|
82 |
$('#comment-spinner').show(); |
166 |
$('#comment-spinner').show(); |
83 |
- |
|
|