Skip to content

Commit

Permalink
(bug) unable to update availability slot end time for training
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed May 20, 2024
1 parent 53b5b36 commit a1469f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions app/frontend/src/javascript/controllers/admin/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
// update availability object
$scope.availability.start_at = $scope.start;
});
// Maintain consistency between the end time and the date object in the availability object
$scope.$watch('end', function (newValue, oldValue, scope) {
if (newValue.valueOf() !== oldValue.valueOf()) {
// update availability object
$scope.availability.end_at = $scope.end;
}
});

$scope.$watch('startTime', function (newValue, oldValue, scope) {
// adjust the start/endTime
Expand All @@ -1020,14 +1027,9 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
$scope.endTime = endTime.toDate();
});

$scope.$watch('endTime', function (newValue, oldValue, scope) {
// adjust the start/endTime
const end = moment($scope.end);
const diff = moment.tz(newValue, moment.tz.guess()).diff(moment.tz(oldValue, moment.tz.guess()));
end.add(diff, 'milliseconds');
$scope.end = end.toDate();
$scope.availability.end_at = $scope.end;
});
$scope.endTimeChanged = function () {
$scope.end = moment.tz($scope.endTime, moment.tz.guess()).toDate();
};
};

/*
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/templates/admin/calendar/eventModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h3 class="text-center red">
</div>
<span class="col-md-1 m-t-xl m-l" translate>{{ 'app.admin.calendar.to_time' }}</span>
<fieldset ng-disabled="endDateReadOnly" class="col-md-5">
<uib-timepicker ng-model="endTime" hour-step="timepickers.end.hstep" readonly-input="true" minute-step="timepickers.end.mstep" show-meridian="false"></uib-timepicker>
<uib-timepicker ng-model="endTime" hour-step="timepickers.end.hstep" readonly-input="true" minute-step="timepickers.end.mstep" show-meridian="false" ng-change="endTimeChanged()"></uib-timepicker>
</fieldset>
</div>
</div>
Expand Down

0 comments on commit a1469f0

Please sign in to comment.