update backend search
This commit is contained in:
parent
2db32cd8b2
commit
26c78f46cc
|
@ -15,15 +15,13 @@ class Admin::AnnouncementsController < OrbitAdminController
|
||||||
@filter_fields = filter_fields(@categories, @tags)
|
@filter_fields = filter_fields(@categories, @tags)
|
||||||
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
|
@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)
|
@bulletins = Bulletin.where(:is_preview.in=>[false,nil])
|
||||||
|
.order_by(sort)
|
||||||
|
.with_categories(filters("category"))
|
||||||
|
.with_tags(filters("tag"))
|
||||||
|
.with_status(filters("status"))
|
||||||
|
|
||||||
if params[:keywords].present?
|
@bulletins = search_data(@bulletins,[:title]).page(params[:page]).per(10)
|
||||||
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?
|
if request.xhr?
|
||||||
render :partial => "index"
|
render :partial => "index"
|
||||||
|
|
|
@ -4,8 +4,3 @@
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var filter = new Filter("#index_table");
|
|
||||||
bindPagination();
|
|
||||||
</script>
|
|
Loading…
Reference in New Issue