diff --git a/src/main/webapp/directives/category.html b/src/main/webapp/directives/category.html index cd3be7d9..028a95f6 100644 --- a/src/main/webapp/directives/category.html +++ b/src/main/webapp/directives/category.html @@ -5,7 +5,7 @@
diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 27134b98..b4d9ae72 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -37,12 +37,14 @@ module.controller('CategoryTreeCtrl', var unreadCount = function(category) { var count = 0; - console.log(category) - for ( var child in category.children) { - count = count + unreadCount(child); + if (category.children) { + for ( var i = 0; i < category.children.length; i++) { + count = count + unreadCount(category.children[i]); + } } - for ( var feed in category.feeds) { - if (feed.unread) { + if (category.feeds) { + for ( var i = 0; i < category.feeds.length; i++) { + var feed = category.feeds[i]; count = count + feed.unread; } } @@ -58,6 +60,15 @@ module.controller('CategoryTreeCtrl', return label; } + $scope.formatFeedName = function(feed) { + console.log('cc') + var label = feed.name; + if (feed.unread > 0) { + label = label + " (" + feed.unread + ")"; + } + return label; + } + $scope.feedClicked = function(id) { $location.path('/feeds/view/feed/' + id); }; diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index 232c4c7a..0512bc8f 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -8,7 +8,8 @@ module.directive('category', function($compile) { selectedId: '=', feedClick: '&', categoryClick: '&', - formatCategoryName: '&' + formatCategoryName: '&', + formatFeedName: '&' }, restrict : 'E', replace: true, @@ -16,7 +17,10 @@ module.directive('category', function($compile) { link: function(scope, element) { if (scope.node.children) { var ul = element.find('ul'); - ul.prepend('