LP#1635354 Support date is/not NULL ACQ searches
authorBill Erickson <berickxx@gmail.com>
Thu, 19 Apr 2018 20:15:51 +0000 (16:15 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 5 Sep 2018 03:49:14 +0000 (23:49 -0400)
Adds support for searching on 'date is NULL' in the ACQ unified search
interface.  To use, chose the 'is' or 'is not'  matcher and leave the
text input value empty.

Update the canned completed invoices search to filter on 'close_date IS
NOT NULL' instead of the now-removed 'complete' field.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm
Open-ILS/web/js/ui/default/acq/search/unified.js

index 9c488b9..c09fd35 100644 (file)
@@ -58,6 +58,9 @@ sub castdate {
     $op = ">=" if $gte;
     $op = "<=" if $lte;
 
+    # avoid transforming a date if the match value is NULL.
+    return {'=' => undef} if $op eq '=' and not $value;
+
     +{$op => {"transform" => "date", "value" => $value}};
 }
 
index 3aa07c0..94c0aa7 100644 (file)
@@ -573,9 +573,13 @@ function TermManager() {
             var value;
             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];
+                    if (this.widgets[id].value) {
+                        value =
+                            dojo.date.stamp.toISOString(
+                                this.widgets[id].value).split("T")[0];
+                    } else {
+                        value = null;
+                    }
                 } else {
                     value = this.widgets[id].attr("value");
                     if (this.widgets[id].declaredClass.match(/Check/))
@@ -946,7 +950,7 @@ function URIManager() {
         "inv": {
             "search_object": {
                 "acqinv": [
-                    {"complete": "f"},
+                    {"close_date": null},
                     {"receiver": openils.User.user.ws_ou()}
                 ]
             },