Bug 35648: (follow-up) Remove sorting from transport columns
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / desk_selection.js
1 $(document).ready(function() {
2
3     $("#branch").on("change", function() {
4
5         $("#desk_id").children().each(function() {
6             var selectedBranch = $("#branch"). children("option:selected"). val();
7             if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
8                 $(this).prop("selected", true);
9                 $(this).prop("disabled", false);
10                 $(this).show();
11             }
12             else if ($(this).hasClass(selectedBranch)) {
13                 $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
14                 $('#nodesk').hide();
15                 $(this).prop("disabled", false);
16                 $(this).show();
17                 if ( selectedBranch == $(".logged-in-branch-code").html() ) {
18                     $("#desk_id").val($(".logged-in-desk-id").html());
19                 }
20                 else {
21                     $("#desk_id").val($("#desk_id option:not([disabled]):first").val());
22                 }
23             } else {
24                 $(this).prop("disabled", true);
25                 $(this).hide();
26             }
27         });
28     });
29 });