Merge branch 'dev-v7.8' of https://github.com/umbraco/Umbraco-CMS into dev-v7.8

This commit is contained in:
Mads Rasmussen
2018-01-17 15:51:25 +01:00
2 changed files with 184 additions and 78 deletions

View File

@@ -1,3 +1,187 @@
/**
@ngdoc directive
@name umbraco.directives.directive:umbTour
@restrict E
@scope
@description
<b>Added in Umbraco 7.8</b>. The tour component is a global component and is already added to the umbraco markup.
In the Umbraco UI the tours live in the "Help drawer" which opens when you click the Help-icon in the bottom left corner of Umbraco.
You can easily add you own tours to the Help-drawer or show and start tours from
anywhere in the Umbraco backoffice. To see a real world example of a custom tour implementation, install <a href="https://our.umbraco.org/projects/starter-kits/the-starter-kit/">The Starter Kit</a> in Umbraco 7.8
<h1><b>Extending the help drawer with custom tours</b></h1>
The easiet way to add new tours to Umbraco is through the Help-drawer. All it requires is a my-tour.json file.
Place the file in <i>App_Plugins/{MyPackage}/backoffice/tours/{my-tour}.json</i> and it will automatically be
picked up by Umbraco and shown in the Help-drawer.
<h3><b>The tour object</b></h3>
The tour object consist of two parts - The overall tour configuration and a list of tour steps. We have split up the tour object for a better overview.
<pre>
// The tour config object
{
"name": "My Custom Tour", // (required)
"alias": "myCustomTour", // A unique tour alias (required)
"group": "My Custom Group" // Used to group tours in the help drawer
"groupOrder": 200 // Control the order of tour groups
"allowDisable": // Adds a "Don't" show this tour again"-button to the intro step
"steps": [] // tour steps - see next example
}
</pre>
<pre>
// A tour step object
{
"title": "Title",
"content": "<p>Step content</p>",
"type": "intro" // makes the step an introduction step,
"element": "[data-element='my-table-row']", // the highlighted element
"event": "click" // forces the user to click the UI to go to next step
"eventElement": "[data-element='my-table-row'] [data-element='my-tour-button']" // specify an element to click inside a highlighted element
"elementPreventClick": false // prevents user interaction in the highlighted element
"backdropOpacity": 0.4 // the backdrop opacity
"view": "" // add a custom view
"customProperties" : {} // add any custom properties needed for the custom view
}
</pre>
<h1><b>Adding tours to other parts of the Umbraco backoffice</b></h1>
It is also possible to add a list of custom tours to other parts of the Umbraco backoffice,
as an example on a Dashboard in a Custom section. You can then use the {@link umbraco.services.tourService tourService} to start and stop tours but you don't have to register them as part of the tour service.
<h1><b>Using the tour service</b></h1>
<h3>Markup example - show custom tour</h3>
<pre>
<div ng-controller="My.TourController as vm">
<div>{{vm.tour.name}}</div>
<button type="button" ng-click="vm.startTour()">Start tour</button>
<!-- This button will be clicked in the tour -->
<button data-element="my-tour-button" type="button">Click me</button>
</div>
</pre>
<h3>Controller example - show custom tour</h3>
<pre>
(function () {
"use strict";
function TourController(tourService) {
var vm = this;
vm.tour = {
"name": "My Custom Tour",
"alias": "myCustomTour",
"steps": [
{
"title": "Welcome to My Custom Tour",
"content": "",
"type": "intro"
},
{
"element": "[data-element='my-tour-button']",
"title": "Click the button",
"content": "Click the button",
"event": "click"
}
]
};
vm.startTour = startTour;
function startTour() {
tourService.startTour(vm.tour);
}
}
angular.module("umbraco").controller("My.TourController", TourController);
})();
</pre>
<h1><b>Custom step views</b></h1>
In some cases you will need a custom view for one of your tour steps.
This could be for validation or for running any other custom logic for that step.
We have added a couple of helper components to make it easier to get the step scaffolding to look like a regular tour step.
In the following example you see how to run some custom logic before a step goes to the next step.
<h3>Markup example - custom step view</h3>
<pre>
<div ng-controller="My.TourStep as vm">
<umb-tour-step on-close="model.endTour()">
<umb-tour-step-header
title="model.currentStep.title">
</umb-tour-step-header>
<umb-tour-step-content
content="model.currentStep.content">
<!-- Add any custom content here -->
</umb-tour-step-content>
<umb-tour-step-footer class="flex justify-between items-center">
<umb-tour-step-counter
current-step="model.currentStepIndex + 1"
total-steps="model.steps.length">
</umb-tour-step-counter>
<div>
<umb-button
size="xs"
button-style="success"
type="button"
action="vm.initNextStep()"
label="Next">
</umb-button>
</div>
</umb-tour-step-footer>
</umb-tour-step>
</div>
</pre>
<h3>Controller example - custom step view</h3>
<pre>
(function () {
"use strict";
function StepController() {
var vm = this;
vm.initNextStep = initNextStep;
function initNextStep() {
// run logic here before going to the next step
$scope.model.nextStep();
}
}
angular.module("umbraco").controller("My.TourStep", StepController);
})();
</pre>
<h3>Related services</h3>
<ul>
<li>{@link umbraco.services.tourService tourService}</li>
</ul>
@param {string} model (<code>binding</code>): Tour object
**/
(function () {
'use strict';

View File

@@ -30,80 +30,6 @@
});
}
/**
* @ngdoc method
* @name umbraco.services.tourService#registerTour
* @methodOf umbraco.services.tourService
*
* @description
* Registers a tour in the service
* @param {Object} tour The tour you want to register in the service
* @param {String} tour.name The tour name
* @param {String} tour.alias The tour alias
* @param {Array} tour.steps Array of tour steps
* @param {String} tour.step.title Step title
* @param {DomElement} tour.step.content Step content (pass in any HTML markup)
* @param {DomElement} tour.step.element Highlight a DOM-element
* @param {Boolean} tour.step.elementPreventClick Adds invisible layer on top of highligted element to prevent all clicks and interaction with it
* @param {Number} tour.step.backdropOpacity Sets the backdrop opacity (default 0.4)
*/
function registerTour(newTour) {
validateTour(newTour);
validateTourRegistration(newTour);
tours.push(newTour);
eventsService.emit("appState.tour.updatedTours", tours);
}
/**
* @ngdoc method
* @name umbraco.services.tourService#registerTours
* @methodOf umbraco.services.tourService
*
* @description
* Registers an array of tours in the service
* @param {Array} tours The tours to register in the service
*/
function registerTours(newTours) {
angular.forEach(newTours, function(newTour){
validateTour(newTour);
validateTourRegistration(newTour);
tours.push(newTour);
});
eventsService.emit("appState.tour.updatedTours", tours);
}
/**
* @ngdoc method
* @name umbraco.services.tourService#unregisterTour
* @methodOf umbraco.services.tourService
*
* @description
* Unregisters a tour in the service
* @param {String} tourAlias The tour alias of the tour you want to unregister
*/
function unregisterTour(tourAlias) {
tours = tours.filter(function( obj ) {
return obj.alias !== tourAlias;
});
eventsService.emit("appState.tour.updatedTours", tours);
}
/**
* @ngdoc method
* @name umbraco.services.tourService#unregisterTourGroup
* @methodOf umbraco.services.tourService
*
* @description
* Unregisters a tour in the service
* @param {String} tourGroupName The name of the tour group you want to unregister
*/
function unregisterTourGroup(tourGroup) {
tours = tours.filter(function( obj ) {
return obj.group !== tourGroup;
});
eventsService.emit("appState.tour.updatedTours", tours);
}
/**
* Method to return all of the tours as a new instance
*/
@@ -334,10 +260,6 @@
var service = {
registerAllTours: registerAllTours,
registerTour: registerTour,
registerTours: registerTours,
unregisterTour: unregisterTour,
unregisterTourGroup: unregisterTourGroup,
startTour: startTour,
endTour: endTour,
disableTour: disableTour,