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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 7 15:36:56 EDT 2010


Author: senator
Date: 2010-04-07 15:36:51 -0400 (Wed, 07 Apr 2010)
New Revision: 16159

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
   trunk/Open-ILS/web/js/ui/default/acq/search/unified.js
Log:
Acq: in acquistions unified search, make timestamp fields searchable

Even if only at whole-day precision


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm	2010-04-07 18:16:54 UTC (rev 16158)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm	2010-04-07 19:36:51 UTC (rev 16159)
@@ -44,6 +44,8 @@
     0;
 }
 
+sub castdate { +{"=" => {"transform" => "date", "value" => $_[0]}}; }
+
 sub prepare_acqlia_search_and {
     my ($acqlia) = @_;
 
@@ -55,6 +57,7 @@
             "where" => {"-and" => [{"lineitem" => {"=" => {"+jub" => "id"}}}]}
         };
 
+        # castdate not supported for acqlia fields: they're all type text
         my ($k, $v, $fuzzy, $between, $not) = breakdown_term($unit);
         my $point = $subquery->{"where"}->{"-and"};
         my $term_clause;
@@ -84,6 +87,7 @@
     my $result = {"+acqlia" => {"-or" => $point}};
 
     foreach my $unit (@$acqlia) {
+        # castdate not supported for acqlia fields: they're all type text
         my ($k, $v, $fuzzy, $between, $not) = breakdown_term($unit);
         my $term_clause;
         if ($fuzzy and not ref $v) {
@@ -120,7 +124,8 @@
         $key, $term->{$key},
         $term->{"__fuzzy"} ? 1 : 0,
         $term->{"__between"} ? 1 : 0,
-        $term->{"__not"} ? 1 : 0
+        $term->{"__not"} ? 1 : 0,
+        $term->{"__castdate"} ? 1 : 0
     );
 }
 
@@ -208,13 +213,16 @@
 
         $outer_clause->{$conj} = [] unless $outer_clause->{$conj};
         foreach my $unit (@{$terms->{$class}}) {
-            my ($k, $v, $fuzzy, $between, $not) = breakdown_term($unit);
+            my ($k, $v, $fuzzy, $between, $not, $castdate) =
+                breakdown_term($unit);
+
             my $term_clause;
             if ($fuzzy and not ref $v) {
                 $term_clause = {$k => {"ilike" => "%" . $v . "%"}};
             } elsif ($between and could_be_range($v)) {
                 $term_clause = {$k => {"between" => $v}};
             } elsif (check_1d_max($v)) {
+                $v = castdate($v) 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-07 18:16:54 UTC (rev 16158)
+++ trunk/Open-ILS/web/js/ui/default/acq/search/unified.js	2010-04-07 19:36:51 UTC (rev 16159)
@@ -1,3 +1,4 @@
+dojo.require("dojo.date.stamp");
 dojo.require("openils.widget.AutoGrid");
 dojo.require("openils.widget.AutoWidget");
 dojo.require("openils.PermaCrud");
@@ -276,17 +277,26 @@
                 this._match_how(id).getValue().split(",").filter(Boolean);
 
             var value;
-            try {
-                value = this.widgets[id].attr("value");
-            } catch (E) {
+            if (typeof(this.widgets[id].declaredClass) != "undefined") {
+                if (this.widgets[id].declaredClass.match(/Date/)) {
+                    value =
+                        dojo.date.stamp.toISOString(this.widgets[id].value).
+                            split("T")[0];
+                } else {
+                    value = this.widgets[id].attr("value");
+                }
+            } else {
                 value = this.widgets[id].value;
             }
 
             if (!so[hint])
                 so[hint] = [];
+
             var unit = {};
+            unit[attr] = value;
             match_how.forEach(function(key) { unit[key] = true; });
-            unit[attr] = value;
+            if (this.terms[hint][attr].datatype == "timestamp")
+                unit.__castdate = true;
 
             so[hint].push(unit);
         }



More information about the open-ils-commits mailing list