Koha/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js
Nicolas Legrand 4163f24014 Bug 24201: (follow-up) add desk choice with library choice
You should be able to add desk choice when you are logging in or
changing library.

Test plan:

1. apply patch
2. have at least three libraries, one without desk, one with one and
one with a few.
3. At login, when choosing a library, it should enable all desks it
has. Pick one.
4. the desk id and name should be set in your session and appear in
the top right, next to the library name.
5. change library and desks from intranet (at the set-library.pl page)
6. you should have the same behaviours
7. if you have a library without a desk, it should prompt you a '---'
option and no desks will be attached to the session.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-08-07 16:54:40 +02:00

42 lines
1.6 KiB
JavaScript

$(document).ready(function() {
$("#desk_id").children().each(function() {
var selectedBranch = $("#branch"). children("option:selected"). val();
if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
$(this).prop("selected", true);
$(this).prop("disabled", false);
$(this).show();
}
else if ($(this).hasClass(selectedBranch)) {
$('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
$('#nodesk').hide();
$(this).prop("disabled", false);
$(this).show();
$(this).prop("selected", true)
} else {
$(this).prop("disabled", true);
$(this).hide();
}
});
$("#branch").on("change", function() {
$("#desk_id").children().each(function() {
var selectedBranch = $("#branch"). children("option:selected"). val();
if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
$(this).prop("selected", true);
$(this).prop("disabled", false);
$(this).show();
}
else if ($(this).hasClass(selectedBranch)) {
$('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
$('#nodesk').hide();
$(this).prop("disabled", false);
$(this).show();
$(this).prop("selected", true)
} else {
$(this).prop("disabled", true);
$(this).hide();
}
});
});
}) ;