From d28ca61d634511a6bf693b8b4e3da1ef18dcd503 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 30 Sep 2011 16:01:22 -0400 Subject: [PATCH] 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 --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 4 +- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 22 +++-- .../src/templates/opac/parts/result/facets.tt2 | 95 +++++++++++++++++++++ Open-ILS/src/templates/opac/parts/result/table.tt2 | 4 +- Open-ILS/web/css/skin/default/opac/style.css | 73 ++++++++++++++++ Open-ILS/web/images/adv_search_minus_btn.png | Bin 0 -> 1292 bytes Open-ILS/web/images/adv_search_plus_btn.png | Bin 0 -> 1388 bytes Open-ILS/web/images/facet_box_bg.png | Bin 0 -> 449 bytes Open-ILS/web/images/facet_box_bg_bottom.png | Bin 0 -> 308 bytes 9 files changed, 188 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/templates/opac/parts/result/facets.tt2 create mode 100644 Open-ILS/web/images/adv_search_minus_btn.png create mode 100644 Open-ILS/web/images/adv_search_plus_btn.png create mode 100644 Open-ILS/web/images/facet_box_bg.png create mode 100644 Open-ILS/web/images/facet_box_bg_bottom.png 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 0000000000000000000000000000000000000000..40505959f724a7c2d45f0a390d65beb419bfe97f GIT binary patch literal 1292 zcmV+n1@roeP)Mt zU3FT}u?xEk>#k(9W$b1*yDCf=DJv63H|UhDP&#|JB8)-lD&4$t6mP~ZhC`e%!(;{5 zIbmX}m4Qu0oj*yeCOPNi{AACYo|7JR)2Ig?&dHbW`=0N8-oKAMbEcE2@bLg%>&;p) zfdZfaawVGx`~1%V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 HcmV?d00001 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 0000000000000000000000000000000000000000..996f0a8331a6212ed0953d938326b63231733e9a GIT binary patch literal 449 zcmeAS@N?(olHy`uVBq!ia0vp^TYy-ZgAGX9u2VP(q$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~;1Ffb;2x;TbZ+UhH-+(EEWL8`4(IcxYny`Ny1yO}O`W*> z@Q{( zJaZG%Q-e|yQz{EjrrH1%UGsEt45_&F=B7Q@Ap;S%g3DT$l+rF-jCFTU|E|-Qrzdwn zdPg2umdKI;Vst E0I+|0bpQYW literal 0 HcmV?d00001 -- 2.11.0
-
- SIDEBAR TODO +
+ [% INCLUDE 'opac/parts/result/facets.tt2' %]