[open-ils-commits] r16167 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/ui/default/acq/search web/templates/default/acq/search (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 8 09:29:08 EDT 2010


Author: senator
Date: 2010-04-08 09:29:06 -0400 (Thu, 08 Apr 2010)
New Revision: 16167

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
   trunk/Open-ILS/web/js/ui/default/acq/search/unified.js
   trunk/Open-ILS/web/templates/default/acq/search/unified.tt2
Log:
Acq: unified search: add before/after searching for timestamp fields


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm	2010-04-08 03:21:41 UTC (rev 16166)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm	2010-04-08 13:29:06 UTC (rev 16167)
@@ -48,8 +48,16 @@
     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 @@
         $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 @@
 
         $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 @@
             } 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;

Modified: trunk/Open-ILS/web/js/ui/default/acq/search/unified.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/search/unified.js	2010-04-08 03:21:41 UTC (rev 16166)
+++ trunk/Open-ILS/web/js/ui/default/acq/search/unified.js	2010-04-08 13:29:06 UTC (rev 16167)
@@ -231,6 +231,10 @@
                         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);
             }
         );
     };

Modified: trunk/Open-ILS/web/templates/default/acq/search/unified.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/search/unified.tt2	2010-04-08 03:21:41 UTC (rev 16166)
+++ trunk/Open-ILS/web/templates/default/acq/search/unified.tt2	2010-04-08 13:29:06 UTC (rev 16167)
@@ -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"



More information about the open-ils-commits mailing list