View | Details | Raw Unified | Return to bug 31187
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Items/BatchUpdate.t (-1 / +12 lines)
Lines 162-168 subtest 'permanent_location' => sub { Link Here
162
    # to allow explicitly setting a temporary location.
162
    # to allow explicitly setting a temporary location.
163
    # When mapped an empty value is submitted in the form with the key of permanent_location
163
    # When mapped an empty value is submitted in the form with the key of permanent_location
164
164
165
    plan tests => 2;
165
    plan tests => 3;
166
166
167
    $items->batch_update(
167
    $items->batch_update(
168
        {
168
        {
Lines 188-193 subtest 'permanent_location' => sub { Link Here
188
    $item = $item->get_from_storage;
188
    $item = $item->get_from_storage;
189
    is( $item->permanent_location, 'perm', 'Permanent location not updated when mapped, so key present, but no value passed ');
189
    is( $item->permanent_location, 'perm', 'Permanent location not updated when mapped, so key present, but no value passed ');
190
190
191
    $items->batch_update(
192
        {
193
            new_values => {
194
                'location' => 'loc'
195
            }
196
        }
197
    )->reset;
198
199
    $item = $item->get_from_storage;
200
    is( $item->permanent_location, 'loc', 'Permanent location updated to location when not mapped and key not present');
201
191
};
202
};
192
203
193
subtest 'regex' => sub {
204
subtest 'regex' => sub {
(-)a/tools/batchMod.pl (-5 / +5 lines)
Lines 152-167 if ( $op eq "action" ) { Link Here
152
                    };
152
                    };
153
                }
153
                }
154
                else {
154
                else {
155
                    my @v =
155
                    my @form_attr = $input->multi_param($cgi_var_name);
156
                      grep { $_ ne "" } uniq $input->multi_param($cgi_var_name);
156
                    my @values =
157
                      grep { $_ ne "" } uniq @form_attr;
157
158
158
                    next unless @v || $attr eq 'permanent_location';
159
                    next unless @values || ( $attr eq 'permanent_location' && @form_attr );
159
                    # If permanent_location is present in the form we need to pass it forward
160
                    # If permanent_location is present in the form we need to pass it forward
160
                    # to indicate that the user may modify this field directly and so
161
                    # to indicate that the user may modify this field directly and so
161
                    # it needs to be marked as 'dirty' on any update. Otherwise the object always
162
                    # it needs to be marked as 'dirty' on any update. Otherwise the object always
162
                    # sets location to the permanent_location as well
163
                    # sets location to the permanent_location as well
163
164
164
                    $new_item_data->{$attr} = join '|', @v;
165
                    $new_item_data->{$attr} = join '|', @values;
165
                }
166
                }
166
            }
167
            }
167
        }
168
        }
168
- 

Return to bug 31187