Sha256: 567bde28304e7d51f3cff98944b222b4f50ab982997e6f96974b79a4bc61675f

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

module Spotlight
  ##
  # Spotlight catalog mixins
  module Catalog
    extend ActiveSupport::Concern
    include Blacklight::Catalog
    include Spotlight::Base

    included do
      before_action :add_facet_visibility_field
    end

    # Adds a facet to display document visibility for the current exhibit
    # if the user is a curator
    def add_facet_visibility_field
      return unless current_exhibit && can?(:curate, current_exhibit)

      blacklight_config.add_facet_field 'exhibit_visibility',
                                        label: I18n.t(:'spotlight.catalog.facets.exhibit_visibility.label'),
                                        query: {
                                          private: {
                                            label: I18n.t(:'spotlight.catalog.facets.exhibit_visibility.private'),
                                            fq: "#{blacklight_config.document_model.visibility_field(current_exhibit)}:false"
                                          }
                                        }
    end

    def render_save_this_search?
      (current_exhibit && can?(:curate, current_exhibit)) &&
        !(params[:controller] == 'spotlight/catalog' && params[:action] == 'admin')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-2.4.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-2.3.3 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-2.3.2 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-2.3.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-2.3.0 app/controllers/concerns/spotlight/catalog.rb