Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make collection-related search builders inherit from the base hyrax collection search builder #4822

Merged
merged 3 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module Hyrax
# This search builder requires that a accessor named "collection" exists in the scope
class CollectionMemberSearchBuilder < ::SearchBuilder
class CollectionMemberSearchBuilder < ::Hyrax::CollectionSearchBuilder
include Hyrax::FilterByType
attr_writer :collection, :search_includes_models

Expand Down Expand Up @@ -41,6 +41,11 @@ def member_of_collection(solr_parameters)
solr_parameters[:fq] << "#{collection_membership_field}:#{collection.id}"
end

# This overrides the models in FilterByType
def models
work_classes + collection_classes
end

private

def only_works?
Expand Down
2 changes: 1 addition & 1 deletion app/search_builders/hyrax/my/collections_search_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
# Added to allow for the My controller to show only things I have edit access to
class Hyrax::My::CollectionsSearchBuilder < ::SearchBuilder
class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
include Hyrax::My::SearchBuilderBehavior
include Hyrax::FilterByType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module Hyrax
##
# Searches for all collections that are parents of a given collection.
class NestedCollectionsParentSearchBuilder < ::SearchBuilder
class NestedCollectionsParentSearchBuilder < ::Hyrax::CollectionSearchBuilder
include Hyrax::FilterByType
attr_reader :child, :page, :limit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module Hyrax
class SingleCollectionSearchBuilder < ::SearchBuilder
class SingleCollectionSearchBuilder < ::Hyrax::CollectionSearchBuilder
include SingleResult
end
end