From 69fa966c8b5f14ac16df5956b3a30556eb7aa095 Mon Sep 17 00:00:00 2001 From: manson Date: Thu, 7 Aug 2014 18:48:12 +0800 Subject: [PATCH] add search for backend index --- .../admin/web_resources_controller.rb | 11 ++- app/views/admin/web_resources/index.html.erb | 83 +------------------ 2 files changed, 10 insertions(+), 84 deletions(-) diff --git a/app/controllers/admin/web_resources_controller.rb b/app/controllers/admin/web_resources_controller.rb index d3af595..0503333 100644 --- a/app/controllers/admin/web_resources_controller.rb +++ b/app/controllers/admin/web_resources_controller.rb @@ -8,11 +8,14 @@ class Admin::WebResourcesController < OrbitAdminController @filter_fields = filter_fields(@categories, @tags) @table_fields = [:status, :category, :title] - @links = WebLink.order_by(sort).with_categories(filters("category")).with_tags(filters("tag")).with_status(filters("status")).page(params[:page]).per(10) + @links = WebLink.order_by(sort) + .with_categories(filters("category")) + .with_tags(filters("tag")) + .with_status(filters("status")) - if request.xhr? - render :partial => "index" - end + @links = search_data(@links,[:title]).page(params[:page]).per(10) + + render :partial => "index" if request.xhr? end def new diff --git a/app/views/admin/web_resources/index.html.erb b/app/views/admin/web_resources/index.html.erb index 31d9a3b..80f6fa7 100644 --- a/app/views/admin/web_resources/index.html.erb +++ b/app/views/admin/web_resources/index.html.erb @@ -1,81 +1,4 @@ -<% content_for :right_nav do %> - -
- <% @filter_fields.keys.each do |field| %> -
-
- <% @filter_fields[field].each do |val| %> - <%= link_to t(val[:title]), "#", :onclick => "filter.addFilter('filters[#{field}][]=#{val[:id]}')", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %> - <% end %> -
- -
- <% end %> -
-<% end %> - - +<%= render_filter @filter_fields, "index_table" %> +
<%= render 'index'%> - - -<%= render 'layouts/delete_modal', delete_options: @delete_options %> - - \ No newline at end of file +
\ No newline at end of file