Pony.fm/public/scripts/app/controllers/playlist-form.coffee

28 lines
615 B
CoffeeScript
Raw Normal View History

2013-07-28 19:45:21 +02:00
angular.module('ponyfm').controller "playlist-form", [
'$scope', 'dialog', 'playlists', 'playlist'
($scope, dialog, playlists, playlist) ->
$scope.isLoading = false
$scope.form = playlist
$scope.isNew = playlist.id == undefined
$scope.errors = {}
$scope.createPlaylist = () ->
$scope.isLoading = true
def =
if $scope.isNew
playlists.createPlaylist($scope.form)
else
playlists.editPlaylist($scope.form)
def
2013-08-01 10:57:08 +02:00
.done (res) ->
dialog.close(res)
2013-07-28 19:45:21 +02:00
.fail (errors)->
$scope.errors = errors
$scope.isLoading = false
2013-08-01 10:57:08 +02:00
$scope.close = () -> dialog.close(null)
2013-07-28 19:45:21 +02:00
]