1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

[bug] summary of create training availability shows incorrect alert about slot splitting

This commit is contained in:
Sylvain 2020-06-16 14:29:18 +02:00
parent 8611a2753b
commit 933ce5df71
3 changed files with 22 additions and 7 deletions

View File

@ -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`

View File

@ -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
*/

View File

@ -222,7 +222,7 @@
<ul>
<li ng-repeat="slot in occurrences">{{slot.start_at | amDateFormat:'L LT'}} - {{slot.end_at | amDateFormat:'LT'}}</li>
</ul>
<div class="alert alert-info text-xs">
<div class="alert alert-info text-xs" ng-show="availability.slot_duration">
<i class="fa fa-lightbulb-o m-r" aria-hidden="true"></i>
<span translate translate-values="{DURATION: availability.slot_duration, COUNT: occurrences.length}"> {{ 'app.admin.calendar.divided_in_slots' }}</span>
</div>