support for fetching a specific tree

This commit is contained in:
perploug
2013-10-10 08:51:46 +02:00
parent 79f7ea60f2
commit a2df4ea742
6 changed files with 36 additions and 16 deletions

View File

@@ -13,12 +13,13 @@ angular.module("umbraco.directives")
scope: {
section: '@',
treealias: '@',
path: '@',
activetree: '@',
showoptions: '@',
showheader: '@',
cachekey: '@',
eventhandler: '=',
path: '@'
eventhandler: '='
},
compile: function (element, attrs) {
@@ -73,14 +74,14 @@ angular.module("umbraco.directives")
enableDeleteAnimations = false;
//use $q.when because a promise OR raw data might be returned.
$q.when(treeService.getTree({ section: scope.section, cachekey: scope.cachekey }))
$q.when(treeService.getTree({ section: scope.section, tree: scope.treealias, cachekey: scope.cachekey }))
.then(function (data) {
//set the data once we have it
scope.tree = data;
//do timeout so that it re-enables them after this digest
$timeout(function() {
scope.tree = data;
//enable delete animations
enableDeleteAnimations = true;
});

View File

@@ -39,12 +39,19 @@ function treeResource($q, $http, umbRequestHelper) {
throw "The object specified for does not contain a 'section' property";
}
if(!options.tree){
options.tree = "";
}
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"treeApplicationApiBaseUrl",
"GetApplicationTrees",
[{ application: options.section }])),
[
{application: options.section},
{tree: options.tree}
])),
'Failed to retreive data for application tree ' + options.section);
},

View File

@@ -4,6 +4,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController",
var dialogOptions = $scope.$parent.dialogOptions;
$scope.dialogTreeEventHandler = $({});
$scope.section = dialogOptions.section;
$scope.treeAlias = dialogOptions.treeAlias;
$scope.dialogTreeEventHandler.bind("treeNodeSelect", function(ev, args){

View File

@@ -3,7 +3,8 @@
<div class="tab-content umb-control-group">
<div class="umb-pane">
<umb-tree
section="{{section}}"
section="{{section}}"
treealias="{{treeAlias}}"
cachekey="treepickerDialog"
showheader="true"
showoptions="false"

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
[PropertyEditor(Constants.PropertyEditors.TinyMCEv3Alias, "Rich Text Editor", "rte", HideLabel = true)]
[PropertyEditor(Constants.PropertyEditors.TinyMCEv3Alias, "Rich Text Editor", "rte", HideLabel = false)]
public class RichTextPropertyEditor : PropertyEditor
{
/// <summary>

View File

@@ -39,7 +39,7 @@ namespace Umbraco.Web.Trees
/// <param name="queryStrings"></param>
/// <returns></returns>
[HttpQueryStringFilter("queryStrings")]
public SectionRootNode GetApplicationTrees(string application, FormDataCollection queryStrings)
public SectionRootNode GetApplicationTrees(string application, string tree, FormDataCollection queryStrings)
{
if (application == null) throw new ArgumentNullException("application");
@@ -47,24 +47,34 @@ namespace Umbraco.Web.Trees
//find all tree definitions that have the current application alias
var appTrees = ApplicationContext.Current.Services.ApplicationTreeService.GetApplicationTrees(application, true).ToArray();
if (appTrees.Count() == 1)
if (appTrees.Count() == 1 || !string.IsNullOrEmpty(tree) )
{
var tree = GetRootForSingleAppTree(
appTrees.Single(),
ApplicationTree apptree;
if (!string.IsNullOrEmpty(tree))
apptree = appTrees.Where(x => x.Alias == tree).Single();
else
apptree = appTrees.Single();
var result = GetRootForSingleAppTree(
apptree,
Constants.System.Root.ToString(CultureInfo.InvariantCulture),
queryStrings,
application);
//PP: should this be further down in the logic?
tree.Title = ui.Text("sections", application);
return tree;
result.Title = ui.Text("sections", application);
return result;
}
var collection = new TreeNodeCollection();
foreach (var tree in appTrees)
foreach (var apptree in appTrees)
{
//return the root nodes for each tree in the app
var rootNode = GetRootForMultipleAppTree(tree, queryStrings);
var rootNode = GetRootForMultipleAppTree(apptree, queryStrings);
collection.Add(rootNode);
}