app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-0.0.2 vs app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-0.0.3
- old
+ new
@@ -1,11 +1,13 @@
class Spotlight::SearchesController < Spotlight::ApplicationController
load_resource :exhibit, class: "Spotlight::Exhibit", only: [:index, :create, :update_all]
before_filter :authenticate_user!
before_filter :only_curators!
load_and_authorize_resource through: :exhibit, shallow: true
+ before_filter :attach_breadcrumbs, only: [:index, :edit]
+
def create
params_copy = params.dup
params_copy.delete(:exhibit_id)
@search.title = params_copy.delete(:search)[:title]
@search.query_params = params_copy.reject { |k,v| blacklisted_search_session_params.include?(k.to_sym) or v.blank? }
@@ -16,10 +18,11 @@
def index
end
def edit
+ add_breadcrumb @search.title, edit_search_path(@search)
@exhibit = @search.exhibit
end
def update
if @search.update params.require(:search).permit(:title, :short_description, :long_description, :featured_image)
@@ -42,9 +45,16 @@
end
redirect_to :back, notice: notice
end
protected
+
+ def attach_breadcrumbs
+ e = @exhibit || (@search.exhibit if @search)
+ add_breadcrumb e.title, e
+ add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(e)
+ add_breadcrumb t(:'spotlight.curation.sidebar.browse'), exhibit_searches_path(e)
+ end
def search_params
params.require(:exhibit).permit("searches_attributes" => [:id, :on_landing_page, :weight])
end