summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-04 19:58:51 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-04 19:59:06 +0200
commit346346e01c5c61e61b522520248de90e0ede3f17 (patch)
tree9d38239274db7e26eac9eda9f1853113e655857b /js
parent2d8b635796ba117619063792b0a00c50dc91d2a6 (diff)
added most of the bl functionality
Diffstat (limited to 'js')
-rw-r--r--js/app/services/bl/bl.coffee45
-rw-r--r--js/app/services/bl/feedbl.coffee30
-rw-r--r--js/app/services/bl/folderbl.coffee45
-rw-r--r--js/app/services/bl/itembl.coffee10
-rw-r--r--js/app/services/bl/starredbl.coffee47
-rw-r--r--js/app/services/bl/subscriptionsbl.coffee57
-rw-r--r--js/app/services/services.coffee21
-rw-r--r--js/public/app.js442
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee29
-rw-r--r--js/tests/services/bl/blSpec.coffee86
-rw-r--r--js/tests/services/bl/feedblSpec.coffee39
-rw-r--r--js/tests/services/bl/folderblSpec.coffee45
-rw-r--r--js/tests/services/bl/itemblSpec.coffee21
-rw-r--r--js/tests/services/bl/starredblSpec.coffee54
-rw-r--r--js/tests/services/bl/subscriptionsblSpec.coffee83
15 files changed, 835 insertions, 219 deletions
diff --git a/js/app/services/bl/bl.coffee b/js/app/services/bl/bl.coffee
new file mode 100644
index 000000000..27e4d321a
--- /dev/null
+++ b/js/app/services/bl/bl.coffee
@@ -0,0 +1,45 @@
+###
+
+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 '_Bl', ->
+
+ class Bl
+
+ constructor: (@_activeFeed, @_persistence, @_itemModel, @_type) ->
+
+
+ load: (id) ->
+ if @_type != @_activeFeed.getType() or id != @_activeFeed.getId()
+ @_itemModel.clear()
+ @_persistence.getItems(@_type, id, 0)
+ @_activeFeed.handle({id: id, type: @_type})
+ else
+ lastModified = @_itemModel.getHighestId()
+ @_persistence.getItems(@_type, id, 0, null, lastModified)
+
+
+ isActive: (id) ->
+ return @_activeFeed.getType() == @_type && @_activeFeed.getId() == id
+
+
+ return Bl \ No newline at end of file
diff --git a/js/app/services/bl/feedbl.coffee b/js/app/services/bl/feedbl.coffee
index ffbc6e51c..d9524ae37 100644
--- a/js/app/services/bl/feedbl.coffee
+++ b/js/app/services/bl/feedbl.coffee
@@ -21,14 +21,19 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_FeedBl', ->
+angular.module('News').factory 'FeedBl',
+['_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel',
+'FeedModel',
+(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel) ->
- class FeedBl
+ class FeedBl extends _Bl
- constructor: (@_feedModel, @_itemBl, @_persistence) ->
+ constructor: (@_showAll, @_feedModel, persistence, activeFeed, feedType,
+ itemModel) ->
+ super(activeFeed, persistence, itemModel, feedType.Feed)
- getFeedUnreadCount: (feedId) ->
+ getUnreadCount: (feedId) ->
@_feedModel.getFeedUnreadCount(feedId)
@@ -40,7 +45,7 @@ angular.module('News').factory '_FeedBl', ->
@_feedModel.getFolderUnreadCount(folderId)
- getUnreadCount: ->
+ getAllUnreadCount: ->
return @_feedModel.getUnreadCount()
@@ -53,7 +58,10 @@ angular.module('News').factory '_FeedBl', ->
feed = @_feedModel.getById(feedId)
if angular.isDefined(feed)
feed.unreadCount = 0
- @_itemBl.markAllRead(feedId)
+ highestItemId = @_itemModel.getHighestId()
+ @_persistence.setFeedRead(feedId, highestItemId)
+ for item in @_itemModel.getAll()
+ item.setRead()
markAllRead: ->
@@ -61,5 +69,13 @@ angular.module('News').factory '_FeedBl', ->
@markFeedRead(feed.id)
+ getNumberOfFeeds: ->
+ return @_feedModel.size()
- return FeedBl
+
+ # todo isvisible, move
+
+ return new FeedBl(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType,
+ ItemModel)
+
+] \ No newline at end of file
diff --git a/js/app/services/bl/folderbl.coffee b/js/app/services/bl/folderbl.coffee
index e869453f2..16e020063 100644
--- a/js/app/services/bl/folderbl.coffee
+++ b/js/app/services/bl/folderbl.coffee
@@ -21,11 +21,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_FolderBl', ->
+angular.module('News').factory 'FolderBl',
+['_Bl', 'FolderModel', 'FeedBl', 'Persistence', 'FeedType', 'ActiveFeed',
+'ItemModel', 'ShowAll',
+(_Bl, FolderModel, FeedBl, Persistence, FeedType, ActiveFeed,
+ItemModel, ShowAll)->
- class FolderBl
+ class FolderBl extends _Bl
- constructor: (@_folderModel, @_feedBl, @_persistence) ->
+ constructor: (@_folderModel, @_feedBl, @_showAll, activeFeed,
+ persistence, @_feedType, itemModel) ->
+ super(activeFeed, persistence, itemModel, @_feedType.Folder)
delete: (folderId) ->
@@ -37,11 +43,6 @@ angular.module('News').factory '_FolderBl', ->
return @_feedBl.getFeedsOfFolder(folderId).length
- markFolderRead: (folderId) ->
- for feed in @_feedBl.getFeedsOfFolder(folderId)
- @_feedBl.markFeedRead(feed.id)
-
-
toggleFolder: (folderId) ->
folder = @_folderModel.getById(folderId)
@@ -53,4 +54,30 @@ angular.module('News').factory '_FolderBl', ->
@_persistence.collapseFolder(folder.id)
- return FolderBl
+ markFolderRead: (folderId) ->
+ for feed in @_feedBl.getFeedsOfFolder(folderId)
+ @_feedBl.markFeedRead(feed.id)
+
+
+ getUnreadCount: (folderId) ->
+ return @_feedBl.getFolderUnreadCount(folderId)
+
+
+ isVisible: (folderId) ->
+ if @_showAll.getShowAll()
+ return true
+ else
+ if @isActive(folderId) or
+ @_feedBl.getFolderUnreadCount(folderId) > 0
+ return true
+ if @_activeFeed.getType() == @_feedType.Feed
+ for feed in @_feedBl.getFeedsOfFolder(folderId)
+ if feed.id == @_activeFeed.getId()
+ return true
+ return false
+
+
+ return new FolderBl(FolderModel, FeedBl, ShowAll, ActiveFeed, Persistence,
+ FeedType, ItemModel)
+
+] \ No newline at end of file
diff --git a/js/app/services/bl/itembl.coffee b/js/app/services/bl/itembl.coffee
index ee4d9049a..5b34aa4f4 100644
--- a/js/app/services/bl/itembl.coffee
+++ b/js/app/services/bl/itembl.coffee
@@ -21,18 +21,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_ItemBl', ->
+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
+ return new ItemBl()
diff --git a/js/app/services/bl/starredbl.coffee b/js/app/services/bl/starredbl.coffee
new file mode 100644
index 000000000..0b1d45500
--- /dev/null
+++ b/js/app/services/bl/starredbl.coffee
@@ -0,0 +1,47 @@
+###
+
+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 'StarredBl',
+['_Bl', 'StarredCount', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel',
+(_Bl, StarredCount, Persistence, ActiveFeed, FeedType, ItemModel) ->
+
+ class StarredBl extends _Bl
+
+ constructor: (@_starredCount, feedType,
+ persistence, activeFeed, itemModel) ->
+ super(activeFeed, persistence, itemModel, feedType.Starred)
+
+ isVisible: ->
+ if @isActive(0)
+ return true
+ else
+ return @_starredCount.getStarredCount() > 0
+
+
+ getUnreadCount: ->
+ return @_starredCount.getStarredCount()
+
+
+ return new StarredBl(StarredCount, FeedType, Persistence,
+ ActiveFeed, ItemModel)
+]
diff --git a/js/app/services/bl/subscriptionsbl.coffee b/js/app/services/bl/subscriptionsbl.coffee
new file mode 100644
index 000000000..102ae8c44
--- /dev/null
+++ b/js/app/services/bl/subscriptionsbl.coffee
@@ -0,0 +1,57 @@
+###
+
+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 'SubscriptionsBl',
+['_Bl', 'FeedBl', 'Persistence', 'ShowAll', 'ActiveFeed', 'FeedType',
+'ItemModel',
+(_Bl, FeedBl, Persistence, ShowAll, ActiveFeed, FeedType, ItemModel) ->
+
+ class SubscriptionsBl extends _Bl
+
+ constructor: (@_feedBl, @_showAll, feedType,
+ persistence, activeFeed, itemModel) ->
+ super(activeFeed, persistence, itemModel, feedType.Subscriptions)
+
+ isVisible: ->
+ if @isActive(0)
+ return true
+
+ if @_showAll.getShowAll()
+ return @_feedBl.getNumberOfFeeds() > 0
+ else
+ visible = @_feedBl.getNumberOfFeeds() > 0 &&
+ @_feedBl.getAllUnreadCount() > 0
+ return visible
+
+
+ markAllRead: ->
+ @_feedBl.markAllRead()
+
+
+ getUnreadCount: ->
+ return @_feedBl.getAllUnreadCount()
+
+
+ return new SubscriptionsBl(FeedBl, ShowAll, FeedType, Persistence,
+ ActiveFeed, ItemModel)
+]
diff --git a/js/app/services/services.coffee b/js/app/services/services.coffee
index 6e27ece9d..837e2004c 100644
--- a/js/app/services/services.coffee
+++ b/js/app/services/services.coffee
@@ -51,27 +51,6 @@ angular.module('News').factory 'NewLoading',
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/public/app.js b/js/public/app.js
index 250e4ce2b..c4aa53323 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -565,62 +565,144 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
- angular.module('News').factory('_FeedBl', function() {
- var FeedBl;
- FeedBl = (function() {
+ angular.module('News').factory('_Bl', function() {
+ var Bl;
+ Bl = (function() {
- function FeedBl(_feedModel, _itemBl, _persistence) {
- this._feedModel = _feedModel;
- this._itemBl = _itemBl;
+ function Bl(_activeFeed, _persistence, _itemModel, _type) {
+ this._activeFeed = _activeFeed;
this._persistence = _persistence;
+ this._itemModel = _itemModel;
+ this._type = _type;
}
- FeedBl.prototype.getFeedUnreadCount = function(feedId) {
- return this._feedModel.getFeedUnreadCount(feedId);
+ Bl.prototype.load = function(id) {
+ var lastModified;
+ if (this._type !== this._activeFeed.getType() || id !== this._activeFeed.getId()) {
+ this._itemModel.clear();
+ this._persistence.getItems(this._type, id, 0);
+ return this._activeFeed.handle({
+ id: id,
+ type: this._type
+ });
+ } else {
+ lastModified = this._itemModel.getHighestId();
+ return this._persistence.getItems(this._type, id, 0, null, lastModified);
+ }
};
- FeedBl.prototype.getFeedsOfFolder = function(folderId) {
- return this._feedModel.getAllOfFolder(folderId);
+ Bl.prototype.isActive = function(id) {
+ return this._activeFeed.getType() === this._type && this._activeFeed.getId() === id;
};
- FeedBl.prototype.getFolderUnreadCount = function(folderId) {
- return this._feedModel.getFolderUnreadCount(folderId);
- };
+ return Bl;
- FeedBl.prototype.getUnreadCount = function() {
- return this._feedModel.getUnreadCount();
- };
+ })();
+ return Bl;
+ });
- FeedBl.prototype["delete"] = function(feedId) {
- this._feedModel.removeById(feedId);
- return this._persistence.deleteFeed(feedId);
- };
+}).call(this);
- FeedBl.prototype.markFeedRead = function(feedId) {
- var feed;
- feed = this._feedModel.getById(feedId);
- if (angular.isDefined(feed)) {
- feed.unreadCount = 0;
- return this._itemBl.markAllRead(feedId);
- }
- };
+// Generated by CoffeeScript 1.4.0
- 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));
+/*
+
+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() {
+ var __hasProp = {}.hasOwnProperty,
+ __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.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('FeedBl', [
+ '_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', function(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel) {
+ var FeedBl;
+ FeedBl = (function(_super) {
+
+ __extends(FeedBl, _super);
+
+ function FeedBl(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel) {
+ this._showAll = _showAll;
+ this._feedModel = _feedModel;
+ FeedBl.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed);
}
- return _results;
- };
- return FeedBl;
+ FeedBl.prototype.getUnreadCount = function(feedId) {
+ return this._feedModel.getFeedUnreadCount(feedId);
+ };
- })();
- return FeedBl;
- });
+ FeedBl.prototype.getFeedsOfFolder = function(folderId) {
+ return this._feedModel.getAllOfFolder(folderId);
+ };
+
+ FeedBl.prototype.getFolderUnreadCount = function(folderId) {
+ return this._feedModel.getFolderUnreadCount(folderId);
+ };
+
+ FeedBl.prototype.getAllUnreadCount = 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, highestItemId, item, _i, _len, _ref, _results;
+ feed = this._feedModel.getById(feedId);
+ if (angular.isDefined(feed)) {
+ feed.unreadCount = 0;
+ 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;
+ }
+ };
+
+ 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;
+ };
+
+ FeedBl.prototype.getNumberOfFeeds = function() {
+ return this._feedModel.size();
+ };
+
+ return FeedBl;
+
+ })(_Bl);
+ return new FeedBl(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel);
+ }
+ ]);
}).call(this);
@@ -649,55 +731,88 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __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.__super__ = parent.prototype; return child; };
- angular.module('News').factory('_FolderBl', function() {
- var FolderBl;
- FolderBl = (function() {
+ angular.module('News').factory('FolderBl', [
+ '_Bl', 'FolderModel', 'FeedBl', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', function(_Bl, FolderModel, FeedBl, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll) {
+ var FolderBl;
+ FolderBl = (function(_super) {
+
+ __extends(FolderBl, _super);
+
+ function FolderBl(_folderModel, _feedBl, _showAll, activeFeed, persistence, _feedType, itemModel) {
+ this._folderModel = _folderModel;
+ this._feedBl = _feedBl;
+ this._showAll = _showAll;
+ this._feedType = _feedType;
+ FolderBl.__super__.constructor.call(this, activeFeed, persistence, itemModel, this._feedType.Folder);
+ }
- 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["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.hasFeeds = function(folderId) {
- return this._feedBl.getFeedsOfFolder(folderId).length;
- };
+ 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);
+ }
+ }
+ };
- 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.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);
+ FolderBl.prototype.getUnreadCount = function(folderId) {
+ return this._feedBl.getFolderUnreadCount(folderId);
+ };
+
+ FolderBl.prototype.isVisible = function(folderId) {
+ var feed, _i, _len, _ref;
+ if (this._showAll.getShowAll()) {
+ return true;
} else {
- return this._persistence.collapseFolder(folder.id);
+ if (this.isActive(folderId) || this._feedBl.getFolderUnreadCount(folderId) > 0) {
+ return true;
+ }
+ if (this._activeFeed.getType() === this._feedType.Feed) {
+ _ref = this._feedBl.getFeedsOfFolder(folderId);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ if (feed.id === this._activeFeed.getId()) {
+ return true;
+ }
+ }
+ }
+ return false;
}
- }
- };
+ };
- return FolderBl;
+ return FolderBl;
- })();
- return FolderBl;
- });
+ })(_Bl);
+ return new FolderBl(FolderModel, FeedBl, ShowAll, ActiveFeed, Persistence, FeedType, ItemModel);
+ }
+ ]);
}).call(this);
@@ -727,7 +842,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
- angular.module('News').factory('_ItemBl', function() {
+ angular.module('News').factory('ItemBl', function() {
var ItemBl;
ItemBl = (function() {
@@ -736,23 +851,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
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;
+ return new ItemBl();
});
}).call(this);
@@ -782,6 +884,138 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __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.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('StarredBl', [
+ '_Bl', 'StarredCount', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', function(_Bl, StarredCount, Persistence, ActiveFeed, FeedType, ItemModel) {
+ var StarredBl;
+ StarredBl = (function(_super) {
+
+ __extends(StarredBl, _super);
+
+ function StarredBl(_starredCount, feedType, persistence, activeFeed, itemModel) {
+ this._starredCount = _starredCount;
+ StarredBl.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Starred);
+ }
+
+ StarredBl.prototype.isVisible = function() {
+ if (this.isActive(0)) {
+ return true;
+ } else {
+ return this._starredCount.getStarredCount() > 0;
+ }
+ };
+
+ StarredBl.prototype.getUnreadCount = function() {
+ return this._starredCount.getStarredCount();
+ };
+
+ return StarredBl;
+
+ })(_Bl);
+ return new StarredBl(StarredCount, FeedType, Persistence, ActiveFeed, ItemModel);
+ }
+ ]);
+
+}).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() {
+ var __hasProp = {}.hasOwnProperty,
+ __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.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('SubscriptionsBl', [
+ '_Bl', 'FeedBl', 'Persistence', 'ShowAll', 'ActiveFeed', 'FeedType', 'ItemModel', function(_Bl, FeedBl, Persistence, ShowAll, ActiveFeed, FeedType, ItemModel) {
+ var SubscriptionsBl;
+ SubscriptionsBl = (function(_super) {
+
+ __extends(SubscriptionsBl, _super);
+
+ function SubscriptionsBl(_feedBl, _showAll, feedType, persistence, activeFeed, itemModel) {
+ this._feedBl = _feedBl;
+ this._showAll = _showAll;
+ SubscriptionsBl.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Subscriptions);
+ }
+
+ SubscriptionsBl.prototype.isVisible = function() {
+ var visible;
+ if (this.isActive(0)) {
+ return true;
+ }
+ if (this._showAll.getShowAll()) {
+ return this._feedBl.getNumberOfFeeds() > 0;
+ } else {
+ visible = this._feedBl.getNumberOfFeeds() > 0 && this._feedBl.getAllUnreadCount() > 0;
+ return visible;
+ }
+ };
+
+ SubscriptionsBl.prototype.markAllRead = function() {
+ return this._feedBl.markAllRead();
+ };
+
+ SubscriptionsBl.prototype.getUnreadCount = function() {
+ return this._feedBl.getAllUnreadCount();
+ };
+
+ return SubscriptionsBl;
+
+ })(_Bl);
+ return new SubscriptionsBl(FeedBl, ShowAll, FeedType, Persistence, ActiveFeed, ItemModel);
+ }
+ ]);
+
+}).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 Lic