Skip to content

Commit

Permalink
Merge pull request #384 from trln/TD-1219-adv-search-constraint-display
Browse files Browse the repository at this point in the history
Td 1219 adv search constraint display
  • Loading branch information
seanaery authored Jul 27, 2022
2 parents 52bf7a0 + d2b9c24 commit 1878235
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.1.2
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %>
<!-- follows the default implementation, but this leads to duplication
of parameters after 'edit search' is used, as chosen is doing
its own thing -->
<noscript>
<%= render_hash_as_hidden_fields(@params) %>
</noscript>
<div class="input-criteria">

<div class="query-criteria" role="radiogroup" aria-labelledby="show-results-from-header">
Expand Down
40 changes: 39 additions & 1 deletion lib/blacklight_advanced_search/render_constraints_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@ module BlacklightAdvancedSearch
module RenderConstraintsOverride
# the default implementation from blacklight_advanced_search
# plugin will effectively duplicate constraints in search header
# -- leaving this blank prevents that.
# so we need to override only some methods

# copied directly from upstream, deals with TD-1219
# the other `render_constraints_` methods will be handled
# by the base implementation in BL rather than by the
# implementation in the adv_search plugin
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def render_constraints_query(my_params = params)
if advanced_query.nil? || advanced_query.keyword_queries.empty?
super(my_params)
else
content = []
advanced_query.keyword_queries.each_pair do |field, query|
label = blacklight_config.search_fields[field][:label]
content << render_constraint_element(
label, query,
remove: search_action_path(remove_advanced_keyword_query(field, my_params).except(:controller, :action))
)
end
if advanced_query.keyword_op == 'OR' &&
advanced_query.keyword_queries.length > 1
content.unshift content_tag(:span, 'Any of:', class: 'operator')
content_tag :span, class: 'inclusive_or appliedFilter well' do
safe_join(content.flatten, "\n")
end
else
safe_join(content.flatten, "\n")
end
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

def remove_advanced_keyword_query(field, my_params = params)
my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
my_params.delete(field)
my_params
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module TrlnArgon
module ViewHelpers
module RenderConstraintsHelperBehavior
include Blacklight::RenderConstraintsHelperBehavior
include BlacklightAdvancedSearch::RenderConstraintsOverride

# handles a special case only in TRLN
def render_constraints_query(my_params = params)
if my_params[:doc_ids].nil?
super(my_params)
Expand Down

0 comments on commit 1878235

Please sign in to comment.