add search for backend index

This commit is contained in:
manson 2014-08-07 18:46:24 +08:00
parent a0391f0c1e
commit a69769c5b7
4 changed files with 48 additions and 58 deletions

View File

@ -1,23 +1,19 @@
class Admin::ArchiveFilesController < OrbitAdminController
def index
@table_fields = [:status, :category, :title]
@table_fields = [:status, :category, :title, :update_at,:last_modified]
@categories = @module_app.categories
@tags = @module_app.tags
@filter_fields = {
:status=>[{:title=>"is_top",:id=>"is_top"},{:title=>"is_hot",:id=>"is_hot"},{:title=>"is_hidden",:id=>"is_hidden"}],
:category=>@categories.map{|c| {:title=>c.title, :id=>c.id}},
:tags=>@tags.map{|tag| {:title=>tag.name, :id=>tag.id}}
}
status = params[:filters][:status].blank? ? [] : params[:filters][:status] rescue []
categories = params[:filters][:category].blank? ? [] : params[:filters][:category] rescue []
tags = params[:filters][:tags].blank? ? [] : params[:filters][:tags] rescue []
@filter_fields = filter_fields(@categories, @tags)
@archives = ArchiveFile.order_by(sort).with_categories(categories).with_tags(tags).with_status(status).page(params[:page]).per(10)
@archives = ArchiveFile.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag"))
.with_status(filters("status"))
if request.xhr?
render :partial => "index"
end
@archives = search_data(@archives,[:title]).page(params[:page]).per(10)
render :partial => "index" if request.xhr?
end
def new

View File

@ -42,7 +42,6 @@ class ArchivesController < ApplicationController
"url_to_edit" => url_to_edit
}
end
{
"categories" => cats
}

View File

@ -13,12 +13,8 @@
<tbody>
<% @archives.each do |archive| %>
<tr>
<td>
<%= archive.status_for_table %>
</td>
<td>
<%= archive.category.title %>
</td>
<td><%= archive.status_for_table %></td>
<td><%= archive.category.title %></td>
<td>
<a href="#" target="_blank"><%= archive.title %></a>
<div class="quick-edit">
@ -30,6 +26,8 @@
</ul>
</div>
</td>
<td><%= format_value archive.updated_at rescue nil %></td>
<td><%= User.find(archive.update_user_id).user_name rescue nil %></td>
</tr>
<% end %>
</tbody>

View File

@ -1,7 +1,4 @@
<%= render_filter @filter_fields %>
<div id="archivelist">
<%= render_filter @filter_fields, "index_table" %>
<div id="index_table">
<%= render 'index'%>
</div>
<script type="text/javascript">
var filter = new Filter("#archivelist");
</script>