Made playlist track delete actually functional

This commit is contained in:
Josef Citrine 2016-06-02 16:52:48 +01:00
parent b22ddcbf5c
commit 583171669f
2 changed files with 27 additions and 10 deletions

View file

@ -0,0 +1,17 @@
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" ng-show="title">
<button type="button" class="close" ng-click="$hide()">&times;</button>
<h4 class="modal-title">Remove {{ track.title }} from playlist</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete {{ track.title }}?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" ng-click="confirmDeleteTrack();$hide()">Yes</button>
<button type="button" class="btn btn-primary" ng-click="$hide()">No</button>
</div>
</div>
</div>
</div>

View file

@ -32,16 +32,16 @@ module.exports = angular.module('ponyfm').directive 'pfmTracksList', () ->
$scope.playlist and $scope.auth.isLogged and $scope.playlist.user.id == $scope.auth.user.id
$scope.removeFromPlaylist = (track) ->
#$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.track = track
dialog = $modal
templateUrl: '/templates/partials/delete-playlist-track-dialog.html'
scope: $scope,
show: true
$scope.confirmDeleteTrack = () ->
playlists.removeTrackFromPlaylist $scope.playlist?.id, $scope.track.id
.done ->
$scope.tracks = _.reject $scope.tracks, (t) -> t.id == $scope.track.id
$scope.toggleFavourite = (track) ->
favourites.toggle('track', track.id).done (res) ->