Skip to content

Instantly share code, notes, and snippets.

@westfall
Created January 12, 2015 15:03
Show Gist options
  • Save westfall/22dc3fe56a27f816ba0b to your computer and use it in GitHub Desktop.
Save westfall/22dc3fe56a27f816ba0b to your computer and use it in GitHub Desktop.
I am creating an Umbraco solution, using grid layout in v 7.2. I need some custom elements, so my thought was to use macros and Property Editors. I need to figure out how to populate my Multi Node Tree Picker from my angular controller, any help is appreciated.
angular.module("umbraco").controller("MultiNodeTreePickerEditor.controller",
function ($scope, assetsService, $http, dialogService, mediaHelper) {
$scope.model.value = [];
// fetch new items and insert them
if ($scope.model.value.length === 0) {
}
// Remove an item from the Multi Node Tree Picker
$scope.remove = function (item) {
$scope.model.value.splice($scope.model.value.indexOf(item), 1);
};
// Render the Multi Node Tree Picker
$scope.pickContent = function (slide) {
dialogService.treePicker({
multiPicker: true,
section: "content",
treeAlias: "content",
callback: function (data) {
$scope.model.value = data.map(function (link) {
return { id: link.id, name: link.name };
});
}
});
};
});
<div ng-controller="MultiNodeTreePickerEditor.controller">
<i class="icon icon-add blue"></i>
<a href ng-click="pickContent(item)">link</a>
<div ng-repeat="item in model.value">
<a ng-click="remove(item)">
<i class="icon icon-delete red"></i>
{{item.name}}
</a>
</div>
</div>
{
propertyEditors: [
{
alias: "MultiNodeTreePickerEditor",
name: "Multi Node Tree Picker Editor",
isParameterEditor: true,
hideLabel: true,
editor: {
view: "~/App_Plugins/MultiNodeTreePicker/MultiNodeTreePickerEditor.html",
valueType: "JSON"
}
}
]
,
javascript: [
'~/App_Plugins/MultiNodeTreePicker/MultiNodeTreePickerEditor.controller.js'
]
}
@westfall
Copy link
Author

westfall commented Sep 9, 2015

I started using another implementation, so I don't have to rely on macros at all. I did not get this work and I doubt there is a reasonable way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment