Bug 27894: Add visual feedback on overridden pickup locations
This patch takes advantage of the previous changes, and makes the select2 dropdown display a warning sign (with a tooltip) on pickup locations that, if chosen, it would mean a circ rule would be overridden. To test: 1. Have some pickup locations that are not valid for existing holds and AllowHoldPolicyOverride set to "Don't allow" 2. Visit a biblio with some holds 3. Choose a hold that cannot use some pickup location and use the dropdown => SUCCESS: Only valid pickup locations are retrieved 4. Set Allow HoldPolicyOverride to "Allow" 5. Refresh the page (I usually click on the Holds tab) 6 .Repeat 3 => SUCCESS: All pickup locations in the system are displayed => FAIL: No visual feedback on overridden pickup locations :-( 7. Apply this patch and refresh the page 8. Repeat 3 => SUCCESS: All pickup locations in the systema are displayed => SUCCESS: Visual feedback on overridden pickup locations is shown! 9. Set AllowHoldPolicyOverride to "Don't allow" 10. Repeat 3 => SUCCESS: Only valid pickup locations are retrieved => SUCCESS: No overrridden warn/symbol, as expected 11. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
d8be3d5084
commit
d2a4691638
|
|
@ -1179,6 +1179,22 @@
|
|||
});
|
||||
[% END %]
|
||||
|
||||
function display_pickup_location (state) {
|
||||
var $text;
|
||||
if ( state.needs_override === true ) {
|
||||
$text = $(
|
||||
'<span>' + state.text + '</span> <span style="float:right;" title="' +
|
||||
_("This pickup location is not allowed according to circulation rules") +
|
||||
'"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>'
|
||||
);
|
||||
}
|
||||
else {
|
||||
$text = $('<span>'+state.text+'</span>');
|
||||
}
|
||||
|
||||
return $text;
|
||||
};
|
||||
|
||||
$(".pickup_location_dropdown").each( function () {
|
||||
var this_dropdown = $(this);
|
||||
var hold_id = $(this).data('hold_id');
|
||||
|
|
@ -1186,34 +1202,32 @@
|
|||
this_dropdown.select2({
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
[%- IF Koha.Preference('AllowHoldPolicyOverride') -%]
|
||||
url: '/api/v1/libraries',
|
||||
[%- ELSE -%]
|
||||
url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations',
|
||||
[%- END -%]
|
||||
delay: 300, // wait 300 milliseconds before triggering the request
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
var search_term = (params.term === undefined) ? '' : params.term;
|
||||
var query = {
|
||||
"q": JSON.stringify({"name":{"-like":search_term+'%'},"pickup_location":1}),
|
||||
"q": JSON.stringify({"name":{"-like":search_term+'%'}}),
|
||||
"_order_by": "name"
|
||||
};
|
||||
return query;
|
||||
},
|
||||
processResults: function (data) {
|
||||
var results = [];
|
||||
data.forEach( function ( library ) {
|
||||
data.forEach( function ( pickup_location ) {
|
||||
results.push(
|
||||
{
|
||||
"id": library.library_id.escapeHtml(),
|
||||
"text": library.name.escapeHtml()
|
||||
"id": pickup_location.library_id.escapeHtml(),
|
||||
"text": pickup_location.name.escapeHtml(),
|
||||
"needs_override": pickup_location.needs_override
|
||||
}
|
||||
);
|
||||
});
|
||||
return { "results": results };
|
||||
}
|
||||
}
|
||||
},
|
||||
templateResult: display_pickup_location
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue