Bug 15184: Prepare the ground - Move funds and sort fields autoupdate
We are going to reuse the same logic: when a fund is selected the statistic values are automatically updated. Let move it to make it reusable more easily and isolate the code. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
32a50dc45e
commit
64f445022b
2 changed files with 68 additions and 64 deletions
|
@ -428,6 +428,7 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
|
||||
[% Asset.js("js/acq.js") | $raw %]
|
||||
[% Asset.js("js/funds_sorts.js") | $raw %]
|
||||
<script type="text/JavaScript">
|
||||
$(document).ready(function() {
|
||||
$("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
|
@ -440,70 +441,6 @@
|
|||
"aaSorting": []
|
||||
} ) );
|
||||
|
||||
// keep copy of the inactive budgets
|
||||
disabledBudgetsCopy = $("select[name='all_budget_id']").html();
|
||||
$("select[name='all_budget_id'] .b_inactive").remove();
|
||||
$("select[name='budget_id'] .b_inactive").remove();
|
||||
|
||||
$("#showallbudgets").click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$("select[name='budget_id']").html(disabledBudgetsCopy)
|
||||
}
|
||||
else {
|
||||
$("select[name='budget_id'] .b_inactive").remove();
|
||||
}
|
||||
});
|
||||
|
||||
$("#all_showallbudgets").click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$("select[name='all_budget_id']").html(disabledBudgetsCopy);
|
||||
}
|
||||
else {
|
||||
$("select[name='all_budget_id'] .b_inactive").remove();
|
||||
}
|
||||
});
|
||||
|
||||
$("select[name='budget_id']").change(function(){
|
||||
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
|
||||
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
|
||||
var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
|
||||
var sort1 = $(destination_sort1).val() || "";
|
||||
if ( destination_sort1.length < 1 ) {
|
||||
destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
|
||||
}
|
||||
var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
|
||||
var sort2 = $(destination_sort2).val() || "";
|
||||
if ( destination_sort2.length < 1 ) {
|
||||
destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
|
||||
}
|
||||
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
|
||||
|
||||
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
|
||||
} );
|
||||
|
||||
$("select[name='budget_id']").change();
|
||||
|
||||
$("select[name='all_budget_id']").change(function(){
|
||||
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
|
||||
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
|
||||
var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
|
||||
if ( destination_sort1.length < 1 ) {
|
||||
destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
|
||||
}
|
||||
var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
|
||||
if ( destination_sort2.length < 1 ) {
|
||||
destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
|
||||
}
|
||||
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
|
||||
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
|
||||
$(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
|
||||
$(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
|
||||
$(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
|
||||
$(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
|
||||
} );
|
||||
|
||||
$("select[name='all_budget_id']").change();
|
||||
|
||||
$("#records_to_import fieldset.rows div").hide();
|
||||
$('input:checkbox[name="import_record_id"]').change(function(){
|
||||
var container = $(this).parents("fieldset");
|
||||
|
|
67
koha-tmpl/intranet-tmpl/prog/js/funds_sorts.js
Normal file
67
koha-tmpl/intranet-tmpl/prog/js/funds_sorts.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* getAuthValueDropbox from js/acq.js is needed */
|
||||
$(document).ready(function() {
|
||||
// keep copy of the inactive budgets
|
||||
disabledBudgetsCopy = $("select[name='all_budget_id']").html();
|
||||
$("select[name='all_budget_id'] .b_inactive").remove();
|
||||
$("select[name='budget_id'] .b_inactive").remove();
|
||||
|
||||
$("#showallbudgets").click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$("select[name='budget_id']").html(disabledBudgetsCopy)
|
||||
}
|
||||
else {
|
||||
$("select[name='budget_id'] .b_inactive").remove();
|
||||
}
|
||||
});
|
||||
|
||||
$("#all_showallbudgets").click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$("select[name='all_budget_id']").html(disabledBudgetsCopy);
|
||||
}
|
||||
else {
|
||||
$("select[name='all_budget_id'] .b_inactive").remove();
|
||||
}
|
||||
});
|
||||
|
||||
$("select[name='budget_id']").change(function(){
|
||||
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
|
||||
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
|
||||
var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
|
||||
var sort1 = $(destination_sort1).val() || "";
|
||||
if ( destination_sort1.length < 1 ) {
|
||||
destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
|
||||
}
|
||||
var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
|
||||
var sort2 = $(destination_sort2).val() || "";
|
||||
if ( destination_sort2.length < 1 ) {
|
||||
destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
|
||||
}
|
||||
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
|
||||
|
||||
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
|
||||
} );
|
||||
|
||||
$("select[name='budget_id']").change();
|
||||
|
||||
$("select[name='all_budget_id']").change(function(){
|
||||
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
|
||||
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
|
||||
var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
|
||||
if ( destination_sort1.length < 1 ) {
|
||||
destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
|
||||
}
|
||||
var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
|
||||
if ( destination_sort2.length < 1 ) {
|
||||
destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
|
||||
}
|
||||
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
|
||||
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
|
||||
$(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
|
||||
$(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
|
||||
$(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
|
||||
$(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
|
||||
} );
|
||||
|
||||
$("select[name='all_budget_id']").change();
|
||||
|
||||
});
|
Loading…
Reference in a new issue