Skip to content

Commit

Permalink
Idea for allowing browse categories to be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Feb 6, 2017
1 parent 31ee1ec commit b16a378
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/controllers/spotlight/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ class SearchesController < Spotlight::ApplicationController
load_resource :exhibit, class: 'Spotlight::Exhibit'
before_action :authenticate_user!
before_action :only_curators!
before_action :create_or_load_resource, only: [:create]
load_and_authorize_resource through: :exhibit
before_action :attach_breadcrumbs, only: [:index, :edit], unless: -> { request.format.json? }

include Spotlight::Base

def create
@search.attributes = search_params
@search.assign_attributes(search_params.except((:title unless @search.new_record?)))
@search.query_params = query_params

if @search.save
Expand Down Expand Up @@ -131,6 +132,10 @@ def blacklisted_search_session_params
def fallback_url
spotlight.exhibit_searches_path(current_exhibit)
end

def create_or_load_resource
@search = current_exhibit.searches.find(params[:search][:id]) if params[:search][:id]
end
end
# rubocop:enable Metrics/ClassLength
end
5 changes: 3 additions & 2 deletions app/views/catalog/_save_search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<h4 class="modal-title" id="save-modal-label"><%= t(:'spotlight.saved_search.label') %></h4>
</div>
<div class="modal-body">
<%=f.text_field :title, label: t(:'spotlight.saved_search.title'), required: true %>
<%= f.text_field :title, label: t(:'spotlight.saved_search.title') %>
<%= f.select :id, current_exhibit.searches.map { |s| [s.title, s.id] }, include_blank: true %>
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:qt, :page, :utf8)) %>
</div>
<div class="modal-footer">
Expand All @@ -18,4 +19,4 @@
</div>
<% end %>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions config/locales/spotlight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ en:
logout: "Sign out"
contact: "Feedback"
saved_search:
label: "Save this search"
title: "Saved search title"
label: "Enter a title to create a new saved search"
title: "Select a title to update a previously saved search"
shared:
report_a_problem:
title: Contact Us
Expand Down

0 comments on commit b16a378

Please sign in to comment.