diff --git a/app/assets/javascripts/controllers/admin/calendar.js.erb b/app/assets/javascripts/controllers/admin/calendar.js.erb index f4c1f647e..65a2f2d85 100644 --- a/app/assets/javascripts/controllers/admin/calendar.js.erb +++ b/app/assets/javascripts/controllers/admin/calendar.js.erb @@ -310,7 +310,7 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('calendar') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('calendar') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/events.js.erb b/app/assets/javascripts/controllers/admin/events.js.erb index a584c2b54..425e7af6d 100644 --- a/app/assets/javascripts/controllers/admin/events.js.erb +++ b/app/assets/javascripts/controllers/admin/events.js.erb @@ -463,7 +463,7 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state', } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('events') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('events') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/invoices.js.erb b/app/assets/javascripts/controllers/admin/invoices.js.erb index ad4629899..4c52654e8 100644 --- a/app/assets/javascripts/controllers/admin/invoices.js.erb +++ b/app/assets/javascripts/controllers/admin/invoices.js.erb @@ -673,7 +673,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('invoices') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('invoices') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/members.js.erb b/app/assets/javascripts/controllers/admin/members.js.erb index 4fd7d68e8..74c469093 100644 --- a/app/assets/javascripts/controllers/admin/members.js.erb +++ b/app/assets/javascripts/controllers/admin/members.js.erb @@ -427,7 +427,7 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce', } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('members') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('members') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/pricing.js.erb b/app/assets/javascripts/controllers/admin/pricing.js.erb index 527ccfdec..73c309f6b 100644 --- a/app/assets/javascripts/controllers/admin/pricing.js.erb +++ b/app/assets/javascripts/controllers/admin/pricing.js.erb @@ -710,7 +710,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state', } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('pricing') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('pricing') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/project_elements.js b/app/assets/javascripts/controllers/admin/project_elements.js index e7f69bf6e..85e2471b8 100644 --- a/app/assets/javascripts/controllers/admin/project_elements.js +++ b/app/assets/javascripts/controllers/admin/project_elements.js @@ -199,7 +199,7 @@ Application.Controllers.controller('ProjectElementsController', ['$scope', '$sta } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('project-elements') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('project-elements') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/settings.js.erb b/app/assets/javascripts/controllers/admin/settings.js.erb index a654b646d..d7e5fc337 100644 --- a/app/assets/javascripts/controllers/admin/settings.js.erb +++ b/app/assets/javascripts/controllers/admin/settings.js.erb @@ -464,7 +464,7 @@ Application.Controllers.controller('SettingsController', ['$scope', '$rootScope' } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('settings') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('settings') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/statistics.js.erb b/app/assets/javascripts/controllers/admin/statistics.js.erb index 8abe8fbb8..bdb6c25b2 100644 --- a/app/assets/javascripts/controllers/admin/statistics.js.erb +++ b/app/assets/javascripts/controllers/admin/statistics.js.erb @@ -388,7 +388,7 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state', } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('statistics') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('statistics') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/admin/trainings.js.erb b/app/assets/javascripts/controllers/admin/trainings.js.erb index b81c04720..1710b5806 100644 --- a/app/assets/javascripts/controllers/admin/trainings.js.erb +++ b/app/assets/javascripts/controllers/admin/trainings.js.erb @@ -398,7 +398,7 @@ Application.Controllers.controller('TrainingsAdminController', ['$scope', '$stat } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('trainings') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('trainings') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/home.js b/app/assets/javascripts/controllers/home.js index 105443427..26f64e0bc 100644 --- a/app/assets/javascripts/controllers/home.js +++ b/app/assets/javascripts/controllers/home.js @@ -290,7 +290,7 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams', } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('welcome') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('welcome') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/machines.js.erb b/app/assets/javascripts/controllers/machines.js.erb index 39e4a4a10..3f7f9b40c 100644 --- a/app/assets/javascripts/controllers/machines.js.erb +++ b/app/assets/javascripts/controllers/machines.js.erb @@ -259,7 +259,7 @@ Application.Controllers.controller('MachinesController', ['$scope', '$state', '_ } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('machines') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('machines') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/controllers/spaces.js.erb b/app/assets/javascripts/controllers/spaces.js.erb index 5e546212a..aa7550a15 100644 --- a/app/assets/javascripts/controllers/spaces.js.erb +++ b/app/assets/javascripts/controllers/spaces.js.erb @@ -171,7 +171,7 @@ Application.Controllers.controller('SpacesController', ['$scope', '$state', 'spa } }); // if the user has never seen the tour, show him now - if ($scope.currentUser.profile.tours.indexOf('spaces') < 0) { + if (Fablab.featureTourDisplay !== 'manual' && $scope.currentUser.profile.tours.indexOf('spaces') < 0) { uitour.start(); } // start this tour when an user press F1 - this is contextual help diff --git a/app/assets/javascripts/services/member.js b/app/assets/javascripts/services/member.js index a366537e0..7b385bf51 100644 --- a/app/assets/javascripts/services/member.js +++ b/app/assets/javascripts/services/member.js @@ -1,6 +1,6 @@ 'use strict'; -Application.Services.factory('Member', ['$resource', function ($resource) { +Application.Services.factory('Member', ['$resource', '$q', function ($resource, $q) { return $resource('/api/members/:id', { id: '@id' }, { update: { @@ -35,22 +35,14 @@ Application.Services.factory('Member', ['$resource', function ($resource) { method: 'PATCH', url: '/api/members/:id/complete_tour', params: { id: '@id' }, - interceptor: function ($q) { - return { - request: function (config) { - if (Fablab.featureTourDisplay === 'session') { - throw new Error('session'); - } - return config; - }, - requestError: function (rejection) { - // do something on error - if (rejection.message === 'session') { - return { toto: 1 }; - } - return rejection; + interceptor: { + response: function (response) { + if (Fablab.featureTourDisplay === 'session') { + Fablab.sessionTours.push(response.data.tours[0]); + return { tours: Fablab.sessionTours }; } - }; + return response; + } } } } diff --git a/app/controllers/api/members_controller.rb b/app/controllers/api/members_controller.rb index 2cfe10a55..6a772e706 100644 --- a/app/controllers/api/members_controller.rb +++ b/app/controllers/api/members_controller.rb @@ -192,10 +192,14 @@ class API::MembersController < API::ApiController def complete_tour authorize @member - tours = "#{@member.profile.tours} #{params[:tour]}" - @member.profile.update_attributes(tours: tours.strip) + if Rails.application.secrets.feature_tour_display == 'session' + render json: { tours: [params[:tour]] } + else + tours = "#{@member.profile.tours} #{params[:tour]}" + @member.profile.update_attributes(tours: tours.strip) - render json: { tours: @member.profile.tours } + render json: { tours: @member.profile.tours.split } + end end private diff --git a/app/views/application/index.html.erb b/app/views/application/index.html.erb index 7e178619e..6446364d4 100644 --- a/app/views/application/index.html.erb +++ b/app/views/application/index.html.erb @@ -62,6 +62,9 @@ Fablab.recaptchaSiteKey = "<%= RecaptchaService.site_key %>"; <% end %> Fablab.userConfirmationNeededToSignIn = ('<%= Rails.application.secrets.user_confirmation_needed_to_sign_in %>' === 'true'); + + // feature tour (used when feature_tour_display = session) + Fablab.sessionTours = []; <%= stylesheet_link_tag 'application', media: 'all' %>