2013-07-28 09:09:10 +02:00
|
|
|
angular.module('ponyfm').controller "account-albums", [
|
|
|
|
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox'
|
|
|
|
($scope, $state, taxonomies, $dialog, lightbox) ->
|
2013-07-28 10:35:31 +02:00
|
|
|
albumsDb = {}
|
2013-07-28 09:09:10 +02:00
|
|
|
|
2013-07-28 10:35:31 +02:00
|
|
|
$scope.albums = []
|
2013-07-28 09:09:10 +02:00
|
|
|
$scope.data =
|
|
|
|
isEditorOpen: false
|
|
|
|
selectedAlbum: null
|
|
|
|
|
2013-07-28 10:35:31 +02:00
|
|
|
refreshList = () ->
|
|
|
|
$.getJSON('/api/web/albums/owned')
|
|
|
|
.done (albums) -> $scope.$apply ->
|
|
|
|
albumsDb[album.id] = album for album in albums
|
|
|
|
$scope.albums = albums
|
|
|
|
|
|
|
|
selectAlbum albumsDb[$state.params.album_id] if $state.params.album_id != undefined
|
|
|
|
|
|
|
|
selectAlbum = (album) -> $scope.data.selectedAlbum = album
|
|
|
|
|
2013-07-28 09:09:10 +02:00
|
|
|
$scope.$on '$stateChangeSuccess', () ->
|
|
|
|
if $state.params.album_id
|
|
|
|
selectAlbum albumsDb[$state.params.album_id]
|
|
|
|
else
|
|
|
|
selectAlbum null
|
2013-07-28 10:35:31 +02:00
|
|
|
|
|
|
|
refreshList()
|
2013-07-28 09:09:10 +02:00
|
|
|
]
|