Bug 36844: (QA follow-up) Fix preselected options on set-library.pl

I found that when switching from a branch with a default register to one without, the default register for
the last branch was remaining selected (though disabled)

When opening the page if no desk was set (choose 'My library' on initial login) the branch was default to 'No desk' rather than defaulting to the first desk of the current branch

Remove a debugging line as well

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2024-05-15 11:51:54 +00:00 committed by Katrin Fischer
parent dc6dcd13bd
commit c9e7b7442b
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
3 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@
<option id="nodesk" value="">---</option>
[% FOREACH d IN desks %]
[% IF d.branchcode == branch %]
[% IF selected == d.desk_id %]
[% IF selected == d.desk_id || ( selected == '' && loop.first ) %]
<option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" selected="selected">[% d.desk_name | html %]</option>
[% ELSE %]
<option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" >[% d.desk_name | html %]</option>

View file

@ -74,7 +74,7 @@
<ol>
<li><label for="set-library-desk_id">Choose desk:</label>
<select name="desk_id" id="set-library-desk_id">
[% PROCESS options_for_desks desks => Desks.all(), selected => desk_id %]
[% PROCESS options_for_desks desks => Desks.all(), selected => desk_id, branch => branch %]
</select></li>
</ol>
</fieldset>

View file

@ -305,7 +305,6 @@ $(document).ready(function () {
$("#set-library-desk_id")
.children()
.each(function () {
console.log( $(this) );
if ($(this).attr("id") === "nodesk") {
// set no desk by default, should be first element
$(this).prop("selected", true);
@ -316,7 +315,7 @@ $(document).ready(function () {
$("#nodesk").hide();
$(this).prop("disabled", false);
$(this).show();
if ( selectedBranch == $(".logged-in-branch-code").html() ) {
if ( selectedBranch == $(".logged-in-branch-code").html() && $(".logged-in-desk-id").length ) {
$("#set-library-desk_id").val( $(".logged-in-desk-id").html() );
} else {
$("#nodesk").hide();
@ -330,6 +329,7 @@ $(document).ready(function () {
}
});
$("#set-library-register_id").val("");
$("#set-library-register_id").children().each(function() {
// default to no-register
if ($(this).is("#noregister")) {