[open-ils-commits] [GIT] Evergreen ILS branch master updated. 7e35393865d42452a366b8be734ce81c0a1e9892

Evergreen Git git at git.evergreen-ils.org
Tue Oct 16 21:17:12 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  7e35393865d42452a366b8be734ce81c0a1e9892 (commit)
      from  c3e39cf81df60b372ce42a94bda822c717fbe5d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7e35393865d42452a366b8be734ce81c0a1e9892
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Thu Oct 11 16:00:36 2012 -0400

    TPAC: Make facet display work as in JSPAC
    
    Namely, this means:
        - You see five facets per category by default, not ten.
        - You can click a link to see all the facets in a category
            (before this it was impossible to display more than ten).
        - When viewing all the facets in a category, you can click a link
            to reduce the list back to five.
        - This number five I'm talking about is configurable in config.tt2.
        - Alphabetical sorting of facets grouped by the same numbers of
          results is restored.
    
    This addresses LP #1065109.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
index 4dc5ea0..660b20e 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -299,7 +299,7 @@ sub get_records_and_facets {
     # collect the facet data
     my $search = OpenSRF::AppSession->create('open-ils.search');
     my $facet_req = $search->request(
-        'open-ils.search.facet_cache.retrieve', $facet_key, 10
+        'open-ils.search.facet_cache.retrieve', $facet_key
     ) if $facet_key;
 
     # gather up the unapi recs
@@ -318,7 +318,13 @@ sub get_records_and_facets {
             for my $ent (keys %$entries) {
                 push(@entries, {value => $ent, count => $$entries{$ent}});
             };
-            @entries = sort { $b->{count} <=> $a->{count} } @entries;
+
+            # Sort facet entries by 1) count descending, 2) text ascending
+            @entries = sort {
+                $b->{count} <=> $a->{count} ||
+                $a->{value} cmp $b->{value}
+            } @entries;
+
             $facets->{$cmf_id} = {
                 cmf => $self->ctx->{get_cmf}->($cmf_id),
                 data => \@entries
diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2
index c22b9ce..b5c7418 100644
--- a/Open-ILS/src/templates/opac/css/style.css.tt2
+++ b/Open-ILS/src/templates/opac/css/style.css.tt2
@@ -970,9 +970,11 @@ div.facet_sidebar {
     overflow:hidden;
 }
 
-.facet_box_temp .header .button {
+.facet_box_temp .header a.button {
     float:right;
+    padding-top:6px;
     padding-right:6px;
+    color:[% css_colors.text_invert %];
 }
 
 .facet_box_wrapper .box_wrapper {
diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2
index 2985f1f..b0fee8f 100644
--- a/Open-ILS/src/templates/opac/parts/config.tt2
+++ b/Open-ILS/src/templates/opac/parts/config.tt2
@@ -77,6 +77,7 @@ facet.display = [
     {facet_class => 'series',  facet_order => ['seriestitle']},
     {facet_class => 'subject', facet_order => ['name', 'geographic']}
 ];
+facet.default_display_count = 5;
 
 ##############################################################################
 # Define the advanced search limiters and labels.
diff --git a/Open-ILS/src/templates/opac/parts/result/facets.tt2 b/Open-ILS/src/templates/opac/parts/result/facets.tt2
index dd27dd9..fed133a 100644
--- a/Open-ILS/src/templates/opac/parts/result/facets.tt2
+++ b/Open-ILS/src/templates/opac/parts/result/facets.tt2
@@ -1,12 +1,15 @@
 <div class="facet_box_wrapper">
 [% 
 
-close_facets = CGI.param('close_facet') || [];
+long_facets = CGI.param('long_facet') || [];
 selected_facets = CGI.param('facet') || [];
 
 # sorted list of search facets
 sorted_facets = [];
 
+# we'll clobber the facet. "namespace" later
+DEFAULT_DISPLAY_COUNT = facet.default_display_count;
+
 IF facet.display;
 
     # facet display configuration present.  Traverse the 
@@ -37,46 +40,38 @@ ELSE;
         labels.push(facet.cmf.label);
     END;
     
-    FOR facet_label IN labels.sort;
-        FOR facet IN ctx.search_facets.values;
-            IF facet.cmf.label == facet_label;
-                sorted_facets.push(facet);
-            END;
-        END;
-    END;
+    # We used to do a sort here, but now that's handled in EGCatLoader.
+    sorted_facets = ctx.search_facets.values;
 END;
 
+display_count_by_cmf = {};
+
 FOR facet IN sorted_facets;
     fclass = facet.cmf.field_class;
     fname = facet.cmf.name;
-    close_key = fclass _ fname %]
+    fid = facet.cmf.id;
+    long_key = fclass _ fname %]
 
     <div class="facet_box_temp">
         <div class="header">
-            <span class="button">
-
-                [% IF close_facets.grep(close_key).0;
-                    new_close = [];
-                    FOR fct IN close_facets;
-                        IF fct != close_key;
-                            new_close.push(fct);
+                [% IF long_facets.grep(long_key).0;
+                    new_long = [];
+                    FOR fct IN long_facets;
+                        IF fct != long_key;
+                            new_long.push(fct);
                         END;
                     END;
-                    expand_url = mkurl('', {close_facet => new_close});
-                    IF new_close.size == 0;
-                        expand_url  = mkurl('', {}, ['close_facet']);
+                    expand_url = mkurl('', {long_facet => new_long});
+                    IF new_long.size == 0;
+                        expand_url  = mkurl('', {}, ['long_facet']);
                     END;
                 %]
-                    <a href="[% expand_url %]"><img 
-                        src="[% ctx.media_prefix %]/images/adv_search_plus_btn.png" alt="[% l('Expand') %]" /></a>
-                [% ELSE %]
-                    <a href="[% mkurl('', {close_facet => close_facets.merge([close_key])}) %]"><img 
-                        src="[% ctx.media_prefix %]/images/adv_search_minus_btn.png" alt="[% l('Collapse') %]" /></a>
+                    <a class="button" href="[% expand_url %]">[% l("Fewer") %]</a>
+                [% ELSIF facet.data.size > DEFAULT_DISPLAY_COUNT %]
+                    <a class="button" href="[% mkurl('', {long_facet => long_facets.merge([long_key])}) %]">[% l("More") %]</a>
                 [% END %]
-            </span>
             <div class="title">[% facet.cmf.label %]</div>
         </div>
-        [% IF !close_facets.grep(close_key).0 %]
         <div class="box_wrapper">
             <div class="box">
             [% FOR facet_data IN facet.data;
@@ -91,6 +86,16 @@ FOR facet IN sorted_facets;
                         new_facets.push(selected);
                     END;
                 END;
+
+                display_count_by_cmf.$fid = display_count_by_cmf.$fid || 0;
+
+                NEXT UNLESS long_facets.grep(long_key).0 OR
+                    display_count_by_cmf.$fid < DEFAULT_DISPLAY_COUNT;
+
+                # fix syntax highlighting: >
+
+                display_count_by_cmf.$fid = display_count_by_cmf.$fid + 1;
+
                 IF this_selected;
                     # This facet is already selected by the user. 
                     # Link removes the facet from the set of selected facets.
@@ -122,7 +127,6 @@ FOR facet IN sorted_facets;
             [% END %]
             </div>
         </div> <!-- box_wrapper -->
-        [% END %]
     </div> <!-- facet_box_temp -->
 [% END %]
 </div> <!-- facet_box_wrapper -->

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm   |   10 +++-
 Open-ILS/src/templates/opac/css/style.css.tt2      |    4 +-
 Open-ILS/src/templates/opac/parts/config.tt2       |    1 +
 .../src/templates/opac/parts/result/facets.tt2     |   58 +++++++++++---------
 4 files changed, 43 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list