|
Lines 1230-1235
Link Here
|
| 1230 |
templateResult: display_pickup_location |
1230 |
templateResult: display_pickup_location |
| 1231 |
}); |
1231 |
}); |
| 1232 |
}); |
1232 |
}); |
|
|
1233 |
$("#pickup").each( function () { |
| 1234 |
var this_dropdown = $(this); |
| 1235 |
var patron_id = $(this).data('patron-id'); |
| 1236 |
var biblio_id = $(this).data('biblio-id'); |
| 1237 |
|
| 1238 |
this_dropdown.select2({ |
| 1239 |
allowClear: false, |
| 1240 |
ajax: { |
| 1241 |
url: '/api/v1/biblios/' + encodeURIComponent(biblio_id) + '/pickup_locations', |
| 1242 |
delay: 300, // wait 300 milliseconds before triggering the request |
| 1243 |
dataType: 'json', |
| 1244 |
data: function (params) { |
| 1245 |
var search_term = (params.term === undefined) ? '' : params.term; |
| 1246 |
var query = { |
| 1247 |
"q": JSON.stringify({"name":{"-like":search_term+'%'}}), |
| 1248 |
"_order_by": "name", |
| 1249 |
"patron_id": patron_id |
| 1250 |
}; |
| 1251 |
return query; |
| 1252 |
}, |
| 1253 |
processResults: function (data) { |
| 1254 |
var results = []; |
| 1255 |
data.forEach( function ( pickup_location ) { |
| 1256 |
results.push( |
| 1257 |
{ |
| 1258 |
"id": pickup_location.library_id.escapeHtml(), |
| 1259 |
"text": pickup_location.name.escapeHtml(), |
| 1260 |
"needs_override": pickup_location.needs_override |
| 1261 |
} |
| 1262 |
); |
| 1263 |
}); |
| 1264 |
return { "results": results }; |
| 1265 |
} |
| 1266 |
}, |
| 1267 |
templateResult: display_pickup_location |
| 1268 |
}); |
| 1269 |
}); |
| 1233 |
}); |
1270 |
}); |
| 1234 |
|
1271 |
|
| 1235 |
function check() { |
1272 |
function check() { |