V8/doctype tours (#6980)
This commit is contained in:
committed by
Kenn Jacobsen
parent
2b4279315a
commit
eeaa5a82d4
@@ -20,10 +20,21 @@
|
||||
"GetTours")),
|
||||
'Failed to get tours');
|
||||
}
|
||||
|
||||
function getToursForDoctype(doctypeAlias) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"tourApiBaseUrl",
|
||||
"GetToursForDoctype",
|
||||
[{ doctypeAlias: doctypeAlias }])),
|
||||
'Failed to get tours');
|
||||
}
|
||||
|
||||
|
||||
var resource = {
|
||||
getTours: getTours
|
||||
getTours: getTours,
|
||||
getToursForDoctype: getToursForDoctype
|
||||
};
|
||||
|
||||
return resource;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
* it is possible to modify this object, so should be used with care
|
||||
*/
|
||||
angular.module('umbraco.services').factory("editorState", function ($rootScope) {
|
||||
angular.module('umbraco.services').factory("editorState", function ($rootScope, eventsService) {
|
||||
|
||||
var current = null;
|
||||
|
||||
@@ -30,6 +30,7 @@ angular.module('umbraco.services').factory("editorState", function ($rootScope)
|
||||
*/
|
||||
set: function (entity) {
|
||||
current = entity;
|
||||
eventsService.emit("editorState.changed", { entity: entity });
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,31 +134,33 @@
|
||||
var groupedTours = [];
|
||||
tours.forEach(function (item) {
|
||||
|
||||
var groupExists = false;
|
||||
var newGroup = {
|
||||
"group": "",
|
||||
"tours": []
|
||||
};
|
||||
if (item.contentType === null || item.contentType === '') {
|
||||
var groupExists = false;
|
||||
var newGroup = {
|
||||
"group": "",
|
||||
"tours": []
|
||||
};
|
||||
|
||||
groupedTours.forEach(function(group){
|
||||
// extend existing group if it is already added
|
||||
if(group.group === item.group) {
|
||||
if(item.groupOrder) {
|
||||
group.groupOrder = item.groupOrder
|
||||
groupedTours.forEach(function (group) {
|
||||
// extend existing group if it is already added
|
||||
if (group.group === item.group) {
|
||||
if (item.groupOrder) {
|
||||
group.groupOrder = item.groupOrder;
|
||||
}
|
||||
groupExists = true;
|
||||
group.tours.push(item);
|
||||
}
|
||||
groupExists = true;
|
||||
group.tours.push(item)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// push new group to array if it doesn't exist
|
||||
if(!groupExists) {
|
||||
newGroup.group = item.group;
|
||||
if(item.groupOrder) {
|
||||
newGroup.groupOrder = item.groupOrder
|
||||
// push new group to array if it doesn't exist
|
||||
if (!groupExists) {
|
||||
newGroup.group = item.group;
|
||||
if (item.groupOrder) {
|
||||
newGroup.groupOrder = item.groupOrder;
|
||||
}
|
||||
newGroup.tours.push(item);
|
||||
groupedTours.push(newGroup);
|
||||
}
|
||||
newGroup.tours.push(item);
|
||||
groupedTours.push(newGroup);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -188,6 +190,24 @@
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.tourService#getToursForDoctype
|
||||
* @methodOf umbraco.services.tourService
|
||||
*
|
||||
* @description
|
||||
* Returns a promise of the tours found by documenttype alias.
|
||||
* @param {Object} doctypeAlias The doctype alias for which the tours which should be returned
|
||||
* @returns {Array} An array of tour objects for the doctype
|
||||
*/
|
||||
function getToursForDoctype(doctypeAlias) {
|
||||
var deferred = $q.defer();
|
||||
tourResource.getToursForDoctype(doctypeAlias).then(function (tours) {
|
||||
deferred.resolve(tours);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
///////////
|
||||
|
||||
/**
|
||||
@@ -269,7 +289,8 @@
|
||||
completeTour: completeTour,
|
||||
getCurrentTour: getCurrentTour,
|
||||
getGroupedTours: getGroupedTours,
|
||||
getTourByAlias: getTourByAlias
|
||||
getTourByAlias: getTourByAlias,
|
||||
getToursForDoctype : getToursForDoctype
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter) {
|
||||
function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState) {
|
||||
|
||||
var vm = this;
|
||||
var evts = [];
|
||||
@@ -18,6 +18,10 @@
|
||||
vm.startTour = startTour;
|
||||
vm.getTourGroupCompletedPercentage = getTourGroupCompletedPercentage;
|
||||
vm.showTourButton = showTourButton;
|
||||
|
||||
vm.showDocTypeTour = false;
|
||||
vm.docTypeTours = [];
|
||||
vm.nodeName = '';
|
||||
|
||||
function startTour(tour) {
|
||||
tourService.startTour(tour);
|
||||
@@ -58,9 +62,16 @@
|
||||
handleSectionChange();
|
||||
}));
|
||||
|
||||
evts.push(eventsService.on("editorState.changed",
|
||||
function (e, args) {
|
||||
setDocTypeTour(args.entity);
|
||||
}));
|
||||
|
||||
findHelp(vm.section, vm.tree, vm.userType, vm.userLang);
|
||||
|
||||
});
|
||||
|
||||
setDocTypeTour(editorState.getCurrent());
|
||||
|
||||
// check if a tour is running - if it is open the matching group
|
||||
var currentTour = tourService.getCurrentTour();
|
||||
@@ -84,7 +95,7 @@
|
||||
|
||||
setSectionName();
|
||||
findHelp(vm.section, vm.tree, vm.userType, vm.userLang);
|
||||
|
||||
setDocTypeTour();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -168,6 +179,26 @@
|
||||
});
|
||||
}
|
||||
|
||||
function setDocTypeTour(node) {
|
||||
vm.showDocTypeTour = false;
|
||||
vm.docTypeTours = [];
|
||||
vm.nodeName = '';
|
||||
|
||||
if (vm.section === 'content' && vm.tree === 'content') {
|
||||
|
||||
if (node) {
|
||||
tourService.getToursForDoctype(node.contentTypeAlias).then(function (data) {
|
||||
if (data && data.length > 0) {
|
||||
vm.docTypeTours = data;
|
||||
var currentVariant = _.find(node.variants, (x) => x.active);
|
||||
vm.nodeName = currentVariant.name;
|
||||
vm.showDocTypeTour = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
evts.push(eventsService.on("appState.tour.complete", function (event, tour) {
|
||||
tourService.getGroupedTours().then(function(groupedTours) {
|
||||
vm.tours = groupedTours;
|
||||
|
||||
@@ -8,12 +8,34 @@
|
||||
|
||||
<umb-drawer-content>
|
||||
|
||||
<!-- Tours -->
|
||||
<div class="umb-help-section" ng-if="vm.tours.length > 0" data-element="help-tours">
|
||||
<!-- Doctype Tours -->
|
||||
<div class="umb-help-section" ng-if="vm.showDocTypeTour" data-element="doctype-tour">
|
||||
<h5>Need help editing current item '{{vm.nodeName}}' ?</h5>
|
||||
|
||||
<h5 class="umb-help-section__title">Tours</h5>
|
||||
<div class="umb-help-list">
|
||||
|
||||
<div ng-repeat="tourGroup in vm.tours | orderBy:'groupOrder'">
|
||||
|
||||
<div ng-repeat="tour in vm.docTypeTours | orderBy:'groupOrder'">
|
||||
<div data-element="tour-{{tour.alias}}" class="umb-help-list-item">
|
||||
<div class="umb-help-list-item__content justify-between">
|
||||
<div class="flex items-center">
|
||||
<span class="umb-help-list-item__title">{{ tour.name }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<umb-button button-style="primary" size="xxs" type="button" label="Start" action="vm.startTour(tour)"></umb-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tours -->
|
||||
<div class="umb-help-section" ng-if="vm.tours.length > 0" data-element="help-tours">
|
||||
|
||||
<h5 class="umb-help-section__title">Tours</h5>
|
||||
|
||||
<div ng-repeat="tourGroup in vm.tours | orderBy:'groupOrder'">
|
||||
|
||||
<div class="umb-help-list">
|
||||
|
||||
@@ -51,33 +73,33 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Show in custom help dashboard -->
|
||||
<div class="umb-help-section" data-element="help-custom-dashboard" ng-if="vm.customDashboard.length > 0">
|
||||
<div ng-repeat="dashboard in vm.customDashboard">
|
||||
<h5 ng-show="dashboard.label">{{dashboard.label}}</h5>
|
||||
<div ng-repeat="property in dashboard.properties">
|
||||
<div>
|
||||
<div ng-include="property.view"></div>
|
||||
<!-- Show in custom help dashboard -->
|
||||
<div class="umb-help-section" data-element="help-custom-dashboard" ng-if="vm.customDashboard.length > 0">
|
||||
<div ng-repeat="dashboard in vm.customDashboard">
|
||||
<h5 ng-show="dashboard.label">{{dashboard.label}}</h5>
|
||||
<div ng-repeat="property in dashboard.properties">
|
||||
<div>
|
||||
<div ng-include="property.view"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Help Content -->
|
||||
<div class="umb-help-section" data-element="help-articles" ng-if="vm.topics.length > 0">
|
||||
<h5 class="umb-help-section__title">Articles</h5>
|
||||
<ul class="umb-help-list">
|
||||
<li class="umb-help-list-item" ng-repeat="topic in vm.topics track by $index">
|
||||
<a class="umb-help-list-item__content" data-element="help-article-{{topic.name}}" target="_blank" ng-href="{{topic.url}}?utm_source=core&utm_medium=help&utm_content=link&utm_campaign=tv">
|
||||
<span>
|
||||
<span class="umb-help-list-item__title">
|
||||
<span class="bold">{{topic.name}}</span>
|
||||
<span class="umb-help-list-item__open-icon icon-out"></span>
|
||||
</span>
|
||||
<span class="umb-help-list-item__description">{{topic.description}}</span>
|
||||
</span>
|
||||
<!-- Help Content -->
|
||||
<div class="umb-help-section" data-element="help-articles" ng-if="vm.topics.length > 0">
|
||||
<h5 class="umb-help-section__title">Articles</h5>
|
||||
<ul class="umb-help-list">
|
||||
<li class="umb-help-list-item" ng-repeat="topic in vm.topics track by $index">
|
||||
<a class="umb-help-list-item__content" data-element="help-article-{{topic.name}}" target="_blank" ng-href="{{topic.url}}?utm_source=core&utm_medium=help&utm_content=link&utm_campaign=tv">
|
||||
<span>
|
||||
<span class="umb-help-list-item__title">
|
||||
<span class="bold">{{topic.name}}</span>
|
||||
<span class="umb-help-list-item__open-icon icon-out"></span>
|
||||
</span>
|
||||
<span class="umb-help-list-item__description">{{topic.description}}</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -110,6 +110,39 @@ namespace Umbraco.Web.Editors
|
||||
return result.Except(toursToBeRemoved).OrderBy(x => x.FileName, StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a tours for a specific doctype
|
||||
/// </summary>
|
||||
/// <param name="doctypeAlias">The documenttype alias</param>
|
||||
/// <returns>A <see cref="BackOfficeTour"/></returns>
|
||||
public IEnumerable<BackOfficeTour> GetToursForDoctype(string doctypeAlias)
|
||||
{
|
||||
var tourFiles = this.GetTours();
|
||||
|
||||
var doctypeAliasWithCompositions = new List<string>
|
||||
{
|
||||
doctypeAlias
|
||||
};
|
||||
|
||||
var contentType = this.Services.ContentTypeService.Get(doctypeAlias);
|
||||
|
||||
if (contentType != null)
|
||||
{
|
||||
doctypeAliasWithCompositions.AddRange(contentType.CompositionAliases());
|
||||
}
|
||||
|
||||
return tourFiles.SelectMany(x => x.Tours)
|
||||
.Where(x =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(x.ContentType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var contentTypes = x.ContentType.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(ct => ct.Trim());
|
||||
return contentTypes.Intersect(doctypeAliasWithCompositions).Any();
|
||||
});
|
||||
}
|
||||
|
||||
private void TryParseTourFile(string tourFile,
|
||||
ICollection<BackOfficeTourFile> result,
|
||||
List<BackOfficeTourFilter> filters,
|
||||
|
||||
@@ -31,5 +31,8 @@ namespace Umbraco.Web.Models
|
||||
|
||||
[DataMember(Name = "culture")]
|
||||
public string Culture { get; set; }
|
||||
|
||||
[DataMember(Name = "contentType")]
|
||||
public string ContentType { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user