LP 1548993: Restore Show More/Show Fewer Details button functionality.
authorJason Stephenson <jstephenson@mvlcstaff.org>
Thu, 19 May 2016 19:53:48 +0000 (15:53 -0400)
committerKathy Lussier <klussier@masslnc.org>
Thu, 2 Jun 2016 21:28:39 +0000 (17:28 -0400)
When using a show_more_details.default setting of true in config.tt2,
the Show More/Show Fewer Details button functionality is broken.  The
detail record view is always shown, regardless of the button's state.
This patch attempts to repair the behavior so that the user can toggle
the detail record view even though the default is set to true.

Signed-off-by: Jason Stephenson <jstephenson@mvlcstaff.org>
Signed-off-by: Jeanette Lundgren <jlundgren@cwmars.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/opac/parts/header.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2
Open-ILS/src/templates/opac/parts/searchbar.tt2
Open-ILS/src/templates/opac/results.tt2

index b0d6883..8b60ba9 100644 (file)
     is_advanced = CGI.param("_adv").size;
     is_special = CGI.param("_special").size;
 
+    # Check if we want to show the detail record view.  Doing this
+    # here because we don't want to repeat logic in multiple other
+    # files, nor do we want to add a new tt2 file just for this.  The
+    # below is currently needed for parts/result/table.tt2,
+    # parts/searchbar.tt2, and results.tt2.
+    show_detail_view = 0;
+    IF CGI.param("detail_record_view").defined;
+        show_detail_view = CGI.param("detail_record_view");
+    ELSIF show_more_details.default == "true" OR
+          show_more_details.default == "hide";
+        show_detail_view = 1;
+    END;
+
     #variables to use to remove parameters via mkurk
     expert_search_parms = ['tag','subfield','term','_special'];
     general_search_parms = ['page','sort','query','bool','contains','pubdate'];
index 251d069..960d8c6 100644 (file)
@@ -43,9 +43,7 @@
                     [%  FOR rec IN ctx.records;
                             attrs = {marc_xml => rec.marc_xml};
                             PROCESS get_marc_attrs args=attrs;
-                            IF CGI.param('detail_record_view')
-                                OR (show_more_details.default == 'true'
-                                OR show_more_details.default == 'hide');
+                            IF show_detail_view;
                                 attrs.title = attrs.title_extended;
                             END;
                             # note: rec.id refers to the record identifier, regardless
@@ -146,9 +144,7 @@ END;
                                                             [% format.label | html %]
                                                         [% END %]
                                                     [%- END %]
-                                                    [%- UNLESS CGI.param('detail_record_view')
-                                                            OR (show_more_details.default == 'true'
-                                                            OR show_more_details.default == 'hide');
+                                                    [%- UNLESS show_detail_view;
                                                             IF attrs.pubdate;
                                                                 pubdate_clean = attrs.pubdate | html;
                                                                 l(" ([_1])", pubdate_clean);
@@ -174,10 +170,7 @@ END;
                                                            [% END %]
                                                         [% END %]
 
-                                                        [%- IF CGI.param('detail_record_view')
-                                                            OR (show_more_details.default == 'true'
-                                                            OR show_more_details.default == 'hide');
-                                                        -%]
+                                                        [%- IF show_detail_view -%]
                                                         <!-- These fields are visible when viewing the results page in 'detailed' mode -->
                                                         [% UNLESS rec.mmr_id %]
                                                         <!-- Do not show publication-specific information on a metarecord search results page -->
index bd23358..20088fa 100644 (file)
@@ -60,9 +60,7 @@
         -%]
         </label>
     <span>
-    [%- IF (show_more_details.default == 'true' OR show_more_details.default == 'hide') AND !CGI.param('detail_record_view') %]
-        <input id="detail" type="hidden" name="detail_record_view" value="1"/>
-    [%- END %]
+        <input id="detail" type="hidden" name="detail_record_view" value="[% show_detail_view %]"/>
         <input id='search-submit-go' type="submit" value="[% l('Search') %]" class="opac-button"
             onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden";[% IF ctx.depth_sel_button AND NOT took_care_of_form %] $("search-submit-go-depth").className="hidden";[% END %]}, 2000)'/>
         [%- IF ctx.depth_sel_button AND NOT took_care_of_form %]
index 37c652c..9d5dbf4 100644 (file)
@@ -69,8 +69,8 @@
 
                     [%- IF show_more_details.default != 'hide' -%]
                     <div class='results_header_sel' id='simple-detail-view-links'>
-                        [% IF CGI.param('detail_record_view') %]
-                        <a href="[% mkurl('', {detail_record_view => ''}) %]">[% l('Show Fewer Details') %]</a> [% ELSE %]
+                        [% IF show_detail_view %]
+                        <a href="[% mkurl('', {detail_record_view => 0}) %]">[% l('Show Fewer Details') %]</a> [% ELSE %]
                         <a href="[% mkurl('', {detail_record_view => 1}) %]">[% l('Show More Details') %]</a>
                         [% END %]
                     </div>
                         [% ctx.depth_sel_checkbox_label | html %]
                     </label>
                     [% END %]
-                    [%- IF CGI.param('detail_record_view')
-                        OR (show_more_details.default == 'true'
-                        OR show_more_details.default == 'hide');
-                    -%]
-                        <input type="hidden" name="detail_record_view" value="1" />
-                    [% END %]
                     [% IF ctx.exclude_electronic_checkbox %]
                     <label class="results_header_lbl" for='opac.result.excludeelec'>
                         <input type='checkbox' id='opac.result.excludeelec' name="fi:-search_format" value="electronic"