Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
   http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items
   from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items
   from Centervile.
4- Test other use cases, like 'is' and 'is not' for multiple choices

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit eae74ed6d9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 0513ffa58e)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2024-04-11 10:40:16 +00:00 committed by Lucas Gass
parent 3884ed2b25
commit 0713fec177
2 changed files with 15 additions and 7 deletions

View file

@ -119,14 +119,21 @@ if ( defined $format ) {
filters => [],
};
foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn)) {
if (my @q = $cgi->multi_param($p)) {
if ($q[0] ne '') {
foreach
my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn))
{
my @q;
@q = $cgi->multi_param( $p . "[]" );
if ( scalar @q == 0 ) {
@q = $cgi->multi_param($p);
}
if (@q) {
if ( $q[0] ne '' ) {
my $f = {
field => $p,
query => \@q,
};
if (my $op = scalar $cgi->param($p . '_op')) {
if ( my $op = scalar $cgi->param( $p . '_op' ) ) {
$f->{operator} = $op;
}
push @{ $filter->{filters} }, $f;

View file

@ -461,10 +461,11 @@
type: 'POST',
data: function ( d ) {
for (i in params) {
if (! d.hasOwnProperty(params[i].name) ) {
d[params[i].name] = [];
if(d[params[i].name]){
d[params[i].name] = [].concat(d[params[i].name], params[i].value);
}else{
d[params[i].name] = params[i].value;
}
d[params[i].name].push(params[i].value);
}
d.format = 'json';
d.columns = JSON.stringify( d.columns );