mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-06 01:08:21 +01:00
[ongoing] trainings tour
This commit is contained in:
parent
16ed2fa73a
commit
0d9f79976d
@ -150,12 +150,11 @@ Application.Controllers.controller('EditTrainingController', [ '$scope', '$state
|
|||||||
/**
|
/**
|
||||||
* Controller used in the trainings management page, allowing admins users to see and manage the list of trainings and reservations.
|
* Controller used in the trainings management page, allowing admins users to see and manage the list of trainings and reservations.
|
||||||
*/
|
*/
|
||||||
Application.Controllers.controller('TrainingsAdminController', ['$scope', '$state', '$uibModal', 'Training', 'trainingsPromise', 'machinesPromise', '_t', 'growl', 'dialogs',
|
Application.Controllers.controller('TrainingsAdminController', ['$scope', '$state', '$uibModal', 'Training', 'trainingsPromise', 'machinesPromise', '_t', 'growl', 'dialogs', 'Member', 'uiTourService',
|
||||||
function ($scope, $state, $uibModal, Training, trainingsPromise, machinesPromise, _t, growl, dialogs) {
|
function ($scope, $state, $uibModal, Training, trainingsPromise, machinesPromise, _t, growl, dialogs, Member, uiTourService) {
|
||||||
/* PUBLIC SCOPE */
|
/* PUBLIC SCOPE */
|
||||||
|
|
||||||
// list of trainings
|
// list of trainings
|
||||||
let groupAvailabilities;
|
|
||||||
$scope.trainings = trainingsPromise;
|
$scope.trainings = trainingsPromise;
|
||||||
|
|
||||||
// simplified list of machines
|
// simplified list of machines
|
||||||
@ -337,12 +336,19 @@ Application.Controllers.controller('TrainingsAdminController', ['$scope', '$stat
|
|||||||
|
|
||||||
/* PRIVATE SCOPE */
|
/* PRIVATE SCOPE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kind of constructor: these actions will be realized first when the controller is loaded
|
||||||
|
*/
|
||||||
|
const initialize = function () {
|
||||||
|
setupTrainingsTour();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group the trainings availabilities by trainings and by dates and return the resulting tree
|
* Group the trainings availabilities by trainings and by dates and return the resulting tree
|
||||||
* @param trainings {Array} $scope.trainings is expected here
|
* @param trainings {Array} $scope.trainings is expected here
|
||||||
* @returns {Object} Tree constructed as /training_name/year/month/day/[availabilities]
|
* @returns {Object} Tree constructed as /training_name/year/month/day/[availabilities]
|
||||||
*/
|
*/
|
||||||
return groupAvailabilities = function (trainings) {
|
const groupAvailabilities = function (trainings) {
|
||||||
const tree = {};
|
const tree = {};
|
||||||
for (let training of Array.from(trainings)) {
|
for (let training of Array.from(trainings)) {
|
||||||
tree[training.name] = {};
|
tree[training.name] = {};
|
||||||
@ -367,6 +373,47 @@ Application.Controllers.controller('TrainingsAdminController', ['$scope', '$stat
|
|||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the feature-tour for the admin/trainings page.
|
||||||
|
* This is intended as a contextual help
|
||||||
|
*/
|
||||||
|
const setupTrainingsTour = function () {
|
||||||
|
// get the tour defined by the ui-tour directive
|
||||||
|
const uitour = uiTourService.getTourByName('trainings'); // FIXME undefined
|
||||||
|
// TODO add the steps
|
||||||
|
uitour.createStep({
|
||||||
|
selector: 'body',
|
||||||
|
stepId: 'welcome',
|
||||||
|
order: 0,
|
||||||
|
title: _t('app.public.tour.welcome.title'),
|
||||||
|
content: _t('app.public.tour.welcome.content'),
|
||||||
|
placement: 'bottom',
|
||||||
|
orphan: true
|
||||||
|
});
|
||||||
|
// on tour end, save the status in database
|
||||||
|
uitour.on('ended', function () {
|
||||||
|
if (uitour.getStatus() === uitour.Status.ON && $scope.currentUser.profile.tours.indexOf('trainings') < 0) {
|
||||||
|
Member.completeTour({ id: $scope.currentUser.id }, { tour: 'trainings' }, function (res) {
|
||||||
|
$scope.currentUser.profile.tours = res.tours;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// if the user has never seen the tour, show him now
|
||||||
|
if ($scope.currentUser.profile.tours.indexOf('trainings') < 0) {
|
||||||
|
uitour.start();
|
||||||
|
}
|
||||||
|
// start this tour when an user press F1 - this is contextual help
|
||||||
|
window.addEventListener('keydown', function (e) {
|
||||||
|
if (e.key === 'F1') {
|
||||||
|
e.preventDefault();
|
||||||
|
uitour.start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// !!! MUST BE CALLED AT THE END of the controller
|
||||||
|
return initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
@ -28,6 +28,12 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the provided html and replace the elements with special IDs (#news, #projects, #twitter, #members, #events)
|
||||||
|
* by their respective angular directives
|
||||||
|
* @param html {String} a valid html string, as defined by the summernote editor in admin/settings/home_page
|
||||||
|
* @returns {string} a valid html string containing angular directives for the specified plugins
|
||||||
|
*/
|
||||||
const insertDirectives = function (html) {
|
const insertDirectives = function (html) {
|
||||||
const node = document.createElement('div');
|
const node = document.createElement('div');
|
||||||
node.innerHTML = html.trim();
|
node.innerHTML = html.trim();
|
||||||
@ -60,6 +66,10 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
|||||||
return node.outerHTML;
|
return node.outerHTML;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the feature-tour for the home page that will present an overview of the whole app.
|
||||||
|
* This is intended as a contextual help.
|
||||||
|
*/
|
||||||
const setupWelcomeTour = function () {
|
const setupWelcomeTour = function () {
|
||||||
// get the tour defined by the ui-tour directive
|
// get the tour defined by the ui-tour directive
|
||||||
const uitour = uiTourService.getTourByName('welcome');
|
const uitour = uiTourService.getTourByName('welcome');
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<section class="m-lg">
|
<section class="m-lg"
|
||||||
|
ui-tour="trainings"
|
||||||
|
ui-tour-backdrop="true"
|
||||||
|
ui-tour-template-url="'<%= asset_path "shared/tour-step-template.html" %>'"
|
||||||
|
ui-tour-use-hotkeys="true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user