Lines 78-84
$(document).ready(function() {
Link Here
|
78 |
{ |
78 |
{ |
79 |
"mDataProp": function( oObj ) { |
79 |
"mDataProp": function( oObj ) { |
80 |
if( oObj.branches.length > 1 && oObj.found !== 'W' && oObj.found !== 'T' ){ |
80 |
if( oObj.branches.length > 1 && oObj.found !== 'W' && oObj.found !== 'T' ){ |
81 |
var branchSelect='<select priority='+oObj.priority+' class="hold_location_select" reserve_id="'+oObj.reserve_id+'" name="pick-location">'; |
81 |
var branchSelect='<select priority='+oObj.priority+' class="hold_location_select" data-hold-id="'+oObj.reserve_id+'" reserve_id="'+oObj.reserve_id+'" name="pick-location">'; |
82 |
for ( var i=0; i < oObj.branches.length; i++ ){ |
82 |
for ( var i=0; i < oObj.branches.length; i++ ){ |
83 |
var selectedbranch; |
83 |
var selectedbranch; |
84 |
var setbranch; |
84 |
var setbranch; |
Lines 219-225
$(document).ready(function() {
Link Here
|
219 |
}); |
219 |
}); |
220 |
}); |
220 |
}); |
221 |
|
221 |
|
222 |
$(".hold_location_select").change(function(){ |
222 |
function display_pickup_location (state) { |
|
|
223 |
var $text; |
224 |
if ( state.needs_override === true ) { |
225 |
$text = $( |
226 |
'<span>' + state.text + '</span> <span style="float:right;" title="' + |
227 |
_("This pickup location is not allowed according to circulation rules") + |
228 |
'"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>' |
229 |
); |
230 |
} |
231 |
else { |
232 |
$text = $('<span>'+state.text+'</span>'); |
233 |
} |
234 |
|
235 |
return $text; |
236 |
}; |
237 |
|
238 |
$(".hold_location_select").each( function () { |
239 |
var this_dropdown = $(this); |
240 |
var hold_id = $(this).data('hold-id'); |
241 |
|
242 |
this_dropdown.select2({ |
243 |
allowClear: false, |
244 |
ajax: { |
245 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations', |
246 |
delay: 300, // wait 300 milliseconds before triggering the request |
247 |
dataType: 'json', |
248 |
cache: true, |
249 |
data: function (params) { |
250 |
var search_term = (params.term === undefined) ? '' : params.term; |
251 |
var query = { |
252 |
"q": JSON.stringify({"name":{"-like":search_term+'%'}}), |
253 |
"_order_by": "name" |
254 |
}; |
255 |
return query; |
256 |
}, |
257 |
processResults: function (data) { |
258 |
var results = []; |
259 |
data.forEach( function ( pickup_location ) { |
260 |
results.push( |
261 |
{ |
262 |
"id": pickup_location.library_id.escapeHtml(), |
263 |
"text": pickup_location.name.escapeHtml(), |
264 |
"needs_override": pickup_location.needs_override |
265 |
} |
266 |
); |
267 |
}); |
268 |
return { "results": results }; |
269 |
} |
270 |
}, |
271 |
templateResult: display_pickup_location |
272 |
}); |
273 |
}); |
274 |
|
275 |
$(".hold_location_select").on("change", function(){ |
223 |
$(this).prop("disabled",true); |
276 |
$(this).prop("disabled",true); |
224 |
var cur_select = $(this); |
277 |
var cur_select = $(this); |
225 |
var res_id = $(this).attr('reserve_id'); |
278 |
var res_id = $(this).attr('reserve_id'); |
226 |
- |
|
|