From 2138186b91b6f035953f4864b0716127528eb469 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 10 Oct 2017 01:33:12 +1100 Subject: [PATCH] CRM-20397 - crmMailingRadioDate - Make the UI less spammy and close it when a good time is set --- ang/crmMailing/RadioDate.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ang/crmMailing/RadioDate.js b/ang/crmMailing/RadioDate.js index c747f2e275..5ed5b204d0 100644 --- a/ang/crmMailing/RadioDate.js +++ b/ang/crmMailing/RadioDate.js @@ -5,6 +5,7 @@ return { require: 'ngModel', link: function($scope, element, attrs, ngModel) { + var lastAlert = null; var schedule = $scope[attrs.crmMailingRadioDate] = { mode: 'now', @@ -63,9 +64,13 @@ date = [year, month, day].join('-'); time = [hours, minutes, "00"].join(':'); currentDate = date + ' ' + time; - ngModel.$setValidity('dateTimeInThePast', !($(this).val().length && submittedDate < currentDate)); - if ($(this).val().length && submittedDate < currentDate) { - crmUiAlert({ + var isInPast = ($(this).val().length && submittedDate < currentDate); + ngModel.$setValidity('dateTimeInThePast', !isInPast); + if (lastAlert && lastAlert.isOpen) { + lastAlert.close(); + } + if (isInPast) { + lastAlert = crmUiAlert({ text: ts('The scheduled date and time is in the past'), title: ts('Error') }); -- 2.25.1