Sha256: 949066244a658b351535d9eb760a15bcbcd40c122785c15f0e60fdeefb29d460

Contents?: true

Size: 1.67 KB

Versions: 50

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

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

    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
    # rubocop:disable Metrics/MethodLength
    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: {
                                          public: {
                                            label: I18n.t(:'spotlight.catalog.facets.exhibit_visibility.public'),
                                            fq: "-#{blacklight_config.document_model.visibility_field(current_exhibit)}:false"
                                          },
                                          private: {
                                            label: I18n.t(:'spotlight.catalog.facets.exhibit_visibility.private'),
                                            fq: "#{blacklight_config.document_model.visibility_field(current_exhibit)}:false"
                                          }
                                        }
    end
    # rubocop:enable Metrics/MethodLength

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

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
blacklight-spotlight-4.6.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.6.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.5.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.4.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.6 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.5 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.4 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.3 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.2 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.3.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.2.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.1.2 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.1.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.1.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.0.3 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.0.2 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.0.1 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-4.0.0 app/controllers/concerns/spotlight/catalog.rb
blacklight-spotlight-3.6.0.beta10 app/controllers/concerns/spotlight/catalog.rb