LP#1452950 date input supports null dates
authorBill Erickson <berickxx@gmail.com>
Wed, 17 Feb 2016 02:40:57 +0000 (21:40 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:32:01 +0000 (17:32 -0500)
Leave a date unset when its value is null instead of defaulting to now.
Support unsetting a date when its value is cleared.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/web/js/ui/default/staff/services/ui.js

index d9f77fa..95a60d6 100644 (file)
@@ -487,10 +487,12 @@ It also allows us to abstract away some browser finickiness.
                 ngModelCtrl.$formatters.unshift(function (modelValue) {
                     // apply strip_time here in case the user never 
                     // modifies the date value.
+                    if (!modelValue) return '';
                     return dateFilter(strip_time(modelValue), 'yyyy-MM-dd');
                 });
                 
                 ngModelCtrl.$parsers.unshift(function(viewValue) {
+                    if (!viewValue) return null;
                     return strip_time(new Date(viewValue));
                 });
             },