diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/app/app.coffee | 1 | ||||
-rw-r--r-- | js/app/directives/undonotification.coffee | 32 | ||||
-rw-r--r-- | js/app/services/businesslayer/feedbusinesslayer.coffee | 22 | ||||
-rw-r--r-- | js/app/services/businesslayer/folderbusinesslayer.coffee | 27 | ||||
-rw-r--r-- | js/app/services/persistence.coffee | 21 | ||||
-rw-r--r-- | js/app/services/undoqueue.coffee | 87 | ||||
-rw-r--r-- | js/public/app.js | 231 | ||||
-rw-r--r-- | js/tests/services/persistenceSpec.coffee | 22 | ||||
-rw-r--r-- | js/tests/services/undoqueueSpec.coffee | 59 |
9 files changed, 171 insertions, 331 deletions
diff --git a/js/app/app.coffee b/js/app/app.coffee index a6e0511f4..32a77a9e3 100644 --- a/js/app/app.coffee +++ b/js/app/app.coffee @@ -28,6 +28,7 @@ angular.module('News', ['OC', 'ui']).config ($provide) -> scrollTimeout: 500 feedUpdateInterval: 1000*60*3 # miliseconds itemBatchSize: 20 + undoTimeout: 1000*10 # miliseconds # the autoPageFactor defines how many articles must be left # before it starts autopaging autoPageFactor: 10 diff --git a/js/app/directives/undonotification.coffee b/js/app/directives/undonotification.coffee index 5e30af169..acf3f886d 100644 --- a/js/app/directives/undonotification.coffee +++ b/js/app/directives/undonotification.coffee @@ -20,23 +20,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -angular.module('News').directive 'undoNotification', ['$rootScope', -($rootScope) -> +angular.module('News').directive 'undoNotification', +['$rootScope', '$timeout', 'Config', +($rootScope, $timeout, Config) -> return (scope, elm, attr) -> - - elm.click -> - $(@).fadeOut() - - scope.$on 'notUndone', -> - $(elm).fadeOut() - undo = -> caption = '' + timeout = null + + $(elm).click -> + timout = null + $(@).fadeOut() - link = $(elm).find('a') - link.click -> + $(elm).find('a').click -> undo() + timout = null $rootScope.$apply() elm.fadeOut() @@ -44,9 +43,18 @@ angular.module('News').directive 'undoNotification', ['$rootScope', return caption scope.$on 'undoMessage', (scope, data) -> + # cancel previous timeouts + if timeout + $timeout.cancel(timeout.promise) + + # fade out if not reset with a new + timeout = $timeout => + $(elm).fadeOut() + , Config.undoTimeout + undo = data.undoCallback caption = data.caption - elm.fadeIn().css("display","inline") + $(elm).fadeIn().css("display","inline") ]
\ No newline at end of file diff --git a/js/app/services/businesslayer/feedbusinesslayer.coffee b/js/app/services/businesslayer/feedbusinesslayer.coffee index 8dc1c126a..2219ce2cd 100644 --- a/js/app/services/businesslayer/feedbusinesslayer.coffee +++ b/js/app/services/businesslayer/feedbusinesslayer.coffee @@ -24,15 +24,15 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. angular.module('News').factory 'FeedBusinessLayer', ['_BusinessLayer', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', -'UndoQueue', 'NewestItem', +'NewestItem', (_BusinessLayer, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, -FeedModel, NewLoading, _ExistsError, Utils, $rootScope, UndoQueue, NewestItem)-> +FeedModel, NewLoading, _ExistsError, Utils, $rootScope, NewestItem)-> class FeedBusinessLayer extends _BusinessLayer constructor: (@_showAll, @_feedModel, persistence, activeFeed, feedType, itemModel, @_newLoading, @_utils, @_$rootScope, - @_undoQueue, @_newestItem) -> + @_newestItem) -> super(activeFeed, persistence, itemModel, feedType.Feed) @_feedType = feedType @@ -55,13 +55,15 @@ FeedModel, NewLoading, _ExistsError, Utils, $rootScope, UndoQueue, NewestItem)-> delete: (feedId) -> feed = @_feedModel.removeById(feedId) - callback = => - @_persistence.deleteFeed(feedId) - - undoCallback = => - @_feedModel.add(feed) - @_undoQueue.add(feed.title, callback, 10*1000, undoCallback) + data = + undoCallback: => + @_persistence.restoreFeed feedId, => + @_persistence.getAllFeeds() + caption: feed.title + + @_$rootScope.$broadcast 'undoMessage', data + @_persistence.deleteFeed(feedId) markRead: (feedId) -> @@ -192,6 +194,6 @@ FeedModel, NewLoading, _ExistsError, Utils, $rootScope, UndoQueue, NewestItem)-> return new FeedBusinessLayer(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading, Utils, - $rootScope, UndoQueue, NewestItem) + $rootScope, NewestItem) ]
\ No newline at end of file diff --git a/js/app/services/businesslayer/folderbusinesslayer.coffee b/js/app/services/businesslayer/folderbusinesslayer.coffee index 3d1fbb7c7..94bc974e6 100644 --- a/js/app/services/businesslayer/folderbusinesslayer.coffee +++ b/js/app/services/businesslayer/folderbusinesslayer.coffee @@ -24,16 +24,16 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. angular.module('News').factory 'FolderBusinessLayer', ['_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', '_ExistsError', 'OPMLParser', -'UndoQueue', 'NewestItem', 'FeedModel', +'NewestItem', 'FeedModel', '$rootScope', (_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, -ActiveFeed, ItemModel, ShowAll, _ExistsError, OPMLParser, UndoQueue, -NewestItem, FeedModel) -> +ActiveFeed, ItemModel, ShowAll, _ExistsError, OPMLParser, NewestItem, +FeedModel, $rootScope) -> class FolderBusinessLayer extends _BusinessLayer constructor: (@_folderModel, @_feedBusinessLayer, @_showAll, activeFeed, persistence, @_feedType, itemModel, @_opmlParser, - @_undoQueue, @_newestItem, @_feedModel) -> + @_newestItem, @_feedModel, @_$rootScope) -> super(activeFeed, persistence, itemModel, @_feedType.Folder) @@ -48,16 +48,17 @@ NewestItem, FeedModel) -> feeds.push(@_feedModel.removeById(feed.id)) folder = @_folderModel.removeById(folderId) - - callback = => - @_persistence.deleteFolder(folderId) - undoCallback = => - @_folderModel.add(folder) - for feed in feeds - @_feedModel.add(feed) + data = + undoCallback: => + @_persistence.restoreFolder folderId, => + @_persistence.getAllFeeds() + @_persistence.getAllFolders() + caption: folder.name + + @_$rootScope.$broadcast 'undoMessage', data + @_persistence.deleteFolder(folderId) - @_undoQueue.add(folder.name, callback, 10*1000, undoCallback) hasFeeds: (folderId) -> @@ -183,6 +184,6 @@ NewestItem, FeedModel) -> return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, ShowAll, ActiveFeed, Persistence, FeedType, ItemModel, - OPMLParser, UndoQueue, NewestItem, FeedModel) + OPMLParser, NewestItem, FeedModel, $rootScope) ]
\ No newline at end of file diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee index a5905e745..98549b98f 100644 --- a/js/app/services/persistence.coffee +++ b/js/app/services/persistence.coffee @@ -200,6 +200,16 @@ $rootScope) -> @_request.post 'news_feeds_delete', params + restoreFeed: (feedId, onSuccess=null) -> + onSuccess or= -> + params = + onSuccess: onSuccess + routeParams: + feedId: feedId + + @_request.post 'news_feeds_restore', params + + moveFeed: (feedId, folderId) -> ### moves a feed to a new folder @@ -319,10 +329,19 @@ $rootScope) -> routeParams: folderId: folderId - @_request.post 'news_folders_delete', params + restoreFolder: (folderId, onSuccess=null) -> + onSuccess or= -> + params = + onSuccess: onSuccess + routeParams: + folderId: folderId + + @_request.post 'news_folders_restore', params + + renameFolder: (folderId, folderName) -> ### Save if a folder was collapsed diff --git a/js/app/services/undoqueue.coffee b/js/app/services/undoqueue.coffee deleted file mode 100644 index 631013d13..000000000 --- a/js/app/services/undoqueue.coffee +++ /dev/null @@ -1,87 +0,0 @@ -### - -ownCloud - App Framework - -@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/>. - -### - -# A class which follows the command pattern -# Can be used for actions that need need to be able to undo like folder deletion -angular.module('News').factory 'UndoQueue', -['$timeout', '$rootScope', -($timeout, $rootScope) -> - - class UndoQueue - - constructor: (@_$timeout, @_$rootScope) -> - @_queue = [] - - - add: (@_caption, @_callback, @_timeout=0, @_undoCallback=null) -> - ### - @_caption the caption which indentifies the item - @_callback function the callback which should be executed when it was - not undone, this will usually be a request to the server to finally - delete something - @_timeout int the timeout after the callback should be executed - defaults to 0 - @_undoCallback function the function which should be executed when - an command has been canceled. Usually this will add back a deleted - object back to the interface, defaults to an empty function - ### - @executeAll() - - command = - _undoCallback: @_undoCallback or= -> - _callback: @_callback - execute: => - command._callback() - undo: => - command._undoCallback() - @_$timeout.cancel(command.promise) - @_queue = [] - promise: @_$timeout => - command.execute() - @_queue = [] - @_$rootScope.$broadcast('notUndone') - , @_timeout - - data = - undoCallback: command.undo - caption: @_caption - - @_$rootScope.$broadcast 'undoMessage', data - - @_queue.push(command) - - - executeAll: -> - ### - Executes the callback before the timeout has run out - This is useful to execute all remaining commands if a new command is - added - ### - for command in @_queue - @_$timeout.cancel(command.promise) - command.execute() - @_queue = [] - - - return new UndoQueue($timeout, $rootScope) - -]
\ No newline at end of file diff --git a/js/public/app.js b/js/public/app.js index df5202f88..68626ce8e 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -43,6 +43,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. scrollTimeout: 500, feedUpdateInterval: 1000 * 60 * 3, itemBatchSize: 20, + undoTimeout: 1000 * 10, autoPageFactor: 10 }); }); @@ -354,21 +355,24 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. (function() { angular.module('News').directive('undoNotification', [ - '$rootScope', function($rootScope) { + '$rootScope', '$timeout', 'Config', function($rootScope, $timeout, Config) { return function(scope, elm, attr) { - var caption, link, undo; + var caption, timeout, undo; - elm.click(function() { - return $(this).fadeOut(); - }); - scope.$on('notUndone', function() { - return $(elm).fadeOut(); - }); undo = function() {}; caption = ''; - link = $(elm).find('a'); - link.click(function() { + timeout = null; + $(elm).click(function() { + var timout; + + timout = null; + return $(this).fadeOut(); + }); + $(elm).find('a').click(function() { + var timout; + undo(); + timout = null; $rootScope.$apply(); return elm.fadeOut(); }); @@ -376,9 +380,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return caption; }; return scope.$on('undoMessage', function(scope, data) { + var _this = this; + + if (timeout) { + $timeout.cancel(timeout.promise); + } + timeout = $timeout(function() { + return $(elm).fadeOut(); + }, Config.undoTimeout); undo = data.undoCallback; caption = data.caption; - return elm.fadeIn().css("display", "inline"); + return $(elm).fadeIn().css("display", "inline"); }); }; } @@ -811,19 +823,18 @@ 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.__super__ = parent.prototype; return child; }; angular.module('News').factory('FeedBusinessLayer', [ - '_BusinessLayer', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', 'UndoQueue', 'NewestItem', function(_BusinessLayer, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading, _ExistsError, Utils, $rootScope, UndoQueue, NewestItem) { + '_BusinessLayer', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', 'NewestItem', function(_BusinessLayer, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading, _ExistsError, Utils, $rootScope, NewestItem) { var FeedBusinessLayer; FeedBusinessLayer = (function(_super) { __extends(FeedBusinessLayer, _super); - function FeedBusinessLayer(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading, _utils, _$rootScope, _undoQueue, _newestItem) { + function FeedBusinessLayer(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading, _utils, _$rootScope, _newestItem) { this._showAll = _showAll; this._feedModel = _feedModel; this._newLoading = _newLoading; this._utils = _utils; this._$rootScope = _$rootScope; - this._undoQueue = _undoQueue; this._newestItem = _newestItem; FeedBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed); this._feedType = feedType; @@ -846,17 +857,19 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }; FeedBusinessLayer.prototype["delete"] = function(feedId) { - var callback, feed, undoCallback, + var data, feed, _this = this; feed = this._feedModel.removeById(feedId); - callback = function() { - return _this._persistence.deleteFeed(feedId); - }; - undoCallback = function() { - return _this._feedModel.add(feed); + data = { + undoCallback: function() { + _this._persistence.restoreFeed(feedId, function() {}); + return _this._persistence.getAllFeeds(); + }, + caption: feed.title }; - return this._undoQueue.add(feed.title, callback, 10 * 1000, undoCallback); + this._$rootScope.$broadcast('undoMessage', data); + return this._persistence.deleteFeed(feedId); }; FeedBusinessLayer.prototype.markRead = function(feedId) { @@ -1015,7 +1028,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return FeedBusinessLayer; })(_BusinessLayer); - return new FeedBusinessLayer(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading, Utils, $rootScope, UndoQueue, NewestItem); + return new FeedBusinessLayer(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading, Utils, $rootScope, NewestItem); } ]); @@ -1049,21 +1062,21 @@ 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.__super__ = parent.prototype; return child; }; angular.module('News').factory('FolderBusinessLayer', [ - '_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', '_ExistsError', 'OPMLParser', 'UndoQueue', 'NewestItem', 'FeedModel', function(_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll, _ExistsError, OPMLParser, UndoQueue, NewestItem, FeedModel) { + '_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', '_ExistsError', 'OPMLParser', 'NewestItem', 'FeedModel', '$rootScope', function(_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll, _ExistsError, OPMLParser, NewestItem, FeedModel, $rootScope) { var FolderBusinessLayer; FolderBusinessLayer = (function(_super) { __extends(FolderBusinessLayer, _super); - function FolderBusinessLayer(_folderModel, _feedBusinessLayer, _showAll, activeFeed, persistence, _feedType, itemModel, _opmlParser, _undoQueue, _newestItem, _feedModel) { + function FolderBusinessLayer(_folderModel, _feedBusinessLayer, _showAll, activeFeed, persistence, _feedType, itemModel, _opmlParser, _newestItem, _feedModel, _$rootScope) { this._folderModel = _folderModel; this._feedBusinessLayer = _feedBusinessLayer; this._showAll = _showAll; this._feedType = _feedType; this._opmlParser = _opmlParser; - this._undoQueue = _undoQueue; this._newestItem = _newestItem; this._feedModel = _feedModel; + this._$rootScope = _$rootScope; FolderBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, this._feedType.Folder); } @@ -1072,7 +1085,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }; FolderBusinessLayer.prototype["delete"] = function(folderId) { - var callback, feed, feeds, folder, undoCallback, _i, _len, _ref, + var data, feed, feeds, folder, _i, _len, _ref, _this = this; feeds = []; @@ -1082,21 +1095,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. feeds.push(this._feedModel.removeById(feed.id)); } folder = this._folderModel.removeById(folderId); - callback = function() { - return _this._persistence.deleteFolder(folderId); - }; - undoCallback = function() { - var _j, _len1, _results; - - _this._folderModel.add(folder); - _results = []; - for (_j = 0, _len1 = feeds.length; _j < _len1; _j++) { - feed = feeds[_j]; - _results.push(_this._feedModel.add(feed)); - } - return _results; + data = { + undoCallback: function() { + return _this._persistence.restoreFolder(folderId, function() { + _this._persistence.getAllFeeds(); + return _this._persistence.getAllFolders(); + }); + }, + caption: folder.name }; - return this._undoQueue.add(folder.name, callback, 10 * 1000, undoCallback); + this._$rootScope.$broadcast('undoMessage', data); + return this._persistence.deleteFolder(folderId); }; FolderBusinessLayer.prototype.hasFeeds = function(folderId) { @@ -1271,7 +1280,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return FolderBusinessLayer; })(_BusinessLayer); - return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, ShowAll, ActiveFeed, Persistence, FeedType, ItemModel, OPMLParser, UndoQueue, NewestItem, FeedModel); + return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, ShowAll, ActiveFeed, Persistence, FeedType, ItemModel, OPMLParser, NewestItem, FeedModel, $rootScope); } ]); @@ -2659,6 +2668,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._request.post('news_feeds_delete', params); }; + Persistence.prototype.restoreFeed = function(feedId, onSuccess) { + var params; + + if (onSuccess == null) { + onSuccess = null; + } + onSuccess || (onSuccess = function() {}); + params = { + onSuccess: onSuccess, + routeParams: { + feedId: feedId + } + }; + return this._request.post('news_feeds_restore', params); + }; + Persistence.prototype.moveFeed = function(feedId, folderId) { /* moves a feed to a new folder @@ -2827,6 +2852,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._request.post('news_folders_delete', params); }; + Persistence.prototype.restoreFolder = function(folderId, onSuccess) { + var params; + + if (onSuccess == null) { + onSuccess = null; + } + onSuccess || (onSuccess = function() {}); + params = { + onSuccess: onSuccess, + routeParams: { + folderId: folderId + } + }; + return this._request.post('news_folders_restore', params); + }; + Persistence.prototype.renameFolder = function(folderId, folderName) { /* Save if a folder was collapsed @@ -3178,114 +3219,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. // Generated by CoffeeScript 1.6.2 /* -ownCloud - App Framework - -@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('UndoQueue', [ - '$timeout', '$rootScope', function($timeout, $rootScope) { - var UndoQueue; - - UndoQueue = (function() { - function UndoQueue(_$timeout, _$rootScope) { - this._$timeout = _$timeout; - this._$rootScope = _$rootScope; - this._queue = []; - } - - UndoQueue.prototype.add = function(_caption, _callback, _timeout, _undoCallback) { - var command, data, - _this = this; - - this._caption = _caption; - this._callback = _callback; - this._timeout = _timeout != null ? _timeout : 0; - this._undoCallback = _undoCallback != null ? _undoCallback : null; - /* - @_caption the caption which indentifies the item - @_callback function the callback which should be executed when it was - not undone, this will usually be a request to the server to finally - delete something - @_timeout int the timeout after the callback should be executed - defaults to 0 - @_undoCallback function the function which should be executed when - an command has been canceled. Usually this will add back a deleted - object back to the interface, defaults to an empty function - */ - - this.executeAll(); - command = { - _undoCallback: this._undoCallback || (this._undoCallback = function() {}), - _callback: this._callback, - execute: function() { - return command._callback(); - }, - undo: function() { - command._undoCallback(); - _this._$timeout.cancel(command.promise); - return _this._queue = []; - }, - promise: this._$timeout(function() { - command.execute(); - _this._queue = []; - return _this._$rootScope.$broadcast('notUndone'); - }, this._timeout) - }; - data = { - undoCallback: command.undo, - caption: this._caption - }; - this._$rootScope.$broadcast('undoMessage', data); - return this._queue.push(command); - }; - - UndoQueue.prototype.executeAll = function() { - /* - Executes the callback before the timeout has run out - This is useful to execute all remaining commands if a new command is - added - */ - - var command, _i, _len, _ref; - - _ref = this._queue; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - command = _ref[_i]; - this._$timeout.cancel(command.promise); - command.execute(); - } - return this._queue = []; - }; - - return UndoQueue; - - })(); - return new UndoQueue($timeout, $rootScope); - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.6.2 -/* - ownCloud - News @author Bernhard Posselt diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee index 16f8cbd69..2f1607cff 100644 --- a/js/tests/services/persistenceSpec.coffee +++ b/js/tests/services/persistenceSpec.coffee @@ -207,6 +207,17 @@ describe 'Persistence', -> expect(@req.post).toHaveBeenCalledWith('news_feeds_delete', params) + it 'send a correct feed restore request', => + params = + onSuccess: -> + routeParams: + feedId: 3 + + @Persistence.restoreFeed(params.routeParams.feedId, params.onSuccess) + + expect(@req.post).toHaveBeenCalledWith('news_feeds_restore', params) + + it 'send a correct feed create request', => params = data: @@ -294,6 +305,17 @@ describe 'Persistence', -> expect(@req.post).toHaveBeenCalledWith('news_folders_delete', params) + it 'send a correct folder restore request', => + params = + onSuccess: -> + routeParams: + folderId: 3 + + @Persistence.restoreFolder(params.routeParams.folderId, params.onSuccess) + + expect(@req.post).toHaveBeenCalledWith('news_folders_restore', params) + + it 'should do a proper folder rename request', => params = routeParams: diff --git a/js/tests/services/undoqueueSpec.coffee b/js/tests/services/undoqueueSpec.coffee deleted file mode 100644 index dcb95e9fd..000000000 --- a/js/tests/services/undoqueueSpec.coffee +++ /dev/null @@ -1,59 +0,0 @@ -### - -ownCloud - App Framework - -@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/>. - -### - -describe 'UndoQueue', -> - - beforeEach module 'News' - - - beforeEach inject (@UndoQueue, @$timeout, @$rootScope) => - @queue = @UndoQueue - - - it 'should execute a callback', => - executed = false - callback = -> - executed = true - - @queue.add('hi', callback, 3000) - - @$timeout.flush() - - expect(executed).toBe(true) - - - it 'should execute a task when a new one is added', => - executed = 0 - undone = 0 - callback = -> - executed += 1 - - undoCallback = -> - undone += 1 - - @queue.add('hi', callback, 3000, undoCallback) - @queue.add('hi', callback, 3000, undoCallback) - - expect(executed).toBe(1) - expect(undone).toBe(0) - - |