From: senator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Thu, 8 Apr 2010 13:29:06 +0000 (+0000) Subject: Acq: unified search: add before/after searching for timestamp fields X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=014ee438cd63e2b1381cc7bda0bb825c85f1bee9;p=evergreen%2Fmasslnc.git Acq: unified search: add before/after searching for timestamp fields git-svn-id: svn://svn.open-ils.org/ILS/trunk@16167 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm index fe2badb4bd..e97a848e81 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm @@ -48,7 +48,15 @@ sub could_be_range { 0; } -sub castdate { +{"=" => {"transform" => "date", "value" => $_[0]}}; } +sub castdate { + my ($value, $gte, $lte) = @_; + + my $op = "="; + $op = ">=" if $gte; + $op = "<=" if $lte; + + +{$op => {"transform" => "date", "value" => $value}}; +} sub prepare_acqlia_search_and { my ($acqlia) = @_; @@ -129,7 +137,9 @@ sub breakdown_term { $term->{"__fuzzy"} ? 1 : 0, $term->{"__between"} ? 1 : 0, $term->{"__not"} ? 1 : 0, - $term->{"__castdate"} ? 1 : 0 + $term->{"__castdate"} ? 1 : 0, + $term->{"__gte"} ? 1 : 0, + $term->{"__lte"} ? 1 : 0 ); } @@ -217,7 +227,7 @@ sub prepare_terms { $outer_clause->{$conj} = [] unless $outer_clause->{$conj}; foreach my $unit (@{$terms->{$class}}) { - my ($k, $v, $fuzzy, $between, $not, $castdate) = + my ($k, $v, $fuzzy, $between, $not, $castdate, $gte, $lte) = breakdown_term($unit); my $term_clause; @@ -226,7 +236,7 @@ sub prepare_terms { } elsif ($between and could_be_range($v)) { $term_clause = {$k => {"between" => $v}}; } elsif (check_1d_max($v)) { - $v = castdate($v) if $castdate; + $v = castdate($v, $gte, $lte) if $castdate; $term_clause = {$k => $v}; } else { next; diff --git a/Open-ILS/web/js/ui/default/acq/search/unified.js b/Open-ILS/web/js/ui/default/acq/search/unified.js index 73d26cb6b4..52542b4b4f 100644 --- a/Open-ILS/web/js/ui/default/acq/search/unified.js +++ b/Open-ILS/web/js/ui/default/acq/search/unified.js @@ -231,6 +231,10 @@ function TermManager() { can_do_fuzzy = false; } self.matchHowAllow(id, "__fuzzy", can_do_fuzzy); + + var inequalities = (term.datatype == "timestamp"); + self.matchHowAllow(id, "__gte", inequalities); + self.matchHowAllow(id, "__lte", inequalities); } ); }; diff --git a/Open-ILS/web/templates/default/acq/search/unified.tt2 b/Open-ILS/web/templates/default/acq/search/unified.tt2 index 146c5412a3..bd63c18b18 100644 --- a/Open-ILS/web/templates/default/acq/search/unified.tt2 +++ b/Open-ILS/web/templates/default/acq/search/unified.tt2 @@ -102,14 +102,18 @@ <td name="match" class="acq-unified-terms-match"> <select> - <option value="">matches exactly</option> - <option value="__not"> - does NOT match exactly - </option> + <option value="">is</option> + <option value="__not">is NOT</option> <option value="__fuzzy">contains</option> <option value="__not,__fuzzy"> does NOT contain </option> + <option value="__lte"> + is on or BEFORE + </option> + <option value="__gte"> + is on or AFTER + </option> </select> </td> <td name="widget"