diff --git a/hyrax/app/search_builders/hyrax/collection_member_search_builder.rb b/hyrax/app/search_builders/hyrax/collection_member_search_builder.rb index d0a9a7ae3c0320254bc9d5175d99a30b5a77f1fd..d2f3912a7dbf2b057589864c3821cd01bfe24d79 100644 --- a/hyrax/app/search_builders/hyrax/collection_member_search_builder.rb +++ b/hyrax/app/search_builders/hyrax/collection_member_search_builder.rb @@ -12,7 +12,8 @@ module Hyrax self.is_tombstoned_field = 'is_tombstoned_ssim' # Defines which search_params_logic should be used when searching for Collection members - self.default_processor_chain += %i[member_of_collection filter_by_crc_work_type filter_by_is_tombstoned] + self.default_processor_chain -= %i[only_active_works] + self.default_processor_chain += %i[member_of_collection filter_by_crc_work_type filter_by_is_tombstoned filter_by_active_works] # @param [Object] scope Typically the controller object # @param [Symbol] search_includes_models +:works+ or +:collections+; (anything else retrieves both) @@ -21,11 +22,13 @@ module Hyrax collection: nil, search_includes_models: nil, search_includes_crc_work_type: nil, - search_includes_is_tombstoned: false) + search_includes_is_tombstoned: false, + search_includes_only_active_works: false) @collection = collection @search_includes_models = search_includes_models @search_includes_crc_work_type = search_includes_crc_work_type @search_includes_is_tombstoned = search_includes_is_tombstoned + @search_includes_only_active_works = search_includes_only_active_works if args.any? super(*args) else @@ -41,7 +44,7 @@ module Hyrax @search_includes_models || :works end - attr_accessor :search_includes_crc_work_type, :search_includes_is_tombstoned + attr_accessor :search_includes_crc_work_type, :search_includes_is_tombstoned, :search_includes_only_active_works # include filters into the query to only include the collection memebers def member_of_collection(solr_parameters) @@ -64,6 +67,13 @@ module Hyrax solr_parameters[:fq] << "#{is_tombstoned_field}:#{search_includes_is_tombstoned}" end + def filter_by_active_works(solr_parameters) + return unless search_includes_only_active_works + + solr_parameters[:fq] ||= [] + solr_parameters[:fq] << '-suppressed_bsi:true' + end + # This overrides the models in FilterByType def models work_classes + collection_classes diff --git a/hyrax/app/services/hyrax/collections/collection_member_search_service.rb b/hyrax/app/services/hyrax/collections/collection_member_search_service.rb index 4002e13df49255fcfb63a0727bc8890572c2ced5..ce1e92790063d27112fd6f4fb24aa3bee90fb348 100644 --- a/hyrax/app/services/hyrax/collections/collection_member_search_service.rb +++ b/hyrax/app/services/hyrax/collections/collection_member_search_service.rb @@ -50,6 +50,7 @@ module Hyrax response, _docs = search_results do |builder| builder.search_includes_models = :works builder.search_includes_is_tombstoned = 'false' + builder.search_includes_only_active_works = user_params[:filter_by_active_works] || true builder end response diff --git a/hyrax/app/views/hyrax/collections/show/_collection_children.html.erb b/hyrax/app/views/hyrax/collections/show/_collection_children.html.erb index 3f2f3a1f712363f4489769b74f8acf5779be0620..ed9669a486c29a8abe6c93518bdc345ccb6a1a8c 100644 --- a/hyrax/app/views/hyrax/collections/show/_collection_children.html.erb +++ b/hyrax/app/views/hyrax/collections/show/_collection_children.html.erb @@ -19,6 +19,7 @@ <% if work.crc_work_type.present? and work.crc_work_type[0] == 'experiment' %> <li> <%= link_to work.title[0], polymorphic_path([main_app, work]) %> + <span class="badge" style="background-color: #198754"><%= work.workflow_state %></span> </li> <% end %> <% end %>