CRM-16019 - Reset mode if user entered an invalid date
authorColeman Watts <coleman@civicrm.org>
Tue, 10 Mar 2015 19:41:11 +0000 (15:41 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 10 Mar 2015 19:41:11 +0000 (15:41 -0400)
js/angular-crmMailing/directives.js

index a9977a6a9fd547ec8693a5d68f6a68975554d91c..307df6369ee4e3aeb55ad4ce6aaca0f5d81f8bc6 100644 (file)
           }
         });
 
-        element.on('click', ':radio[value=at]', function() {
-          $('.crm-form-date', element).focus();
-        });
+        element
+          // Open datepicker when clicking "At" radio
+          .on('click', ':radio[value=at]', function() {
+            $('.crm-form-date', element).focus();
+          })
+          // Reset mode if user entered an invalid date
+          .on('change', '.crm-hidden-date', function(e, context) {
+            if (context === 'userInput' && $(this).val() === '' && $(this).siblings('.crm-form-date').val().length) {
+              schedule.mode = 'at';
+              schedule.datetime = '?';
+            }
+          });
 
         $scope.$watch(attrs.crmMailingRadioDate + '.mode', updateParent);
         $scope.$watch(attrs.crmMailingRadioDate + '.datetime', function (newValue, oldValue) {