From b10387c91e5168e90eb46355e3f9339644e38e20 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 31 Oct 2014 15:25:52 +0500 Subject: [PATCH] [#369] fix an advisory pagination --- .../angular-new/controllers/advisories_controller.js | 6 ++---- app/views/advisories/index.html.haml | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/angular-new/controllers/advisories_controller.js b/app/assets/javascripts/angular-new/controllers/advisories_controller.js index 6020a2ca4..64fd2e4e1 100644 --- a/app/assets/javascripts/angular-new/controllers/advisories_controller.js +++ b/app/assets/javascripts/angular-new/controllers/advisories_controller.js @@ -4,16 +4,14 @@ RosaABF.controller('AdvisoryCtrl', ['$scope', '$http', function($scope, $http) { $scope.advisories = null; $scope.q = null; - $scope.init = function(total_items, page, q) { - $scope.total_items = total_items; - $scope.page = page; + $scope.init = function(q) { $scope.q = q; }; $scope.getAdvisories = function() { $http.get(Routes.advisories_path({format: 'json', page: $scope.page, q: $scope.q})).then(function(res) { $scope.page = res.data.page; - $scope.total_items = parseInt(res.data.advisories_count, 10); + $scope.total_items = res.data.advisories_count; $scope.advisories = res.data.advisories; }); }; diff --git a/app/views/advisories/index.html.haml b/app/views/advisories/index.html.haml index 373403b19..d615fbdf3 100644 --- a/app/views/advisories/index.html.haml +++ b/app/views/advisories/index.html.haml @@ -2,14 +2,10 @@ - render partial: 'submenu' .row .container{ 'ng-controller' => 'AdvisoryCtrl', - 'ng-init' => "init(#{@advisories_count}, #{params[:page]}, #{params[:q].presence || 'null'})" } + 'ng-init' => "init(#{params[:q].presence || 'null'})" } %h3 = t 'layout.advisories.list_header' = link_to image_tag("rss.ico", width: '15px', height: '15px', class: 'atom_icon'), APP_CONFIG['anonymous_access'] ? advisories_path(format: 'atom') : advisories_path(format: 'atom', token: current_user.authentication_token) = render partial: 'list', object: @advisories - = paginate( total_items: 'total_items', - page: 'page', - per_page: Advisory.per_page, - ng_show: "total_items > #{Advisory.per_page}", - select_page: "goToPage(page)" ) + = angularjs_paginate( per_page: Advisory.per_page )