[#369] update a platform content paginate

This commit is contained in:
Alexander Machehin 2014-10-30 22:30:39 +05:00
parent d8fda24f39
commit 5b27309d21
5 changed files with 21 additions and 20 deletions

View File

@ -1,10 +1,11 @@
RosaABF.controller 'ContentsController', ['$scope', '$http', '$location', ($scope, $http, $location) ->
$scope.platform = $('#platform_name').val()
$scope.processing = true
$scope.contents = []
$scope.folders = []
$scope.pages = []
$scope.platform = $('#platform_name').val()
$scope.processing = true
$scope.contents = []
$scope.folders = []
$scope.page = null
$scope.total_items = null
# Fixes: redirect to page after form submit
$("#search_contents_form").on 'submit', ->
@ -21,14 +22,14 @@ RosaABF.controller 'ContentsController', ['$scope', '$http', '$location', ($scop
format: 'json'
$http.get(Routes.platform_contents_path(params)).success( (data) ->
$scope.folders = data.folders
$scope.contents = data.contents
$scope.pages = data.pages
$scope.back = data.back
$scope.processing = false
$scope.folders = data.folders
$scope.contents = data.contents
$scope.total_items = data.total_items
$scope.back = data.back
$scope.processing = false
).error( ->
$scope.contents = []
$scope.processing = false
$scope.contents = []
$scope.processing = false
)
true

View File

@ -6,19 +6,20 @@ class Platforms::ContentsController < Platforms::BaseController
skip_before_filter :authenticate_user!, only: :index if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
def index
def index
respond_to do |format|
format.html
format.json do
@path = params[:path].to_s
@term = params[:term]
@contents = PlatformContent.find_by_platform(@platform, @path, @term)
.paginate(paginate_params)
@total_items = @contents.count
@contents = @contents.paginate(paginate_params)
end
end
end
def remove_file

View File

@ -20,10 +20,9 @@ module PaginateHelper
end
def angularjs_paginate(options = {})
return if options[:per_page].blank?
options.reverse_merge!(
{
per_page: 25,
total_items: 'total_items',
page: 'page',
select_page: "goToPage(page)"

View File

@ -63,4 +63,4 @@
span.delete ng-click="destroy(content)" ng-hide='content.processing' ng-confirm-click=t('layout.confirm')
| &nbsp;
= render 'shared/angularjs_will_paginate'
= angularjs_paginate

View File

@ -22,4 +22,4 @@ end
json.back paths.size == 1 ? '/' : paths[0...-1].join('/')
json.pages angularjs_will_paginate(@contents)
json.total_items @total_items