seach for backend

This commit is contained in:
manson 2014-08-06 19:37:43 +08:00
parent 8467dd3189
commit 2db32cd8b2
2 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,14 @@ class Admin::AnnouncementsController < OrbitAdminController
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
@bulletins = Bulletin.where(:is_preview.in=>[false,nil]).order_by(sort).with_categories(filters("category")).with_tags(filters("tag")).with_status(filters("status")).page(params[:page]).per(10)
if params[:keywords].present?
key_string = params[:keywords]
key_string = key_string.strip.nil? ? key_string : key_string.strip
keywords = key_string.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
regex = Regexp.union(keywords.map{|word| Regexp.new(".*"+word+".*", "i")})
@bulletins = @bulletins.any_of({:title=>regex}).page(params[:page]).per(10)
end
if request.xhr?
render :partial => "index"

View File

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