Bug 37246: Use the same dropdown for filtering and editing/adding budgets
This patch removes a second fetch of budgets form the db, and clones the dropdown in the template as we will only ever be displaying one of them at a time. The JS is moved to fire for both operations. To test: 1 - Create an active and inactive budget in acquisitions 2 - Add funs to both 3 - Visit - Acquisitions -> Suggestions 4 - Click 'Acquisition information' under filters on the left 5 - Note all funds are showing 6 - Apply patch 7 - Reload 8 - Note you only see active budgets 9 - Check the box to show inactive, verify they show 10 - Filter by an inactive budget 11 - Confirm selection remains 12 - Add a suggestion and verify budget dropdown works 13 - Edit the suggestion and verify budget dropdown works Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
905932e451
commit
12a9e98d2d
2 changed files with 24 additions and 35 deletions
|
@ -605,7 +605,7 @@
|
|||
[% END %]
|
||||
</select>
|
||||
<label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
|
||||
<input type="checkbox" id="showallfunds" />
|
||||
<input type="checkbox" class="showallfunds" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="quantity">Copies:</label>
|
||||
|
@ -1219,22 +1219,25 @@
|
|||
<fieldset class="brief acquisition_information">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="budgetid"> Book fund:</label>
|
||||
<label for="budgetid">Fund:</label>
|
||||
<select name="budgetid" id="budgetid">
|
||||
<option value="__ANY__">Any</option>
|
||||
[% IF budgetid == '__NONE__' %]
|
||||
<option value="__NONE__" selected="selected">None</option>
|
||||
[% ELSE %]
|
||||
<option value="__NONE__">None</option>
|
||||
[% END %]
|
||||
[% FOREACH budgetsloo IN budgetsloop %]
|
||||
[% IF ( budgetsloo.selected ) %]
|
||||
<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>
|
||||
[% FOREACH budget IN sugg_budgets %]
|
||||
[% IF ( budget.selected ) %]
|
||||
<option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
|
||||
[% ELSIF ( budget.b_active ) %]
|
||||
<option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
|
||||
[% ELSE %]
|
||||
<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>
|
||||
<option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</select>
|
||||
<label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
|
||||
<input type="checkbox" class="showallfunds" />
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset> <!-- /#acquisition_information -->
|
||||
|
@ -1325,6 +1328,20 @@
|
|||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
//keep a copy of all budgets before removing the inactives
|
||||
var budgetId = $("#budgetid");
|
||||
var disabledBudgetsCopy = budgetId.html();
|
||||
$('.b_inactive').remove();
|
||||
|
||||
$('.showallfunds').click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
budgetId.html(disabledBudgetsCopy); //Puts back all the funds
|
||||
}
|
||||
else {
|
||||
$('.b_inactive').remove();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
[% IF ( op == 'show' || op == 'else' ) %]
|
||||
|
@ -1483,19 +1500,6 @@
|
|||
$('#notify').prop('checked', false).prop('disabled', true);
|
||||
});
|
||||
|
||||
//keep a copy of all budgets before removing the inactives
|
||||
var budgetId = $("form#add_edit #budgetid");
|
||||
var disabledBudgetsCopy = budgetId.html();
|
||||
$('.b_inactive').remove();
|
||||
|
||||
$('#showallfunds').click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
budgetId.html(disabledBudgetsCopy); //Puts back all the funds
|
||||
}
|
||||
else {
|
||||
$('.b_inactive').remove();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -470,21 +470,6 @@ $template->param( returnsuggestedby => $returnsuggestedby );
|
|||
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
|
||||
$template->param(patron_reason_loop=>$patron_reason_loop);
|
||||
|
||||
# Budgets for filtering
|
||||
my $budgets = GetBudgets;
|
||||
my @budgets_loop;
|
||||
foreach my $budget ( @{$budgets} ) {
|
||||
next unless (CanUserUseBudget($borrowernumber, $budget, $userflags));
|
||||
|
||||
## Please see file perltidy.ERR
|
||||
$budget->{'selected'} = 1
|
||||
if ($$suggestion_ref{'budgetid'}
|
||||
&& $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'});
|
||||
|
||||
push @budgets_loop, $budget;
|
||||
}
|
||||
$template->param( budgetsloop => \@budgets_loop);
|
||||
|
||||
# Budgets for suggestion add or edition
|
||||
my $sugg_budget_loop = [];
|
||||
my $sugg_budgets = GetBudgetHierarchy();
|
||||
|
|
Loading…
Reference in a new issue