add search for backend index
This commit is contained in:
parent
a0391f0c1e
commit
a69769c5b7
|
@ -1,23 +1,19 @@
|
||||||
class Admin::ArchiveFilesController < OrbitAdminController
|
class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@table_fields = [:status, :category, :title]
|
@table_fields = [:status, :category, :title, :update_at,:last_modified]
|
||||||
@categories = @module_app.categories
|
@categories = @module_app.categories
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
@filter_fields = {
|
@filter_fields = filter_fields(@categories, @tags)
|
||||||
: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 []
|
|
||||||
|
|
||||||
@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?
|
@archives = search_data(@archives,[:title]).page(params[:page]).per(10)
|
||||||
render :partial => "index"
|
|
||||||
end
|
render :partial => "index" if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -42,7 +42,6 @@ class ArchivesController < ApplicationController
|
||||||
"url_to_edit" => url_to_edit
|
"url_to_edit" => url_to_edit
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
"categories" => cats
|
"categories" => cats
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,8 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @archives.each do |archive| %>
|
<% @archives.each do |archive| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td><%= archive.status_for_table %></td>
|
||||||
<%= archive.status_for_table %>
|
<td><%= archive.category.title %></td>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= archive.category.title %>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<a href="#" target="_blank"><%= archive.title %></a>
|
<a href="#" target="_blank"><%= archive.title %></a>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
|
@ -30,6 +26,8 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td><%= format_value archive.updated_at rescue nil %></td>
|
||||||
|
<td><%= User.find(archive.update_user_id).user_name rescue nil %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
<%= render_filter @filter_fields %>
|
<%= render_filter @filter_fields, "index_table" %>
|
||||||
<div id="archivelist">
|
<div id="index_table">
|
||||||
<%= render 'index'%>
|
<%= render 'index'%>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
|
||||||
var filter = new Filter("#archivelist");
|
|
||||||
</script>
|
|
||||||
|
|
Loading…
Reference in New Issue