diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f826b7c0..61067c59d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Updated Sidekiq to 6.0.7 - Fix a bug: managers do not see the name of the user who reserved a slot - Fix a bug: OpenAPI documentation is not available +- Fix a bug: summary of create training availability shows incorrect alert about slot splitting - Fix a security issue: updated websocket-extensions to 0.1.5 to fix [CVE-2020-7663](https://nvd.nist.gov/vuln/detail/CVE-2020-7663) - [TODO DEPLOY] `rails fablab:setup:env_to_db` - [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/redis-upgrade.sh | bash` diff --git a/app/assets/javascripts/controllers/admin/calendar.js.erb b/app/assets/javascripts/controllers/admin/calendar.js.erb index eb3350244..1a5cf5b0f 100644 --- a/app/assets/javascripts/controllers/admin/calendar.js.erb +++ b/app/assets/javascripts/controllers/admin/calendar.js.erb @@ -637,7 +637,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui const count = $scope.selectedMachines.length; $scope.selectedMachines = []; $scope.selectedMachinesBinding = {}; - if (count == 0) { + if (count === 0) { $scope.machines.forEach(function (machine) { $scope.selectedMachines.push(machine); $scope.selectedMachinesBinding[machine.id] = true; @@ -665,7 +665,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui const count = $scope.selectedPlans.length; $scope.selectedPlans = []; $scope.selectedPlansBinding = {}; - if (count == 0) { + if (count === 0) { plansPromise.forEach(function (plan) { $scope.selectedPlans.push(plan); $scope.selectedPlansBinding[plan.id] = true; @@ -705,7 +705,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui * Move the modal UI to the next step */ $scope.next = function () { - if ($scope.step === 1) { $scope.setNbTotalPlaces(); } + if ($scope.step === 1) { return validateType(); } if ($scope.step === 2) { return validateSelection(); } if ($scope.step === 5) { return validateRecurrence(); } return $scope.step++; @@ -722,13 +722,14 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); }; /** - * For training avaiabilities, set the maximum number of people allowed to register on this slot + * For training/space availabilities, set the maximum number of people allowed registering on this slot. + * Also, set the default slot duration */ $scope.setNbTotalPlaces = function () { if ($scope.availability.available_type === 'training') { - return $scope.availability.nb_total_places = $scope.selectedTraining.nb_total_places; + $scope.availability.nb_total_places = $scope.selectedTraining.nb_total_places; } else if ($scope.availability.available_type === 'space') { - return $scope.availability.nb_total_places = $scope.selectedSpace.default_places; + $scope.availability.nb_total_places = $scope.selectedSpace.default_places; } }; @@ -876,6 +877,19 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui $scope.step++; }; + /** + * Initialize some settings, depending on the availability type, before continuing to step 2 (select a machine/training/space) + */ + const validateType = function () { + $scope.setNbTotalPlaces(); + if ($scope.availability.available_type === 'training') { + $scope.availability.slot_duration = undefined; + } else { + $scope.availability.slot_duration = parseInt(slotDurationPromise.setting.value, 10); + } + $scope.step++; + } + /** * Compute the various occurrences of the availability, according to the recurrence settings */ diff --git a/app/assets/templates/admin/calendar/eventModal.html.erb b/app/assets/templates/admin/calendar/eventModal.html.erb index a47859435..12a8ddf85 100644 --- a/app/assets/templates/admin/calendar/eventModal.html.erb +++ b/app/assets/templates/admin/calendar/eventModal.html.erb @@ -222,7 +222,7 @@ -
+
{{ 'app.admin.calendar.divided_in_slots' }}