diff options
-rw-r--r-- | js/app/controllers/controllers.coffee | 6 | ||||
-rw-r--r-- | js/app/controllers/feedcontroller.coffee | 81 | ||||
-rw-r--r-- | js/app/services/bl/feedbl.coffee | 65 | ||||
-rw-r--r-- | js/app/services/bl/folderbl.coffee | 56 | ||||
-rw-r--r-- | js/app/services/bl/itembl.coffee | 38 | ||||
-rw-r--r-- | js/app/services/models/itemmodel.coffee | 21 | ||||
-rw-r--r-- | js/app/services/services.coffee | 32 | ||||
-rw-r--r-- | js/app/services/statusflag.coffee | 31 | ||||
-rw-r--r-- | js/public/app.js | 416 | ||||
-rw-r--r-- | js/tests/controllers/feedcontrollerSpec.coffee | 179 | ||||
-rw-r--r-- | js/tests/services/bl/feedblSpec.coffee | 109 | ||||
-rw-r--r-- | js/tests/services/bl/folderblSpec.coffee | 82 | ||||
-rw-r--r-- | js/tests/services/bl/itemblSpec.coffee | 49 | ||||
-rw-r--r-- | js/tests/services/models/itemmodelSpec.coffee | 76 | ||||
-rw-r--r-- | js/tests/services/statusflagSpec.coffee | 36 |
15 files changed, 949 insertions, 328 deletions
diff --git a/js/app/controllers/controllers.coffee b/js/app/controllers/controllers.coffee index 41c272347..a7d86b074 100644 --- a/js/app/controllers/controllers.coffee +++ b/js/app/controllers/controllers.coffee @@ -30,13 +30,13 @@ angular.module('News').controller 'SettingsController', angular.module('News').controller 'FeedController', ['$scope', '_FeedController', 'FolderModel', 'FeedModel', 'ActiveFeed', -'ShowAll', 'FeedType', 'StarredCount', 'Persistence', 'ItemModel', +'ShowAll', 'FeedType', 'StarredCount', 'Persistence', 'FolderBl', 'FeedBl', ($scope, _FeedController, FolderModel, FeedModel, ActiveFeed, -ShowAll, FeedType, StarredCount, Persistence, ItemModel)-> +ShowAll, FeedType, StarredCount, Persistence, FolderBl, FeedBl)-> return new _FeedController($scope, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, - ItemModel) + FolderBl, FeedBl) ] angular.module('News').controller 'ItemController', diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee index 82586378f..580bd4763 100644 --- a/js/app/controllers/feedcontroller.coffee +++ b/js/app/controllers/feedcontroller.coffee @@ -27,7 +27,7 @@ angular.module('News').factory '_FeedController', -> constructor: (@$scope, @_folderModel, @_feedModel, @_active, @_showAll, @_feedType, @_starredCount, @_persistence, - @_itemModel) -> + @_folderBl, @_feedBl) -> @_isAddingFolder = false @_isAddingFeed = false @@ -36,15 +36,24 @@ angular.module('News').factory '_FeedController', -> @$scope.feeds = @_feedModel.getAll() @$scope.folders = @_folderModel.getAll() @$scope.feedType = @_feedType + @$scope.folderBl = @_folderBl + @$scope.feedBl = @_feedBl - @$scope.isFeedActive = (type, id) => - return @isFeedActive(type, id) @$scope.isShown = (type, id) => return @isShown(type, id) - @$scope.getUnreadCount = (type, id) => - return @getUnreadCount(type, id) + @$scope.getUnreadCount = => + return @_transFormCount(@_feedBl.getUnreadCount()) + + @$scope.getStarredCount = => + return @_transFormCount(@_starredCount.getStarredCount()) + + @$scope.getFeedUnreadCount = (feedId) => + return @_transFormCount(@_feedBl.getFeedUnreadCount(feedId)) + + @$scope.getUnreadCount = (folderId) => + return @_transFormCount(@_folderBl.getFolderUnreadCount(folderId)) @$scope.isShowAll = => return @isShowAll() @@ -120,17 +129,6 @@ angular.module('News').factory '_FeedController', -> @_isAddingFolder = false - toggleFolder: (folderId) -> - folder = @_folderModel.getById(folderId) - - if angular.isDefined(folder) - folder.open = !folder.open - if folder.open - @_persistence.openFolder(folder.id) - else - @_persistence.collapseFolder(folder.id) - - isFeedActive: (type, id) -> return type == @_active.getType() and id == @_active.getId() @@ -155,18 +153,7 @@ angular.module('News').factory '_FeedController', -> return @_showAll.getShowAll() - getUnreadCount: (type, id) -> - # TODO: use polymorphism instead of switches - switch type - when @_feedType.Subscriptions - count = @_feedModel.getUnreadCount() - when @_feedType.Starred - count = @_starredCount.getStarredCount() - when @_feedType.Feed - count = @_feedModel.getFeedUnreadCount(id) - when @_feedType.Folder - count = @_feedModel.getFolderUnreadCount(id) - + _transFormCount: (count) -> if count > 999 count = '999+' @@ -184,44 +171,6 @@ angular.module('News').factory '_FeedController', -> @_persistence.getItems(type, id, 0, null, lastModified) - hasFeeds: (folderId) -> - return @_feedModel.getAllOfFolder(folderId).length - - - delete: (type, id) -> - # TODO: use polymorphism instead of switches - switch type - when @_feedType.Feed - count = @_feedModel.removeById(id) - @_persistence.deleteFeed(id) - when @_feedType.Folder - count = @_folderModel.removeById(id) - @_persistence.deleteFolder(id) - - - markAllRead: (type, id) -> - # TODO: use polymorphism instead of switches - switch type - when @_feedType.Subscriptions - for feed in @_feedModel.getAll() - @markAllRead(@_feedType.Feed, feed.id) - when @_feedType.Feed - feed = @_feedModel.getById(id) - if angular.isDefined(feed) - feed.unreadCount = 0 - # TODO: also update items in the right field if id is the - # the same - highestItemId = @_itemModel.getHighestId() - @_persistence.setFeedRead(id, highestItemId) - when @_feedType.Folder - for feed in @_feedModel.getAllOfFolder(id) - @markAllRead(@_feedType.Feed, feed.id) - - - getFeedsOfFolder: (folderId) -> - return @_feedModel.getAllOfFolder(folderId) - - setShowAll: (showAll) -> @_showAll.setShowAll(showAll) if showAll diff --git a/js/app/services/bl/feedbl.coffee b/js/app/services/bl/feedbl.coffee new file mode 100644 index 000000000..1c2e4af09 --- /dev/null +++ b/js/app/services/bl/feedbl.coffee @@ -0,0 +1,65 @@ +### + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. + +### + + +angular.module('News').factory '_FeedBl', -> + + class FeedBl + + constructor: (@_feedModel, @_itemBl, @_persistence) -> + + + getUnreadCount: (feedId) -> + @_feedModel.getFeedUnreadCount(feedId) + + + getFeedsOfFolder: (folderId) -> + return @_feedModel.getAllOfFolder(folderId) + + + getFolderUnreadCount: (folderId) -> + @_feedModel.getFolderUnreadCount(folderId) + + + getUnreadCount: -> + return @_feedModel.getUnreadCount() + + + delete: (feedId) -> + @_feedModel.removeById(feedId) + @_persistence.deleteFeed(feedId) + + + markFeedRead: (feedId) -> + feed = @_feedModel.getById(feedId) + if angular.isDefined(feed) + feed.unreadCount = 0 + @_itemBl.markAllRead(feedId) + + + markAllRead: -> + for feed in @_feedModel.getAll() + @markFeedRead(feed.id) + + + + return FeedBl diff --git a/js/app/services/bl/folderbl.coffee b/js/app/services/bl/folderbl.coffee new file mode 100644 index 000000000..e869453f2 --- /dev/null +++ b/js/app/services/bl/folderbl.coffee @@ -0,0 +1,56 @@ +### + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. + +### + + +angular.module('News').factory '_FolderBl', -> + + class FolderBl + + constructor: (@_folderModel, @_feedBl, @_persistence) -> + + + delete: (folderId) -> + @_folderModel.removeById(folderId) + @_persistence.deleteFolder(folderId) + + + hasFeeds: (folderId) -> + return @_feedBl.getFeedsOfFolder(folderId).length + + + markFolderRead: (folderId) -> + for feed in @_feedBl.getFeedsOfFolder(folderId) + @_feedBl.markFeedRead(feed.id) + + + toggleFolder: (folderId) -> + folder = @_folderModel.getById(folderId) + + if angular.isDefined(folder) + folder.open = !folder.open + if folder.open + @_persistence.openFolder(folder.id) + else + @_persistence.collapseFolder(folder.id) + + + return FolderBl diff --git a/js/app/services/bl/itembl.coffee b/js/app/services/bl/itembl.coffee new file mode 100644 index 000000000..ee4d9049a --- /dev/null +++ b/js/app/services/bl/itembl.coffee @@ -0,0 +1,38 @@ +### + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. + +### + + +angular.module('News').factory '_ItemBl', -> + + class ItemBl + + constructor: (@_itemModel, @_persistence) -> + + + markAllRead: (feedId) -> + highestItemId = @_itemModel.getHighestId() + @_persistence.setFeedRead(feedId, highestItemId) + for item in @_itemModel.getAll() + item.setRead() + + + return ItemBl diff --git a/js/app/services/models/itemmodel.coffee b/js/app/services/models/itemmodel.coffee index 09c187443..61030b50e 100644 --- a/js/app/services/models/itemmodel.coffee +++ b/js/app/services/models/itemmodel.coffee @@ -21,8 +21,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### angular.module('News').factory '_ItemModel', -['_Model', '_MaximumQuery', '_MinimumQuery', -(_Model, _MaximumQuery, _MinimumQuery) -> +['_Model', '_MaximumQuery', '_MinimumQuery', 'StatusFlag', +(_Model, _MaximumQuery, _MinimumQuery, StatusFlag) -> class ItemModel extends _Model @@ -41,6 +41,8 @@ angular.module('News').factory '_ItemModel', # in case we get updated items with the same two fields we # also need to update the field add: (data, clearCache=true) -> + @_bindMethods(data) + hash = data.feedId + '_' + data.guidHash entry = @_guidFeedIdHash[hash] @@ -52,6 +54,21 @@ angular.module('News').factory '_ItemModel', super(data, clearCache) + _bindMethods: (data) -> + data.isRead = -> + return !((@status & StatusFlag.UNREAD) == StatusFlag.UNREAD) + data.setRead = -> + @status &= ~StatusFlag.UNREAD + data.setUnread = -> + @status |= StatusFlag.UNREAD + data.isStarred = -> + return (@status & StatusFlag.STARRED) == StatusFlag.STARRED + data.setStarred = -> + @status |= StatusFlag.STARRED + data.setUnstarred = -> + @status &= ~StatusFlag.STARRED + + update: (data, clearCache=true) -> hash = data.feedId + '_' + data.guidHash entry = @_guidFeedIdHash[hash] diff --git a/js/app/services/services.coffee b/js/app/services/services.coffee index cf1389fa7..6e27ece9d 100644 --- a/js/app/services/services.coffee +++ b/js/app/services/services.coffee @@ -34,12 +34,44 @@ angular.module('News').factory 'Request', return new _Request($http, Publisher, Router) ] + # loading helpers angular.module('News').factory 'FeedLoading', ['_Loading', (_Loading) -> return new _Loading() ] +angular.module('News').factory 'AutoPageLoading', +['_Loading', (_Loading) -> + return new _Loading() +] + +angular.module('News').factory 'NewLoading', +['_Loading', (_Loading) -> + return new _Loading() +] + + +# business layer +angular.module('News').factory 'ItemBl', +['_ItemBl', 'ItemModel', 'Persistence', +(_ItemBl, ItemModel, Persistence) -> + return new _ItemBl(ItemModel, Persistence) +] + +angular.module('News').factory 'FeedBl', +['_FeedBl', 'FeedModel', 'ItemBl', 'Persistence', +(_FeedBl, FeedModel, ItemBl, Persistence) -> + return new _FeedBl(FeedModel, ItemBl, Persistence) +] + +angular.module('News').factory 'FolderBl', +['_FolderBl', 'FolderModel', 'FeedBl', 'Persistence', +(_FolderBl, FolderModel, FeedBl, Persistence) -> + return new _FolderBl(FolderModel, FeedBl, Persistence) +] + + # models angular.module('News').factory 'ActiveFeed', ['_ActiveFeed', (_ActiveFeed) -> return new _ActiveFeed() diff --git a/js/app/services/statusflag.coffee b/js/app/services/statusflag.coffee new file mode 100644 index 000000000..c280c7ced --- /dev/null +++ b/js/app/services/statusflag.coffee @@ -0,0 +1,31 @@ +### + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. + +### + + +angular.module('News').factory 'StatusFlag', -> + + return { + UNREAD: 0x02 + STARRED: 0x04 + DELETED: 0x08 + UPDATED: 0x16 + }
\ No newline at end of file diff --git a/js/public/app.js b/js/public/app.js index e486da2e3..463bf8c4c 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -171,8 +171,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ]); angular.module('News').controller('FeedController', [ - '$scope', '_FeedController', 'FolderModel', 'FeedModel', 'ActiveFeed', 'ShowAll', 'FeedType', 'StarredCount', 'Persistence', 'ItemModel', function($scope, _FeedController, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, ItemModel) { - return new _FeedController($scope, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, ItemModel); + '$scope', '_FeedController', 'FolderModel', 'FeedModel', 'ActiveFeed', 'ShowAll', 'FeedType', 'StarredCount', 'Persistence', 'FolderBl', 'FeedBl', function($scope, _FeedController, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, FolderBl, FeedBl) { + return new _FeedController($scope, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, FolderBl, FeedBl); } ]); @@ -214,7 +214,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var FeedController; FeedController = (function() { - function FeedController($scope, _folderModel, _feedModel, _active, _showAll, _feedType, _starredCount, _persistence, _itemModel) { + function FeedController($scope, _folderModel, _feedModel, _active, _showAll, _feedType, _starredCount, _persistence, _folderBl, _feedBl) { var _this = this; this.$scope = $scope; this._folderModel = _folderModel; @@ -224,20 +224,29 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. this._feedType = _feedType; this._starredCount = _starredCount; this._persistence = _persistence; - this._itemModel = _itemModel; + this._folderBl = _folderBl; + this._feedBl = _feedBl; this._isAddingFolder = false; this._isAddingFeed = false; this.$scope.feeds = this._feedModel.getAll(); this.$scope.folders = this._folderModel.getAll(); this.$scope.feedType = this._feedType; - this.$scope.isFeedActive = function(type, id) { - return _this.isFeedActive(type, id); - }; + this.$scope.folderBl = this._folderBl; + this.$scope.feedBl = this._feedBl; this.$scope.isShown = function(type, id) { return _this.isShown(type, id); }; - this.$scope.getUnreadCount = function(type, id) { - return _this.getUnreadCount(type, id); + this.$scope.getUnreadCount = function() { + return _this._transFormCount(_this._feedBl.getUnreadCount()); + }; + this.$scope.getStarredCount = function() { + return _this._transFormCount(_this._starredCount.getStarredCount()); + }; + this.$scope.getFeedUnreadCount = function(feedId) { + return _this._transFormCount(_this._feedBl.getFeedUnreadCount(feedId)); + }; + this.$scope.getUnreadCount = function(folderId) { + return _this._transFormCount(_this._folderBl.getFolderUnreadCount(folderId)); }; this.$scope.isShowAll = function() { return _this.isShowAll(); @@ -318,19 +327,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }; } - FeedController.prototype.toggleFolder = function(folderId) { - var folder; - folder = this._folderModel.getById(folderId); - if (angular.isDefined(folder)) { - folder.open = !folder.open; - if (folder.open) { - return this._persistence.openFolder(folder.id); - } else { - return this._persistence.collapseFolder(folder.id); - } - } - }; - FeedController.prototype.isFeedActive = function(type, id) { return type === this._active.getType() && id === this._active.getId(); }; @@ -359,21 +355,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._showAll.getShowAll(); }; - FeedController.prototype.getUnreadCount = function(type, id) { - var count; - switch (type) { - case this._feedType.Subscriptions: - count = this._feedModel.getUnreadCount(); - break; - case this._feedType.Starred: - count = this._starredCount.getStarredCount(); - break; - case this._feedType.Feed: - count = this._feedModel.getFeedUnreadCount(id); - break; - case this._feedType.Folder: - count = this._feedModel.getFolderUnreadCount(id); - } + FeedController.prototype._transFormCount = function(count) { if (count > 999) { count = '999+'; } @@ -395,57 +377,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. } }; - FeedController.prototype.hasFeeds = function(folderId) { - return this._feedModel.getAllOfFolder(folderId).length; - }; - - FeedController.prototype["delete"] = function(type, id) { - var count; - switch (type) { - case this._feedType.Feed: - count = this._feedModel.removeById(id); - return this._persistence.deleteFeed(id); - case this._feedType.Folder: - count = this._folderModel.removeById(id); - return this._persistence.deleteFolder(id); - } - }; - - FeedController.prototype.markAllRead = function(type, id) { - var feed, highestItemId, _i, _j, _len, _len1, _ref, _ref1, _results, _results1; - switch (type) { - case this._feedType.Subscriptions: - _ref = this._feedModel.getAll(); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - feed = _ref[_i]; - _results.push(this.markAllRead(this._feedType.Feed, feed.id)); - } - return _results; - break; - case this._feedType.Feed: - feed = this._feedModel.getById(id); - if (angular.isDefined(feed)) { - feed.unreadCount = 0; - highestItemId = this._itemModel.getHighestId(); - return this._persistence.setFeedRead(id, highestItemId); - } - break; - case this._feedType.Folder: - _ref1 = this._feedModel.getAllOfFolder(id); - _results1 = []; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - feed = _ref1[_j]; - _results1.push(this.markAllRead(this._feedType.Feed, feed.id)); - } - return _results1; - } - }; - - FeedController.prototype.getFeedsOfFolder = function(folderId) { - return this._feedModel.getAllOfFolder(folderId); - }; - FeedController.prototype.setShowAll = function(showAll) { this._showAll.setShowAll(showAll); if (showAll) { @@ -649,6 +580,224 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. (function() { + angular.module('News').factory('_FeedBl', function() { + var FeedBl; + FeedBl = (function() { + + function FeedBl(_feedModel, _itemBl, _persistence) { + this._feedModel = _feedModel; + this._itemBl = _itemBl; + this._persistence = _persistence; + } + + FeedBl.prototype.getUnreadCount = function(feedId) { + return this._feedModel.getFeedUnreadCount(feedId); + }; + + FeedBl.prototype.getFeedsOfFolder = function(folderId) { + return this._feedModel.getAllOfFolder(folderId); + }; + + FeedBl.prototype.getFolderUnreadCount = function(folderId) { + return this._feedModel.getFolderUnreadCount(folderId); + }; + + FeedBl.prototype.getUnreadCount = function() { + return this._feedModel.getUnreadCount(); + }; + + FeedBl.prototype["delete"] = function(feedId) { + this._feedModel.removeById(feedId); + return this._persistence.deleteFeed(feedId); + }; + + FeedBl.prototype.markFeedRead = function(feedId) { + var feed; + feed = this._feedModel.getById(feedId); + if (angular.isDefined(feed)) { + feed.unreadCount = 0; + return this._itemBl.markAllRead(feedId); + } + }; + + FeedBl.prototype.markAllRead = function() { + var feed, _i, _len, _ref, _results; + _ref = this._feedModel.getAll(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + feed = _ref[_i]; + _results.push(this.markFeedRead(feed.id)); + } + return _results; + }; + + return FeedBl; + + })(); + return FeedBl; + }); + +}).call(this); + +// Generated by CoffeeScript 1.4.0 + +/* + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + + angular.module('News').factory('_FolderBl', function() { + var FolderBl; + FolderBl = (function() { + + function FolderBl(_folderModel, _feedBl, _persistence) { + this._folderModel = _folderModel; + this._feedBl = _feedBl; + this._persistence = _persistence; + } + + FolderBl.prototype["delete"] = function(folderId) { + this._folderModel.removeById(folderId); + return this._persistence.deleteFolder(folderId); + }; + + FolderBl.prototype.hasFeeds = function(folderId) { + return this._feedBl.getFeedsOfFolder(folderId).length; + }; + + FolderBl.prototype.markFolderRead = function(folderId) { + var feed, _i, _len, _ref, _results; + _ref = this._feedBl.getFeedsOfFolder(folderId); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + feed = _ref[_i]; + _results.push(this._feedBl.markFeedRead(feed.id)); + } + return _results; + }; + + FolderBl.prototype.toggleFolder = function(folderId) { + var folder; + folder = this._folderModel.getById(folderId); + if (angular.isDefined(folder)) { + folder.open = !folder.open; + if (folder.open) { + return this._persistence.openFolder(folder.id); + } else { + return this._persistence.collapseFolder(folder.id); + } + } + }; + + return FolderBl; + + })(); + return FolderBl; + }); + +}).call(this); + +// Generated by CoffeeScript 1.4.0 + +/* + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + + angular.module('News').factory('_ItemBl', function() { + var ItemBl; + ItemBl = (function() { + + function ItemBl(_itemModel, _persistence) { + this._itemModel = _itemModel; + this._persistence = _persistence; + } + + ItemBl.prototype.markAllRead = function(feedId) { + var highestItemId, item, _i, _len, _ref, _results; + highestItemId = this._itemModel.getHighestId(); + this._persistence.setFeedRead(feedId, highestItemId); + _ref = this._itemModel.getAll(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + _results.push(item.setRead()); + } + return _results; + }; + + return ItemBl; + + })(); + return ItemBl; + }); + +}).call(this); + +// Generated by CoffeeScript 1.4.0 + +/* + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + angular.module('News').factory('FeedType', function() { var feedType; return feedType = { @@ -888,7 +1037,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child. |