summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 15:15:32 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 15:15:32 +0100
commit6dc8dad23eea121989e0a89a67e92091802857a0 (patch)
tree15d6b5eda5fece8bf691d5ef8662f697b56b7073 /js
parent28d28d8c9eb5ed9f184b572cfd16994c024e4227 (diff)
add persistent option for compact view
Diffstat (limited to 'js')
-rw-r--r--js/app/controllers/itemcontroller.coffee13
-rw-r--r--js/app/controllers/settingscontroller.coffee13
-rw-r--r--js/app/services/compact.coffee38
-rw-r--r--js/app/services/persistence.coffee16
-rw-r--r--js/app/services/services.coffee5
-rw-r--r--js/public/app.js90
-rw-r--r--js/tests/controllers/itemcontrollerSpec.coffee10
-rw-r--r--js/tests/controllers/settingscontrollerSpec.coffee13
-rw-r--r--js/tests/services/compactSpec.coffee44
-rw-r--r--js/tests/services/persistenceSpec.coffee17
10 files changed, 243 insertions, 16 deletions
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
index 1a3c876b9..ee2fa7e82 100644
--- a/js/app/controllers/itemcontroller.coffee
+++ b/js/app/controllers/itemcontroller.coffee
@@ -23,15 +23,15 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').controller 'ItemController',
['$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer',
-'Language', 'AutoPageLoading',
+'Language', 'AutoPageLoading', 'Compact',
($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer,
-Language, AutoPageLoading) ->
+Language, AutoPageLoading, Compact) ->
class ItemController
constructor: (@_$scope, @_itemBusinessLayer, @_feedModel,
@_feedLoading, @_autoPageLoading, @_feedBusinessLayer,
- @_language) ->
+ @_language, @_compact) ->
@_autoPaging = true
@_$scope.itemBusinessLayer = @_itemBusinessLayer
@@ -84,6 +84,11 @@ Language, AutoPageLoading) ->
@_autoPaging = true
+ @_$scope.isCompactView = =>
+ return @_compact.isCompact()
+
+
return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading,
- AutoPageLoading, FeedBusinessLayer, Language)
+ AutoPageLoading, FeedBusinessLayer, Language,
+ Compact)
] \ No newline at end of file
diff --git a/js/app/controllers/settingscontroller.coffee b/js/app/controllers/settingscontroller.coffee
index b5cfb7550..66f7f8824 100644
--- a/js/app/controllers/settingscontroller.coffee
+++ b/js/app/controllers/settingscontroller.coffee
@@ -23,7 +23,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').controller 'SettingsController',
['$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'ShowAll',
-($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll) ->
+'Persistence', 'Compact',
+($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll, Persistence,
+Compact) ->
$scope.feedBusinessLayer = FeedBusinessLayer
@@ -49,4 +51,13 @@ angular.module('News').controller 'SettingsController',
$scope.jsonError = true
$scope.loading = false
+
+ $scope.setCompactView = (isCompact) ->
+ Compact.handle(!Compact.isCompact())
+
+ Persistence.userSettingsSetCompact(Compact.isCompact())
+
+ $scope.isCompactView = ->
+ return Compact.isCompact()
+
] \ No newline at end of file
diff --git a/js/app/services/compact.coffee b/js/app/services/compact.coffee
new file mode 100644
index 000000000..55f96fb59
--- /dev/null
+++ b/js/app/services/compact.coffee
@@ -0,0 +1,38 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.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 'Compact', ->
+
+ class Compact
+
+ constructor: ->
+ @_compact = false
+
+ isCompact: ->
+ return @_compact
+
+ handle: (data) ->
+ @_compact = data
+
+
+ return new Compact()
+
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
index 6bf040e07..05558b3e1 100644
--- a/js/app/services/persistence.coffee
+++ b/js/app/services/persistence.coffee
@@ -51,6 +51,7 @@ $rootScope, $q) ->
@getAllFeeds(successCallback)
@userSettingsRead()
@userSettingsLanguage()
+ @userSettingsIsCompact()
@deferred.promise
@@ -474,6 +475,21 @@ $rootScope, $q) ->
@_request.get 'news_usersettings_language', data
+ userSettingsIsCompact: ->
+ @_request.get 'news_usersettings_iscompact'
+
+
+ userSettingsSetCompact: (isCompact) ->
+ ###
+ sets all items of a folder as read
+ ###
+ params =
+ data:
+ compact: isCompact
+
+ @_request.post 'news_usersettings_setcompact', params
+
+
_triggerHideRead: ->
@_$rootScope.$broadcast('triggerHideRead')
diff --git a/js/app/services/services.coffee b/js/app/services/services.coffee
index a5297f0a1..1a7633d42 100644
--- a/js/app/services/services.coffee
+++ b/js/app/services/services.coffee
@@ -45,9 +45,9 @@ angular.module('News').factory 'NewLoading', ['_Loading', (_Loading) ->
angular.module('News').factory 'Publisher',
['_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel',
-'FolderModel', 'FeedModel', 'Language', 'NewestItem',
+'FolderModel', 'FeedModel', 'Language', 'NewestItem', 'Compact',
(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel,
-FolderModel, FeedModel, Language, NewestItem) ->
+FolderModel, FeedModel, Language, NewestItem, Compact) ->
# register items at publisher to automatically add incoming items
publisher = new _Publisher()
@@ -59,6 +59,7 @@ FolderModel, FeedModel, Language, NewestItem) ->
publisher.subscribeObjectTo(FeedModel, 'feeds')
publisher.subscribeObjectTo(ItemModel, 'items')
publisher.subscribeObjectTo(NewestItem, 'newestItemId')
+ publisher.subscribeObjectTo(Compact, 'compact')
return publisher
]
diff --git a/js/public/app.js b/js/public/app.js
index a99a469fc..f49f2546c 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -797,10 +797,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').controller('ItemController', [
- '$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer', 'Language', 'AutoPageLoading', function($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer, Language, AutoPageLoading) {
+ '$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer', 'Language', 'AutoPageLoading', 'Compact', function($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer, Language, AutoPageLoading, Compact) {
var ItemController;
ItemController = (function() {
- function ItemController(_$scope, _itemBusinessLayer, _feedModel, _feedLoading, _autoPageLoading, _feedBusinessLayer, _language) {
+ function ItemController(_$scope, _itemBusinessLayer, _feedModel, _feedLoading, _autoPageLoading, _feedBusinessLayer, _language, _compact) {
var _this = this;
this._$scope = _$scope;
this._itemBusinessLayer = _itemBusinessLayer;
@@ -809,6 +809,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._autoPageLoading = _autoPageLoading;
this._feedBusinessLayer = _feedBusinessLayer;
this._language = _language;
+ this._compact = _compact;
this._autoPaging = true;
this._$scope.itemBusinessLayer = this._itemBusinessLayer;
this._$scope.feedBusinessLayer = this._feedBusinessLayer;
@@ -863,12 +864,15 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
});
}
});
+ this._$scope.isCompactView = function() {
+ return _this._compact.isCompact();
+ };
}
return ItemController;
})();
- return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading, AutoPageLoading, FeedBusinessLayer, Language);
+ return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading, AutoPageLoading, FeedBusinessLayer, Language, Compact);
}
]);
@@ -899,7 +903,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').controller('SettingsController', [
- '$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'ShowAll', function($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll) {
+ '$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'ShowAll', 'Persistence', 'Compact', function($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll, Persistence, Compact) {
$scope.feedBusinessLayer = FeedBusinessLayer;
$scope["import"] = function(fileContent) {
var error;
@@ -912,7 +916,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return $scope.error = true;
}
};
- return $scope.importArticles = function(fileContent) {
+ $scope.importArticles = function(fileContent) {
var error, parsedJSON;
$scope.jsonError = false;
$scope.loading = true;
@@ -927,6 +931,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return $scope.loading = false;
}
};
+ $scope.setCompactView = function(isCompact) {
+ Compact.handle(!Compact.isCompact());
+ return Persistence.userSettingsSetCompact(Compact.isCompact());
+ };
+ return $scope.isCompactView = function() {
+ return Compact.isCompact();
+ };
}
]);
@@ -1842,6 +1853,53 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ angular.module('News').factory('Compact', function() {
+ var Compact;
+ Compact = (function() {
+ function Compact() {
+ this._compact = false;
+ }
+
+ Compact.prototype.isCompact = function() {
+ return this._compact;
+ };
+
+ Compact.prototype.handle = function(data) {
+ return this._compact = data;
+ };
+
+ return Compact;
+
+ })();
+ return new Compact();
+ });
+
+}).call(this);
+
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.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('_ExistsError', function() {
var ExistsError;
ExistsError = (function() {
@@ -2674,6 +2732,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this.getAllFeeds(successCallback);
this.userSettingsRead();
this.userSettingsLanguage();
+ this.userSettingsIsCompact();
return this.deferred.promise;
};
@@ -3218,6 +3277,24 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._request.get('news_usersettings_language', data);
};
+ Persistence.prototype.userSettingsIsCompact = function() {
+ return this._request.get('news_usersettings_iscompact');
+ };
+
+ Persistence.prototype.userSettingsSetCompact = function(isCompact) {
+ /*
+ sets all items of a folder as read
+ */
+
+ var params;
+ params = {
+ data: {
+ compact: isCompact
+ }
+ };
+ return this._request.post('news_usersettings_setcompact', params);
+ };
+
Persistence.prototype._triggerHideRead = function() {
return this._$rootScope.$broadcast('triggerHideRead');
};
@@ -3280,7 +3357,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
]);
angular.module('News').factory('Publisher', [
- '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', 'Language', 'NewestItem', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel, Language, NewestItem) {
+ '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', 'Language', 'NewestItem', 'Compact', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel, Language, NewestItem, Compact) {
var publisher;
publisher = new _Publisher();
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed');
@@ -3291,6 +3368,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
publisher.subscribeObjectTo(FeedModel, 'feeds');
publisher.subscribeObjectTo(ItemModel, 'items');
publisher.subscribeObjectTo(NewestItem, 'newestItemId');
+ publisher.subscribeObjectTo(Compact, 'compact');
return publisher;
}
]);
diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee
index 27fc82f71..955f9fe16 100644
--- a/js/tests/controllers/itemcontrollerSpec.coffee
+++ b/js/tests/controllers/itemcontrollerSpec.coffee
@@ -40,7 +40,7 @@ describe 'ItemController', ->
beforeEach inject ($controller, @ItemBusinessLayer, @FeedBusinessLayer,
$rootScope, @FeedLoading, @AutoPageLoading, @FeedModel, @ItemModel,
- @ActiveFeed, @FeedType, @NewestItem) =>
+ @ActiveFeed, @FeedType, @NewestItem, @Compact) =>
@ActiveFeed.handle({type: @FeedType.Folder, id: 3})
@scope = $rootScope.$new()
@@ -183,4 +183,10 @@ describe 'ItemController', ->
callback()
@scope.loadNew()
- expect(@scope.refresh).toBe(false) \ No newline at end of file
+ expect(@scope.refresh).toBe(false)
+
+
+ it 'should bind the compact object', =>
+ expect(@scope.isCompactView()).toBe(false)
+ @Compact.handle(true)
+ expect(@scope.isCompactView()).toBe(true) \ No newline at end of file
diff --git a/js/tests/controllers/settingscontrollerSpec.coffee b/js/tests/controllers/settingscontrollerSpec.coffee
index beb404261..bdf1f2bc2 100644
--- a/js/tests/controllers/settingscontrollerSpec.coffee
+++ b/js/tests/controllers/settingscontrollerSpec.coffee
@@ -30,7 +30,7 @@ describe 'SettingsController', ->
$provide.value 'Persistence', @persistence
return
- beforeEach inject ($controller, @ShowAll) =>
+ beforeEach inject ($controller, @ShowAll, @Compact) =>
@scope = {}
@replace =
'$scope': @scope
@@ -38,6 +38,7 @@ describe 'SettingsController', ->
import: jasmine.createSpy('import')
'FeedBusinessLayer':
importArticles: jasmine.createSpy('import')
+ 'Compact': @Compact
@controller = $controller('SettingsController', @replace)
@@ -88,3 +89,13 @@ describe 'SettingsController', ->
expect(@replace.FeedBusinessLayer.importArticles).toHaveBeenCalledWith(
expected, jasmine.any(Function)
)
+
+
+ it 'should set the compact view', =>
+ @persistence.userSettingsSetCompact = jasmine.createSpy('compact')
+
+ @Compact.handle(false)
+ @scope.setCompactView()
+
+ expect(@persistence.userSettingsSetCompact).toHaveBeenCalledWith(true)
+ expect(@scope.isCompactView()).toBe(true) \ No newline at end of file
diff --git a/js/tests/services/compactSpec.coffee b/js/tests/services/compactSpec.coffee
new file mode 100644
index 000000000..34a1db462
--- /dev/null
+++ b/js/tests/services/compactSpec.coffee
@@ -0,0 +1,44 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.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/>.
+
+###
+
+
+describe 'Compact', ->
+
+ beforeEach module 'News'
+
+ beforeEach inject (@Compact) =>
+ @data = true
+
+
+ it 'should be false by default', =>
+ expect(@Compact.isCompact()).toBe(false)
+
+
+ it 'should set the correct compact', =>
+ @Compact.handle(@data)
+ expect(@Compact.isCompact()).toBe(true)
+
+
+ it 'should set the correct compact', =>
+ @data = false
+ @Compact.handle(@data)
+ expect(@Compact.isCompact()).toBe(false) \ No newline at end of file
diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee
index 708a68b07..b9250b974 100644
--- a/js/tests/services/persistenceSpec.coffee
+++ b/js/tests/services/persistenceSpec.coffee
@@ -429,3 +429,20 @@ describe 'Persistence', ->
expect(@req.get).toHaveBeenCalledWith('news_usersettings_language',
expected)
+
+
+ it 'should send a get compact view request', =>
+ @Persistence.userSettingsIsCompact()
+
+ expect(@req.get).toHaveBeenCalledWith('news_usersettings_iscompact')
+
+
+ it 'should send a set compact view request', =>
+ @Persistence.userSettingsSetCompact(true)
+
+ expected =
+ data:
+ compact: true
+
+ expect(@req.post).toHaveBeenCalledWith('news_usersettings_setcompact',
+ expected)