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 <charles.farmer@inLibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Conflicts:
	koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt

(cherry picked from commit 16dfb0309b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2017-12-20 21:35:47 -03:00 committed by Fridolin Somers
parent bbd9325893
commit 5fba0ba123
2 changed files with 15 additions and 9 deletions

View File

@ -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 = '<option value = ""></option>';
for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
}
span.html('<select name="patron_attributes_value">' + options + '</select>');
$(disable_input_node).show();
} else if ( $(selected_option).val() != "" ) {
span.html('<input type="text" name="patron_attributes_value"/>');
$(disable_input_node).show();
} else {
span.html('<input type="text" name="patron_attributes_value"/>')
span.html('');
$(disable_input_node).hide();
}
}
@ -379,6 +387,7 @@
<li class="attributes">
<label style="width:auto;">Attribute:
<select name="patron_attributes">
<option value=""></option>
[% FOREACH pac IN patron_attributes_codes %]
<option value="[% pac.attribute_code %]" data-type="[% pac.type %]" data-category="[% pac.category_lib %]">[% pac.attribute_lib %]</option>
[% END %]

View File

@ -312,9 +312,6 @@ if ( $op eq 'do' ) {
};
push @errors, { error => $@ } if $@;
} else {
# Attribute's value is empty, we don't want to modify it
++$i and next if not $attribute->{attribute};
eval {
C4::Members::Attributes::UpdateBorrowerAttribute( $borrowernumber, $attribute );
};