Sha256: 090759777ff52d0cf2224cd636b026d945fbf0b3cbfcf759db7b616c1eea9ef5

Contents?: true

Size: 1.77 KB

Versions: 8

Compression:

Stored size: 1.77 KB

Contents

module Sufia
  module MyControllerBehavior
    extend ActiveSupport::Concern
    include Hydra::Catalog
    include Hydra::BatchEditBehavior

    included do
      include Blacklight::Configurable

      copy_blacklight_config_from(CatalogController)

      before_action :authenticate_user!
      before_action :enforce_show_permissions, only: :show
      before_action :enforce_viewing_context_for_show_requests, only: :show

      layout 'sufia-dashboard'
    end

    def index
      # return the user's collections
      @user_collections = CurationConcerns::CollectionsService.new(self).search_results(:edit)

      @user = current_user
      (@response, @document_list) = query_solr
      prepare_instance_variables_for_batch_control_display

      respond_to do |format|
        format.html {}
        format.rss  { render layout: false }
        format.atom { render layout: false }
      end
    end

    private

      # TODO: Extract a presenter object that wrangles all of these instance variables.
      def prepare_instance_variables_for_batch_control_display
        # set up some parameters for allowing the batch controls to show appropriately
        max_batch_size = 80
        count_on_page = @document_list.count { |doc| batch.index(doc.id) }
        @disable_select_all = @document_list.count > max_batch_size
        batch_size = batch.uniq.size
        @result_set_size = @response.response["numFound"]
        @empty_batch = batch.empty?
        @all_checked = (count_on_page == @document_list.count)
        batch_size_on_other_page = batch_size - count_on_page
        @batch_part_on_other_page = batch_size_on_other_page > 0

        @add_files_to_collection = params.fetch(:add_files_to_collection, '')
      end

      def query_solr
        search_results(params)
      end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.4.0 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.3.1 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.3.0 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.3.0.rc3 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.3.0.rc2 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.3.0.rc1 app/controllers/concerns/sufia/my_controller_behavior.rb
sufia-7.2.0 app/controllers/concerns/sufia/my_controller_behavior.rb