diff options
Diffstat (limited to 'js/app/controllers/feedcontroller.coffee')
-rw-r--r-- | js/app/controllers/feedcontroller.coffee | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee index fea2cb46d..7a61f4ab1 100644 --- a/js/app/controllers/feedcontroller.coffee +++ b/js/app/controllers/feedcontroller.coffee @@ -67,34 +67,40 @@ angular.module('News').factory '_FeedController', -> @$scope.setShowAll = (showAll) => @setShowAll(showAll) - @$scope.addFeed = (feedUrl, parentFolderId) => - ### + @$scope.isAddingFolder = => + return @_isAddingFolder + + @$scope.isAddingFeed = => + return @_isAddingFeed + + @$scope.toggleFolder = (folderId) => + @toggleFolder(folderId) + + @$scope.addFeed = (feedUrl, parentFolderId=0) => @$scope.feedEmptyError = false @$scope.feedExistsError = false @$scope.feedError = false - + if angular.isUndefined(feedUrl) or feedUrl.trim() == '' @$scope.feedEmptyError = true else feedUrl = feedUrl.trim() - for feed in @feedModel.getItems() - if feedUrl == feed.feedUrl # FIXME: can we really compare this + for feed in @_feedModel.getAll() + if feedUrl == feed.url @$scope.feedExistsError = true - + + if not (@$scope.feedEmptyError or @$scope.feedExistsError) - if angular.isUndefined(parentFolderId) - folderId = 0 - else - folderId = folder.id - @$scope.adding = true + @_isAddingFeed = true + onSuccess = => @$scope.feedUrl = '' - @$scope.adding = false + @_isAddingFeed = false onError = => @$scope.feedError = true - @$scope.adding = false - @persistence.createFeed(url, folderId, onSuccess, onError) - ### + @_isAddingFeed = false + @_persistence.createFeed(feedUrl, parentFolderId, onSuccess, + onError) @$scope.addFolder = (folderName) => @$scope.folderEmptyError = false @@ -115,16 +121,6 @@ angular.module('News').factory '_FeedController', -> @_isAddingFolder = false - @$scope.isAddingFolder = => - return @_isAddingFolder - - @$scope.isAddingFeed = => - return @_isAddingFeed - - @$scope.toggleFolder = (folderId) => - @toggleFolder(folderId) - - toggleFolder: (folderId) -> folder = @_folderModel.getById(folderId) |