mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
parent
4a5c2418eb
commit
fb2997c2e9
3 changed files with 16 additions and 4 deletions
|
@ -12,6 +12,9 @@
|
|||
<a pfm-eat-click class="icon-favourite" href="#" ng-click="toggleFavourite(track)" ng-if="::auth.isLogged">
|
||||
<i class="icon-star-empty"></i>
|
||||
</a>
|
||||
<a pfm-eat-click href="#" ng-click="removeFromPlaylist(track)" ng-if="::canModifyPlaylist()">
|
||||
<i class="icon-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
<a class="info" ng-href="{{::track.url}}">
|
||||
<span class="title">{{::track.title}}</span>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
|
||||
<h2>Tracks</h2>
|
||||
<pfm-tracks-list tracks="::playlist.tracks"></pfm-tracks-list>
|
||||
<pfm-tracks-list tracks="::playlist.tracks" playlist="::playlist"></pfm-tracks-list>
|
||||
|
||||
<pfm-comments type="playlist" resource="::playlist"></pfm-comments>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue