diff --git a/public/templates/directives/tracks-list.html b/public/templates/directives/tracks-list.html index dcb4416b..34a63b60 100644 --- a/public/templates/directives/tracks-list.html +++ b/public/templates/directives/tracks-list.html @@ -12,6 +12,9 @@ + + + {{::track.title}} diff --git a/public/templates/playlists/show.html b/public/templates/playlists/show.html index 84df2af8..23f59895 100644 --- a/public/templates/playlists/show.html +++ b/public/templates/playlists/show.html @@ -57,7 +57,7 @@

Tracks

- + diff --git a/resources/assets/scripts/app/directives/tracks-list.coffee b/resources/assets/scripts/app/directives/tracks-list.coffee index d0d665aa..b32e357e 100644 --- a/resources/assets/scripts/app/directives/tracks-list.coffee +++ b/resources/assets/scripts/app/directives/tracks-list.coffee @@ -19,14 +19,23 @@ module.exports = angular.module('ponyfm').directive 'pfmTracksList', () -> templateUrl: '/templates/directives/tracks-list.html' replace: true scope: - tracks: '=tracks', + playlist: '=' + tracks: '=tracks' class: '@class' controller: [ - '$scope', 'favourites', 'player', 'auth' - ($scope, favourites, player, auth) -> + '$scope', 'favourites', 'player', 'playlists', 'auth' + ($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 + $scope.toggleFavourite = (track) -> favourites.toggle('track', track.id).done (res) -> track.user_data.is_favourited = res.is_favourited