Merge pull request #2385 from umbraco/temp-U4-10804

Removed unused tour code from tour.service.js
This commit is contained in:
Claus
2018-01-12 10:54:27 +01:00
committed by GitHub

View File

@@ -37,7 +37,7 @@
*
* @description
* Registers a tour in the service
* @param {Object} tour The tour you want to register 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
@@ -46,7 +46,7 @@
* @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);
@@ -61,8 +61,8 @@
*
* @description
* Registers an array of tours in the service
* @param {Array} tours The tours to register in the service
*/
* @param {Array} tours The tours to register in the service
*/
function registerTours(newTours) {
angular.forEach(newTours, function(newTour){
validateTour(newTour);
@@ -79,8 +79,8 @@
*
* @description
* Unregisters a tour in the service
* @param {String} tourAlias The tour alias of the tour you want to unregister
*/
* @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;
@@ -95,8 +95,8 @@
*
* @description
* Unregisters a tour in the service
* @param {String} tourGroupName The name of the tour group you want to unregister
*/
* @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;
@@ -118,8 +118,8 @@
*
* @description
* Raises an event to start a tour
* @param {Object} tour The tour which should be started
*/
* @param {Object} tour The tour which should be started
*/
function startTour(tour) {
validateTour(tour);
eventsService.emit("appState.tour.start", tour);
@@ -133,7 +133,7 @@
*
* @description
* Raises an event to end the current tour
*/
*/
function endTour(tour) {
eventsService.emit("appState.tour.end", tour);
currentTour = null;
@@ -164,7 +164,7 @@
* @description
* Completes a tour for the user, raises an event and returns a promise
* @param {Object} tour The tour which should be completed
*/
*/
function completeTour(tour) {
var deferred = $q.defer();
tour.completed = true;
@@ -186,26 +186,12 @@
* @description
* Returns the current tour
* @returns {Object} Returns the current tour
*/
*/
function getCurrentTour() {
//TODO: This should be reset if a new user logs in
return currentTour;
}
/**
* @ngdoc method
* @name umbraco.services.tourService#getAllTours
* @methodOf umbraco.services.tourService
*
* @description
* Returns a promise of all tours with the current user statuses
* @returns {Array} All registered tours
*/
function getAllTours() {
var tours = getTours();
return setTourStatuses(tours);
}
/**
* @ngdoc method
* @name umbraco.services.tourService#getGroupedTours
@@ -214,7 +200,7 @@
* @description
* Returns a promise of grouped tours with the current user statuses
* @returns {Array} All registered tours grouped by tour group
*/
*/
function getGroupedTours() {
var deferred = $q.defer();
var tours = getTours();
@@ -265,7 +251,7 @@
* Returns a promise of the tour found by alias with the current user statuses
* @param {Object} tourAlias The tour alias of the tour which should be returned
* @returns {Object} Tour object
*/
*/
function getTourByAlias(tourAlias) {
var deferred = $q.defer();
var tours = getTours();
@@ -276,38 +262,6 @@
return deferred.promise;
}
/**
* @ngdoc method
* @name umbraco.services.tourService#getCompletedTours
* @methodOf umbraco.services.tourService
*
* @description
* Returns a promise of completed tours for the user
* @returns {Array} Array of completed tour aliases
*/
function getCompletedTours() {
var deferred = $q.defer();
currentUserResource.getTours().then(function (storedTours) {
var completedTours = _.where(storedTours, { completed: true });
var aliases = _.pluck(completedTours, "alias");
deferred.resolve(aliases);
});
return deferred.promise;
}
/**
* Returns a promise of disabled tours for the user
*/
function getDisabledTours() {
var deferred = $q.defer();
currentUserResource.getTours().then(function (storedTours) {
var disabledTours = _.where(storedTours, { disabled: true });
var aliases = _.pluck(disabledTours, "alias");
deferred.resolve(aliases);
});
return deferred.promise;
}
///////////
/**
@@ -378,40 +332,6 @@
return deferred.promise;
}
function saveInLocalStorage(tour) {
var storedTours = [];
var tourFound = false;
// check if something exists in local storage
if (localStorageService.get(localStorageKey)) {
storedTours = localStorageService.get(localStorageKey);
}
// update existing tour in localstorage if it's already there
if (storedTours.length > 0) {
angular.forEach(storedTours, function (storedTour) {
if (storedTour.alias === tour.alias) {
storedTour.completed = storedTour.completed ? storedTour.completed : tour.completed;
storedTour.disabled = storedTour.disabled ? storedTour.disabled : tour.disabled;
tourFound = true;
}
});
}
// create new entry in local storage
if (!tourFound) {
var storageObject = {
"alias": tour.alias,
"completed": tour.completed,
"disabled": tour.disabled
};
storedTours.push(storageObject);
}
localStorageService.set(localStorageKey, storedTours);
}
var service = {
registerAllTours: registerAllTours,
registerTour: registerTour,
@@ -423,14 +343,8 @@
disableTour: disableTour,
completeTour: completeTour,
getCurrentTour: getCurrentTour,
//TODO: Not used
getAllTours: getAllTours,
getGroupedTours: getGroupedTours,
getTourByAlias: getTourByAlias,
//TODO: Not used
getCompletedTours: getCompletedTours,
//TODO: Not used
getDisabledTours: getDisabledTours,
getTourByAlias: getTourByAlias
};
return service;
@@ -439,4 +353,4 @@
angular.module("umbraco.services").factory("tourService", tourService);
})();
})();