diff --git a/app/controllers/admin/faqs_controller.rb b/app/controllers/admin/faqs_controller.rb index d93acf9..1cf21a6 100644 --- a/app/controllers/admin/faqs_controller.rb +++ b/app/controllers/admin/faqs_controller.rb @@ -3,48 +3,23 @@ class Admin::FaqsController < OrbitAdminController before_filter :setup_vars def index - @table_fields = ["status","category","title","tags"] + @table_fields = [:status,:category,:title,:tags] @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) - @qas = Qa.order_by(sort).with_categories(categories).with_tags(tags).with_status(status).page(params[:page]).per(10) + @qas = Qa.order_by(sort) + .with_categories(filters("category")) + .with_tags(filters("tag")) + .with_status(filters("status")) - if request.xhr? - render :partial => "index" - end + @qas = search_data(@qas,[:title]).page(params[:page]).per(10) + + render :partial => "index" if request.xhr? end - def sort - unless params[:sort].blank? - case params[:sort] - when "status" - @sort = [[:is_top, params[:order]], - [:is_hot, params[:order]], - [:is_hidden,params[:order]]] - when "category" - @sort = {:category_id=>params[:order]} - when "title" - @sort = {:title=>params[:order]} - when "last_modified" - @sort = {:update_user_id=>params[:order]} - end - else - @sort = {:created_at=>'desc'} - end - @sort - end - - def new - @qa = Qa.new + @qa = Qa.new @tags = @module_app.tags @categories = @module_app.categories respond_to do |format| @@ -87,7 +62,7 @@ class Admin::FaqsController < OrbitAdminController private def setup_vars - @module_app = ModuleApp.where(:key => "faq").first + @module_app = ModuleApp.where(:key => "faq").first end def create_params diff --git a/app/views/admin/faqs/_index.html.erb b/app/views/admin/faqs/_index.html.erb index 22e09f0..f343445 100644 --- a/app/views/admin/faqs/_index.html.erb +++ b/app/views/admin/faqs/_index.html.erb @@ -1,37 +1,39 @@
- <%= qa.status_for_table %> - | -- <%= qa.category.title %> - | -
- <%= qa.title %>
-
-
-
- |
- - <% qa.tags.each do |tag| %> - <%= tag.name %> - <% end %> - | -