Skip to content

Commit

Permalink
Merge pull request #2819 from projectblacklight/7xbackports
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne authored Oct 3, 2022
2 parents 496c12c + 88b3978 commit c279224
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rails generate blacklight:install
Code contributions are always welcome, instructions for contributing can be found at [CONTRIBUTING.md](https://github.com/projectblacklight/blacklight/blob/main/CONTRIBUTING.md).

## Configuring Apache Solr
You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR)
You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [Solr Configuration](https://github.com/projectblacklight/blacklight/wiki/Solr-Configuration#solr-configuration)

## Building the javascript
The javascript is built by npm from sources in `app/javascript` into a bundle
Expand Down
20 changes: 20 additions & 0 deletions app/components/blacklight/icons/icon_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Blacklight
module Icons
# This is the list icon for the search button.
# You can override the default svg by setting:
# Blacklight::Icons::ListComponent.svg = '<svg>your SVG here</svg>'
class IconComponent < ::ViewComponent::Base
def initialize(svg: nil)
self.svg = svg if svg
end

def call
svg&.html_safe # rubocop:disable Rails/OutputSafety
end

class_attribute :svg
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def initialize(view:, key: nil, selected: false, search_state: nil, classes: 'bt
end

def icon
return render(@view.icon.new) if @view.icon.is_a?(Class)
return render(@view.icon) if @view.icon.is_a?(ViewComponent::Base)

Deprecation.silence(Blacklight::CatalogHelperBehavior) do
helpers.render_view_type_group_icon(@view.icon || @key)
end
Expand Down
4 changes: 3 additions & 1 deletion lib/blacklight/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def compiler
@__vc_compiler ||= EngineCompiler.new(self)
end
# rubocop:enable Naming/MemoizedInstanceVariableName

alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files
end

class EngineCompiler < ::ViewComponent::Compiler
Expand All @@ -23,7 +25,7 @@ def templates
@templates ||= begin
extensions = ActionView::Template.template_handler_extensions

component_class._sidecar_files(extensions).each_with_object([]) do |path, memo|
component_class.sidecar_files(extensions).each_with_object([]) do |path, memo|
pieces = File.basename(path).split(".")
app_path = "#{Rails.root}/#{path.slice(path.index(component_class.view_component_path)..-1)}"

Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/configuration/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Fields
def define_field_access(key, base_class_name = nil, class: nil)
key = key.to_s if respond_to? :to_s

default_values[key.pluralize.to_sym] = ActiveSupport::OrderedHash.new
default_values[key.pluralize.to_sym] = ActiveSupport::HashWithIndifferentAccess.new

@field_type_for_class ||= {}
@field_type_for_class[key] = binding.local_variable_get(:class) || base_class_name
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/configuration/view_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ViewConfig < Blacklight::OpenStructWithHashAccess
# @!attribute display_type_field
# @return [String, Symbol] solr field to use to render format-specific partials
# @!attribute icon
# @return [String, Symbol] icon file to use in the view picker
# @return [String, Symbol, Blacklight::Icons::IconComponent] icon file to use in the view picker
# @!attribute document_actions
# @return [NestedOpenStructWithHashAccess{Symbol => Blacklight::Configuration::ToolConfig}] 'tools' to render for each document
# @!attribute facet_group_component
Expand Down
3 changes: 3 additions & 0 deletions lib/blacklight/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def with(blacklight_params_or_search_state = {})

##
# Update the :q (query) parameter
# @param [Hash<Symbol,Object>] conditions the field and values to query on
# @example
# search_builder.where(id: [1,2,3]) # produces: q:"{!lucene}id:(1 OR 2 OR 3)"
def where(conditions)
Deprecation.warn(Blacklight::SearchBuilder, "SearchBuilder#where must be called with a hash, received #{conditions.inspect}.") unless conditions.is_a? Hash
params_will_change!
Expand Down
14 changes: 7 additions & 7 deletions spec/models/blacklight/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
end

it "has ordered hashes for field configuration" do
expect(config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.sort_fields).to be_a_kind_of ActiveSupport::OrderedHash
expect(config.facet_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.index_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
expect(config.sort_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
end
end

Expand Down

0 comments on commit c279224

Please sign in to comment.