Updated the tree structure to support the root section node. Now we actually get a menu listing for section roots when there is only one tree (i.e. media/content).
This commit is contained in:
@@ -24,18 +24,17 @@ angular.module("umbraco.directives")
|
||||
var hideheader = (attrs.showheader === 'false') ? true : false;
|
||||
var hideoptions = (attrs.showoptions === 'false') ? "hide-options" : "";
|
||||
|
||||
|
||||
|
||||
var template = '<ul class="umb-tree ' + hideoptions + '">' +
|
||||
'<li class="root">';
|
||||
|
||||
if(!hideheader){
|
||||
template +='<div>' +
|
||||
'<h5><a class="root-link">{{tree.name}}</a><i class="umb-options"><i></i><i></i><i></i></i></h5>' +
|
||||
'<h5><a class="root-link">{{tree.name}}</a></h5>' +
|
||||
'<i class="umb-options" ng-hide="tree.root.isContainer" ng-click="options(this, tree.root, $event)"><i></i><i></i><i></i></i>' +
|
||||
'</div>';
|
||||
}
|
||||
template += '<ul>' +
|
||||
'<umb-tree-item ng-repeat="child in tree.children" node="child" callback="callback" section="{{section}}"></umb-tree-item>' +
|
||||
'<umb-tree-item ng-repeat="child in tree.root.children" node="child" callback="callback" section="{{section}}"></umb-tree-item>' +
|
||||
'</ul>' +
|
||||
'</li>' +
|
||||
'</ul>';
|
||||
@@ -45,6 +44,22 @@ angular.module("umbraco.directives")
|
||||
|
||||
return function (scope, element, attrs, controller) {
|
||||
|
||||
/** Helper function to emit tree events */
|
||||
function emitEvent(eventName, args) {
|
||||
if (scope.callback) {
|
||||
$(scope.callback).trigger(eventName, args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Method called when the options button next to the root node is called.
|
||||
The tree doesnt know about this, so it raises an event to tell the parent controller
|
||||
about it.
|
||||
*/
|
||||
scope.options = function (e, n, ev) {
|
||||
emitEvent("treeOptionsClick", { element: e, node: n, event: ev });
|
||||
};
|
||||
|
||||
function loadTree() {
|
||||
if (scope.section) {
|
||||
|
||||
|
||||
@@ -74,39 +74,76 @@ angular.module('umbraco.mocks').
|
||||
switch (section) {
|
||||
|
||||
case "content":
|
||||
t = [
|
||||
t = {
|
||||
name: "content",
|
||||
id: -1,
|
||||
children: [
|
||||
{ name: "My website", id: 1234, childNodesUrl: url, icon: "icon-home", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menuUrl: menuUrl },
|
||||
{ name: "Components", id: 1235, childNodesUrl: url, icon: "icon-cogs", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menuUrl: menuUrl },
|
||||
{ name: "Archieve", id: 1236, childNodesUrl: url, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menuUrl: menuUrl },
|
||||
{ name: "Recycle Bin", id: 1237, childNodesUrl: url, icon: "icon-trash", view: section + "/trash/view/", children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menuUrl: menuUrl }
|
||||
];
|
||||
],
|
||||
expanded: true,
|
||||
hasChildren: true,
|
||||
level: 0,
|
||||
menuUrl: menuUrl
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case "developer":
|
||||
t = [
|
||||
{ name: "Data types", childNodesUrl: url, id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Macros", childNodesUrl: url, id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Pacakges", childNodesUrl: url, id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "XSLT Files", childNodesUrl: url, id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Razor Files", childNodesUrl: url, id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
];
|
||||
t = {
|
||||
name: "developer",
|
||||
id: -1,
|
||||
children: [
|
||||
{ name: "Data types", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Macros", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Pacakges", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "XSLT Files", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Razor Files", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
],
|
||||
expanded: true,
|
||||
hasChildren: true,
|
||||
level: 0,
|
||||
isContainer: true
|
||||
};
|
||||
|
||||
break;
|
||||
case "settings":
|
||||
t = [
|
||||
{ name: "Stylesheets", childNodesUrl: url, id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Templates", childNodesUrl: url, id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Dictionary", childNodesUrl: url, id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Media types", childNodesUrl: url, id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Document types", childNodesUrl: url, id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
];
|
||||
t = {
|
||||
name: "settings",
|
||||
id: -1,
|
||||
children: [
|
||||
{ name: "Stylesheets", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Templates", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Dictionary", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Media types", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "Document types", childNodesUrl: url, id: -1, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
],
|
||||
expanded: true,
|
||||
hasChildren: true,
|
||||
level: 0,
|
||||
isContainer: true
|
||||
};
|
||||
|
||||
break;
|
||||
default:
|
||||
t = [
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
];
|
||||
|
||||
t = {
|
||||
name: "randomTree",
|
||||
id: -1,
|
||||
children: [
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl },
|
||||
{ name: "random-name-" + section, childNodesUrl: url, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl }
|
||||
],
|
||||
expanded: true,
|
||||
hasChildren: true,
|
||||
level: 0,
|
||||
menuUrl: menuUrl
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ function treeService($q, treeResource, iconHelper) {
|
||||
var result = {
|
||||
name: section,
|
||||
alias: section,
|
||||
children: data
|
||||
root: data
|
||||
};
|
||||
//ensure the view is added to each tree node
|
||||
ensureParentLevelAndView(null, result.children, section);
|
||||
ensureParentLevelAndView(result.root, result.root.children, section);
|
||||
//cache this result
|
||||
//TODO: We'll need to un-cache this in many circumstances
|
||||
treeArray[cacheKey] = result;
|
||||
|
||||
@@ -124,6 +124,10 @@ i.umb-options i {
|
||||
margin: 10px -2px 0 0;
|
||||
}
|
||||
|
||||
li.root > div > i.umb-options {
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.hide-options .umb-options{display: none !important}
|
||||
.hide-header h5{display: none !important}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="leftcolumn" ng-controller="NavigationController" ng-mouseleave="hideTree()">
|
||||
<div id="leftcolumn" ng-controller="NavigationController" >
|
||||
<div id="applications" ng-class="{faded:ui.stickyNavigation}">
|
||||
<ul class="sections">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user