diff --git a/app/controllers/hyrax/dashboard/collections_controller_decorator.rb b/app/controllers/hyrax/dashboard/collections_controller_decorator.rb index 4056376c6..cc2246a90 100644 --- a/app/controllers/hyrax/dashboard/collections_controller_decorator.rb +++ b/app/controllers/hyrax/dashboard/collections_controller_decorator.rb @@ -2,9 +2,9 @@ # OVERRIDE Hyrax v5.0.0rc2 # - Fix file upload in logo and banner -# - Use work titles for collection thumbnail select & to add an option to reset to the default thumbnail - -# OVERRIDE Hyrax v5.0.0 to add the ability to upload a collection thumbnail +# - ensure user is allowed to change visibility +# - add the ability to upload a collection thumbnail +# - add altext to collection banner module Hyrax module Dashboard @@ -19,13 +19,6 @@ def show super end - # OVERRIDE Hyrax v5.0.0 to add the ability to upload a collection thumbnail - START - def process_branding - process_banner_input - process_logo_input - process_thumbnail_input - end - # rubocop:disable Metrics/AbcSize def update_valkyrie_collection return after_update_errors(form_err_msg(form)) unless form.validate(collection_params) @@ -33,7 +26,7 @@ def update_valkyrie_collection result = transactions['change_set.update_collection'] .with_step_args( 'collection_resource.save_collection_banner' => { update_banner_file_ids: params["banner_files"], - banner_unchanged_indicator: params["banner_unchanged"] }, + alttext: params["banner_text"]&.first }, 'collection_resource.save_collection_logo' => { update_logo_file_ids: params["logo_files"], alttext_values: params["alttext"], linkurl_values: params["linkurl"] }, @@ -48,7 +41,6 @@ def update_valkyrie_collection after_update_response end # rubocop:enable Metrics/AbcSize - # OVERRIDE Hyrax v5.0.0 to add the ability to upload a collection thumbnail - END def edit form @@ -72,6 +64,14 @@ def update super end + # OVERRIDE Hyrax v5.0.0 to add the ability to upload a collection thumbnail + # Not used with Valkyrie + def process_branding + process_banner_input + process_logo_input + process_thumbnail_input + end + # Deletes any previous thumbnails. The thumbnail indexer (see services/hyrax/indexes_thumbnails) # checks if an uploaded thumbnail exists in the public folder before indexing the thumbnail path. def delete_uploaded_thumbnail @@ -124,7 +124,7 @@ def configure_show_sort_fields blacklight_config.sort_fields = CatalogController.blacklight_config.sort_fields end - # branding specific methods + ## Branding Methods not used with Valkyrie def process_banner_input return update_existing_banner if params["banner_unchanged"] == "true" remove_banner diff --git a/app/views/hyrax/collections/show.html.erb b/app/views/hyrax/collections/show.html.erb index 4a704adf7..5ca4d02c8 100644 --- a/app/views/hyrax/collections/show.html.erb +++ b/app/views/hyrax/collections/show.html.erb @@ -1,4 +1,7 @@ -<%# OVERRIDE Hyrax 5.0.1 add show actions buttons to collection show page %> +<%# OVERRIDE Hyrax 5.0.1: %> +<%# add show actions buttons to collection show page %> +<%# add branding text for banner image %> +<%# remove duplicate items count originating in Hyrax view %> <% provide :page_title, construct_page_title(@presenter.title) %>
@@ -36,16 +39,15 @@ <% unless @presenter.total_viewable_items.blank? %>
- <%= @presenter.total_viewable_items %> <%= pluralize(@presenter.total_viewable_items, t('.item_count')) %>
- <% unless @presenter.creator.blank? %> -
Created by: <%= @presenter.creator.first %>
- <% end %> + <% unless @presenter.creator.blank? %> +
Created by: <%= @presenter.creator.first %>
+ <% end %> - <% unless @presenter.modified_date.blank? %> -
Last Updated: <%= @presenter.modified_date %>
- <% end %> + <% unless @presenter.modified_date.blank? %> +
Last Updated: <%= @presenter.modified_date %>
+ <% end %>
<% end %> diff --git a/lib/hyrax/transactions/steps/save_collection_banner_decorator.rb b/lib/hyrax/transactions/steps/save_collection_banner_decorator.rb index d5e8faa0d..23e6ce756 100644 --- a/lib/hyrax/transactions/steps/save_collection_banner_decorator.rb +++ b/lib/hyrax/transactions/steps/save_collection_banner_decorator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# OVERRIDE Hyrax v5.0.0 to save the collection banner in 'public/uploads' +# OVERRIDE Hyrax v5.0.0 to save the collection banner in 'public/uploads' and include alttext module Hyrax module Transactions @@ -8,7 +8,26 @@ module Steps module SaveCollectionBannerDecorator include Hyku::CollectionBrandingBehavior - def add_new_banner(collection_id:, uploaded_file_ids:) + def call(collection_resource, update_banner_file_ids: nil, alttext: nil) + collection_id = collection_resource.id.to_s + process_banner_input(collection_id: collection_id, update_banner_file_ids: update_banner_file_ids, alttext: alttext) + Success(collection_resource) + end + + def process_banner_input(collection_id:, update_banner_file_ids:, alttext:) + if !update_banner_file_ids && !alttext + remove_banner(collection_id: collection_id) + elsif update_banner_file_ids + remove_banner(collection_id: collection_id) + add_new_banner(collection_id: collection_id, uploaded_file_ids: update_banner_file_ids, alttext: alttext) + elsif alttext + CollectionBrandingInfo + .where(collection_id: collection_id, role: "banner") + .first.update_column(:alt_text, alttext) + end + end + + def add_new_banner(collection_id:, uploaded_file_ids:, alttext:) f = uploaded_files(uploaded_file_ids).first file_location = process_file_location(f) @@ -16,7 +35,7 @@ def add_new_banner(collection_id:, uploaded_file_ids:) collection_id:, filename: File.split(f.file_url).last, role: "banner", - alt_txt: "", + alt_txt: alttext, target_url: "" ) banner_info.save file_location