@@ -68,6 +68,9 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
68
68
$scope .current_playlist = $scope .all_songs
69
69
else
70
70
$scope .current_playlist = playlist
71
+ ApiFactory .getPlaylist (playlist .id ).then (updated_playlist) ->
72
+ playlist = updated_playlist
73
+ $scope .current_playlist = updated_playlist
71
74
$scope .removePlaylist = (playlist ) ->
72
75
ApiFactory .deletePlaylist (playlist .id ).then (val) ->
73
76
if $scope .current_playlist .id == playlist .id
@@ -89,6 +92,12 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
89
92
$scope .last_clicked_song = song
90
93
song .selected = true
91
94
95
+ $scope .softClickSong = (song ) ->
96
+ if $scope .last_clicked_song
97
+ $scope .last_clicked_song .selected = false
98
+ $scope .last_clicked_song = song
99
+ song .selected = true
100
+
92
101
$scope .playSong = (index ) ->
93
102
$scope .current_song = $scope .current_playlist .songs [index]
94
103
$scope .last_clicked_song .selected = false
@@ -100,16 +109,26 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
100
109
$rootScope .$broadcast (' audio.play' )
101
110
, 0
102
111
103
- $scope .openAddToPlaylistModal = () ->
112
+ $scope .openAddToPlaylistModal = (songs , playlists ) ->
113
+ modalInstance = $modal .open ({
114
+ templateUrl : ' /partial/modal/add_to_playlist'
115
+ controller : ' AddToPlaylistCtrl'
116
+ resolve : {
117
+ songs : ()-> songs
118
+ playlists : ()-> playlists
119
+ }
120
+ })
104
121
105
122
$scope .rename = () ->
106
- $scope .remove = (song ) ->
107
- song_id = song .id
108
- if $scope .current_playlist .id == ' all'
109
- ApiFactory .deleteSong (song_id)
110
- _ .each $scope .playlists , (playlist ) ->
111
- playlist .songs = _ .reject playlist .songs , (song ) -> song .id == song_id
112
- $scope .current_playlist .songs = _ .without ($scope .current_playlist .songs , song)
123
+ $scope .remove = (songs ) ->
124
+ if $scope .current_playlist .id == ' -1'
125
+ _ .each songs, (song ) ->
126
+ ApiFactory .deleteSong (song .id )
127
+ $scope .current_playlist .songs = _ .without ($scope .current_playlist .songs , song)
128
+ else
129
+ ApiFactory .removeFromPlaylist (_ .pluck (songs, ' id' ), $scope .current_playlist .id ).then (playlist) ->
130
+ $scope .current_playlist = playlist
131
+ $scope .current_playlist .songs = _ .reject ($scope .current_playlist .songs , (song )-> _ .has (_ .pluck (songs, ' id' ), song .id ))
113
132
114
133
$scope .localUpload = (playlist ) ->
115
134
modalInstance = $modal .open ({
@@ -121,4 +140,6 @@ app.controller 'PlayerCtrl',['$scope', 'AuthFactory', 'ApiFactory', '$sce', '$ro
121
140
})
122
141
modalInstance .result .then (result) ->
123
142
console .log result
143
+ $scope .selectedSongs = () ->
144
+ _ .select ($scope .current_playlist .songs , (song ) -> song .selected )
124
145
]
0 commit comments