Add confirmation dialog to track removal.

This commit is contained in:
Mihail-K 2016-03-20 17:41:54 -04:00
parent e7ed44d7de
commit d8cb98b912

View file

@ -24,17 +24,24 @@ module.exports = angular.module('ponyfm').directive 'pfmTracksList', () ->
class: '@class'
controller: [
'$scope', 'favourites', 'player', 'playlists', 'auth'
($scope, favourites, player, playlists, auth) ->
'$dialog', '$scope', 'favourites', 'player', 'playlists', 'auth'
($dialog, $scope, favourites, player, playlists, auth) ->
$scope.auth = auth.data
$scope.canModifyPlaylist = ->
$scope.playlist and $scope.auth.isLogged and $scope.playlist.user.id == $scope.auth.user.id
$scope.removeFromPlaylist = (track) ->
playlists.removeTrackFromPlaylist $scope.playlist?.id, track.id
.done ->
$scope.tracks = _.reject $scope.tracks, (t) -> t.id == track.id
$dialog.messageBox "Remove #{track.title} from playlist",
"Are you sure you want to delete \"#{track.title}\"?", [
{ result: 'ok', label: 'Yes', cssClass: 'btn-danger' },
{ result: 'cancel', label: 'No', cssClass: 'btn-primary' }
]
.open().then (res) ->
return if res is 'cancel'
playlists.removeTrackFromPlaylist $scope.playlist?.id, track.id
.done ->
$scope.tracks = _.reject $scope.tracks, (t) -> t.id == track.id
$scope.toggleFavourite = (track) ->
favourites.toggle('track', track.id).done (res) ->