mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-31 03:16:42 +01:00
Add confirmation dialog to track removal.
This commit is contained in:
parent
e7ed44d7de
commit
d8cb98b912
1 changed files with 12 additions and 5 deletions
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue