From: Bill Erickson Date: Tue, 11 Oct 2011 15:33:28 +0000 (-0400) Subject: TPac; repairs to advanced search query propagation X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9ef0d32e369c0501746dd0cc3edfb81a7cecff43;p=evergreen%2Fpines.git TPac; repairs to advanced search query propagation In some cases, TPac will duplicate components of an advanced search query into the advanced search rows. This patch fixes that with better array handling, particularly with CGI param search components that do not have corresponding analogs at a given array position (i.e. starting out with arrays of different sizes) Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 b/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 index 66ecea427e..02aa5d17b2 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/global_row.tt2 @@ -7,20 +7,14 @@ ]; contains = CGI.param('contains'); queries = CGI.param('query'); - bools = CGI.param('bool') || ['and' x 3]; - qtypes = CGI.param('qtype') || ['keyword' x 3]; + bools = CGI.param('bool'); + qtypes = CGI.param('qtype'); + rowcount = 3; - IF !qtypes.0; # not an array - qtypes = [qtypes]; - bools = [bools]; - queries = [queries]; - END; - - WHILE qtypes.size < 3; - qtypes.push('keyword'); - bools.push('and'); - queries.push(''); - END; + # scalar.merge treats the scalar as a 1-item array + WHILE queries.size < rowcount; queries = queries.merge(['']); END; + WHILE bools.size < rowcount; bools = bools.merge(['and']); END; + WHILE qtypes.size < rowcount; qtypes = qtypes.merge(['keyword']); END; FOR qtype IN qtypes; c = contains.shift;