From: Bill Erickson Date: Fri, 30 Sep 2011 20:01:22 +0000 (-0400) Subject: TPac: Facets on results page X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d28ca61d634511a6bf693b8b4e3da1ef18dcd503;p=evergreen%2Fpines.git TPac: Facets on results page Show search facets along the left side of the results page. Clicking on a facet re-runs the current search with the new facet appeneded. Selected facets are styled to indicate they are selected. Clicking on a selected facet removes that facet from the set of selected facets (i.e. it backs out the facet). TODO: update CSS to match default Evergreen skin Signed-off-by: Bill Erickson Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 635678b982..37fa582254 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -168,7 +168,7 @@ sub load_rresults { } my $page = $cgi->param('page') || 0; - my $facet = $cgi->param('facet'); + my @facets = $cgi->param('facet'); my $limit = $self->_get_search_limit; my $loc = $cgi->param('loc') || $ctx->{aou_tree}->()->id; my $offset = $page * $limit; @@ -229,7 +229,7 @@ sub load_rresults { # Stuff these into the TT context so that templates can use them in redrawing forms $ctx->{processed_search_query} = $query; - $query = "$query $facet" if $facet; # TODO + $query .= " $_" for @facets; $logger->activity("EGWeb: [search] $query"); 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 6af3a7a9fe..3b72dbc556 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -201,13 +201,23 @@ sub get_records_and_facets { # gather up the unapi recs $ses->session_wait(1); - my $facets; + my $facets = {}; if ($facet_key) { - $facets = $facet_req->gather(1); - $facets->{$_} = { - cmf => $self->ctx->{get_cmf}->($_), - data => $facets->{$_} - } for keys %$facets; # quick-n-dirty + my $tmp_facets = $facet_req->gather(1); + for my $cmf_id (keys %$tmp_facets) { + + # sort highest to lowest match count + my @entries; + my $entries = $tmp_facets->{$cmf_id}; + for my $ent (keys %$entries) { + push(@entries, {value => $ent, count => $$entries{$ent}}); + }; + @entries = sort { $b->{count} <=> $a->{count} } @entries; + $facets->{$cmf_id} = { + cmf => $self->ctx->{get_cmf}->($cmf_id), + data => \@entries + } + } } else { $facets = undef; } diff --git a/Open-ILS/src/templates/opac/parts/result/facets.tt2 b/Open-ILS/src/templates/opac/parts/result/facets.tt2 new file mode 100644 index 0000000000..c4a719d6b4 --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/result/facets.tt2 @@ -0,0 +1,95 @@ +
+[% + +close_facets = CGI.param('close_facet') || []; +selected_facets = CGI.param('facet') || []; + +# collect facet type labels for easier sorting +labels = []; +FOR facet IN ctx.search_facets.values; + 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; + fclass = facet.cmf.field_class; + fname = facet.cmf.name; + close_key = fclass _ fname %] + +
+
+
[% facet.cmf.label %]
+
+ + [% IF close_facets.grep(close_key).0; + new_close = []; + FOR fct IN close_facets; + IF fct != close_key; + new_close.push(fct); + END; + END + %] + [% l('Expand') %] + [% ELSE %] + [% l('Collapse') %] + [% END %] +
+
 
+
+ [% IF !close_facets.grep(close_key).0 %] +
+
+ [% FOR facet_data IN facet.data; + display_value = facet_data.value | html; + param_string = fclass _ '|' _ fname _ '[' _ facet_data.value _ ']'; + new_facets = []; + this_selected = 0; + FOR selected IN selected_facets; + IF selected == param_string; + this_selected = 1; + ELSE; + new_facets.push(selected); + END; + END; + IF this_selected; + # This facet is already selected by the user. + # Link removes the facet from the set of selected facets. + %] +
+
+ [% IF new_facets.size == 0 %] + [% display_value %] + [% ELSE %] + [% display_value %] + [% END %] +
+
([% facet_data.count %])
+
 
+
+ [% + ELSE; + # This facet is not currently selected. If selected, + # append this facet to the list of currently active facets. + %] + + [% END %] + [% END %] +
+
 
+
+ [% END %] +
+ [% END %] + [% END %] +[% END %] +
+ diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2 index 0706ef6766..b60e647d72 100644 --- a/Open-ILS/src/templates/opac/parts/result/table.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/table.tt2 @@ -19,8 +19,8 @@ diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index 368dad5a5c..e90a0ef82a 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -886,6 +886,7 @@ div.select-wrapper:hover { } /* some facet styling */ +/* .facetClassContainer { margin: 2px; border: 1px solid #CCC; } .facetClassLabelContainer { border: 1px solid #CCC; } .facetClassLabel { font-weight: bold; text-align: center; } @@ -897,6 +898,77 @@ div.select-wrapper:hover { .facetField { border-top: 1px solid #CCC; } .facetFields { padding-left: 5px; } .facetFieldLineValue { overflow: hidden; text-overflow: ellipsis; } +*/ + +.facet_box_temp { + padding-bottom:3px; + width:180px; + overflow:hidden; +} + +.facet_box_temp .header { + width:180px; + height:31px; + overflow:hidden; + background:url('/images/facet_box_bg.png') no-repeat; + font-weight:bold; + color:#074079; + padding-top:4px; +} + +.facet_box_temp .header .title { + float:left; + padding-top:6px; + padding-left:12px; + width:134px; + overflow:hidden; +} + +.facet_box_temp .header .button { + float:right; + padding-right:6px; +} + +.facet_box_wrapper .box_wrapper { + position:relative; + top:-4px; + margin-bottom:-5px; + *margin-bottom:-6px; +} + +.facet_box_wrapper .box_wrapper .box { + width:166px; + border-top:1px solid #7ebee5; + border-left:1px solid #f3f3f3; + border-right:1px solid #f3f3f3; + background:white; + padding-left:12px; + padding-top:6px; +} + +.facet_box_wrapper .box_wrapper .bottom { + background:url('/images/facet_box_bg_bottom.png') no-repeat; +} + +.facet_template { + padding-bottom:5px; +} + +.facet_template .facet { + float:left; + width:124px; +} + +.facet_template .count { + float:right; + color:#818080; + padding-right:11px; +} + +.facet_template_selected { + background-color: #d7d7d7; +} + #footer-wrap { background: linear-gradient(lightGreen, #252525); background: -moz-linear-gradient(lightGreen, #252525); @@ -904,6 +976,7 @@ div.select-wrapper:hover { background: -webkit-linear-gradient(lightGreen, #252525); background-color: lightGreen; } + #footer { padding-top:5px; padding-bottom: 10px; diff --git a/Open-ILS/web/images/adv_search_minus_btn.png b/Open-ILS/web/images/adv_search_minus_btn.png new file mode 100644 index 0000000000..40505959f7 Binary files /dev/null and b/Open-ILS/web/images/adv_search_minus_btn.png differ diff --git a/Open-ILS/web/images/adv_search_plus_btn.png b/Open-ILS/web/images/adv_search_plus_btn.png new file mode 100644 index 0000000000..7f1ae93a71 Binary files /dev/null and b/Open-ILS/web/images/adv_search_plus_btn.png differ diff --git a/Open-ILS/web/images/facet_box_bg.png b/Open-ILS/web/images/facet_box_bg.png new file mode 100644 index 0000000000..996f0a8331 Binary files /dev/null and b/Open-ILS/web/images/facet_box_bg.png differ diff --git a/Open-ILS/web/images/facet_box_bg_bottom.png b/Open-ILS/web/images/facet_box_bg_bottom.png new file mode 100644 index 0000000000..fc776c3304 Binary files /dev/null and b/Open-ILS/web/images/facet_box_bg_bottom.png differ
-
- SIDEBAR TODO +
+ [% INCLUDE 'opac/parts/result/facets.tt2' %]