From a0dec487278c92e92f8596d1a0358f1d8de9ae9d Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 2 Sep 2016 18:21:00 +0800 Subject: [PATCH] added filter and search --- app/controllers/admin/galleries_controller.rb | 15 ++++++++--- app/views/admin/galleries/index.html.erb | 25 +++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/controllers/admin/galleries_controller.rb b/app/controllers/admin/galleries_controller.rb index f6008ef..91dd718 100644 --- a/app/controllers/admin/galleries_controller.rb +++ b/app/controllers/admin/galleries_controller.rb @@ -2,12 +2,19 @@ class Admin::GalleriesController < OrbitAdminController before_filter :setup_vars before_action :authenticate_user, :except => "imgs" before_action :log_user_action - layout "back_end" def index - @albums = Album.where(:order => -1).desc(:created_at) - albums = Album.where(:order.gt => -1).asc(:order) + @tags = @module_app.tags + categories = @module_app.categories.enabled + @filter_fields = filter_fields(categories, @tags) + @filter_fields.delete(:status) + @albums = Album.where(:order => -1).desc(:created_at).with_categories(filters("category")).with_tags(filters("tag")) + albums = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag")) @albums = @albums.concat(albums) - @tags = @module_app.tags + + if request.xhr? + render :partial => "album", :collection => @albums + end + end def show diff --git a/app/views/admin/galleries/index.html.erb b/app/views/admin/galleries/index.html.erb index f844aed..7b533e8 100644 --- a/app/views/admin/galleries/index.html.erb +++ b/app/views/admin/galleries/index.html.erb @@ -1,10 +1,18 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "gallery" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/jquery-ui-1.10.0.custom.min" %> + <%= javascript_include_tag "jquery.masonry.min.js" %> + <%= javascript_include_tag "jquery.lite.image.resize.js" %> + <%= javascript_include_tag "gallery" %> +<% end %> +<%= render_filter @filter_fields, "orbit_gallery" %>
Albums re-ordering enabled.
@@ -15,16 +23,7 @@
-<% content_for :page_specific_css do %> - <%= stylesheet_link_tag "gallery" %> -<% end %> - -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "lib/jquery-ui-1.10.0.custom.min" %> - <%= javascript_include_tag "jquery.masonry.min.js" %> - <%= javascript_include_tag "jquery.lite.image.resize.js" %> - <%= javascript_include_tag "gallery" %> -<% end %> +