LP173259 - Array error appears in search box while placing hold after advanced search
authorDan Pearl <dpearl@cwmars.org>
Fri, 2 Mar 2018 18:37:43 +0000 (13:37 -0500)
committerDan Wells <dbw2@calvin.edu>
Mon, 30 Apr 2018 18:29:16 +0000 (14:29 -0400)
The place-hold code assumed it was not in "_adv" parameter mode.  This
assumption was faulty.  Now, the link generated for Place Hold will
translate the argument list to the single-line format that Place Hold
expected, when necessary.

Testing procedure:

Set holds for all the following items, observing that the searchbox in
the searchbar is not blank and does not contain ARRAY(xxx).

Basic Search / Place Hold
Basic Search / Record Detail / Place Hold
Advanced Search with a plain search term / Place Hold
Advanced Search with a plain search term / Record Detail / Place Hold
Advanced Search with a fancy (multiline) search term / Place Hold
Advanced Search with a fancy (multiline) search term / Record Detail / Place Hold

Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/templates/opac/parts/result/table.tt2

index c913555..432dffa 100644 (file)
                             IF rec.mmr_id;
                                 IF rec.mr_constituent_count > 1;
                                     # metarecords link to record list page
-                                    record_url = mkurl(ctx.opac_root _ '/results', 
-                                        {metarecord => rec.mmr_id}, ['page']);
+                                    record_url_path = ctx.opac_root _ '/results'; 
+                                    add_parms = {metarecord => rec.mmr_id};
+                                    del_parms = ['page'];
                                 ELSE;
                                     # for MR, bre_id refers to the master and in
                                     # this case, only, record
-                                    record_url = mkurl(ctx.opac_root _ '/record/' _ attrs.mr_constituent_ids.0, { badges => rec.badges.join(',') });
+                                    record_url_path = ctx.opac_root _ '/record/' _ attrs.mr_constituent_ids.0;
+                                    add_parms = { badges => rec.badges.join(',') };
+                                    del_parms = [];
                                 END;
                                 hold_type = 'M';
                             ELSE;
-                                record_url = mkurl(ctx.opac_root _ '/record/' _ rec.bre_id, { badges => rec.badges.join(',') });
+                                record_url_path = ctx.opac_root _ '/record/' _ rec.bre_id; 
+                                add_parms = { badges => rec.badges.join(',') };
+                                del_parms = [];
                                 hold_type = 'T';
                             END;
-                    -%]
+
+                            IF is_advanced; 
+                                   # Do not pass "advanced params" to result detail code.
+                                   # Instead, pass the scrubed query in one-line form
+                                   del_parms = del_parms.merge(['query', 'bool', 
+                                                    'qtype', 'contains', '_adv']);
+                                   add_parms.import(
+                                        {query => ctx.naive_query_scrub(ctx.user_query)} );
+                            END;
+                        %]
                         <tr class="result_table_row">
                                             <td class="results_row_count" name="results_row_count">[%
                                                     result_count; result_count = result_count + 1
                                                 %].</td>
                                             <td class='result_table_pic_header'>
-                                                <a href="[% record_url %]"><img alt="[% l('Book cover') %]"
+                                                <a href="[% mkurl(record_url_path, add_parms, del_parms); %]">
+                                                 <img alt="[% l('Book cover') %]"
                                                         name='item_jacket' class='result_table_pic' width="55"
                                                         src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/r/[% rec.bre_id | uri %]' /></a><br />
                                             </td>
@@ -386,10 +401,25 @@ END;
             && (ctx.holds_block.enabled != 'true' || attrs.org_copy_counts.$search_ou.available == 0)
         )
 %]
+
+                                                        [% del_parms = ['tag','subfield','term','_special',
+                                                                   'sort','page'];
+                                                        add_parms = {hold_target => rec.id, 
+                                                                     hold_type => hold_type, 
+                                                                     hold_source_page => mkurl()};
+
+                                                        IF is_advanced;
+                                                            # Do not pass "advanced params" to hold code
+                                                            # Instead, pass the scrubed query in one-line form
+                                                            del_parms = del_parms.merge(['query', 'bool', 
+                                                                            'qtype', 'contains', '_adv']);
+                                                            add_parms.import(
+                                                                {query => ctx.naive_query_scrub(ctx.user_query)});
+                                                        END; %]
+
                                                         <div class="results_aux_utils place_hold"><a
                                                                 href="[% mkurl(ctx.opac_root _ '/place_hold',
-                                                                    {hold_target => rec.id, hold_type => hold_type, 
-                                                                      hold_source_page => mkurl()}, ['tag','subfield','term','_special','sort','page']) %]"
+                                                                    add_parms, del_parms) %]"
                                                                 [% html_text_attr('title', l('Place Hold on [_1]', attrs.title)) %]
                                                                     class="no-dec" rel="nofollow" vocab=""><img
                                                                 src="[% ctx.media_prefix %]/images/green_check.png[% ctx.cache_key %]"