mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
recapitulative screen
This commit is contained in:
parent
22251e6516
commit
0d740c95a9
@ -300,7 +300,8 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
|
||||
end () { return end; },
|
||||
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
|
||||
trainingsPromise: ['Training', function (Training) { return Training.query().$promise; }],
|
||||
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }]
|
||||
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }],
|
||||
tagsPromise: ['Tag', function (Tag) { return Tag.query().$promise; }]
|
||||
} });
|
||||
// when the modal is closed, we send the slot to the server for saving
|
||||
modalInstance.result.then(
|
||||
@ -378,8 +379,8 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
|
||||
/**
|
||||
* Controller used in the slot creation modal window
|
||||
*/
|
||||
Application.Controllers.controller('CreateEventModalController', ['$scope', '$uibModalInstance', '$sce', 'moment', 'start', 'end', 'machinesPromise', 'Availability', 'trainingsPromise', 'spacesPromise', 'Tag', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, $sce, moment, start, end, machinesPromise, Availability, trainingsPromise, spacesPromise, Tag, growl, _t) {
|
||||
Application.Controllers.controller('CreateEventModalController', ['$scope', '$uibModalInstance', '$sce', 'moment', 'start', 'end', 'machinesPromise', 'Availability', 'trainingsPromise', 'spacesPromise', 'tagsPromise', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, $sce, moment, start, end, machinesPromise, Availability, trainingsPromise, spacesPromise, tagsPromise, growl, _t) {
|
||||
// $uibModal parameter
|
||||
$scope.start = start;
|
||||
|
||||
@ -395,6 +396,9 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
// spaces list
|
||||
$scope.spaces = spacesPromise.filter(function (s) { return !s.disabled; });
|
||||
|
||||
// all tags list
|
||||
$scope.tags = tagsPromise;
|
||||
|
||||
// machines associated with the created slot
|
||||
$scope.selectedMachines = [];
|
||||
|
||||
@ -427,6 +431,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
start_at: start,
|
||||
end_at: end,
|
||||
available_type: 'machines', // default
|
||||
tag_ids: [],
|
||||
is_recurrent: false,
|
||||
period: 'week',
|
||||
nb_periods: 1,
|
||||
@ -439,6 +444,9 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
// localized name(s) of the reservable item(s)
|
||||
$scope.reservableName = '';
|
||||
|
||||
// localized name(s) of the selected tag(s)
|
||||
$scope.tagsName = '';
|
||||
|
||||
/**
|
||||
* Adds or removes the provided machine from the current slot
|
||||
* @param machine {Object}
|
||||
@ -517,8 +525,6 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
$scope.selectedSpace = $scope.spaces[0];
|
||||
}
|
||||
|
||||
Tag.query().$promise.then(function (data) { $scope.tags = data; });
|
||||
|
||||
// When we configure a machine/space availability, do not let the user change the end time, as the total
|
||||
// time must be dividable by Fablab.slotDuration minutes (base slot duration). For training availabilities, the user
|
||||
// can configure any duration as it does not matters.
|
||||
@ -595,7 +601,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
}
|
||||
// settings are ok
|
||||
computeOccurrences();
|
||||
computeName();
|
||||
computeNames();
|
||||
$scope.step++;
|
||||
};
|
||||
|
||||
@ -625,22 +631,34 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
}
|
||||
};
|
||||
|
||||
const computeName = function () {
|
||||
const computeNames = function () {
|
||||
$scope.reservableName = '';
|
||||
switch ($scope.availability.available_type) {
|
||||
case 'machines':
|
||||
const reservableNames = $scope.selectedMachines.map(function (m) { return $sce.trustAsHtml(`<strong>${m.name}</strong>`); });
|
||||
$scope.reservableName = reservableNames.slice(0, -1).join(', ') + ` ${_t('and')} ` + reservableNames[reservableNames.length - 1];
|
||||
$scope.reservableName = localizedList($scope.selectedMachines)
|
||||
break;
|
||||
case 'training':
|
||||
$scope.reservableName = $scope.selectedTraining.name;
|
||||
$scope.reservableName = `<strong>${$scope.selectedTraining.name}</strong>`;
|
||||
break;
|
||||
case 'space':
|
||||
$scope.reservableName = $scope.selectedSpace.name;
|
||||
$scope.reservableName = `<strong>${$scope.selectedSpace.name}</strong>`;
|
||||
break;
|
||||
default:
|
||||
$scope.reservableName = '';
|
||||
$scope.reservableName = `<span class="warning">${_t("admin_calendar.none")}</span>`;
|
||||
}
|
||||
const tags = $scope.tags.filter(function (t) {
|
||||
return $scope.availability.tag_ids.indexOf(t.id) > -1;
|
||||
})
|
||||
$scope.tagsName = localizedList(tags);
|
||||
}
|
||||
|
||||
const localizedList = function (items) {
|
||||
if (items.length === 0) return `<span class="text-gray text-italic">${_t("admin_calendar.none")}</span>`;
|
||||
|
||||
const names = items.map(function (i) { return $sce.trustAsHtml(`<strong>${i.name}</strong>`); });
|
||||
if (items.length > 1) return names.slice(0, -1).join(', ') + ` ${_t('and')} ` + names[names.length - 1];
|
||||
|
||||
return names[0];
|
||||
}
|
||||
|
||||
// !!! MUST BE CALLED AT THE END of the controller
|
||||
|
@ -159,12 +159,12 @@
|
||||
<li ng-repeat="slot in occurrences">{{slot.start_at | amDateFormat:'L LT'}} - {{slot.end_at | amDateFormat:'LT'}}</li>
|
||||
</ul>
|
||||
<div>
|
||||
<span translate>{{ 'admin_calendar.reservable' }}</span>
|
||||
<span class="underline" translate>{{ 'admin_calendar.reservable' }}</span>
|
||||
<span ng-bind-html="reservableName"></span>
|
||||
</div>
|
||||
<div class="m-t">
|
||||
<span translate>{{ 'admin_calendar.labels' }}</span>
|
||||
<span>{{availability.tag_ids.join(', ') || ('admin_calendar.none' | translate)}}</span><!-- TODO change tag_ids with a localized list of names -->
|
||||
<span class="underline" translate>{{ 'admin_calendar.labels' }}</span>
|
||||
<span ng-bind-html="tagsName"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,7 +55,7 @@ en:
|
||||
select_period: "Please select a period for the recurrence"
|
||||
select_nb_period: "Please select a number of periods for the recurrence"
|
||||
select_end_date: "Please select the date of the last occurrence"
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}, {NAME}:" # messageFormat interpolation
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}:" # messageFormat interpolation
|
||||
reservable: "Reservable(s):"
|
||||
labels: "Label(s):"
|
||||
none: "None"
|
||||
|
@ -55,7 +55,7 @@ es:
|
||||
select_period: "Please select a period for the recurrence" # translation_missing
|
||||
select_nb_period: "Please select a number of periods for the recurrence" # translation_missing
|
||||
select_end_date: "Please select the date of the last occurrence" # translation_missing
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}, {NAME}:" # messageFormat interpolation # translation_missing
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}:" # messageFormat interpolation # translation_missing
|
||||
reservable: "Reservable(s):" # translation_missing
|
||||
labels: "Etiqueta(s):"
|
||||
none: "Ninguna"
|
||||
|
@ -55,7 +55,7 @@ fr:
|
||||
select_period: "Veuillez choisir une période pour la récurrence"
|
||||
select_nb_period: "Veuillez choisir un nombre de périodes pour la récurrence"
|
||||
select_end_date: "Veuillez choisir la date de dernière occurrence"
|
||||
about_to_create: "Vous vous apprêtez à créer {NUMBER, plural, one{le créneau} other{les créneaux}} {TYPE, select, machines{machine} training{formation} space{espace} other{autre}} {NAME} suivant :" # messageFormat interpolation
|
||||
about_to_create: "Vous vous apprêtez à créer {NUMBER, plural, one{le créneau} other{les créneaux}} {TYPE, select, machines{machine} training{formation} space{espace} other{autre}} suivant :" # messageFormat interpolation
|
||||
reservable: "Réservable(s) :"
|
||||
labels: "Étiquette(s) :"
|
||||
none: "Aucune"
|
||||
|
@ -55,7 +55,7 @@ pt:
|
||||
select_period: "Please select a period for the recurrence" # translation_missing
|
||||
select_nb_period: "Please select a number of periods for the recurrence" # translation_missing
|
||||
select_end_date: "Please select the date of the last occurrence" # translation_missing
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}, {NAME}:" # messageFormat interpolation # translation_missing
|
||||
about_to_create: "You are about to create the following {TYPE, select, machines{machine} training{training} space{space} other{other}} {NUMBER, plural, one{slot} other{slots}}:" # messageFormat interpolation # translation_missing
|
||||
reservable: "Reservable(s) :" # translation_missing
|
||||
labels: "Etiqueta(s):"
|
||||
none: "Nenhuma"
|
||||
|
Loading…
x
Reference in New Issue
Block a user