Skip to content

Commit

Permalink
update references to ::Collection to use configurations
Browse files Browse the repository at this point in the history
Places where any collection class could be input or processing occurs across all collection classes were updated to use `Hyrax.config.collection_classes`.  Remaining single references to `::Collection` were updated to `Hyrax.config.collection_class`.  These changes allow for almost all remaining uses of `::Collection` to be removed.

Exceptions:
* work_form which is only used with ActiveFedora
* `PermissionTemplate #collection` which is deprecated and only works with `::Collection`
* `Hyrax::Collections::MigrationService` which performs a migration dependent on reading in the collection as a `::Collection`

This PR does not update `CollectionAbiility` as it is being updated in PR #5206.  Whichever PR is merged first, there will be a small fix required to get abilities to reference the `collection_classes` config instead of creating the list in the `CollectionAbility` class.
  • Loading branch information
elrayle committed Oct 19, 2021
1 parent 5c108f4 commit 78f6490
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/helpers/hyrax/file_set_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def display_media_download_link?(file_set:)
end

def parent_path(parent)
if parent.is_a?(::Collection)
if Hyrax.config.collection_classes.any? { |klas| parent.is_a? klas }
main_app.collection_path(parent)
else
polymorphic_path([main_app, parent])
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/hyrax/hyrax_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def user_display_name_and_key(user_key)

# Used by the gallery view
def collection_thumbnail(_document, _image_options = {}, _url_options = {})
tag.span("", class: [Hyrax::ModelIcon.css_class_for(::Collection), "collection-icon-search"])
tag.span("", class: [Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class), "collection-icon-search"])
end

def collection_title_by_id(id)
Expand Down
2 changes: 1 addition & 1 deletion app/search_builders/hyrax/exposed_models_relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Hyrax
# A relation that scopes to all user visible models (e.g. works + collections + file sets)
class ExposedModelsRelation < AbstractTypeRelation
def allowable_types
(Hyrax.config.curation_concerns + [Hyrax.config.collection_class, ::Collection, ::FileSet]).uniq
(Hyrax.config.curation_concerns + Hyrax.config.collection_classes + [::FileSet]).uniq
end
end
end
2 changes: 1 addition & 1 deletion app/search_builders/hyrax/filter_by_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def work_classes

def collection_classes
return [] if only_works?
[::Collection, Hyrax.config.collection_class].uniq
Hyrax.config.collection_classes
end
end
end
2 changes: 1 addition & 1 deletion app/views/hyrax/collections/_list_collections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<td></td>
<td>
<div class="media">
<span class="<%= Hyrax::ModelIcon.css_class_for(::Collection) %> collection-icon-small pull-left"></span>
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-small pull-left"></span>
<div class="media-body">
<div class="media-heading">
<%= link_to collection_presenter.show_path do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/collections/_media_display.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
alt: "",
role: "presentation" %>
<% else %>
<span class="<%= Hyrax::ModelIcon.css_class_for(::Collection) %> collection-icon-search" aria-hidden="true"></span>
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-search" aria-hidden="true"></span>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="thumbnail-title-wrapper">
<div class="thumbnail-wrapper">
<% if (collection_presenter.thumbnail_path == nil) %>
<span class="<%= Hyrax::ModelIcon.css_class_for(::Collection) %> collection-icon-small"></span>
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-small"></span>
<% else %>
<%= image_tag(collection_presenter.thumbnail_path, alt: "#{collection_presenter.title_or_label} #{t('hyrax.dashboard.my.sr.thumbnail')}") %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/my/collections/_list_collections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="thumbnail-title-wrapper">
<div class="thumbnail-wrapper">
<% if (collection_presenter.thumbnail_path == nil) %>
<span class="<%= Hyrax::ModelIcon.css_class_for(::Collection) %> collection-icon-small"></span>
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-small"></span>
<% else %>
<%= image_tag(collection_presenter.thumbnail_path, alt: "#{collection_presenter.title_or_label} #{t('hyrax.dashboard.my.sr.thumbnail')}") %>
<% end %>
Expand Down

0 comments on commit 78f6490

Please sign in to comment.