mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-06 01:08:21 +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
|
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 */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,19 +41,19 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
|||||||
// We set the home page content, with the directives replacing the placeholders
|
// We set the home page content, with the directives replacing the placeholders
|
||||||
$scope.homeContent = insertDirectives(settingsPromise.home_content);
|
$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
|
// listen the $destroy event of the controller to remove the F1 key binding
|
||||||
$scope.$on('$destroy', function () {
|
$scope.$on('$destroy', function () {
|
||||||
window.removeEventListener('keydown', handleF1);
|
window.removeEventListener('keydown', handleF1);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
// for admins, setup the tour on login
|
||||||
$scope.$watch('currentUser', function (newValue, oldValue) {
|
$scope.$watch('currentUser', function (newValue, oldValue) {
|
||||||
if (!oldValue && newValue && newValue.role === 'admin') {
|
if (!oldValue && newValue && newValue.role === 'admin') {
|
||||||
|
const uitour = uiTourService.getTourByName('welcome');
|
||||||
|
if (!uitour.hasStep()) {
|
||||||
setupWelcomeTour();
|
setupWelcomeTour();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,2 +1,9 @@
|
|||||||
|
<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 class="home-page" compile="homeContent">
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -95,12 +95,7 @@
|
|||||||
|
|
||||||
<body ng-controller="ApplicationController"
|
<body ng-controller="ApplicationController"
|
||||||
ng-init="setCurrentUser(<%= current_user ? current_user.to_json : 'null' %>)"
|
ng-init="setCurrentUser(<%= current_user ? current_user.to_json : 'null' %>)"
|
||||||
ng-cloak
|
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">
|
|
||||||
<div growl></div>
|
<div growl></div>
|
||||||
|
|
||||||
<%= flash_messages %>
|
<%= flash_messages %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user