Adds RequiredForPersistenceAttribute to easily detect if any entity fails validation in a way that it cannot be persisted to the data store. Changes all tree events to not be jquery events and to not require a 'callback' jquery object, instead we just use angular events broadcast globally, much nicer.

This commit is contained in:
Shannon
2013-07-18 17:05:40 +10:00
parent 17eb3db336
commit d3fe37a080
14 changed files with 139 additions and 315 deletions

View File

@@ -4,7 +4,7 @@
* @restrict E
**/
angular.module("umbraco.directives")
.directive('umbTree', function ($compile, $log, $q, treeService, notificationsService, $timeout) {
.directive('umbTree', function ($compile, $log, $q, $rootScope, treeService, notificationsService, $timeout) {
return {
restrict: 'E',
@@ -15,8 +15,7 @@ angular.module("umbraco.directives")
section: '@',
showoptions: '@',
showheader: '@',
cachekey: '@',
callback: '='
cachekey: '@'
},
compile: function (element, attrs) {
@@ -34,7 +33,7 @@ angular.module("umbraco.directives")
'</div>';
}
template += '<ul>' +
'<umb-tree-item ng-repeat="child in tree.root.children" node="child" callback="callback" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
'<umb-tree-item ng-repeat="child in tree.root.children" node="child" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
'</ul>' +
'</li>' +
'</ul>';
@@ -56,9 +55,7 @@ angular.module("umbraco.directives")
/** Helper function to emit tree events */
function emitEvent(eventName, args) {
if (scope.callback) {
$(scope.callback).trigger(eventName, args);
}
$rootScope.$broadcast(eventName, args);
}
/** Method to load in the tree data */

View File

@@ -18,7 +18,7 @@
</example>
*/
angular.module("umbraco.directives")
.directive('umbTreeItem', function($compile, $http, $templateCache, $interpolate, $log, $location, treeService, notificationsService) {
.directive('umbTreeItem', function ($compile, $http, $templateCache, $interpolate, $log, $location, $rootScope, treeService, notificationsService) {
return {
restrict: 'E',
replace: true,
@@ -46,11 +46,9 @@ angular.module("umbraco.directives")
var enableDeleteAnimations = true;
/** Helper function to emit tree events */
function emitEvent(eventName, args){
if(scope.callback){
$(scope.callback).trigger(eventName,args);
}
function emitEvent(eventName, args) {
$rootScope.$broadcast(eventName, args);
}
/**

View File

@@ -20,10 +20,7 @@ angular.module('umbraco.services')
.factory('navigationService', function ($rootScope, $routeParams, $log, $location, $q, dialogService, treeService, notificationsService) {
//TODO: would be nicer to set all of the options here first instead of implicitly below!
var ui = {
//tree event handler everyone can subscribe to (TODO: but why not use angular events instead of jquery ?)
tree: $({})
};
var ui = {};
function setMode(mode) {
switch (mode) {

View File

@@ -3,7 +3,8 @@ angular.module("umbraco").controller("Umbraco.Dialogs.ContentPickerController",
function ($scope) {
$scope.treeCallback = $({});
$scope.treeCallback.bind("treeNodeSelect", function(event, args){
//$scope.treeCallback.bind("treeNodeSelect", function(event, args){
$scope.$on("treeNodeSelect", function (ev, args) {
args.event.preventDefault();
args.event.stopPropagation();

View File

@@ -33,20 +33,16 @@ function NavigationController($scope,$rootScope, $location, $log, navigationServ
});
//this reacts to the options item in the tree
navigationService.ui.tree.bind("treeOptionsClick", function (ev, args) {
ev.stopPropagation();
ev.preventDefault();
$scope.$on("treeOptionsClick", function (ev, args) {
$scope.currentNode = args.node;
args.scope = $scope;
navigationService.showMenu(ev, args);
});
//this reacts to tree items themselves being clicked
//the tree directive should not contain any handling, simply just bubble events
navigationService.ui.tree.bind("treeNodeSelect", function (ev, args) {
$scope.$on("treeNodeSelect", function (ev, args) {
var n = args.node;
//here we need to check for some legacy tree code

View File

@@ -65,7 +65,7 @@
<!-- the tree -->
<div id="tree" class="span5 umb-scrollable umb-panel" auto-scale="0" ng-animate="'slide'">
<umb-tree callback="nav.ui.tree" section="{{nav.ui.currentSection}}" ></umb-tree>
<umb-tree section="{{nav.ui.currentSection}}" ></umb-tree>
</div>
<!-- The context menu -->