summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/app/controllers/controllers.coffee6
-rw-r--r--js/app/controllers/itemcontroller.coffee4
-rw-r--r--js/app/services/bl/itembl.coffee32
-rw-r--r--js/public/app.js54
-rw-r--r--js/tests/controllers/itemcontrollerSpec.coffee12
-rw-r--r--js/tests/services/bl/itemblSpec.coffee37
-rw-r--r--templates/part.items.php41
7 files changed, 134 insertions, 52 deletions
diff --git a/js/app/controllers/controllers.coffee b/js/app/controllers/controllers.coffee
index 77c178fef..190f8dd0b 100644
--- a/js/app/controllers/controllers.coffee
+++ b/js/app/controllers/controllers.coffee
@@ -39,8 +39,8 @@ StarredBl, unreadCountFormatter)->
]
angular.module('News').controller 'ItemController',
-['$scope', '_ItemController', 'ItemModel', 'FeedModel', 'FeedLoading',
-($scope, _ItemController, ItemModel, FeedModel, FeedLoading)->
+['$scope', '_ItemController', 'ItemBl', 'FeedModel', 'FeedLoading',
+($scope, _ItemController, ItemBl, FeedModel, FeedLoading)->
- return new _ItemController($scope, ItemModel, FeedModel, FeedLoading)
+ return new _ItemController($scope, ItemBl, FeedModel, FeedLoading)
] \ No newline at end of file
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
index 0a2c1229e..2daf13335 100644
--- a/js/app/controllers/itemcontroller.coffee
+++ b/js/app/controllers/itemcontroller.coffee
@@ -25,9 +25,9 @@ angular.module('News').factory '_ItemController', ->
class ItemController
- constructor: (@_$scope, @_itemModel, @_feedModel, @_feedLoading) ->
+ constructor: (@_$scope, @_itemBl, @_feedModel, @_feedLoading) ->
- @_$scope.items = @_itemModel.getAll()
+ @_$scope.itemBl = @_itemBl
@_$scope.isLoading = =>
return @_feedLoading.isLoading()
diff --git a/js/app/services/bl/itembl.coffee b/js/app/services/bl/itembl.coffee
index 5b34aa4f4..8c718d653 100644
--- a/js/app/services/bl/itembl.coffee
+++ b/js/app/services/bl/itembl.coffee
@@ -21,12 +21,38 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory 'ItemBl', ->
+angular.module('News').factory 'ItemBl',
+['ItemModel', 'Persistence', 'ActiveFeed', 'FeedType',
+(ItemModel, Persistence, ActiveFeed, FeedType) ->
class ItemBl
- constructor: (@_itemModel, @_persistence) ->
+ constructor: (@_itemModel, @_persistence, @_activeFeed, @_feedType) ->
+ getAll: ->
+ return @_itemModel.getAll()
- return new ItemBl()
+ noFeedActive: ->
+ return @_activeFeed.getType() != @_feedType.Feed
+
+
+ isKeptUnread: (itemId) ->
+
+
+ toggleKeepUnread: (itemId) ->
+
+
+ toggleStarred: (itemId) ->
+
+
+ setRead: (itemId) ->
+
+
+ getFeedTitle: (itemId) ->
+
+
+
+ return new ItemBl(ItemModel, Persistence, ActiveFeed, FeedType)
+
+] \ No newline at end of file
diff --git a/js/public/app.js b/js/public/app.js
index 448778e9d..718c89a02 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -177,8 +177,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
]);
angular.module('News').controller('ItemController', [
- '$scope', '_ItemController', 'ItemModel', 'FeedModel', 'FeedLoading', function($scope, _ItemController, ItemModel, FeedModel, FeedLoading) {
- return new _ItemController($scope, ItemModel, FeedModel, FeedLoading);
+ '$scope', '_ItemController', 'ItemBl', 'FeedModel', 'FeedLoading', function($scope, _ItemController, ItemBl, FeedModel, FeedLoading) {
+ return new _ItemController($scope, ItemBl, FeedModel, FeedLoading);
}
]);
@@ -323,13 +323,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
var ItemController;
ItemController = (function() {
- function ItemController(_$scope, _itemModel, _feedModel, _feedLoading) {
+ function ItemController(_$scope, _itemBl, _feedModel, _feedLoading) {
var _this = this;
this._$scope = _$scope;
- this._itemModel = _itemModel;
+ this._itemBl = _itemBl;
this._feedModel = _feedModel;
this._feedLoading = _feedLoading;
- this._$scope.items = this._itemModel.getAll();
+ this._$scope.itemBl = this._itemBl;
this._$scope.isLoading = function() {
return _this._feedLoading.isLoading();
};
@@ -804,20 +804,42 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
- angular.module('News').factory('ItemBl', function() {
- var ItemBl;
- ItemBl = (function() {
+ angular.module('News').factory('ItemBl', [
+ 'ItemModel', 'Persistence', 'ActiveFeed', 'FeedType', function(ItemModel, Persistence, ActiveFeed, FeedType) {
+ var ItemBl;
+ ItemBl = (function() {
- function ItemBl(_itemModel, _persistence) {
- this._itemModel = _itemModel;
- this._persistence = _persistence;
- }
+ function ItemBl(_itemModel, _persistence, _activeFeed, _feedType) {
+ this._itemModel = _itemModel;
+ this._persistence = _persistence;
+ this._activeFeed = _activeFeed;
+ this._feedType = _feedType;
+ }
- return ItemBl;
+ ItemBl.prototype.getAll = function() {
+ return this._itemModel.getAll();
+ };
- })();
- return new ItemBl();
- });
+ ItemBl.prototype.noFeedActive = function() {
+ return this._activeFeed.getType() !== this._feedType.Feed;
+ };
+
+ ItemBl.prototype.isKeptUnread = function(itemId) {};
+
+ ItemBl.prototype.toggleKeepUnread = function(itemId) {};
+
+ ItemBl.prototype.toggleStarred = function(itemId) {};
+
+ ItemBl.prototype.setRead = function(itemId) {};
+
+ ItemBl.prototype.getFeedTitle = function(itemId) {};
+
+ return ItemBl;
+
+ })();
+ return new ItemBl(ItemModel, Persistence, ActiveFeed, FeedType);
+ }
+ ]);
}).call(this);
diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee
index 19cce6c6f..35aff7141 100644
--- a/js/tests/controllers/itemcontrollerSpec.coffee
+++ b/js/tests/controllers/itemcontrollerSpec.coffee
@@ -27,16 +27,14 @@ describe '_ItemController', ->
beforeEach module 'News'
beforeEach inject (@_ItemController, @ActiveFeed, @ShowAll, @FeedType,
- @StarredCount, @FeedModel, @FolderModel, @ItemModel) =>
+ @StarredCount, @FeedModel, @FolderModel, @ItemModel,
+ @ItemBl) =>
@scope = {}
@persistence = {
getItems: ->
}
- @controller = new @_ItemController(@scope, @ItemModel, @FeedModel)
+ @controller = new @_ItemController(@scope, @ItemBl, @FeedModel)
- it 'should make items availabe', =>
- @ItemModel.getAll = jasmine.createSpy('ItemModel')
- new @_ItemController(@scope, @ItemModel)
-
- expect(@ItemModel.getAll).toHaveBeenCalled()
+ it 'should make ItemBl availabe', =>
+ expect(@scope.itemBl).toBe(@ItemBl)
diff --git a/js/tests/services/bl/itemblSpec.coffee b/js/tests/services/bl/itemblSpec.coffee
index 158b09467..ff2bbd80a 100644
--- a/js/tests/services/bl/itemblSpec.coffee
+++ b/js/tests/services/bl/itemblSpec.coffee
@@ -33,4 +33,39 @@ describe 'ItemBl', ->
}
- beforeEach inject (@ItemModel, @ItemBl, @StatusFlag) =>
+ beforeEach inject (@ItemModel, @ItemBl, @StatusFlag, @ActiveFeed
+ @FeedType) =>
+
+
+ it 'should return all items', =>
+ item1 = {id: 6, feedId: 5, guidHash: 'a1'}
+ item2 = {id: 3, feedId: 5, guidHash: 'a2'}
+ item3 = {id: 2, feedId: 5, guidHash: 'a3'}
+
+ @ItemModel.add(item1)
+ @ItemModel.add(item2)
+ @ItemModel.add(item3)
+
+ items = @ItemBl.getAll()
+
+ expect(items).toContain(item1)
+ expect(items).toContain(item2)
+ expect(items).toContain(item3)
+
+
+ it 'should tell if no feed is active', =>
+ @ActiveFeed.handle({type: @FeedType.Folder, id: 0})
+ expect(@ItemBl.noFeedActive()).toBe(true)
+
+ @ActiveFeed.handle({type: @FeedType.Subscriptions, id: 0})
+ expect(@ItemBl.noFeedActive()).toBe(true)
+
+ @ActiveFeed.handle({type: @FeedType.Starred, id: 0})
+ expect(@ItemBl.noFeedActive()).toBe(true)
+
+ @ActiveFeed.handle({type: @FeedType.Shared, id: 0})
+ expect(@ItemBl.noFeedActive()).toBe(true)
+
+ @ActiveFeed.handle({type: @FeedType.Feed, id: 0})
+ expect(@ItemBl.noFeedActive()).toBe(false)
+
diff --git a/templates/part.items.php b/templates/part.items.php
index 5ff6fa534..ea17d0f40 100644
--- a/templates/part.items.php
+++ b/templates/part.items.php
@@ -1,56 +1,57 @@
<ul>
<li class="feed_item"
- ng-repeat="item in items | orderBy:'id':true "
- ng-class="{read: item.isRead}"
- data-id="{{item.id}}"
- data-feed="{{item.feedId}}">
+ ng-repeat="item in itemBl.getAll() | orderBy:'id':true "
+ ng-class="{ read: item.isRead() }"
+ data-id="{{ item.id }}"
+ data-feed="{{ item.feedId }}">
<h2 class="item_date">
- <time class="timeago" datetime="">{{item.getRelativeDate()}}</time>
+ <time class="timeago" datetime="">{{ item.getRelativeDate() }}</time>
</h2>
<div class="utils">
<ul class="primary_item_utils">
- <li ng-class="{important: item.isImportant}"
- ng-click="toggleImportant(item.id)"
+ <li ng-class="{ important: item.isStarred() }"
+ ng-click="itemBl.toggleStarred(item.id)"
class="star"
- title="{{item.isImportant}}">
+ title="{{ item.isStarred() }}">
</li>
</ul>
</div>
<h1 class="item_title">
- <a ng-click="markRead(item.id, item.feedId)"
- target="_blank" href="{{item.url}}">{{item.title}}</a>
+ <a ng-click="itemBl.setRead(item.id)"
+ target="_blank" href="{{ item.url }}">{{ item.title }}</a>
</h1>
<h2 class="item_author">
<?php p($l->t('from')) ?>
- <a href="#"
- ng-click="loadFeed(item.feedId)"
- class="from_feed">{{ getFeedTitle(item.feedId) }}</a>
+ <a href="#"
+ ng-show="itemBl.noFeedActive()"
+ class="from_feed">{{ itemBl.getFeedTitle(item.id) }}</a>
<span ui-if="item.author">
<?php p($l->t('by')) ?>
{{ item.author }}
</span>
</h2>
- <div class="enclosure" ui-if="item.enclosure">
- <audio controls="controls" ng-src="{{item.enclosure.link}}" type="{{item.enclosure.type}}">
- <?php p($l->t('Cant play audio format')) ?> {{item.enclosure.type}}
+ <div class="enclosure" ui-if="item.enclosureLink">
+ <audio controls="controls" ng-src="{{ item.enclosureLink }}"
+ type="{{ item.enclosureType }}">
+ <?php p($l->t('Cant play audio format')) ?> {{item.enclosureType}}
</audio>
</div>
<div class="body"
- ng-click="markRead(item.id, item.feedId)"
+ ng-click="setRead(item.id)"
ng-bind-html-unsafe="item.body">
</div>
<div class="bottom_utils">
<ul class="secondary_item_utils"
- ng-class="{show_keep_unread: isKeptUnread(item.id)}">
- <li ng-click="keepUnread(item.id, item.feedId)"
+ ng-class="{ show_keep_unread: itemBl.isKeptUnread(item.id) }">
+ <li ng-click="itemBl.toggleKeepUnread(item.id)"
class="keep_unread"><?php p($l->t('Keep unread')); ?>
- <input type="checkbox" ng-checked="isKeptUnread(item.id)"/>
+ <input type="checkbox" ng-checked="itemBl.isKeptUnread(item.id)"/>
</li>
</ul>
</div>