diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-11 17:55:59 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-11 17:55:59 +0200 |
commit | 59f42f80ad4f292ebbb95ec58d95e0503d29711f (patch) | |
tree | b1387b6afb4d67b3a08d99bb006ac99946d9f57d /js/app/services | |
parent | adcf13d214a2b1289cc86c116082e0889abb649c (diff) |
add a button for people to get out of add folder mode
Diffstat (limited to 'js/app/services')
-rw-r--r-- | js/app/services/bl/folderbl.coffee | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/js/app/services/bl/folderbl.coffee b/js/app/services/bl/folderbl.coffee index 68031371a..20f545e43 100644 --- a/js/app/services/bl/folderbl.coffee +++ b/js/app/services/bl/folderbl.coffee @@ -81,10 +81,31 @@ ItemModel, ShowAll, _ExistsError)-> return @_folderModel.getAll() - create: (folderName) -> - if @_folderModel.nameExists(folderName) + create: (folderName, onSuccess=null, onFailure=null) -> + onSuccess or= -> + onFailure or= -> + + if angular.isUndefined(folderName) or folderName.trim() == '' + throw new Error() + + folderName = folderName.trim() + + if @_folderModel.getByName(folderName) throw new _ExistsError() + folder = + name: folderName + + @_folderModel.add(folder) + + success = (response) => + if response.status == 'error' + folder.error = response.msg + onFailure() + else + onSuccess() + + @_persistence.createFolder folderName, 0, success return new FolderBl(FolderModel, FeedBl, ShowAll, ActiveFeed, Persistence, |