Lines 1157-1162
Link Here
|
1157 |
}); |
1157 |
}); |
1158 |
[% END %] |
1158 |
[% END %] |
1159 |
|
1159 |
|
|
|
1160 |
function display_pickup_location (state) { |
1161 |
var $text; |
1162 |
if ( state.needs_override === true ) { |
1163 |
$text = $( |
1164 |
'<span>' + state.text + '</span> <span style="float:right;" title="' + |
1165 |
_("This pickup location is not allowed according to circulation rules") + |
1166 |
'"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>' |
1167 |
); |
1168 |
} |
1169 |
else { |
1170 |
$text = $('<span>'+state.text+'</span>'); |
1171 |
} |
1172 |
|
1173 |
return $text; |
1174 |
}; |
1175 |
|
1160 |
$(".pickup_location_dropdown").each( function () { |
1176 |
$(".pickup_location_dropdown").each( function () { |
1161 |
var this_dropdown = $(this); |
1177 |
var this_dropdown = $(this); |
1162 |
var hold_id = $(this).data('hold_id'); |
1178 |
var hold_id = $(this).data('hold_id'); |
Lines 1164-1197
Link Here
|
1164 |
this_dropdown.select2({ |
1180 |
this_dropdown.select2({ |
1165 |
allowClear: false, |
1181 |
allowClear: false, |
1166 |
ajax: { |
1182 |
ajax: { |
1167 |
[%- IF Koha.Preference('AllowHoldPolicyOverride') -%] |
|
|
1168 |
url: '/api/v1/libraries', |
1169 |
[%- ELSE -%] |
1170 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations', |
1183 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations', |
1171 |
[%- END -%] |
|
|
1172 |
delay: 300, // wait 300 milliseconds before triggering the request |
1184 |
delay: 300, // wait 300 milliseconds before triggering the request |
1173 |
dataType: 'json', |
1185 |
dataType: 'json', |
1174 |
data: function (params) { |
1186 |
data: function (params) { |
1175 |
var search_term = (params.term === undefined) ? '' : params.term; |
1187 |
var search_term = (params.term === undefined) ? '' : params.term; |
1176 |
var query = { |
1188 |
var query = { |
1177 |
"q": JSON.stringify({"name":{"-like":search_term+'%'},"pickup_location":1}), |
1189 |
"q": JSON.stringify({"name":{"-like":search_term+'%'}}), |
1178 |
"_order_by": "name" |
1190 |
"_order_by": "name" |
1179 |
}; |
1191 |
}; |
1180 |
return query; |
1192 |
return query; |
1181 |
}, |
1193 |
}, |
1182 |
processResults: function (data) { |
1194 |
processResults: function (data) { |
1183 |
var results = []; |
1195 |
var results = []; |
1184 |
data.forEach( function ( library ) { |
1196 |
data.forEach( function ( pickup_location ) { |
1185 |
results.push( |
1197 |
results.push( |
1186 |
{ |
1198 |
{ |
1187 |
"id": library.library_id.escapeHtml(), |
1199 |
"id": pickup_location.library_id.escapeHtml(), |
1188 |
"text": library.name.escapeHtml() |
1200 |
"text": pickup_location.name.escapeHtml(), |
|
|
1201 |
"needs_override": pickup_location.needs_override |
1189 |
} |
1202 |
} |
1190 |
); |
1203 |
); |
1191 |
}); |
1204 |
}); |
1192 |
return { "results": results }; |
1205 |
return { "results": results }; |
1193 |
} |
1206 |
} |
1194 |
} |
1207 |
}, |
|
|
1208 |
templateResult: display_pickup_location |
1195 |
}); |
1209 |
}); |
1196 |
}); |
1210 |
}); |
1197 |
}); |
1211 |
}); |
1198 |
- |
|
|