Skip to content

Commit

Permalink
Reimplementing the reverted PR #842/#843 but not included changes wer…
Browse files Browse the repository at this point in the history
…e localModel is set. I'm confused to why we need to format scope.localModel differently. (#844)
  • Loading branch information
dr-bizz authored Sep 8, 2023
1 parent 877ca1e commit 71a7b48
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions app/scripts/controllers/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/directives/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/spec/directives/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 71a7b48

Please sign in to comment.