Class: Spotlight::Appearance
- Inherits:
-
Object
- Object
- Spotlight::Appearance
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation
- Includes:
- ActiveModel::Conversion
- Defined in:
- app/forms/spotlight/appearance.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #allowed_params ⇒ Object
- #default_sort_field ⇒ Object
-
#document_index_view_types ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#document_index_view_types.
-
#initialize(configuration) ⇒ Appearance
constructor
A new instance of Appearance.
- #per_page_options ⇒ Object
-
#sort_fields ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#default_sort_fields.
- #update(params) ⇒ Object
- #view_type_options ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Appearance
Returns a new instance of Appearance.
7 8 9 |
# File 'app/forms/spotlight/appearance.rb', line 7 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
11 12 13 |
# File 'app/forms/spotlight/appearance.rb', line 11 def configuration @configuration end |
Instance Method Details
#allowed_params ⇒ Object
45 46 47 48 49 |
# File 'app/forms/spotlight/appearance.rb', line 45 def allowed_params sort_fields.keys.each_with_object({}) do |field, hsh| hsh[field] = [:enabled, :label, :weight] end end |
#default_sort_field ⇒ Object
64 65 66 |
# File 'app/forms/spotlight/appearance.rb', line 64 def default_sort_field configuration.blacklight_config.default_sort_field.key end |
#document_index_view_types ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#document_index_view_types
20 21 22 23 24 25 26 27 |
# File 'app/forms/spotlight/appearance.rb', line 20 def document_index_view_types vals = configuration.document_index_view_types Blacklight::OpenStructWithHashAccess.new.tap do |s| .each do |k| s[k] = vals.include?(k.to_s) end end end |
#per_page_options ⇒ Object
60 61 62 |
# File 'app/forms/spotlight/appearance.rb', line 60 def default_blacklight_config.per_page end |
#sort_fields ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#default_sort_fields
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/forms/spotlight/appearance.rb', line 32 def sort_fields fields = configuration.sort_fields Blacklight::OpenStructWithHashAccess.new.tap do |s| default_sort_fields.each_with_index do |(k, field), index| s[k] = Blacklight::OpenStructWithHashAccess.new.tap do |c| c.enabled = fields[k] && fields[k][:enabled] c.label = fields[k][:label] if fields[k] c.weight = index + 1 end end end end |
#update(params) ⇒ Object
51 52 53 54 |
# File 'app/forms/spotlight/appearance.rb', line 51 def update(params) configuration.exhibit.update(exhibit_params(params)) configuration.update(configuration_params(params)) end |
#view_type_options ⇒ Object
56 57 58 |
# File 'app/forms/spotlight/appearance.rb', line 56 def default_blacklight_config.view.keys end |