diff --git a/app/scripts/controllers/registration.js b/app/scripts/controllers/registration.js index 5c3ea210a..8ef325741 100644 --- a/app/scripts/controllers/registration.js +++ b/app/scripts/controllers/registration.js @@ -367,6 +367,16 @@ angular var currentRegistrant = _.find($scope.currentRegistration.registrants, { id: $scope.currentRegistrant, }); + const invalidBlocks = _.find(currentRegistration.registrants, { + id: currentRegistrant.id, + }) + ? validateRegistrant.validate( + conference, + _.find(currentRegistration.registrants, { + id: currentRegistrant.id, + }), + ) + : []; var answersToSave = []; angular.forEach( @@ -376,8 +386,9 @@ angular id: a.id, }); if ( - angular.isUndefined(savedAnswer) || - !angular.equals(savedAnswer.value, a.value) + (angular.isUndefined(savedAnswer) || + !angular.equals(savedAnswer.value, a.value)) && + !invalidBlocks.includes(a.blockId) ) { if ($scope.registerMode !== 'preview') { answersToSave.push($http.put('answers/' + a.id, a)); diff --git a/app/scripts/directives/datepicker.js b/app/scripts/directives/datepicker.js index c60f50ef5..eb9e7ae51 100644 --- a/app/scripts/directives/datepicker.js +++ b/app/scripts/directives/datepicker.js @@ -14,9 +14,9 @@ angular }, controller: function ($timeout, $scope) { $scope.updateTimeStamp = function (timestamp) { - //For Graduation date question, set the day to 1. The API needs the day but that could change in the future. + //For the Graduation date question, set the day to 10. The API needs the day but that could change in the future. timestamp = $scope.monthYearOnly - ? moment(new Date(timestamp)).set('date', 1) + ? moment(new Date(timestamp)).set('date', 10) : timestamp; $scope.$apply(function () { let dateSaveFormat = $scope.monthYearOnly @@ -30,12 +30,13 @@ angular }, link: function (scope, element) { var datePickerElement = angular.element(element).find('.datepicker'); - var initialDate = + scope.localModel = scope.localModel && scope.monthYearOnly - ? scope.localModel + ? moment(new Date(scope.localModel)).format('YYYY-MM-DD') : scope.localModel ? moment(new Date(scope.localModel)).format('MM/DD/YYYY hh:mm A') : null; + let initialDate = scope.localModel || null; scope.dateOptions = scope.monthYearOnly ? { viewMode: 'years', diff --git a/test/spec/directives/datepicker.spec.js b/test/spec/directives/datepicker.spec.js index 03e200fc5..76066216b 100644 --- a/test/spec/directives/datepicker.spec.js +++ b/test/spec/directives/datepicker.spec.js @@ -21,7 +21,7 @@ describe('Directive: datepicker', function () { it('Sets the date to the correct format based on the type of date question', function () { scope.updateTimeStamp(new Date('02/05/1994')); - expect(scope.localModel).toBe('1994-02-01'); + expect(scope.localModel).toBe('1994-02-10'); scope.monthYearOnly = false;