diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 19:48:55 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 19:48:55 +0100 |
commit | 7b2a214017097098ad1d020fe9b4a5c8b767486f (patch) | |
tree | f4fae66a92d7e88906fb68e8f499f1c43f1418b6 | |
parent | f7c819938067fb6a81822f26943a5c136643a1f7 (diff) |
show title and author below feed
-rw-r--r-- | js/app/controllers/controllers.coffee | 6 | ||||
-rw-r--r-- | js/app/controllers/itemcontroller.coffee | 17 | ||||
-rw-r--r-- | js/public/app.js | 30 | ||||
-rw-r--r-- | js/tests/controllers/itemcontrollerSpec.coffee | 3 |
4 files changed, 37 insertions, 19 deletions
diff --git a/js/app/controllers/controllers.coffee b/js/app/controllers/controllers.coffee index a302b1033..41c272347 100644 --- a/js/app/controllers/controllers.coffee +++ b/js/app/controllers/controllers.coffee @@ -40,8 +40,8 @@ ShowAll, FeedType, StarredCount, Persistence, ItemModel)-> ] angular.module('News').controller 'ItemController', -['$scope', '_ItemController', 'ItemModel', 'FeedLoading', -($scope, _ItemController, ItemModel, FeedLoading)-> +['$scope', '_ItemController', 'ItemModel', 'FeedModel', 'FeedLoading', +($scope, _ItemController, ItemModel, FeedModel, FeedLoading)-> - return new _ItemController($scope, ItemModel, FeedLoading) + return new _ItemController($scope, ItemModel, FeedModel, FeedLoading) ]
\ No newline at end of file diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee index c23d84e14..0a2c1229e 100644 --- a/js/app/controllers/itemcontroller.coffee +++ b/js/app/controllers/itemcontroller.coffee @@ -2,7 +2,7 @@ ownCloud - News -@author Bernhard Posselt +@_author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.com This library is free software; you can redistribute it and/or @@ -25,12 +25,19 @@ angular.module('News').factory '_ItemController', -> class ItemController - constructor: (@$scope, @itemModel, @feedLoading) -> + constructor: (@_$scope, @_itemModel, @_feedModel, @_feedLoading) -> - @$scope.items = @itemModel.getAll() + @_$scope.items = @_itemModel.getAll() - @$scope.isLoading = => - return @feedLoading.isLoading() + @_$scope.isLoading = => + return @_feedLoading.isLoading() + + @_$scope.getFeedTitle = (feedId) => + feed = @_feedModel.getById(feedId) + if angular.isDefined(feed) + return feed.title + else + return '' return ItemController
\ No newline at end of file diff --git a/js/public/app.js b/js/public/app.js index 766317fd5..9efc9aece 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -155,8 +155,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ]); angular.module('News').controller('ItemController', [ - '$scope', '_ItemController', 'ItemModel', 'FeedLoading', function($scope, _ItemController, ItemModel, FeedLoading) { - return new _ItemController($scope, ItemModel, FeedLoading); + '$scope', '_ItemController', 'ItemModel', 'FeedModel', 'FeedLoading', function($scope, _ItemController, ItemModel, FeedModel, FeedLoading) { + return new _ItemController($scope, ItemModel, FeedModel, FeedLoading); } ]); @@ -451,7 +451,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ownCloud - News -@author Bernhard Posselt +@_author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.com This library is free software; you can redistribute it and/or @@ -475,14 +475,24 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var ItemController; ItemController = (function() { - function ItemController($scope, itemModel, feedLoading) { + function ItemController(_$scope, _itemModel, _feedModel, _feedLoading) { var _this = this; - this.$scope = $scope; - this.itemModel = itemModel; - this.feedLoading = feedLoading; - this.$scope.items = this.itemModel.getAll(); - this.$scope.isLoading = function() { - return _this.feedLoading.isLoading(); + this._$scope = _$scope; + this._itemModel = _itemModel; + this._feedModel = _feedModel; + this._feedLoading = _feedLoading; + this._$scope.items = this._itemModel.getAll(); + this._$scope.isLoading = function() { + return _this._feedLoading.isLoading(); + }; + this._$scope.getFeedTitle = function(feedId) { + var feed; + feed = _this._feedModel.getById(feedId); + if (angular.isDefined(feed)) { + return feed.title; + } else { + return ''; + } }; } diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee index 02682214f..19cce6c6f 100644 --- a/js/tests/controllers/itemcontrollerSpec.coffee +++ b/js/tests/controllers/itemcontrollerSpec.coffee @@ -32,7 +32,8 @@ describe '_ItemController', -> @persistence = { getItems: -> } - @controller = new @_ItemController(@scope, @ItemModel) + @controller = new @_ItemController(@scope, @ItemModel, @FeedModel) + it 'should make items availabe', => @ItemModel.getAll = jasmine.createSpy('ItemModel') |