[#369] update a platform content paginate
This commit is contained in:
parent
d8fda24f39
commit
5b27309d21
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)"
|
||||
|
|
|
@ -63,4 +63,4 @@
|
|||
span.delete ng-click="destroy(content)" ng-hide='content.processing' ng-confirm-click=t('layout.confirm')
|
||||
|
|
||||
|
||||
= render 'shared/angularjs_will_paginate'
|
||||
= angularjs_paginate
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue