From: Galen Charlton Date: Tue, 4 Oct 2016 21:00:15 +0000 (-0400) Subject: LP#1005040: add filter control widget for publication year X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3d917fb818193f409d03845eb1b63b3d6956399f;p=evergreen%2Fpines.git LP#1005040: add filter control widget for publication year This patch also changes the rewriting of an "is" pubdate filter from between(value,value) to date1(value), which should be slightly faster. Signed-off-by: Galen Charlton --- 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 d234753a57..c5a5307879 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -108,8 +108,7 @@ sub _prepare_biblio_search { $btw .= ')'; $query = "$btw $query"; } elsif ($cgi->param('pubdate') eq 'is') { - $query = 'between(' . $cgi->param('date1') . - ',' . $cgi->param('date1') . ") $query"; # sic, date1 twice + $query = 'date1(' . $cgi->param('date1') . ") $query"; } else { $query = $cgi->param('pubdate') . '(' . $cgi->param('date1') . ") $query"; diff --git a/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 b/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 index ca3cbf00fe..dbe712ffd4 100644 --- a/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 @@ -5,6 +5,8 @@ # as that's got its own widget ignore_filters = ['search_format']; +pubdate_filters = ['date1', 'before', 'after', 'between']; + FOR filter IN ctx.query_struct.filters; fname = filter.name; IF ignore_filters.grep('^' _ fname _ '$').size; @@ -14,7 +16,8 @@ FOR filter IN ctx.query_struct.filters; fvalues = filter.args; crad = ctx.get_crad(fname); - IF crad; # will be some special ones, like locations + # will be some special ones, like locations + IF crad AND NOT pubdate_filters.grep('^' _ filter.name _ '$').size; remove_filter = 'fi:' _ fname; %]
@@ -75,7 +78,33 @@ FOR filter IN ctx.query_struct.filters;
- [% END; # IF locations %] +[% END; # IF locations %] + +[% IF pubdate_filters.grep('^' _ filter.name _ '$').size; + date1 = CGI.param('date1'); + date2 = CGI.param('date2'); +%] +
+
+ + [% l("Remove") %] + +

[% IF filter.negate; l('Not'); END %] [% l('Publication Year') %]

+
+
+
+ [% IF filter.name == 'date1' %][% l('[_1]', date1) %] + [% ELSIF filter.name == 'before' %][% l('Before [_1]', date1) %] + [% ELSIF filter.name == 'after' %][% l('After [_1]', date1) %] + [% ELSIF filter.name == 'between' %][% l('Between [_1] and [_2]', date1, date2) %] + [% END %] +
+
+
+[% END; # IF pubdate_filters %] + [% END; # FOR %]