Sha256: cdb092066affd2e2cb95d955225bb9200125ee248addbb21d5cbc1b18f0e6e6c

Contents?: true

Size: 992 Bytes

Versions: 46

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  # Exhibit-specific custom search fields
  class CustomSearchField < ApplicationRecord
    serialize :configuration, Hash
    belongs_to :exhibit

    def label=(label)
      configuration['label'] = label

      update_blacklight_configuration_label label
    end

    def label
      conf = if slug && blacklight_configuration && blacklight_configuration.search_fields.key?(slug)
               blacklight_configuration.search_fields[slug].reverse_merge(configuration)
             else
               configuration
             end
      conf['label']
    end

    protected

    def blacklight_configuration
      exhibit&.blacklight_configuration
    end

    def update_blacklight_configuration_label(label)
      return unless slug && blacklight_configuration && blacklight_configuration.search_fields.key?(slug)

      blacklight_configuration.search_fields[slug]['label'] = label
      blacklight_configuration.save
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
blacklight-spotlight-3.5.0.4 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.5.0.3 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.6.0.beta6 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.6.0.beta5 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.6.0.beta4 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.6.0.beta3 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.6.0.beta1 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.5.0.2 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.5.0.1 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.5.0 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.4.1 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.4 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.3 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.2.2 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.2.1 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.2 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.1 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.4.0 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.3.0 app/models/spotlight/custom_search_field.rb
blacklight-spotlight-3.2.0 app/models/spotlight/custom_search_field.rb