mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-23 21:47:59 +01:00
28 lines
No EOL
765 B
CoffeeScript
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()
|
|
] |