[#369] fix an advisory pagination

This commit is contained in:
Alexander Machehin 2014-10-31 15:25:52 +05:00
parent 4efe951c6d
commit b10387c91e
2 changed files with 4 additions and 10 deletions

View File

@ -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;
});
};

View File

@ -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 )