Pass page to directive

This commit is contained in:
Josef Citrine 2017-05-16 21:48:19 +01:00
parent 7fc9310760
commit 6248f07eb1
3 changed files with 65 additions and 63 deletions

View file

@ -1,4 +1,4 @@
<div class="classifier">
<pfm-paged-tracks-list type="all" click-override="clickOverride(id)" has-override="true" class="classifier-track-list"></pfm-paged-tracks-list>
<pfm-paged-tracks-list type="all" click-override="clickOverride(id)" has-override="true" class="classifier-track-list" admin="true"></pfm-paged-tracks-list>
<pfm-track-editor track-id="trackIdToEdit" class="classifier-track-editor"></pfm-track-editor>
</div>

View file

@ -1 +1 @@
<pfm-paged-tracks-list type="all"></pfm-paged-tracks-list>
<pfm-paged-tracks-list type="all" admin="true"></pfm-paged-tracks-list>

View file

@ -23,14 +23,17 @@ module.exports = angular.module('ponyfm').directive 'pfmPagedTracksList', () ->
class: '@class'
clickOverride: '&'
hasOverride: '@'
admin: '@'
controller: [
'$scope', 'tracks', '$state', '$location'
($scope, tracks, $state, $location) ->
tracks.loadFilters().then(->
$scope.filters = tracks.filters
$scope.query = tracks.mainQuery
tracks.mainQuery.fromFilterString($state.params.filter)
tracks.mainQuery.setPage $state.params.page || 1
tracks.mainQuery.setAdmin $scope.admin || false
$scope.toggleListFilter = (filter, id) ->
$scope.query.toggleListFilter filter, id
@ -103,5 +106,4 @@ module.exports = angular.module('ponyfm').directive 'pfmPagedTracksList', () ->
$scope.jumpToPage = (inputPageNumber) ->
$scope.gotoPage(inputPageNumber)
)
]