mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
refactor the home tour to start after the render
This commit is contained in:
parent
5186d6b22c
commit
f1928c0d4c
@ -16,6 +16,16 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
||||
events: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup the feature-tour for the home page. (admins only)
|
||||
* This is intended as a contextual help (when pressing F1)
|
||||
*/
|
||||
$scope.setupHomeTour = function () {
|
||||
if ($scope.currentUser && $scope.currentUser.role === 'admin') {
|
||||
setupWelcomeTour();
|
||||
}
|
||||
};
|
||||
|
||||
/* PRIVATE SCOPE */
|
||||
|
||||
/**
|
||||
@ -31,18 +41,18 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
||||
// We set the home page content, with the directives replacing the placeholders
|
||||
$scope.homeContent = insertDirectives(settingsPromise.home_content);
|
||||
|
||||
// setup the tour for admins
|
||||
if ($scope.currentUser && $scope.currentUser.role === 'admin') {
|
||||
setupWelcomeTour();
|
||||
// listen the $destroy event of the controller to remove the F1 key binding
|
||||
$scope.$on('$destroy', function () {
|
||||
window.removeEventListener('keydown', handleF1);
|
||||
});
|
||||
}
|
||||
// listen the $destroy event of the controller to remove the F1 key binding
|
||||
$scope.$on('$destroy', function () {
|
||||
window.removeEventListener('keydown', handleF1);
|
||||
});
|
||||
|
||||
// for admins, setup the tour on login
|
||||
$scope.$watch('currentUser', function (newValue, oldValue) {
|
||||
if (!oldValue && newValue && newValue.role === 'admin') {
|
||||
setupWelcomeTour();
|
||||
const uitour = uiTourService.getTourByName('welcome');
|
||||
if (!uitour.hasStep()) {
|
||||
setupWelcomeTour();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1,2 +1,9 @@
|
||||
<div class="home-page" compile="homeContent">
|
||||
<div ui-tour="welcome"
|
||||
ui-tour-backdrop="true"
|
||||
ui-tour-template-url="'<%= asset_path "shared/tour-step-template.html" %>'"
|
||||
ui-tour-use-hotkeys="true"
|
||||
ui-tour-scroll-parent-id="content-main"
|
||||
post-render="setupHomeTour">
|
||||
<div class="home-page" compile="homeContent">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -95,12 +95,7 @@
|
||||
|
||||
<body ng-controller="ApplicationController"
|
||||
ng-init="setCurrentUser(<%= current_user ? current_user.to_json : 'null' %>)"
|
||||
ng-cloak
|
||||
ui-tour="welcome"
|
||||
ui-tour-backdrop="true"
|
||||
ui-tour-template-url="'<%= asset_path "shared/tour-step-template.html" %>'"
|
||||
ui-tour-use-hotkeys="true"
|
||||
ui-tour-scroll-parent-id="content-main">
|
||||
ng-cloak>
|
||||
<div growl></div>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user