diff --git a/app/frontend/src/javascript/controllers/admin/events.js b/app/frontend/src/javascript/controllers/admin/events.js index d1288f4f2..02b19a1d4 100644 --- a/app/frontend/src/javascript/controllers/admin/events.js +++ b/app/frontend/src/javascript/controllers/admin/events.js @@ -436,7 +436,7 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state', /** * Controller used in the reservations listing page for a specific event */ -Application.Controllers.controller('ShowEventReservationsController', ['$scope', 'eventPromise', 'reservationsPromise', 'dialogs', 'SlotsReservation', 'growl', '_t', 'Price', 'Wallet', '$uibModal', function ($scope, eventPromise, reservationsPromise, dialogs, SlotsReservation, growl, _t, Price, Wallet, $uibModal) { +Application.Controllers.controller('ShowEventReservationsController', ['$scope', 'eventPromise', 'reservationsPromise', 'dialogs', 'SlotsReservation', 'growl', '_t', 'Price', 'Wallet', '$uibModal', 'Event', function ($scope, eventPromise, reservationsPromise, dialogs, SlotsReservation, growl, _t, Price, Wallet, $uibModal, Event) { // retrieve the event from the ID provided in the current URL $scope.event = eventPromise; @@ -472,6 +472,9 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope', growl.success(_t('app.admin.event_reservations.reservation_was_successfully_validated')); const index = $scope.reservations.indexOf(reservation); $scope.reservations[index].slots_reservations_attributes[0].is_valid = true; + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, () => { growl.warning(_t('app.admin.event_reservations.validation_failed')); }); @@ -488,6 +491,9 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope', growl.success(_t('app.admin.event_reservations.reservation_was_successfully_invalidated')); const index = $scope.reservations.indexOf(reservation); $scope.reservations[index].slots_reservations_attributes[0].is_valid = false; + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, () => { growl.warning(_t('app.admin.event_reservations.invalidation_failed')); }); diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index eceaacc9f..8117807a1 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -360,9 +360,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' if ($scope.ctrl.member) { Member.get({ id: $scope.ctrl.member.id }, function (member) { $scope.ctrl.member = member; - getReservations($scope.event.id, 'Event', $scope.ctrl.member.id); - getChildren($scope.ctrl.member.id).then(() => { - updateNbReservePlaces(); + getReservations($scope.event.id, 'Event', $scope.ctrl.member.id).then(function (reservations) { + getChildren($scope.currentUser.id).then(function (children) { + updateNbReservePlaces(); + }); }); }); } @@ -441,8 +442,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' let index; growl.success(_t('app.public.events_show.reservation_was_successfully_cancelled')); index = $scope.reservations.indexOf(reservation); - $scope.event.nb_free_places = $scope.event.nb_free_places + reservation.total_booked_seats; $scope.reservations[index].slots_reservations_attributes[0].canceled_at = new Date(); + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + }); }, function(error) { growl.warning(_t('app.public.events_show.cancellation_failed')); }); @@ -985,13 +988,14 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' * @param invoice {Object} the invoice for the booked reservation */ const afterPayment = function (invoice) { - Reservation.get({ id: invoice.main_object.id }, function (reservation) { - $scope.event.nb_free_places = $scope.event.nb_free_places - reservation.total_booked_seats; - $scope.reservations.push(reservation); + Event.get({ id: $scope.event.id }).$promise.then(function (event) { + $scope.event = event; + getReservations($scope.event.id, 'Event', $scope.ctrl.member.id).then(function (reservations) { + updateNbReservePlaces(); + $scope.reserveSuccess = true; + $scope.coupon.applied = null; + }); resetEventReserve(); - updateNbReservePlaces(); - $scope.reserveSuccess = true; - $scope.coupon.applied = null; }); if ($scope.currentUser.role === 'admin') { return $scope.ctrl.member = null; diff --git a/app/frontend/templates/admin/events/reservations.html b/app/frontend/templates/admin/events/reservations.html index 44f7392ef..ea5f3d8c7 100644 --- a/app/frontend/templates/admin/events/reservations.html +++ b/app/frontend/templates/admin/events/reservations.html @@ -48,7 +48,8 @@ {{ 'app.admin.event_reservations.event_status.pre_registered' }} - {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.registered' }} {{ 'app.admin.event_reservations.event_status.paid' }} {{ 'app.admin.event_reservations.event_status.present' }} {{ 'app.admin.event_reservations.event_status.canceled' }} @@ -58,11 +59,11 @@