added filter and search

This commit is contained in:
Harry Bomrah 2016-09-02 18:21:00 +08:00
parent afb11a2fa2
commit a0dec48727
2 changed files with 23 additions and 17 deletions

View File

@ -2,12 +2,19 @@ class Admin::GalleriesController < OrbitAdminController
before_filter :setup_vars before_filter :setup_vars
before_action :authenticate_user, :except => "imgs" before_action :authenticate_user, :except => "imgs"
before_action :log_user_action before_action :log_user_action
layout "back_end"
def index def index
@albums = Album.where(:order => -1).desc(:created_at) @tags = @module_app.tags
albums = Album.where(:order.gt => -1).asc(:order) 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) @albums = @albums.concat(albums)
@tags = @module_app.tags
if request.xhr?
render :partial => "album", :collection => @albums
end
end end
def show def show

View File

@ -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" %>
<div class="order-edit-notification">Albums re-ordering enabled.</div> <div class="order-edit-notification">Albums re-ordering enabled.</div>
<div class="rgbody"> <div class="rgbody">
<ul id="orbit_gallery" class="gallery clearfix" data-gallery-id="gallery"> <ul id="orbit_gallery" class="gallery clearfix" data-gallery-id="gallery">
<% @albums.each do |album| %> <%= render :partial => "album", :collection => @albums %>
<%= render :partial => "album", :object => album %>
<% end %>
</ul> </ul>
</div> </div>
<div class="bottomnav clearfix"> <div class="bottomnav clearfix">
@ -15,16 +23,7 @@
</div> </div>
</div> </div>
<% 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 %>