From 16dfb0309b778725fdb76cadee9943a0344285ed Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Dec 2017 21:35:47 -0300 Subject: [PATCH] Bug 19673: Allow to set patron attributes to 0 with batch patron modification This patch will have to be tested deeply to make sure it will not introduce regression! The idea is to display an empty option in the patron attributes select and ignore it. That way we can deal with false values 0 and "" which were skipped before. Test plan: Add several patron attributes Use the batch patron modification tool to add/update/remove them Play with empty "" and 0 values, as well as other values Modify several attributes in a row Signed-off-by: Charles Farmer Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart Conflicts: koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt --- .../prog/en/modules/tools/modborrowers.tt | 21 +++++++++++++------ tools/modborrowers.pl | 3 --- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index cb06ab4738..dd5277b9ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -77,22 +77,30 @@ function updateAttrValues (select_attr) { var attr_code = $(select_attr).val(); - var type = $(select_attr).find("option:selected").attr('data-type'); - var category = $(select_attr).find("option:selected").attr('data-category'); - var span = $(select_attr).parent().parent().find('span.patron_attributes_value'); - var information_category_node = $(select_attr).parent().parent().find('span.information_category'); + var selected_option = $(select_attr).find("option:selected"); + var type = $(selected_option).attr('data-type'); + var category = $(selected_option).attr('data-category'); + var li_node = $(select_attr).parent().parent(); + var span = $(li_node).find('span.patron_attributes_value'); + var information_category_node = $(li_node).find('span.information_category'); information_category_node.html(""); - if ( category.length > 0 ) { + if ( category && category.length > 0 ) { information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category)); } + var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']"); if ( type == 'select' ) { var options = ''; for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) { options += ''; } span.html(''); + $(disable_input_node).show(); + } else if ( $(selected_option).val() != "" ) { + span.html(''); + $(disable_input_node).show(); } else { - span.html('') + span.html(''); + $(disable_input_node).hide(); } } @@ -379,6 +387,7 @@