2013-08-01 01:04:04 +02:00
|
|
|
window.pfm.preloaders['tracks'] = [
|
|
|
|
'tracks', '$state'
|
|
|
|
(tracks) ->
|
|
|
|
tracks.loadFilters()
|
|
|
|
]
|
|
|
|
|
2013-07-28 23:51:35 +02:00
|
|
|
angular.module('ponyfm').controller "tracks", [
|
2013-07-31 13:47:16 +02:00
|
|
|
'$scope', 'tracks', '$state'
|
|
|
|
($scope, tracks, $state) ->
|
2013-07-28 23:51:35 +02:00
|
|
|
$scope.recentTracks = null
|
2013-07-31 13:47:16 +02:00
|
|
|
$scope.query = tracks.mainQuery
|
|
|
|
$scope.filters = tracks.filters
|
2013-07-28 23:51:35 +02:00
|
|
|
|
2013-07-31 13:47:16 +02:00
|
|
|
$scope.toggleListFilter = (filter, id) ->
|
|
|
|
$scope.query.toggleListFilter filter, id
|
2013-08-14 07:53:12 +02:00
|
|
|
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
2013-07-28 23:51:35 +02:00
|
|
|
|
2013-07-31 13:47:16 +02:00
|
|
|
$scope.setFilter = (filter, value) ->
|
|
|
|
$scope.query.setFilter filter, value
|
2013-08-14 07:53:12 +02:00
|
|
|
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
2013-07-31 13:47:16 +02:00
|
|
|
|
|
|
|
$scope.setListFilter = (filter, id) ->
|
|
|
|
$scope.query.setListFilter filter, id
|
2013-08-14 07:53:12 +02:00
|
|
|
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
2013-07-31 13:47:16 +02:00
|
|
|
|
2013-08-16 01:49:20 +02:00
|
|
|
$scope.clearFilter = (filter) ->
|
|
|
|
$scope.query.clearFilter filter
|
|
|
|
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
|
|
|
|
2013-07-31 13:47:16 +02:00
|
|
|
tracks.mainQuery.listen (searchResults) ->
|
|
|
|
$scope.tracks = searchResults.tracks
|
|
|
|
$scope.currentPage = parseInt(searchResults.current_page)
|
|
|
|
$scope.totalPages = parseInt(searchResults.total_pages)
|
|
|
|
delete $scope.nextPage
|
|
|
|
delete $scope.prevPage
|
|
|
|
|
|
|
|
$scope.nextPage = $scope.currentPage + 1 if $scope.currentPage < $scope.totalPages
|
|
|
|
$scope.prevPage = $scope.currentPage - 1 if $scope.currentPage > 1
|
|
|
|
$scope.pages = [1..$scope.totalPages]
|
|
|
|
|
|
|
|
$scope.gotoPage = (page) ->
|
2013-08-14 07:53:12 +02:00
|
|
|
$state.transitionTo 'content.tracks.list', {filter: $state.params.filter, page: page}
|
2013-08-01 01:04:04 +02:00
|
|
|
|
|
|
|
$scope.$on '$destroy', -> tracks.mainQuery = tracks.createQuery()
|
2013-07-28 23:51:35 +02:00
|
|
|
]
|