From 9ef0d32e369c0501746dd0cc3edfb81a7cecff43 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 11 Oct 2011 11:33:28 -0400 Subject: [PATCH] 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 --- .../src/templates/opac/parts/advanced/global_row.tt2 | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) 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; -- 2.11.0