New treepicker

This commit is contained in:
perploug
2013-09-16 16:05:56 +02:00
parent 681ce4abb3
commit 0a2fa12b58
3 changed files with 69 additions and 0 deletions

View File

@@ -356,6 +356,26 @@ angular.module('umbraco.services')
return openDialog(options);
},
/**
* @ngdoc method
* @name umbraco.services.dialogService#treePicker
* @methodOf umbraco.services.dialogService
*
* @description
* Opens a tree picker in a modal, the callback returns a object representing the selected tree item
* @param {Object} options iconpicker dialog options object
* @param {$scope} options.scope dialog scope
* @param {$scope} options.section tree section to display
* @param {$scope} options.multiPicker should the tree pick one or multiple items before returning
* @param {Function} options.callback callback function
* @returns {Object} modal object
*/
treePicker: function (options) {
options.template = 'views/common/dialogs/treePicker.html';
options.show = true;
return openDialog(options);
},
/**
* @ngdoc method
* @name umbraco.services.dialogService#propertyDialog

View File

@@ -0,0 +1,26 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController",
function ($scope, eventsService, $log) {
var dialogOptions = $scope.$parent.dialogOptions;
$scope.dialogTreeEventHandler = $({});
$scope.section = dialogOptions.section | "content";
$scope.dialogTreeEventHandler.bind("treeNodeSelect", function(ev, args){
args.event.preventDefault();
args.event.stopPropagation();
eventsService.publish("Umbraco.Dialogs.TreePickerController.Select", args).then(function(args){
if(dialogOptions && dialogOptions.multipicker){
$(args.event.target.parentElement)
.find("i.umb-tree-icon")
.attr("class", "icon umb-tree-icon sprTree icon-check blue");
$scope.select(args.node);
}else{
$scope.submit(args.node);
}
});
});
});

View File

@@ -0,0 +1,23 @@
<div class="umb-panel" ng-controller="Umbraco.Dialogs.TreePickerController">
<div class="umb-panel-header">
<div class="umb-el-wrap umb-panel-buttons">
<div class="btn-toolbar umb-btn-toolbar">
<input type="button" ng-click="submit(dialogData)" class="btn btn-primary" value="select" />
</div>
</div>
</div>
<div class="umb-panel-body umb-scrollable">
<div class="tab-content umb-control-group">
<div class="umb-pane">
<umb-tree
section="{{section}}"
cachekey="contentpickerDialog"
showheader="false"
showoptions="false"
eventhandler="dialogTreeEventHandler">
</umb-tree>
</div>
</div>
</div>
</div>