mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-12-04 18:28:00 +01:00
18e41d2af4
Volume Slider Track Uploader Fav list A bunch of other things And stuff.
46 lines
No EOL
1.3 KiB
CoffeeScript
46 lines
No EOL
1.3 KiB
CoffeeScript
window.pfm.preloaders['account-albums'] = [
|
|
'account-tracks', 'account-albums'
|
|
(tracks, albums) ->
|
|
$.when.all [tracks.refresh('published=true&in_album=false', true), albums.refresh(true)]
|
|
]
|
|
|
|
angular.module('ponyfm').controller "account-albums", [
|
|
'$scope', '$state', 'account-albums', 'account-tracks'
|
|
($scope, $state, albums, tracks) ->
|
|
$scope.albums = []
|
|
$scope.data =
|
|
isEditorOpen: false
|
|
selectedAlbum: null
|
|
tracksDb: []
|
|
|
|
selectAlbum = (album) -> $scope.data.selectedAlbum = album
|
|
|
|
updateTracks = (tracks) ->
|
|
$scope.data.tracksDb.push track for track in tracks
|
|
|
|
tracks.refresh('published=true&in_album=false').done updateTracks
|
|
|
|
albumsDb = {}
|
|
|
|
updateAlbums = (albums) ->
|
|
$scope.albums.length = 0
|
|
|
|
for album in albums
|
|
$scope.albums.push album
|
|
albumsDb[album.id] = album
|
|
|
|
if $state.params.album_id
|
|
selectAlbum albumsDb[$state.params.album_id]
|
|
|
|
albums.refresh().done updateAlbums
|
|
|
|
$scope.$on '$stateChangeSuccess', () ->
|
|
if $state.params.album_id
|
|
selectAlbum albumsDb[$state.params.album_id]
|
|
else
|
|
selectAlbum null
|
|
|
|
$scope.$on 'album-created', () -> albums.refresh(true).done(updateAlbums)
|
|
$scope.$on 'album-deleted', () -> albums.refresh(true).done(updateAlbums)
|
|
$scope.$on 'album-updated', () -> tracks.refresh('published=true&in_album=false', true).done updateTracks
|
|
] |