Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract a NullDisplayField that includes the necessary default values… #2827

Draft
wants to merge 1 commit into
base: release-7.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/presenters/blacklight/index_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fields
end

def field_config(field)
configuration.index_fields.fetch(field) { Configuration::NullField.new(field) }
configuration.index_fields.fetch(field) { Configuration::NullDisplayField.new(field) }
end
end
end
2 changes: 1 addition & 1 deletion app/presenters/blacklight/show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def fields
end

def field_config(field)
configuration.show_fields.fetch(field) { Configuration::NullField.new(field) }
configuration.show_fields.fetch(field) { Configuration::NullDisplayField.new(field) }
end

def field_presenter_options
Expand Down
1 change: 1 addition & 0 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Configuration < OpenStructWithHashAccess
autoload :Fields
autoload :Field
autoload :NullField
autoload :NullDisplayField
autoload :SearchField
autoload :FacetField
autoload :SortField
Expand Down
17 changes: 17 additions & 0 deletions lib/blacklight/configuration/null_display_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Blacklight
# Returned if no config is defined for a display field in the Blacklight::Configuration
class Configuration::NullDisplayField < Blacklight::Configuration::DisplayField
def initialize(field_or_hash = nil)
case field_or_hash
when String, Symbol
super(field: field_or_hash)
else
super
end

normalize!
end
end
end