2015-08-31 17:42:21 +02:00
|
|
|
window.pfm.preloaders['account-tracks'] = [
|
2015-10-25 03:35:37 +01:00
|
|
|
'account-tracks', 'account-albums', 'taxonomies'
|
|
|
|
(tracks, albums, taxonomies) ->
|
|
|
|
$.when.all [tracks.refresh(null, true), albums.refresh(true), taxonomies.refresh()]
|
2015-08-31 17:42:21 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
angular.module('ponyfm').controller "account-tracks", [
|
2015-10-25 03:35:37 +01:00
|
|
|
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox', 'account-albums', 'account-tracks'
|
|
|
|
($scope, $state, taxonomies, $dialog, lightbox, albums, tracks) ->
|
|
|
|
$scope.data =
|
|
|
|
selectedTrack: null
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
$scope.tracks = []
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
tracksDb = {}
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
setTracks = (tracks) ->
|
|
|
|
$scope.tracks.length = 0
|
|
|
|
tracksDb = {}
|
|
|
|
for track in tracks
|
|
|
|
tracksDb[track.id] = track
|
|
|
|
$scope.tracks.push track
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
if $state.params.track_id
|
|
|
|
$scope.data.selectedTrack = tracksDb[$state.params.track_id]
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
tracks.refresh().done setTracks
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
$scope.refreshList = () ->
|
|
|
|
tracks.refresh().done setTracks
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
$scope.selectTrack = (track) ->
|
|
|
|
$scope.data.selectedTrack = track
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
$scope.$on '$stateChangeSuccess', () ->
|
|
|
|
if $state.params.track_id
|
|
|
|
$scope.selectTrack tracksDb[$state.params.track_id]
|
|
|
|
else
|
|
|
|
$scope.selectTrack null
|
2015-08-31 17:42:21 +02:00
|
|
|
|
2015-10-25 03:35:37 +01:00
|
|
|
$scope.$on 'track-deleted', () ->
|
|
|
|
tracks.clearCache()
|
|
|
|
$scope.refreshList()
|
|
|
|
]
|