mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
adjust nb of slots per availability
This commit is contained in:
parent
91953d2ca1
commit
d717ed704c
@ -606,6 +606,9 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
// localized name(s) of the selected plan(s)
|
||||
$scope.plansName = '';
|
||||
|
||||
// number of slots for this availability
|
||||
$scope.slots_nb = slots;
|
||||
|
||||
/**
|
||||
* Adds or removes the provided machine from the current slot
|
||||
* @param machine {Object}
|
||||
@ -763,21 +766,32 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
// When the slot duration changes, we increment the availability to match the value
|
||||
$scope.$watch('availability.slot_duration', function (newValue, oldValue, scope) {
|
||||
start = moment($scope.start);
|
||||
start.add(newValue * slots, 'minutes');
|
||||
start.add(newValue * $scope.slots_nb, 'minutes');
|
||||
$scope.end = start.toDate();
|
||||
});
|
||||
|
||||
// When the number of slot changes, we increment the availability to match the value
|
||||
$scope.$watch('slots_nb', function (newValue, oldValue, scope) {
|
||||
start = moment($scope.start);
|
||||
start.add($scope.availability.slot_duration * newValue, 'minutes');
|
||||
$scope.end = start.toDate();
|
||||
});
|
||||
|
||||
// When we configure a machine/space availability, do not let the user change the end time, as the total
|
||||
// time must be dividable by $scope.availability.slot_duration minutes (base slot duration). For training availabilities, the user
|
||||
// can configure any duration as it does not matters.
|
||||
$scope.$watch('availability.available_type', function (newValue, oldValue, scope) {
|
||||
if (isTypeDivided(newValue)) {
|
||||
$scope.endDateReadOnly = true;
|
||||
const slots = Math.trunc(($scope.end.valueOf() - $scope.start.valueOf()) / (60 * 1000)) / $scope.availability.slot_duration;
|
||||
if (!Number.isInteger(slots)) {
|
||||
const slotsCurrentRange = Math.trunc(($scope.end.valueOf() - $scope.start.valueOf()) / (60 * 1000)) / $scope.availability.slot_duration;
|
||||
if (!Number.isInteger(slotsCurrentRange)) {
|
||||
// otherwise, round it to upper decimal
|
||||
const upper = Math.ceil(slots) * $scope.availability.slot_duration;
|
||||
const upperSlots = Math.ceil(slotsCurrentRange);
|
||||
const upper = upperSlots * $scope.availability.slot_duration;
|
||||
$scope.end = moment($scope.start).add(upper, 'minutes').toDate();
|
||||
$scope.slots_nb = upperSlots;
|
||||
} else {
|
||||
$scope.slots_nb = slotsCurrentRange;
|
||||
}
|
||||
$scope.availability.end_at = $scope.end;
|
||||
} else {
|
||||
|
@ -678,3 +678,11 @@ body.container {
|
||||
left: -4px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.middle-of-inputs {
|
||||
line-height: 24px;
|
||||
padding: 6px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
@ -77,9 +77,22 @@
|
||||
<div class="modal-body" ng-show="step === 3">
|
||||
<div id="slotDuration" class="m-t-sm" ng-show="isTypeDivided()">
|
||||
<p class="text-center font-sbold" translate>{{ 'app.admin.calendar.divide_this_availability' }}</p>
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" ng-model="availability.slot_duration" step="5" />
|
||||
<span class="input-group-addon" translate>{{ 'app.admin.calendar.minutes' }}</span>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" ng-model="slots_nb" step="1" />
|
||||
<span class="input-group-addon" translate>{{ 'app.admin.calendar.slots' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="col-md-2 middle-of-inputs" translate>
|
||||
{{ 'app.admin.calendar.slots_of' }}
|
||||
</p>
|
||||
<div class="col-md-5">
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" ng-model="availability.slot_duration" step="5" />
|
||||
<span class="input-group-addon" translate>{{ 'app.admin.calendar.minutes' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="timeAdjust" class="m-t-sm">
|
||||
|
@ -98,7 +98,9 @@ en:
|
||||
legend: "Legend"
|
||||
and: "and"
|
||||
external_sync: "Calendar synchronization"
|
||||
divide_this_availability: "Divide this availability in slots of"
|
||||
divide_this_availability: "Divide this availability in"
|
||||
slots: "slots"
|
||||
slots_of: "of"
|
||||
minutes: "minutes"
|
||||
# import external iCal calendar
|
||||
icalendar:
|
||||
|
@ -98,7 +98,9 @@ fr:
|
||||
legend: "Légende"
|
||||
and: "et"
|
||||
external_sync: "Synchronisation d'agendas"
|
||||
divide_this_availability: "Diviser cette disponibilité en créneaux de"
|
||||
divide_this_availability: "Diviser cette disponibilité en"
|
||||
slots: "créneaux"
|
||||
slots_of: "de"
|
||||
minutes: "minutes"
|
||||
#import external iCal calendar
|
||||
icalendar:
|
||||
|
Loading…
Reference in New Issue
Block a user