add search for backend index

This commit is contained in:
manson 2014-08-07 18:48:51 +08:00
parent dfe9065916
commit 4d2007e560
3 changed files with 47 additions and 36 deletions

View File

@ -1,7 +1,12 @@
class Admin::PageContentsController < OrbitAdminController class Admin::PageContentsController < OrbitAdminController
def index def index
@pages = Page.where(:module=>"page_content").page(params[:page]).per(10) @table_fields = [:page_id, :name,:version,:update_at,:last_modified]
@table_fields = ["Name","Version","Updated At","Last Modified By"] @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 end
def show def show
@ -33,6 +38,6 @@ class Admin::PageContentsController < OrbitAdminController
private private
def update_params def update_params
params.require(:page_context).permit! params.require(:page_context).permit!
end end
end end

View File

@ -0,0 +1,35 @@
<table class="table table-striped table-hover main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @pages.each do |page| %>
<tr>
<td><%= page.page_id %></td>
<td>
<a href="/<%= I18n.locale %><%= page.url %>" target="_blank"><%= page.name %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(page) %>
<li><a href="/admin/page_contents/new?page_id=<%= page.id.to_s %>"><%= t(:edit) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><a href="/admin/page_contents/<%= page.id.to_s %>/view" ><%= page.page_contexts.last.version rescue nil %></a></td>
<td><%= format_value page.page_contexts.last.updated_at rescue nil %></td>
<td><%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@pages), class: "pagination pagination-centered"
end
%>

View File

@ -1,34 +1,5 @@
<table class="table main-list"> <%= render_filter @filter_fields, "index_table" %>
<thead> <span id="index_table">
<tr class="sort-header"> <%= render 'index'%>
<% @table_fields.each do |f| %> </span>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @pages.each do |page| %>
<tr>
<td>
<a href="/<%= I18n.locale %><%= page.url %>" target="_blank"><%= page.name %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(page) %>
<li><a href="/admin/page_contents/new?page_id=<%= page.id.to_s %>"><%= t(:edit) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><a href="/admin/page_contents/<%= page.id.to_s %>/view" ><%= page.page_contexts.last.version rescue nil %></a></td>
<td><%= format_value page.page_contexts.last.updated_at rescue nil %></td>
<td><%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@pages), class: "pagination pagination-centered"
end
%>