diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index a586507bd..dd90273f9 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -8,6 +8,7 @@ class SitesController < ApplicationController def update # FIXME: Pull these strings out to i18n locale if @site.update(update_params) + remove_appearance_text(update_params) redirect_to hyrax.admin_appearance_path, notice: 'The appearance was successfully updated.' else redirect_to hyrax.admin_appearance_path, flash: { error: 'Updating the appearance was unsuccessful.' } @@ -33,4 +34,20 @@ def update_params def site_theme_params params.require(:site).permit(:home_theme, :search_theme, :show_theme) end + + REMOVE_TEXT_MAPS = { + "remove_logo_image" => "logo_image_text", + "remove_banner_image" => "banner_image_text", + "remove_directory_image" => "directory_image_text", + "remove_default_collection_image" => "default_collection_image_text", + "remove_default_work_image" => "default_work_image_text" + }.freeze + + def remove_appearance_text(update_params) + image_text_keys = update_params.keys + image_text_keys.each do |image_text_key| + block = ContentBlock.find_by(name: REMOVE_TEXT_MAPS[image_text_key]) + block.delete if block&.value.present? + end + end end diff --git a/app/forms/hyrax/forms/admin/appearance.rb b/app/forms/hyrax/forms/admin/appearance.rb index 9a1c1068b..a1d84b349 100644 --- a/app/forms/hyrax/forms/admin/appearance.rb +++ b/app/forms/hyrax/forms/admin/appearance.rb @@ -79,6 +79,31 @@ def persisted? true end + # The alt text for the logo image + def logo_image_text + block_for('logo_image_text') + end + + # The alt text for the banner image + def banner_image_text + block_for('banner_image_text') + end + + # The alt text for the directory image + def directory_image_text + block_for('directory_image_text') + end + + # The alt text for the default_collection image + def default_collection_image_text + block_for('default_collection_image_text') + end + + # The alt text for the default_work image + def default_work_image_text + block_for('default_work_image_text') + end + # The font for the body copy def body_font block_for('body_font') @@ -287,20 +312,33 @@ def default_image_attributes # @return [Array] a list of fields that are related to the banner def self.banner_fields - [:banner_image] + %i[ + banner_image banner_label + ] end - # @return [Array] a list of fields that are related to the banner + # @return [Array] a list of fields that are related to the logo def self.logo_fields - [:logo_image] + %i[ + logo_image logo_label + ] end + # @return [Array] a list of fields that are related to the directory def self.directory_fields - [:directory_image] + %i[ + directory_image directory_image_label + ] end + # @return [Array] a list of fields that are related to default works & collections def self.default_image_fields - %i[default_collection_image default_work_image] + %i[ + default_collection_image + default_work_image + default_collection_label + default_work_label + ] end # Persist the form values @@ -337,6 +375,11 @@ def self.customization_params searchbar_text_color searchbar_text_hover_color custom_css_block + logo_image_text + banner_image_text + directory_image_text + default_collection_image_text + default_work_image_text ] end diff --git a/app/helpers/hyrax_helper.rb b/app/helpers/hyrax_helper.rb index 6ca473c0e..23341d4ae 100644 --- a/app/helpers/hyrax_helper.rb +++ b/app/helpers/hyrax_helper.rb @@ -25,6 +25,12 @@ def logo_image Site.instance.logo_image? ? Site.instance.logo_image.url : false end + def block_for(name:) + block = ContentBlock.find_by(name: name) + has_value = block&.value.present? + has_value ? block.value : false + end + def directory_image Site.instance.directory_image? ? Site.instance.directory_image.url : false end diff --git a/app/jobs/reindex_admin_sets_job.rb b/app/jobs/reindex_admin_sets_job.rb new file mode 100644 index 000000000..c1a68e4b9 --- /dev/null +++ b/app/jobs/reindex_admin_sets_job.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class ReindexAdminSetsJob < ApplicationJob + def perform + AdminSet.find_each(&:update_index) + end +end diff --git a/app/jobs/reindex_collections_job.rb b/app/jobs/reindex_collections_job.rb new file mode 100644 index 000000000..4f266b67d --- /dev/null +++ b/app/jobs/reindex_collections_job.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class ReindexCollectionsJob < ApplicationJob + def perform + Collection.find_each do |collection| + collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX + collection.update_index + end + end +end diff --git a/app/jobs/reindex_works_job.rb b/app/jobs/reindex_works_job.rb new file mode 100644 index 000000000..6aee04ba6 --- /dev/null +++ b/app/jobs/reindex_works_job.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class ReindexWorksJob < ApplicationJob + def perform + Hyrax.config.registered_curation_concern_types.each do |work_type| + work_type.constantize.find_each(&:update_index) + end + end +end diff --git a/app/views/_logo.html.erb b/app/views/_logo.html.erb index 133e033f0..841216770 100644 --- a/app/views/_logo.html.erb +++ b/app/views/_logo.html.erb @@ -1,7 +1,7 @@ <% if logo_image %> <% else %>