Updates tree/resource/service so that devs can provider their own custom query string data to load trees/dialogs if required.
This commit is contained in:
@@ -17,7 +17,8 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
showheader: '@',
|
||||
cachekey: '@',
|
||||
isdialog: '@',
|
||||
startnodeid: '@',
|
||||
//Custom query string arguments to pass in to the tree as a string, example: "startnodeid=123&something=value"
|
||||
customtreeparams: '@',
|
||||
eventhandler: '='
|
||||
},
|
||||
|
||||
@@ -220,7 +221,15 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
//anytime we want to load the tree we need to disable the delete animations
|
||||
deleteAnimations = false;
|
||||
|
||||
treeService.getTree({ section: scope.section, tree: scope.treealias, cacheKey: scope.cachekey, isDialog: scope.isdialog ? scope.isdialog : false, startNodeId: scope.startnodeid ? scope.startnodeid : -1 })
|
||||
//default args
|
||||
var args = { section: scope.section, tree: scope.treealias, cacheKey: scope.cachekey, isDialog: scope.isdialog ? scope.isdialog : false };
|
||||
|
||||
//add the extra query string params if specified
|
||||
if (scope.customtreeparams) {
|
||||
args["queryString"] = scope.customtreeparams;
|
||||
}
|
||||
|
||||
treeService.getTree(args)
|
||||
.then(function(data) {
|
||||
//set the data once we have it
|
||||
scope.tree = data;
|
||||
|
||||
@@ -45,8 +45,13 @@ function treeResource($q, $http, umbRequestHelper) {
|
||||
if (!options.isDialog) {
|
||||
options.isDialog = false;
|
||||
}
|
||||
if (!options.startNodeId) {
|
||||
options.startNodeId = -1;
|
||||
|
||||
//create the query string for the tree request, these are the mandatory options:
|
||||
var query = "application=" + options.section + "&tree=" + options.tree + "&isDialog=" + options.isDialog;
|
||||
|
||||
//the options can contain extra query string parameters
|
||||
if (options.queryString) {
|
||||
query += "&" + options.queryString;
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
@@ -54,12 +59,7 @@ function treeResource($q, $http, umbRequestHelper) {
|
||||
umbRequestHelper.getApiUrl(
|
||||
"treeApplicationApiBaseUrl",
|
||||
"GetApplicationTrees",
|
||||
[
|
||||
{application: options.section},
|
||||
{ tree: options.tree },
|
||||
{ isDialog: options.isDialog },
|
||||
{ startNodeId: options.startNodeId }
|
||||
])),
|
||||
query)),
|
||||
'Failed to retreive data for application tree ' + options.section);
|
||||
},
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController",
|
||||
$scope.multiPicker = dialogOptions.multiPicker;
|
||||
$scope.startNodeId = dialogOptions.startNodeId;
|
||||
|
||||
//create the custom query string param for this tree
|
||||
$scope.customTreeParams = "startNodeId=" + dialogOptions.startNodeId;
|
||||
if (dialogOptions.customTreeParams) {
|
||||
$scope.customTreeParams += "&" + dialogOptions.customTreeParams;
|
||||
}
|
||||
|
||||
//search defaults
|
||||
$scope.searcher = searchService.searchContent;
|
||||
$scope.entityType = "Document";
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
showheader="true"
|
||||
showoptions="false"
|
||||
isdialog="true"
|
||||
startnodeid="{{startNodeId}}"
|
||||
customtreeparams="{{customTreeParams}}"
|
||||
eventhandler="dialogTreeEventHandler">
|
||||
</umb-tree>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user