From bce22d6877db16939c7d1a1ca67e49c42457b4d4 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Sun, 28 Aug 2016 04:14:48 +0100 Subject: [PATCH 1/2] Attempting (and failing) to fix pagination --- .../scripts/app/directives/paged-tracks-list.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/assets/scripts/app/directives/paged-tracks-list.coffee b/resources/assets/scripts/app/directives/paged-tracks-list.coffee index 66958271..51ab0074 100644 --- a/resources/assets/scripts/app/directives/paged-tracks-list.coffee +++ b/resources/assets/scripts/app/directives/paged-tracks-list.coffee @@ -23,8 +23,8 @@ module.exports = angular.module('ponyfm').directive 'pfmPagedTracksList', () -> class: '@class' controller: [ - '$scope', 'tracks', '$state', - ($scope, tracks, $state) -> + '$scope', 'tracks', '$state', '$location' + ($scope, tracks, $state, $location) -> typeEnum = switch when $scope.type == 'normal' then tracks.FetchType.NORMAL when $scope.type == 'all' then tracks.FetchType.ALL @@ -58,10 +58,16 @@ module.exports = angular.module('ponyfm').directive 'pfmPagedTracksList', () -> # The actual last page will always be in the paginator. $scope.pages.push($scope.totalPages) unless $scope.totalPages in $scope.pages + console.log $state + $scope.pageSelectorShown = false $scope.gotoPage = (page) -> - $state.transitionTo $state.current.name, {filter: $state.params.filter, page: page} + #$state.transitionTo $state.current.name, {filter: $state.params.filter, page: page} + #$location.search 'filter', $state.params.filter + #$location.search 'page', page + tracks.mainQuery.fromFilterString($state.params.filter) + tracks.mainQuery.setPage page || 1 $scope.showPageSelector = () -> $scope.pageSelectorShown = true From ff7b6fca3ffe955a1749b9851aa230558a8f9f9b Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Mon, 29 Aug 2016 00:09:01 +0100 Subject: [PATCH 2/2] Fixed paged tracks directive --- package.json | 7 +++---- resources/assets/scripts/app/app.coffee | 4 ++-- .../scripts/app/controllers/admin-classifier.coffee | 2 +- .../assets/scripts/app/controllers/admin-tracks.coffee | 3 +-- .../scripts/app/directives/paged-tracks-list.coffee | 9 ++------- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index da874af9..25d7a916 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "packages": {}, "dependencies": {}, "devDependencies": { - "angular": "1.5.6", + "angular": "1.5.8", "angular-chart.js": "1.0.0-alpha6", "angular-strap": "2.3.8", - "angular-ui-router": "0.2.18", + "angular-ui-router": "0.3.1", "chart.js": "2.1.0", "coffee-loader": "0.7.2", "coffee-script": "1.10.0", @@ -31,8 +31,7 @@ "gulp-plumber": "1.1.0", "gulp-sourcemaps": "1.6.0", "gulp-util": "3.0.7", - "jquery": "2.2.0", - "jquery-ui": "1.10.5", + "jquery": "2.2.4", "script-loader": "0.7.0", "underscore": "1.8.3", "webpack": "1.13.1", diff --git a/resources/assets/scripts/app/app.coffee b/resources/assets/scripts/app/app.coffee index 7d768c42..2ddf4f7e 100644 --- a/resources/assets/scripts/app/app.coffee +++ b/resources/assets/scripts/app/app.coffee @@ -279,12 +279,12 @@ ponyfm.config [ templateUrl: '/templates/admin/show-songs.html' state.state 'admin.tracks', - url: '/tracks' + url: '/tracks?filter&page' controller: 'admin-tracks' templateUrl: '/templates/admin/tracks.html' state.state 'admin.classifier', - url: '/tracks/unclassified' + url: '/tracks/unclassified?filter&page' controller: 'admin-classifier' templateUrl: '/templates/admin/classifier.html' diff --git a/resources/assets/scripts/app/controllers/admin-classifier.coffee b/resources/assets/scripts/app/controllers/admin-classifier.coffee index cf795510..e8a1dc22 100644 --- a/resources/assets/scripts/app/controllers/admin-classifier.coffee +++ b/resources/assets/scripts/app/controllers/admin-classifier.coffee @@ -21,6 +21,7 @@ window.pfm.preloaders['admin-classifier'] = [ tracks.mainQuery.fromFilterString($state.params.filter) tracks.mainQuery.setPage $state.params.page || 1 tracks.mainQuery.setAdmin true + tracks.mainQuery.fetch(tracks.FetchType.UNCLASSIFIED) ) ] @@ -28,5 +29,4 @@ module.exports = angular.module('ponyfm').controller "admin-classifier", [ '$scope', 'tracks', '$state', ($scope, tracks, $state) -> - ] diff --git a/resources/assets/scripts/app/controllers/admin-tracks.coffee b/resources/assets/scripts/app/controllers/admin-tracks.coffee index 9d66f888..d4d2f0ea 100644 --- a/resources/assets/scripts/app/controllers/admin-tracks.coffee +++ b/resources/assets/scripts/app/controllers/admin-tracks.coffee @@ -21,12 +21,11 @@ window.pfm.preloaders['admin-tracks'] = [ tracks.mainQuery.fromFilterString($state.params.filter) tracks.mainQuery.setPage $state.params.page || 1 tracks.mainQuery.setAdmin true + tracks.mainQuery.fetch(tracks.FetchType.ALL) ) ] module.exports = angular.module('ponyfm').controller "admin-tracks", [ '$scope', 'tracks', '$state', ($scope, tracks, $state) -> - - ] diff --git a/resources/assets/scripts/app/directives/paged-tracks-list.coffee b/resources/assets/scripts/app/directives/paged-tracks-list.coffee index 51ab0074..9e870eb9 100644 --- a/resources/assets/scripts/app/directives/paged-tracks-list.coffee +++ b/resources/assets/scripts/app/directives/paged-tracks-list.coffee @@ -58,16 +58,11 @@ module.exports = angular.module('ponyfm').directive 'pfmPagedTracksList', () -> # The actual last page will always be in the paginator. $scope.pages.push($scope.totalPages) unless $scope.totalPages in $scope.pages - console.log $state - $scope.pageSelectorShown = false $scope.gotoPage = (page) -> - #$state.transitionTo $state.current.name, {filter: $state.params.filter, page: page} - #$location.search 'filter', $state.params.filter - #$location.search 'page', page - tracks.mainQuery.fromFilterString($state.params.filter) - tracks.mainQuery.setPage page || 1 + #$scope.$emit 'pageChange', {filter: $state.params.filter, page: page} + $state.go '.', {filter: $state.params.filter, page: page} $scope.showPageSelector = () -> $scope.pageSelectorShown = true