From 4d2007e56023218e9e686a28a05f3cc677ba613c Mon Sep 17 00:00:00 2001 From: manson Date: Thu, 7 Aug 2014 18:48:51 +0800 Subject: [PATCH] add search for backend index --- .../admin/page_contents_controller.rb | 11 ++++-- app/views/admin/page_contents/_index.html.erb | 35 ++++++++++++++++++ app/views/admin/page_contents/index.html.erb | 37 ++----------------- 3 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 app/views/admin/page_contents/_index.html.erb diff --git a/app/controllers/admin/page_contents_controller.rb b/app/controllers/admin/page_contents_controller.rb index 800f963..2c61904 100644 --- a/app/controllers/admin/page_contents_controller.rb +++ b/app/controllers/admin/page_contents_controller.rb @@ -1,7 +1,12 @@ class Admin::PageContentsController < OrbitAdminController def index - @pages = Page.where(:module=>"page_content").page(params[:page]).per(10) - @table_fields = ["Name","Version","Updated At","Last Modified By"] + @table_fields = [:page_id, :name,:version,:update_at,:last_modified] + @filter_fields = {} + @pages = Page.where(:module=>"page_content").order_by(sort) + + @pages = search_data(@pages,[:name, :page_id]).page(params[:page]).per(10) + + render :partial => "index" if request.xhr? end def show @@ -33,6 +38,6 @@ class Admin::PageContentsController < OrbitAdminController private def update_params - params.require(:page_context).permit! + params.require(:page_context).permit! end end diff --git a/app/views/admin/page_contents/_index.html.erb b/app/views/admin/page_contents/_index.html.erb new file mode 100644 index 0000000..cf2c727 --- /dev/null +++ b/app/views/admin/page_contents/_index.html.erb @@ -0,0 +1,35 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @pages.each do |page| %> + + + + + + + + <% end %> + +
<%= page.page_id %> + <%= page.name %> +
+ +
+
<%= page.page_contexts.last.version rescue nil %><%= format_value page.page_contexts.last.updated_at rescue nil %><%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %>
+ +<%= + content_tag :div, class: "bottomnav clearfix" do + content_tag :div, paginate(@pages), class: "pagination pagination-centered" + end +%> \ No newline at end of file diff --git a/app/views/admin/page_contents/index.html.erb b/app/views/admin/page_contents/index.html.erb index 97a3c8b..66bb688 100644 --- a/app/views/admin/page_contents/index.html.erb +++ b/app/views/admin/page_contents/index.html.erb @@ -1,34 +1,5 @@ - - - - <% @table_fields.each do |f| %> - <%= thead(f) %> - <% end %> - - - - <% @pages.each do |page| %> - - - - - - - <% end %> - -
- <%= page.name %> -
- -
-
<%= page.page_contexts.last.version rescue nil %><%= format_value page.page_contexts.last.updated_at rescue nil %><%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %>
-<%= - content_tag :div, class: "bottomnav clearfix" do - content_tag :div, paginate(@pages), class: "pagination pagination-centered" - end -%> +<%= render_filter @filter_fields, "index_table" %> + + <%= render 'index'%> +