diff --git a/CHANGELOG.md b/CHANGELOG.md index 53cfd1622..4bd02d555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Fix a bug: unable to refresh machine/space/training calender after pay an reservation + ## v6.0.7 2023 June 20 - Fix a bug: OpenAPI accounting gateway_object_id missing error diff --git a/app/frontend/src/javascript/controllers/machines.js.erb b/app/frontend/src/javascript/controllers/machines.js.erb index 9d8556865..984eaf665 100644 --- a/app/frontend/src/javascript/controllers/machines.js.erb +++ b/app/frontend/src/javascript/controllers/machines.js.erb @@ -692,20 +692,9 @@ Application.Controllers.controller('ReserveMachineController', ['$scope', '$tran * Refetch all events from the API and re-populate the calendar with the resulting slots */ const refreshCalendar = function () { - const view = uiCalendarConfig.calendars.calendar.fullCalendar('getView'); - return Availability.machine({ - machineId: $scope.machine.id, - member_id: $scope.ctrl.member.id, - start: view.start, - end: view.end, - timezone: Fablab.timezone - }, function (slots) { - uiCalendarConfig.calendars.calendar.fullCalendar('removeEvents'); - return $scope.eventSources.splice(0, 1, { - events: slots, - textColor: 'black' - } - ); + $scope.eventSources.splice(0, 1, { + url: `/api/availabilities/machines/${$transition$.params().id}?member_id=${$scope.ctrl.member.id}`, + textColor: 'black' }); } diff --git a/app/frontend/src/javascript/controllers/spaces.js.erb b/app/frontend/src/javascript/controllers/spaces.js.erb index d4bded6da..379c17123 100644 --- a/app/frontend/src/javascript/controllers/spaces.js.erb +++ b/app/frontend/src/javascript/controllers/spaces.js.erb @@ -609,20 +609,9 @@ Application.Controllers.controller('ReserveSpaceController', ['$scope', '$transi * Refetch all events from the API and re-populate the calendar with the resulting slots */ const refreshCalendar = function () { - const view = uiCalendarConfig.calendars.calendar.fullCalendar('getView'); - return Availability.spaces({ - spaceId: $scope.space.id, - member_id: $scope.ctrl.member.id, - start: view.start, - end: view.end, - timezone: Fablab.timezone - }, function (spaces) { - uiCalendarConfig.calendars.calendar.fullCalendar('removeEvents'); - return $scope.eventSources.splice(0, 1, { - events: spaces, - textColor: 'black' - } - ); + $scope.eventSources.splice(0, 1, { + url: `/api/availabilities/spaces/${$transition$.params().id}?member_id=${$scope.ctrl.member.id}`, + textColor: 'black' }); }; diff --git a/app/frontend/src/javascript/controllers/trainings.js.erb b/app/frontend/src/javascript/controllers/trainings.js.erb index 0fa0a18a8..fe96a2e77 100644 --- a/app/frontend/src/javascript/controllers/trainings.js.erb +++ b/app/frontend/src/javascript/controllers/trainings.js.erb @@ -385,20 +385,9 @@ Application.Controllers.controller('ReserveTrainingController', ['$scope', '$tra * Refetch all events from the API and re-populate the calendar with the resulting slots */ const refreshCalendar = function () { - const view = uiCalendarConfig.calendars.calendar.fullCalendar('getView'); - const id = $transition$.params().id === 'all' ? $transition$.params().id : $scope.training.id; - Availability.trainings({ - trainingId: id, - member_id: $scope.ctrl.member.id, - start: view.start, - end: view.end, - timezone: Fablab.timezone - }, function (trainings) { - uiCalendarConfig.calendars.calendar.fullCalendar('removeEvents'); - $scope.eventSources.splice(0, 1, { - events: trainings, - textColor: 'black' - }); + $scope.eventSources.splice(0, 1, { + url: `/api/availabilities/trainings/${$transition$.params().id}`, + textColor: 'black' }); }