Removes hack for defaultAction, navigationService.showMenu now returns a promise because it needs to get the defaultAction from the resource. Fixes up the mock menu to have metaData assigned.
This commit is contained in:
@@ -9,9 +9,9 @@ angular.module('umbraco.mocks').
|
||||
}
|
||||
|
||||
var types = [
|
||||
{ name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" },
|
||||
{ name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" },
|
||||
{ name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" }
|
||||
{ name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, icon: "file" },
|
||||
{ name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, icon: "suitcase" },
|
||||
{ name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, icon: "user" }
|
||||
];
|
||||
return [200, types, null];
|
||||
}
|
||||
|
||||
@@ -9,24 +9,24 @@ angular.module('umbraco.mocks').
|
||||
}
|
||||
|
||||
var menu = [
|
||||
{ name: "Create", cssclass: "plus", alias: "create" },
|
||||
{ name: "Create", cssclass: "plus", alias: "create", metaData: {} },
|
||||
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete" },
|
||||
{ name: "Move", cssclass: "move", alias: "move" },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy" },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort" },
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete", metaData: {} },
|
||||
{ name: "Move", cssclass: "move", alias: "move", metaData: {} },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy", metaData: {} },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort", metaData: {} },
|
||||
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish" },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback" },
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish", metaData: {} },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback", metaData: {} },
|
||||
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions" },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail" },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications" },
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions", metaData: {} },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail", metaData: {} },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications", metaData: {} },
|
||||
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames" },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess" },
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames", metaData: {} },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess", metaData: {} },
|
||||
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users" }
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users", metaData: {} }
|
||||
];
|
||||
|
||||
return [200, menu, null];
|
||||
|
||||
@@ -66,7 +66,7 @@ angular.module('umbraco.services')
|
||||
return {
|
||||
mode: "default",
|
||||
ui: ui,
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.navigationService#load
|
||||
@@ -140,46 +140,54 @@ angular.module('umbraco.services')
|
||||
* @methodOf umbraco.services.navigationService
|
||||
*
|
||||
* @description
|
||||
* Hides the tree by hiding the containing dom element
|
||||
* Hides the tree by hiding the containing dom element.
|
||||
* This always returns a promise!
|
||||
*
|
||||
* @param {Event} event the click event triggering the method, passed from the DOM element
|
||||
*/
|
||||
showMenu: function (event, args) {
|
||||
if (args.event !== undefined && args.node.defaultAction && !args.event.altKey) {
|
||||
//hack for now, it needs the complete action object to, so either include in tree item json
|
||||
//or lookup in service...
|
||||
var act = {
|
||||
alias: args.node.defaultAction,
|
||||
name: args.node.defaultAction
|
||||
};
|
||||
|
||||
this.ui.currentNode = args.node;
|
||||
|
||||
//return the dialog this is opening.
|
||||
return this.showDialog({
|
||||
scope: args.scope,
|
||||
node: args.node,
|
||||
action: act,
|
||||
section: this.ui.currentTree
|
||||
});
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
|
||||
if (args.event !== undefined && args.node.defaultAction && !args.event.altKey) {
|
||||
|
||||
treeService.getMenuItemByAlias({ treeNode: args.node, menuItemAlias: args.node.defaultAction })
|
||||
.then(function(result) {
|
||||
|
||||
if (!result) {
|
||||
throw "No menu item found with alias " + args.node.defaultAction;
|
||||
}
|
||||
|
||||
self.ui.currentNode = args.node;
|
||||
|
||||
var dialog = self.showDialog({
|
||||
scope: args.scope,
|
||||
node: args.node,
|
||||
action: result,
|
||||
section: self.ui.currentTree
|
||||
});
|
||||
|
||||
//return the dialog this is opening.
|
||||
deferred.resolve(dialog);
|
||||
});
|
||||
}
|
||||
else {
|
||||
setMode("menu");
|
||||
|
||||
treeService.getActions({ node: args.node, section: this.ui.currentTree })
|
||||
.then(function (data) {
|
||||
ui.actions = data;
|
||||
}, function (err) {
|
||||
//display the error
|
||||
notificationsService.error(err.errorMsg);
|
||||
});
|
||||
|
||||
treeService.getMenu({ treeNode: args.node })
|
||||
.then(function(data) {
|
||||
ui.actions = data;
|
||||
});
|
||||
|
||||
this.ui.currentNode = args.node;
|
||||
this.ui.dialogTitle = args.node.name;
|
||||
|
||||
//we're not opening a dialog, return null.
|
||||
return null;
|
||||
deferred.resolve(null);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -253,10 +261,10 @@ angular.module('umbraco.services')
|
||||
|
||||
var templateUrl;
|
||||
var iframe;
|
||||
|
||||
|
||||
//TODO: fix hardcoded hack for content/media... once these trees are converted over to
|
||||
// new c# trees we won't need to do this any longer.
|
||||
var isCreateForContent = args.action.alias === "create" && (this.ui.currentTree === "content" && this.ui.currentTree === "media");
|
||||
var isCreateForContent = args.action.alias === "create" && (this.ui.currentTree === "content" || this.ui.currentTree === "media");
|
||||
|
||||
if (args.action.metaData["actionUrl"] && !isCreateForContent) {
|
||||
templateUrl = args.action.metaData["actionUrl"];
|
||||
@@ -266,7 +274,7 @@ angular.module('umbraco.services')
|
||||
templateUrl = "views/" + this.ui.currentTree + "/" + args.action.alias + ".html";
|
||||
iframe = false;
|
||||
}
|
||||
|
||||
|
||||
//TODO: some action's want to launch a new window like live editing, we support this in the menu item's metadata with
|
||||
// a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog
|
||||
// if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window,
|
||||
|
||||
@@ -57,9 +57,16 @@ function treeService($q, treeResource, iconHelper) {
|
||||
});
|
||||
},
|
||||
|
||||
getActions: function(treeItem, section) {
|
||||
getMenu: function (args) {
|
||||
|
||||
return treeResource.loadMenu(treeItem.node)
|
||||
if (!args) {
|
||||
throw "args cannot be null";
|
||||
}
|
||||
if (!args.treeNode) {
|
||||
throw "args.treeNode cannot be null";
|
||||
}
|
||||
|
||||
return treeResource.loadMenu(args.treeNode)
|
||||
.then(function(data) {
|
||||
//need to convert the icons to new ones
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
@@ -67,7 +74,41 @@ function treeService($q, treeResource, iconHelper) {
|
||||
}
|
||||
return data;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.treeService#getMenuItemByAlias
|
||||
* @methodOf umbraco.services.treeService
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Attempts to return a tree node's menu item based on the alias supplied, otherwise returns null.
|
||||
|
||||
* @param {object} args An arguments object
|
||||
* @param {object} args.treeNode The tree node to get the menu item for
|
||||
* @param {object} args.menuItemAlias The menu item alias to attempt to find
|
||||
*/
|
||||
getMenuItemByAlias: function (args) {
|
||||
|
||||
if (!args) {
|
||||
throw "args cannot be null";
|
||||
}
|
||||
if (!args.treeNode) {
|
||||
throw "args.treeNode cannot be null";
|
||||
}
|
||||
if (!args.menuItemAlias) {
|
||||
throw "args.menuItemAlias cannot be null";
|
||||
}
|
||||
|
||||
return this.getMenu(args)
|
||||
.then(function (menuItems) {
|
||||
//try to find the node with the alias
|
||||
return _.find(menuItems, function(item) {
|
||||
return item.alias === args.menuItemAlias;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getChildren: function (options) {
|
||||
|
||||
|
||||
@@ -59,7 +59,10 @@ function NavigationController($scope,$rootScope, $location, navigationService, d
|
||||
if (menuDialog) {
|
||||
dialogService.close(menuDialog);
|
||||
}
|
||||
menuDialog = navigationService.showMenu(ev, args);
|
||||
navigationService.showMenu(ev, args)
|
||||
.then(function(result) {
|
||||
menuDialog = result;
|
||||
});
|
||||
});
|
||||
|
||||
//this reacts to tree items themselves being clicked
|
||||
|
||||
Reference in New Issue
Block a user