Sha256: 736880e375ba628d25c2c116956b000ce9391bf5c457787e9f5eecd5e7862d54

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

class Spotlight::BlacklightConfigurationsController < Spotlight::ApplicationController
  before_filter :authenticate_user!
  load_resource :exhibit, class: Spotlight::Exhibit
  load_and_authorize_resource through: :exhibit, singleton: true

  include Blacklight::SolrHelper

  def update
    if @blacklight_configuration.update(exhibit_params)
      redirect_to main_app.root_path, notice: "The exhibit was saved."
    else
      redirect_to [:edit, @exhibit]
    end
  end

  ##
  # Edit the index and show view metadata fields
  def edit_metadata_fields
  end

  ##
  # Edit the index and show view metadata fields
  def edit_facet_fields
    @fields = blacklight_solr.get('admin/luke', params: { fl: '*', 'json.nl' => 'map' })['fields']
  end

  protected

  def exhibit_params
    params.require(:blacklight_configuration).permit(
      facet_fields: [exhibit_configuration_facet_params],
      index_fields: [exhibit_configuration_index_params]
    )
  end

  def exhibit_configuration_index_params
    views = @blacklight_configuration.default_blacklight_config.view.keys | [:show]

    @blacklight_configuration.default_blacklight_config.index_fields.keys.inject({}) { |result, element| result[element] = ([:enabled] | views); result }
  end

  def exhibit_configuration_facet_params
    @blacklight_configuration.default_blacklight_config.facet_fields.keys.inject({}) { |result, element| result[element] = [:enabled, :label]; result }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.0.1 app/controllers/spotlight/blacklight_configurations_controller.rb