diff --git a/CHANGELOG.md b/CHANGELOG.md index 2578f7226..abcb0b091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Interface to manage partners - Ability to define, per availability, a custom duration for the reservation slots +- Corrected the documentation about BOOK_SLOT_AT_SAME_TIME - Fix a bug: unable to change group if the previous was deactivated - Fix a bug: unable to create events or trainings that are not multiples of SLOT_DURATION - Fix a bug: unable to delete an unreserved event diff --git a/app/assets/javascripts/controllers/home.js b/app/assets/javascripts/controllers/home.js index 1d961ae00..a70f9ccf0 100644 --- a/app/assets/javascripts/controllers/home.js +++ b/app/assets/javascripts/controllers/home.js @@ -1,7 +1,7 @@ 'use strict'; -Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'settingsPromise', 'Member', 'uiTourService', '_t', 'Help', - function ($scope, $stateParams, settingsPromise, Member, uiTourService, _t, Help) { +Application.Controllers.controller('HomeController', ['$scope', '$stateParams', '$translatePartialLoader', 'AuthService', 'settingsPromise', 'Member', 'uiTourService', '_t', 'Help', + function ($scope, $stateParams, $translatePartialLoader, AuthService, settingsPromise, Member, uiTourService, _t, Help) { /* PUBLIC SCOPE */ // Home page HTML content @@ -21,8 +21,10 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams', * This is intended as a contextual help (when pressing F1) */ $scope.setupHomeTour = function () { - if ($scope.currentUser && $scope.currentUser.role === 'admin') { - setupWelcomeTour(); + if (AuthService.isAuthorized(['admin', 'manager'])) { + // this is an ugly hack, but we can't do better for now because angular-ui-tour does not support removing steps + // and we can't use promises with _t's translations (needs a very big refactoring) + setTimeout(setupWelcomeTour, 1000); } }; @@ -271,14 +273,16 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams', placement: 'bottom', orphan: 'true' }); - uitour.createStep({ - selector: '.app-generator .app-version', - stepId: 'version', - order: 19, - title: _t('app.public.tour.welcome.version.title'), - content: _t('app.public.tour.welcome.version.content'), - placement: 'top' - }); + if (AuthService.isAuthorized('admin')) { + uitour.createStep({ + selector: '.app-generator .app-version', + stepId: 'version', + order: 19, + title: _t('app.public.tour.welcome.version.title'), + content: _t('app.public.tour.welcome.version.content'), + placement: 'top' + }); + } uitour.createStep({ selector: 'body', stepId: 'conclusion', diff --git a/app/assets/javascripts/services/_t.js b/app/assets/javascripts/services/_t.js index 2ea42f764..735f51e6f 100644 --- a/app/assets/javascripts/services/_t.js +++ b/app/assets/javascripts/services/_t.js @@ -1,9 +1,8 @@ 'use strict'; -Application.Services.factory('_t', ['$filter', function ($filter) { - return function (key, interpolation, options) { - if (interpolation == null) { interpolation = undefined; } - if (options == null) { options = undefined; } - return $filter('translate')(key, interpolation, options); +Application.Services.factory('_t', ['$translate', function ($translate) { + return function (key, interpolations) { + if (interpolations == null) { interpolations = undefined; } + return $translate.instant(key, interpolations); }; }]); diff --git a/app/assets/javascripts/services/help.js.erb b/app/assets/javascripts/services/help.js.erb index 344af4bde..1397422eb 100644 --- a/app/assets/javascripts/services/help.js.erb +++ b/app/assets/javascripts/services/help.js.erb @@ -1,6 +1,7 @@ 'use strict'; -Application.Services.factory('Help', ['$rootScope', '$uibModal', '$state', function ($rootScope, $uibModal, $state) { +Application.Services.factory('Help', ['$rootScope', '$uibModal', '$state', 'AuthService', + function ($rootScope, $uibModal, $state, AuthService) { const TOURS = { 'app.public.home': 'welcome', 'app.public.machines_list': 'machines', @@ -19,7 +20,7 @@ Application.Services.factory('Help', ['$rootScope', '$uibModal', '$state', funct return function (e) { - if (!$rootScope.currentUser || $rootScope.currentUser.role !== 'admin') return; + if (!AuthService.isAuthorized(['admin', 'manager'])) return; if (e.key === 'F1') { e.preventDefault(); diff --git a/doc/environment.md b/doc/environment.md index 61cd1ca81..90d713044 100644 --- a/doc/environment.md +++ b/doc/environment.md @@ -121,7 +121,7 @@ If set to 'false' the phone number won't be required to register a new user on t BOOK_SLOT_AT_SAME_TIME -If set to 'false', users won't be able to book a machine/formation/event slot if they already have a reservation the same day at the same time. +If set to 'true', users will be able to book a machine/formation/event slot, even if they already have a reservation the same day at the same time. USER_CONFIRMATION_NEEDED_TO_SIGN_IN