now pages are sorted according to the page number in structure
This commit is contained in:
parent
8be1843081
commit
4f53f41cc9
|
@ -3,9 +3,14 @@ class Admin::PageContentsController < OrbitAdminController
|
||||||
def index
|
def index
|
||||||
@table_fields = [:page_id, :name,:version,:update_at,:last_modified, :category]
|
@table_fields = [:page_id, :name,:version,:update_at,:last_modified, :category]
|
||||||
@filter_fields = {}
|
@filter_fields = {}
|
||||||
@pages = Page.where(:module=>"page_content").order_by(sort)
|
if params[:sort].blank? && params[:keywords].blank?
|
||||||
|
@pages = get_pages_sorted(Page.root)
|
||||||
|
@pages = Kaminari.paginate_array(@pages).page(params[:page]).per(10)
|
||||||
|
else
|
||||||
|
@pages = Page.where(:module=>"page_content").order_by(sort)
|
||||||
|
@pages = search_data(@pages,[:name, :page_id]).page(params[:page]).per(10)
|
||||||
|
end
|
||||||
@categories = @module_app.categories.enabled.authorized(current_user).collect{|c| [c.title, c.id]}
|
@categories = @module_app.categories.enabled.authorized(current_user).collect{|c| [c.title, c.id]}
|
||||||
@pages = search_data(@pages,[:name, :page_id]).page(params[:page]).per(10)
|
|
||||||
|
|
||||||
render :partial => "index" if request.xhr?
|
render :partial => "index" if request.xhr?
|
||||||
end
|
end
|
||||||
|
@ -52,4 +57,18 @@ class Admin::PageContentsController < OrbitAdminController
|
||||||
def update_params
|
def update_params
|
||||||
params.require(:page_context).permit!
|
params.require(:page_context).permit!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_pages_sorted(page)
|
||||||
|
pages = []
|
||||||
|
page.child_page.asc(:number).each do |cp|
|
||||||
|
if cp.child_page.blank? || cp.child_page.nil?
|
||||||
|
pages << cp if cp.module == "page_content"
|
||||||
|
else
|
||||||
|
pages << cp if cp.module == "page_content"
|
||||||
|
pages.concat(get_pages_sorted(cp))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pages
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue