Pony.fm/public/scripts/app/controllers/account-albums.coffee
2013-07-28 03:35:31 -05:00

28 lines
No EOL
765 B
CoffeeScript

angular.module('ponyfm').controller "account-albums", [
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox'
($scope, $state, taxonomies, $dialog, lightbox) ->
albumsDb = {}
$scope.albums = []
$scope.data =
isEditorOpen: false
selectedAlbum: null
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
$scope.$on '$stateChangeSuccess', () ->
if $state.params.album_id
selectAlbum albumsDb[$state.params.album_id]
else
selectAlbum null
refreshList()
]