From 5ec7d1b5279e4f5bff814b7db520b67fe03d8790 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 4 Jun 2024 10:59:53 -0700 Subject: [PATCH 001/100] :construction: WIP: Port over AFlex UI to upload profile This work solely focused on the UI elements needed to build out the ability to import a metadat profile. This heavily relies on backend functionality to complete. --- .../hyrax/metadata_profiles_controller.rb | 31 +++++++ app/views/hyrax/dashboard/_sidebar.html.erb | 10 +++ .../metadata_profiles/_import_modal.html.erb | 7 ++ .../hyrax/metadata_profiles/index.html.erb | 81 +++++++++++++++++++ config/locales/hyrax.en.yml | 3 + config/routes.rb | 7 ++ 6 files changed, 139 insertions(+) create mode 100644 app/controllers/hyrax/metadata_profiles_controller.rb create mode 100644 app/views/hyrax/metadata_profiles/_import_modal.html.erb create mode 100644 app/views/hyrax/metadata_profiles/index.html.erb diff --git a/app/controllers/hyrax/metadata_profiles_controller.rb b/app/controllers/hyrax/metadata_profiles_controller.rb new file mode 100644 index 0000000000..2a4fb06d88 --- /dev/null +++ b/app/controllers/hyrax/metadata_profiles_controller.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Hyrax + class MetadataProfilesController < ApplicationController + include Hyrax::ThemedLayoutController + require 'yaml' + + with_themed_layout 'dashboard' + + # GET /allinson_flex_profiles + def index + add_breadcrumbs + end + + def import + uploaded_io = params[:file] + if uploaded_io.blank? + redirect_to profiles_path, alert: 'Please select a file to upload' + return + end + end + + private + + def add_breadcrumbs + add_breadcrumb t(:'hyrax.controls.home'), main_app.root_path + add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path + add_breadcrumb t(:'hyrax.dashboard.metadata_profiles'), hyrax.metadata_profiles_path + end + end +end \ No newline at end of file diff --git a/app/views/hyrax/dashboard/_sidebar.html.erb b/app/views/hyrax/dashboard/_sidebar.html.erb index 8a3522e07b..a48921241b 100644 --- a/app/views/hyrax/dashboard/_sidebar.html.erb +++ b/app/views/hyrax/dashboard/_sidebar.html.erb @@ -18,6 +18,16 @@ <% end %> <%= render 'hyrax/dashboard/sidebar/activity', menu: menu %> + + <% if current_ability.admin? %> + + + <%= menu.nav_link(hyrax.metadata_profiles_path, + title: t('hyrax.admin.sidebar.metadata_profiles')) do %> + <%= t('hyrax.admin.sidebar.metadata_profiles') %> + <% end %> + <% end %> + <%= render 'hyrax/dashboard/sidebar/repository_content', menu: menu %> <%= render 'hyrax/dashboard/sidebar/tasks', menu: menu %> <%= render 'hyrax/dashboard/sidebar/configuration', menu: menu %> diff --git a/app/views/hyrax/metadata_profiles/_import_modal.html.erb b/app/views/hyrax/metadata_profiles/_import_modal.html.erb new file mode 100644 index 0000000000..f56e55aa68 --- /dev/null +++ b/app/views/hyrax/metadata_profiles/_import_modal.html.erb @@ -0,0 +1,7 @@ +<%= form_tag(hyrax.import_metadata_profiles_path, :multipart => true, :class => "form-inline") do %> + <%= file_field_tag :file %> + +<% end %> \ No newline at end of file diff --git a/app/views/hyrax/metadata_profiles/index.html.erb b/app/views/hyrax/metadata_profiles/index.html.erb new file mode 100644 index 0000000000..6cc004cb67 --- /dev/null +++ b/app/views/hyrax/metadata_profiles/index.html.erb @@ -0,0 +1,81 @@ +<% provide :page_title, t(:'hyrax.dashboard.metadata_profiles') %> + +<% provide :page_header do %> +

<%= t(:'hyrax.admin.sidebar.metadata_profiles') %>

+
+ +
+<% end %> + +
+
+ <% if @metadata_profiles.present? %> +
+ + + + + + + + + + + <% @metadata_profiles.order("updated_at DESC").each do |hyrax_metadata_profile| %> + + + + + + + + <% if hyrax_metadata_profile == AllinsonFlex::Profile.current_version %> + <% if hyrax_metadata_profile.locked_at && hyrax_metadata_profile.locked_at < Time.now %> + + + <% else %> + + + + <% end %> + <% else %> + + + + <% end %> + + <% end %> + +
Schema VersionProfile VersionProfile TypeCreated At
<%= hyrax_metadata_profile.schema_version %><%= link_to hyrax_metadata_profile.metadata_profile_version.to_f, hyrax.metadata_profile_path(hyrax_metadata_profile) %><%= hyrax_metadata_profile.metadata_profile_type %><%= hyrax_metadata_profile.created_at.strftime("%b %d, %Y") %><%= link_to raw(""), hyrax.unlock_metadata_profile_path(hyrax_metadata_profile), method: :post, data: { confirm: 'Are you sure that no other user is editing the metadata_profile right now?' } %> + <%= hyrax_metadata_profile.lock_statement %> + <%= link_to raw(''), hyrax.edit_metadata_profile_path(hyrax_metadata_profile), data: { turbolinks: false } %><%= link_to raw(''), hyrax.metadata_profile_export_path(hyrax_metadata_profile), tagert: "_blank" %><%= link_to raw(''), hyrax.metadata_profile_path(hyrax_metadata_profile), method: :delete, data: { confirm: 'Are you sure?' } %>
+ + <%= page_entries_info @metadata_profiles %>
+ <%= paginate(@metadata_profiles, param_name: :metadata_profile_entries_page) %> + +
+ <% else %> +

No Metadata Schema Profiles have been created.

+ <% end %> +
+
+ + + + + <% if Hyrax.config.flexible? %> + <%= collection_presenter.schema_version.to_f if collection_presenter.schema_version %> + <% end %> <%= collection_presenter.collection_type_badge %> diff --git a/app/views/hyrax/my/works/_default_group.html.erb b/app/views/hyrax/my/works/_default_group.html.erb index 09415527da..020b09d8b3 100644 --- a/app/views/hyrax/my/works/_default_group.html.erb +++ b/app/views/hyrax/my/works/_default_group.html.erb @@ -5,6 +5,9 @@ <%= render_check_all %> <%= t("hyrax.dashboard.my.heading.title") %> + <% if Hyrax.config.flexible? %> + <%= t("hyrax.dashboard.my.heading.profile_version") %> + <% end %> <%= t("hyrax.dashboard.my.heading.last_modified") %> <%= t("hyrax.dashboard.my.heading.highlighted") %> <%= t("hyrax.dashboard.my.heading.work.visibility") %> diff --git a/app/views/hyrax/my/works/_list_works.html.erb b/app/views/hyrax/my/works/_list_works.html.erb index f69d8edd9a..9de582d84b 100644 --- a/app/views/hyrax/my/works/_list_works.html.erb +++ b/app/views/hyrax/my/works/_list_works.html.erb @@ -10,7 +10,7 @@ <%= link_to [main_app, document], class: 'mr-2' do %> <%= document_presenter(document)&.thumbnail&.thumbnail_tag( { class: 'd-none d-md-block file_listing_thumbnail', alt: "#{document.title_or_label} #{t('hyrax.homepage.admin_sets.thumbnail')}" }, - { suppress_link: true } + { suppress_link: true } ) %> <% end %> @@ -27,6 +27,9 @@ + <% if Hyrax.config.flexible? %> + <%= document.schema_version.to_f if document.schema_version %> + <% end %> <%= document.date_modified %> From d3db2739ce5fa3e588605f46fb773961f1fe1b93 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Wed, 26 Jun 2024 16:08:22 -0700 Subject: [PATCH 059/100] Add badge to work edit form --- app/forms/hyrax/forms/resource_form.rb | 9 ++++- .../hyrax/indexers/resource_indexer.rb | 6 ++- .../concerns/hyrax/solr_document_behavior.rb | 4 ++ app/presenters/hyrax/collection_presenter.rb | 2 +- .../edit_fields/_schema_version.html.erb | 37 +++++++++++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 app/views/records/edit_fields/_schema_version.html.erb diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index afda49edcc..b1e572495a 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -141,9 +141,12 @@ def model_class # rubocop:disable Rails/Delegate # @return [Array] terms for display 'above-the-fold', or in the most # prominent form real estate def primary_terms - _form_field_definitions + terms = _form_field_definitions .select { |_, definition| definition[:primary] } .keys.map(&:to_sym) + + terms = [:schema_version] + terms if Hyrax.config.flexible? + terms end ## @@ -165,6 +168,10 @@ def schema Definition::Each.new(singleton_class.definitions) end + def schema_version + resource.schema_version + end + private # OVERRIDE valkyrie 3.0.1 to make schema dynamic diff --git a/app/indexers/hyrax/indexers/resource_indexer.rb b/app/indexers/hyrax/indexers/resource_indexer.rb index 71273bc166..09138fecf4 100644 --- a/app/indexers/hyrax/indexers/resource_indexer.rb +++ b/app/indexers/hyrax/indexers/resource_indexer.rb @@ -39,7 +39,7 @@ def initialize(resource:) # @api public # @return [HashWithIndifferentAccess] def to_solr - { + solr_hash = { "id": resource.id.to_s, "date_uploaded_dtsi": resource.created_at, "date_modified_dtsi": resource.updated_at, @@ -49,6 +49,10 @@ def to_solr "human_readable_type_tesim": resource.human_readable_type, "alternate_ids_sim": resource.alternate_ids.map(&:to_s) }.with_indifferent_access + + solr_hash.merge!({ "schema_version_ssi": resource.schema_version }) if Hyrax.config.flexible? + + solr_hash end ## diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb index 99bc881725..6ebac9e839 100644 --- a/app/models/concerns/hyrax/solr_document_behavior.rb +++ b/app/models/concerns/hyrax/solr_document_behavior.rb @@ -146,6 +146,10 @@ def extensions_and_mime_types JSON.parse(self['extensions_and_mime_types_ssm'].first).map(&:with_indifferent_access) if self['extensions_and_mime_types_ssm'] end + def schema_version + self['schema_version_ssi'] + end + private def model_classifier(classifier) diff --git a/app/presenters/hyrax/collection_presenter.rb b/app/presenters/hyrax/collection_presenter.rb index bb8f931a73..49cac418c9 100644 --- a/app/presenters/hyrax/collection_presenter.rb +++ b/app/presenters/hyrax/collection_presenter.rb @@ -25,7 +25,7 @@ def initialize(solr_document, current_ability, request = nil) # CurationConcern methods delegate :stringify_keys, :human_readable_type, :collection?, :representative_id, - :to_s, to: :solr_document + :to_s, :schema_version, to: :solr_document delegate(*Hyrax::CollectionType.settings_attributes, to: :collection_type, prefix: :collection_type_is) alias nestable? collection_type_is_nestable? diff --git a/app/views/records/edit_fields/_schema_version.html.erb b/app/views/records/edit_fields/_schema_version.html.erb new file mode 100644 index 0000000000..55469b31dd --- /dev/null +++ b/app/views/records/edit_fields/_schema_version.html.erb @@ -0,0 +1,37 @@ +<% if Hyrax.config.flexible? %> + <% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> +
+ <% if f.object.schema_version.present? %> +
+ Created On Version +

<%= f.object.schema_version.to_f %>

+
+ <% end %> +
+ Version After Save +

<%= Hyrax::FlexibleSchema.last.id.to_f %>

+
+
+ + +<% end %> From 4a4dd855499ab14b2703a17d5a6575c93ab56a00 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Thu, 27 Jun 2024 10:45:34 -0700 Subject: [PATCH 060/100] Add badge for collection and filset show --- app/forms/hyrax/forms/pcdm_collection_form.rb | 5 ++- .../edit_fields/_schema_version.html.erb | 37 +++++++++++++++++++ app/views/hyrax/file_sets/_form.html.erb | 1 + .../hyrax/file_sets/_schema_version.html.erb | 35 ++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/views/collections/edit_fields/_schema_version.html.erb create mode 100644 app/views/hyrax/file_sets/_schema_version.html.erb diff --git a/app/forms/hyrax/forms/pcdm_collection_form.rb b/app/forms/hyrax/forms/pcdm_collection_form.rb index 3d8da0eae7..b07304a880 100644 --- a/app/forms/hyrax/forms/pcdm_collection_form.rb +++ b/app/forms/hyrax/forms/pcdm_collection_form.rb @@ -62,9 +62,12 @@ def required_fields # @return [Array] terms for display 'above-the-fold', or in the most # prominent form real estate def primary_terms - _form_field_definitions + terms = _form_field_definitions .select { |_, definition| definition[:primary] } .keys.map(&:to_sym) + + terms = [:schema_version] + terms if Hyrax.config.flexible? + terms end ## diff --git a/app/views/collections/edit_fields/_schema_version.html.erb b/app/views/collections/edit_fields/_schema_version.html.erb new file mode 100644 index 0000000000..55469b31dd --- /dev/null +++ b/app/views/collections/edit_fields/_schema_version.html.erb @@ -0,0 +1,37 @@ +<% if Hyrax.config.flexible? %> + <% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> +
+ <% if f.object.schema_version.present? %> +
+ Created On Version +

<%= f.object.schema_version.to_f %>

+
+ <% end %> +
+ Version After Save +

<%= Hyrax::FlexibleSchema.last.id.to_f %>

+
+
+ + +<% end %> diff --git a/app/views/hyrax/file_sets/_form.html.erb b/app/views/hyrax/file_sets/_form.html.erb index 999890e8ac..31b03177f9 100644 --- a/app/views/hyrax/file_sets/_form.html.erb +++ b/app/views/hyrax/file_sets/_form.html.erb @@ -1,4 +1,5 @@ <%= simple_form_for [main_app, curation_concern], html: { multipart: true, class: 'nav-safety' } do |f| %> + <%= render('schema_version', f: f) if Hyrax.config.flexible? %>
<%= label_tag 'file_set[title][]', t('.title'), class: "string optional" %> diff --git a/app/views/hyrax/file_sets/_schema_version.html.erb b/app/views/hyrax/file_sets/_schema_version.html.erb new file mode 100644 index 0000000000..8ae0907b33 --- /dev/null +++ b/app/views/hyrax/file_sets/_schema_version.html.erb @@ -0,0 +1,35 @@ +<% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> +
+ <% if f.object.schema_version.present? %> +
+ Created On Version +

<%= f.object.schema_version.to_f %>

+
+ <% end %> +
+ Version After Save +

<%= Hyrax::FlexibleSchema.last.id.to_f %>

+
+
+ + From e3f76225e60097a3e1256034f245d1abd76ca695 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Thu, 27 Jun 2024 14:43:59 -0400 Subject: [PATCH 061/100] Pull in changes from flexible_metadata --- .circleci/config.yml | 12 ++++++++++++ .dassie/app/indexers/collection_resource_indexer.rb | 1 + .../app/indexers/generic_work_resource_indexer.rb | 1 + .dassie/app/indexers/monograph_indexer.rb | 1 + .koppie/app/indexers/collection_resource_indexer.rb | 1 + .koppie/app/indexers/generic_work_indexer.rb | 1 + .koppie/app/indexers/monograph_indexer.rb | 1 + .../hyrax/indexers/administrative_set_indexer.rb | 1 + app/indexers/hyrax/indexers/file_set_indexer.rb | 1 + .../hyrax/indexers/pcdm_collection_indexer.rb | 1 + .../templates/collection_indexer.rb.erb | 1 + .../hyrax/work_resource/templates/indexer.rb.erb | 1 + lib/hyrax/indexer.rb | 1 + 13 files changed, 24 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..bb445a1e87 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,12 @@ +version: 2.1 + +# Run a no-op workflow so CircleCI reports as a green check in pull requests. +# This file is needed until all active hyrax branches have moved off CircleCI +# and the integration can be deactivated. +jobs: + build: + docker: + - image: cimg/base:current + resource_class: small + steps: + - run: echo "Hyrax tests have moved to Github Actions." diff --git a/.dassie/app/indexers/collection_resource_indexer.rb b/.dassie/app/indexers/collection_resource_indexer.rb index 038eb8e10a..76a4ace871 100644 --- a/.dassie/app/indexers/collection_resource_indexer.rb +++ b/.dassie/app/indexers/collection_resource_indexer.rb @@ -5,4 +5,5 @@ class CollectionResourceIndexer < Hyrax::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:collection_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('CollectionResource') if Hyrax.config.flexible? end diff --git a/.dassie/app/indexers/generic_work_resource_indexer.rb b/.dassie/app/indexers/generic_work_resource_indexer.rb index d4251f64af..6fb90b0083 100644 --- a/.dassie/app/indexers/generic_work_resource_indexer.rb +++ b/.dassie/app/indexers/generic_work_resource_indexer.rb @@ -5,6 +5,7 @@ class GenericWorkResourceIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:generic_work_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('GenericWorkResource') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.dassie/app/indexers/monograph_indexer.rb b/.dassie/app/indexers/monograph_indexer.rb index 00c60cfd7d..092a84a4ba 100644 --- a/.dassie/app/indexers/monograph_indexer.rb +++ b/.dassie/app/indexers/monograph_indexer.rb @@ -5,6 +5,7 @@ class MonographIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:monograph) unless Hyrax.config.flexible? + include Hyrax::Indexer('Monograph') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.koppie/app/indexers/collection_resource_indexer.rb b/.koppie/app/indexers/collection_resource_indexer.rb index 038eb8e10a..76a4ace871 100644 --- a/.koppie/app/indexers/collection_resource_indexer.rb +++ b/.koppie/app/indexers/collection_resource_indexer.rb @@ -5,4 +5,5 @@ class CollectionResourceIndexer < Hyrax::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:collection_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('CollectionResource') if Hyrax.config.flexible? end diff --git a/.koppie/app/indexers/generic_work_indexer.rb b/.koppie/app/indexers/generic_work_indexer.rb index 84ded03718..27345aecaf 100644 --- a/.koppie/app/indexers/generic_work_indexer.rb +++ b/.koppie/app/indexers/generic_work_indexer.rb @@ -5,6 +5,7 @@ class GenericWorkIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:generic_work) unless Hyrax.config.flexible? + include Hyrax::Indexer('GenericWork') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.koppie/app/indexers/monograph_indexer.rb b/.koppie/app/indexers/monograph_indexer.rb index 00c60cfd7d..092a84a4ba 100644 --- a/.koppie/app/indexers/monograph_indexer.rb +++ b/.koppie/app/indexers/monograph_indexer.rb @@ -5,6 +5,7 @@ class MonographIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:monograph) unless Hyrax.config.flexible? + include Hyrax::Indexer('Monograph') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/app/indexers/hyrax/indexers/administrative_set_indexer.rb b/app/indexers/hyrax/indexers/administrative_set_indexer.rb index 575842ee4b..5c69a8e589 100644 --- a/app/indexers/hyrax/indexers/administrative_set_indexer.rb +++ b/app/indexers/hyrax/indexers/administrative_set_indexer.rb @@ -8,6 +8,7 @@ class AdministrativeSetIndexer < Hyrax::Indexers::ResourceIndexer include Hyrax::PermissionIndexer include Hyrax::VisibilityIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::AdministrativeSet') if Hyrax.config.flexible? def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength super.tap do |solr_doc| diff --git a/app/indexers/hyrax/indexers/file_set_indexer.rb b/app/indexers/hyrax/indexers/file_set_indexer.rb index 80d053c24c..5862e2d32a 100644 --- a/app/indexers/hyrax/indexers/file_set_indexer.rb +++ b/app/indexers/hyrax/indexers/file_set_indexer.rb @@ -10,6 +10,7 @@ class FileSetIndexer < Hyrax::Indexers::ResourceIndexer # rubocop:disable Metric include Hyrax::ThumbnailIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:file_set_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::FileSet') if Hyrax.config.flexible? def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength diff --git a/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb b/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb index e33cf54e55..deb9e52338 100644 --- a/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb +++ b/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb @@ -10,6 +10,7 @@ class PcdmCollectionIndexer < Hyrax::Indexers::ResourceIndexer include Hyrax::LocationIndexer include Hyrax::ThumbnailIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::PcdmCollection') if Hyrax.config.flexible? self.thumbnail_path_service = CollectionThumbnailPathService diff --git a/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb b/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb index c85cba5054..1715502ebd 100644 --- a/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +++ b/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb @@ -4,4 +4,5 @@ # `rails generate hyrax:collection_resource <%= class_name %>` class <%= class_name %>Indexer < Hyrax::Indexers::PcdmCollectionIndexer include Hyrax::Indexer(:<%= file_name %>) unless Hyrax.config.flexible? + include Hyrax::Indexer('<%= class_name %>') if Hyrax.config.flexible? end diff --git a/lib/generators/hyrax/work_resource/templates/indexer.rb.erb b/lib/generators/hyrax/work_resource/templates/indexer.rb.erb index 1514165664..626cdac9d6 100644 --- a/lib/generators/hyrax/work_resource/templates/indexer.rb.erb +++ b/lib/generators/hyrax/work_resource/templates/indexer.rb.erb @@ -5,6 +5,7 @@ class <%= class_name %>Indexer < Hyrax::Indexers::PcdmObjectIndexer(<%= class_name %>) include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:<%= file_name %>) unless Hyrax.config.flexible? + include Hyrax::Indexer('<%= class_name %>') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/lib/hyrax/indexer.rb b/lib/hyrax/indexer.rb index 0d766b14a0..c1efaab1a2 100644 --- a/lib/hyrax/indexer.rb +++ b/lib/hyrax/indexer.rb @@ -37,6 +37,7 @@ def initialize(rules) Hyrax::Schema.default_schema_loader.index_rules_for(schema: resource.class.to_s, version: resource.schema_version).each do |index_key, method| document[index_key] = resource.try(method) end + document['schema_version_ssi'] = resource.schema_version else rules.each do |index_key, method| document[index_key] = resource.try(method) From d9cbf521495ae618c37a86175927c864036f5b71 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Thu, 27 Jun 2024 12:59:16 -0700 Subject: [PATCH 062/100] Remove #schema_version from SolrDocument This will be handled at a higher level. --- app/models/concerns/hyrax/solr_document_behavior.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb index 6ebac9e839..99bc881725 100644 --- a/app/models/concerns/hyrax/solr_document_behavior.rb +++ b/app/models/concerns/hyrax/solr_document_behavior.rb @@ -146,10 +146,6 @@ def extensions_and_mime_types JSON.parse(self['extensions_and_mime_types_ssm'].first).map(&:with_indifferent_access) if self['extensions_and_mime_types_ssm'] end - def schema_version - self['schema_version_ssi'] - end - private def model_classifier(classifier) From 345677f0983f70c83315d005c18cc0c1f8d8aa24 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Thu, 27 Jun 2024 13:21:15 -0700 Subject: [PATCH 063/100] Removing the schema_version_ssi This is now moved to a higher level in a different commit. --- app/indexers/hyrax/indexers/resource_indexer.rb | 4 ---- app/models/concerns/hyrax/solr_document_behavior.rb | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/indexers/hyrax/indexers/resource_indexer.rb b/app/indexers/hyrax/indexers/resource_indexer.rb index 09138fecf4..0e40723adf 100644 --- a/app/indexers/hyrax/indexers/resource_indexer.rb +++ b/app/indexers/hyrax/indexers/resource_indexer.rb @@ -49,10 +49,6 @@ def to_solr "human_readable_type_tesim": resource.human_readable_type, "alternate_ids_sim": resource.alternate_ids.map(&:to_s) }.with_indifferent_access - - solr_hash.merge!({ "schema_version_ssi": resource.schema_version }) if Hyrax.config.flexible? - - solr_hash end ## diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb index 99bc881725..6ebac9e839 100644 --- a/app/models/concerns/hyrax/solr_document_behavior.rb +++ b/app/models/concerns/hyrax/solr_document_behavior.rb @@ -146,6 +146,10 @@ def extensions_and_mime_types JSON.parse(self['extensions_and_mime_types_ssm'].first).map(&:with_indifferent_access) if self['extensions_and_mime_types_ssm'] end + def schema_version + self['schema_version_ssi'] + end + private def model_classifier(classifier) From a7b0ccfcc78a7f28b783159970f0ab341c687c4e Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Tue, 25 Jun 2024 15:50:27 -0400 Subject: [PATCH 064/100] Quiet down CircleCI and have it report as green --- .circleci/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..bb445a1e87 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,12 @@ +version: 2.1 + +# Run a no-op workflow so CircleCI reports as a green check in pull requests. +# This file is needed until all active hyrax branches have moved off CircleCI +# and the integration can be deactivated. +jobs: + build: + docker: + - image: cimg/base:current + resource_class: small + steps: + - run: echo "Hyrax tests have moved to Github Actions." From 39cbf9942a801636ae7d325644c95b12a408b006 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Thu, 27 Jun 2024 13:22:58 -0700 Subject: [PATCH 065/100] Load the indexer module for flexible metadata Configures dassie, koppie, hyrax app, and generators for flexible metadata indexing to occur. --- .dassie/app/indexers/collection_resource_indexer.rb | 1 + .dassie/app/indexers/generic_work_resource_indexer.rb | 1 + .dassie/app/indexers/monograph_indexer.rb | 1 + .koppie/app/indexers/collection_resource_indexer.rb | 1 + .koppie/app/indexers/generic_work_indexer.rb | 1 + .koppie/app/indexers/monograph_indexer.rb | 1 + app/indexers/hyrax/indexers/administrative_set_indexer.rb | 1 + app/indexers/hyrax/indexers/file_set_indexer.rb | 1 + app/indexers/hyrax/indexers/pcdm_collection_indexer.rb | 1 + .../collection_resource/templates/collection_indexer.rb.erb | 1 + lib/generators/hyrax/work_resource/templates/indexer.rb.erb | 1 + lib/hyrax/indexer.rb | 1 + 12 files changed, 12 insertions(+) diff --git a/.dassie/app/indexers/collection_resource_indexer.rb b/.dassie/app/indexers/collection_resource_indexer.rb index 038eb8e10a..76a4ace871 100644 --- a/.dassie/app/indexers/collection_resource_indexer.rb +++ b/.dassie/app/indexers/collection_resource_indexer.rb @@ -5,4 +5,5 @@ class CollectionResourceIndexer < Hyrax::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:collection_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('CollectionResource') if Hyrax.config.flexible? end diff --git a/.dassie/app/indexers/generic_work_resource_indexer.rb b/.dassie/app/indexers/generic_work_resource_indexer.rb index d4251f64af..6fb90b0083 100644 --- a/.dassie/app/indexers/generic_work_resource_indexer.rb +++ b/.dassie/app/indexers/generic_work_resource_indexer.rb @@ -5,6 +5,7 @@ class GenericWorkResourceIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:generic_work_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('GenericWorkResource') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.dassie/app/indexers/monograph_indexer.rb b/.dassie/app/indexers/monograph_indexer.rb index 00c60cfd7d..092a84a4ba 100644 --- a/.dassie/app/indexers/monograph_indexer.rb +++ b/.dassie/app/indexers/monograph_indexer.rb @@ -5,6 +5,7 @@ class MonographIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:monograph) unless Hyrax.config.flexible? + include Hyrax::Indexer('Monograph') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.koppie/app/indexers/collection_resource_indexer.rb b/.koppie/app/indexers/collection_resource_indexer.rb index 038eb8e10a..76a4ace871 100644 --- a/.koppie/app/indexers/collection_resource_indexer.rb +++ b/.koppie/app/indexers/collection_resource_indexer.rb @@ -5,4 +5,5 @@ class CollectionResourceIndexer < Hyrax::PcdmCollectionIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:collection_resource) unless Hyrax.config.flexible? + include Hyrax::Indexer('CollectionResource') if Hyrax.config.flexible? end diff --git a/.koppie/app/indexers/generic_work_indexer.rb b/.koppie/app/indexers/generic_work_indexer.rb index 84ded03718..27345aecaf 100644 --- a/.koppie/app/indexers/generic_work_indexer.rb +++ b/.koppie/app/indexers/generic_work_indexer.rb @@ -5,6 +5,7 @@ class GenericWorkIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:generic_work) unless Hyrax.config.flexible? + include Hyrax::Indexer('GenericWork') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/.koppie/app/indexers/monograph_indexer.rb b/.koppie/app/indexers/monograph_indexer.rb index 00c60cfd7d..092a84a4ba 100644 --- a/.koppie/app/indexers/monograph_indexer.rb +++ b/.koppie/app/indexers/monograph_indexer.rb @@ -5,6 +5,7 @@ class MonographIndexer < Hyrax::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:monograph) unless Hyrax.config.flexible? + include Hyrax::Indexer('Monograph') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/app/indexers/hyrax/indexers/administrative_set_indexer.rb b/app/indexers/hyrax/indexers/administrative_set_indexer.rb index 575842ee4b..5c69a8e589 100644 --- a/app/indexers/hyrax/indexers/administrative_set_indexer.rb +++ b/app/indexers/hyrax/indexers/administrative_set_indexer.rb @@ -8,6 +8,7 @@ class AdministrativeSetIndexer < Hyrax::Indexers::ResourceIndexer include Hyrax::PermissionIndexer include Hyrax::VisibilityIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::AdministrativeSet') if Hyrax.config.flexible? def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength super.tap do |solr_doc| diff --git a/app/indexers/hyrax/indexers/file_set_indexer.rb b/app/indexers/hyrax/indexers/file_set_indexer.rb index 80d053c24c..5862e2d32a 100644 --- a/app/indexers/hyrax/indexers/file_set_indexer.rb +++ b/app/indexers/hyrax/indexers/file_set_indexer.rb @@ -10,6 +10,7 @@ class FileSetIndexer < Hyrax::Indexers::ResourceIndexer # rubocop:disable Metric include Hyrax::ThumbnailIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:file_set_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::FileSet') if Hyrax.config.flexible? def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength diff --git a/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb b/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb index e33cf54e55..deb9e52338 100644 --- a/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb +++ b/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb @@ -10,6 +10,7 @@ class PcdmCollectionIndexer < Hyrax::Indexers::ResourceIndexer include Hyrax::LocationIndexer include Hyrax::ThumbnailIndexer include Hyrax::Indexer(:core_metadata) unless Hyrax.config.flexible? + include Hyrax::Indexer('Hyrax::PcdmCollection') if Hyrax.config.flexible? self.thumbnail_path_service = CollectionThumbnailPathService diff --git a/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb b/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb index c85cba5054..1715502ebd 100644 --- a/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +++ b/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb @@ -4,4 +4,5 @@ # `rails generate hyrax:collection_resource <%= class_name %>` class <%= class_name %>Indexer < Hyrax::Indexers::PcdmCollectionIndexer include Hyrax::Indexer(:<%= file_name %>) unless Hyrax.config.flexible? + include Hyrax::Indexer('<%= class_name %>') if Hyrax.config.flexible? end diff --git a/lib/generators/hyrax/work_resource/templates/indexer.rb.erb b/lib/generators/hyrax/work_resource/templates/indexer.rb.erb index 1514165664..626cdac9d6 100644 --- a/lib/generators/hyrax/work_resource/templates/indexer.rb.erb +++ b/lib/generators/hyrax/work_resource/templates/indexer.rb.erb @@ -5,6 +5,7 @@ class <%= class_name %>Indexer < Hyrax::Indexers::PcdmObjectIndexer(<%= class_name %>) include Hyrax::Indexer(:basic_metadata) unless Hyrax.config.flexible? include Hyrax::Indexer(:<%= file_name %>) unless Hyrax.config.flexible? + include Hyrax::Indexer('<%= class_name %>') if Hyrax.config.flexible? # Uncomment this block if you want to add custom indexing behavior: # def to_solr diff --git a/lib/hyrax/indexer.rb b/lib/hyrax/indexer.rb index 0d766b14a0..c1efaab1a2 100644 --- a/lib/hyrax/indexer.rb +++ b/lib/hyrax/indexer.rb @@ -37,6 +37,7 @@ def initialize(rules) Hyrax::Schema.default_schema_loader.index_rules_for(schema: resource.class.to_s, version: resource.schema_version).each do |index_key, method| document[index_key] = resource.try(method) end + document['schema_version_ssi'] = resource.schema_version else rules.each do |index_key, method| document[index_key] = resource.try(method) From 552d5648e5fce9ae6e2e7d37bc78600cb99bf38e Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Thu, 27 Jun 2024 18:05:42 -0400 Subject: [PATCH 066/100] Work show view for flexible metadata --- .../config/metadata_profiles/m3_profile.yaml | 219 +++++++++++------- app/helpers/hyrax/attributes_helper.rb | 49 ++-- app/presenters/hyrax/work_show_presenter.rb | 4 + app/views/hyrax/base/_attribute_rows.html.erb | 2 +- lib/hyrax/schema.rb | 15 -- 5 files changed, 177 insertions(+), 112 deletions(-) diff --git a/.koppie/config/metadata_profiles/m3_profile.yaml b/.koppie/config/metadata_profiles/m3_profile.yaml index 51ce6e5f5f..63a6ae3359 100644 --- a/.koppie/config/metadata_profiles/m3_profile.yaml +++ b/.koppie/config/metadata_profiles/m3_profile.yaml @@ -4,7 +4,7 @@ profile: date_modified: '2024-06-01' responsibility: https://samvera.org responsibility_statement: Hyrax Initial Profile - type: + type: Flexible with Views version: 1 classes: GenericWork: @@ -39,7 +39,6 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork - - Monograph cardinality: minimum: 1 multi_value: true @@ -48,15 +47,14 @@ properties: sources: - 'null' definition: - default: Enter a standardized title for display. If only one - title is needed, transcribe the title from the source - itself. + default: Enter a standardized title for display. If only one title is needed, + transcribe the title from the source itself. display_label: default: Title index_documentation: displayable, searchable indexing: - - 'title_sim' - - 'title_tesim' + - title_sim + - title_tesim form: required: true primary: true @@ -71,6 +69,11 @@ properties: requirement: required sample_values: - Pencil drawn portrait study of woman + view: + label: + en: 'Title' + es: 'Título' + html_dl: true date_modified: available_on: class: @@ -78,7 +81,6 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork - - Monograph cardinality: minimum: 0 maximum: 1 @@ -88,7 +90,10 @@ properties: property_uri: http://purl.org/dc/terms/modified range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + label: Date Modified + html_dl: true date_uploaded: available_on: class: @@ -96,7 +101,6 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork - - Monograph cardinality: minimum: 0 maximum: 1 @@ -106,7 +110,9 @@ properties: property_uri: http://purl.org/dc/terms/dateSubmitted range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + html_dl: true depositor: available_on: class: @@ -114,7 +120,6 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork - - Monograph cardinality: minimum: 0 maximum: 1 @@ -127,11 +132,13 @@ properties: default: Depositor index_documentation: searchable indexing: - - 'depositor_tesim' + - depositor_tesim property_uri: http://id.loc.gov/vocabulary/relators/dpt range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + html_dl: true creator: available_on: class: @@ -150,8 +157,8 @@ properties: default: Creator index_documentation: displayable, searchable indexing: - - 'creator_sim' - - 'creator_tesim' + - creator_sim + - creator_tesim form: required: true primary: true @@ -159,6 +166,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + html_dl: true license: available_on: class: @@ -177,14 +186,16 @@ properties: default: License index_documentation: displayable, searchable indexing: - - 'license_sim' - - 'license_tesim' + - license_sim + - license_tesim form: primary: false property_uri: http://purl.org/dc/terms/license range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://creativecommons.org/licenses/by/3.0/us/ + view: + html_dl: true abstract: available_on: class: @@ -203,14 +214,16 @@ properties: default: Abstract index_documentation: displayable, searchable indexing: - - 'abstract_sim' - - 'abstract_tesim' + - abstract_sim + - abstract_tesim form: primary: false property_uri: http://purl.org/dc/terms/abstract range: http://www.w3.org/2001/XMLSchema#string sample_values: - This is an abstract. + view: + html_dl: true access_right: available_on: class: @@ -228,14 +241,16 @@ properties: default: Access Right index_documentation: displayable, searchable indexing: - - 'access_right_sim' - - 'access_right_tesim' + - access_right_sim + - access_right_tesim form: primary: false property_uri: http://purl.org/dc/terms/accessRights range: http://www.w3.org/2001/XMLSchema#string sample_values: - Open Access + view: + html_dl: true alternative_title: available_on: class: @@ -253,14 +268,16 @@ properties: default: Alternative Title index_documentation: displayable, searchable indexing: - - 'alternative_title_sim' - - 'alternative_title_tesim' + - alternative_title_sim + - alternative_title_tesim form: primary: false property_uri: http://purl.org/dc/terms/alternative range: http://www.w3.org/2001/XMLSchema#string sample_values: - Alternate Title Example + view: + html_dl: true arkivo_checksum: available_on: class: @@ -283,6 +300,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - c0855931b7f1aefedb91d31af76873c0 + view: + html_dl: true based_near: available_on: class: @@ -301,14 +320,16 @@ properties: default: Location index_documentation: displayable, searchable indexing: - - 'based_near_sim' - - 'based_near_tesim' + - based_near_sim + - based_near_tesim form: primary: false property_uri: http://xmlns.com/foaf/0.1/based_near range: http://www.w3.org/2001/XMLSchema#string sample_values: - San Diego, California, United States + view: + html_dl: true bibliographic_citation: available_on: class: @@ -326,14 +347,16 @@ properties: default: Bibliographic Citation index_documentation: displayable, searchable indexing: - - 'bibliographic_citation_sim' - - 'bibliographic_citation_tesim' + - bibliographic_citation_sim + - bibliographic_citation_tesim form: primary: false property_uri: http://purl.org/dc/terms/bibliographicCitation range: http://www.w3.org/2001/XMLSchema#string sample_values: - - "Doe, J. (2024). Example Citation. Journal of Examples, 12(3), 45-67." + - Doe, J. (2024). Example Citation. Journal of Examples, 12(3), 45-67. + view: + html_dl: true contributor: available_on: class: @@ -352,14 +375,16 @@ properties: default: Contributor index_documentation: displayable, searchable indexing: - - 'contributor_tesim' - - 'contributor_sim' + - contributor_tesim + - contributor_sim form: primary: false property_uri: http://purl.org/dc/elements/1.1/contributor range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + html_dl: true date_created: available_on: class: @@ -378,15 +403,16 @@ properties: default: Date Created index_documentation: displayable, searchable indexing: - - 'date_created_sim' - - 'date_created_tesim' + - date_created_sim + - date_created_tesim form: primary: false property_uri: http://purl.org/dc/terms/created range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + html_dl: true description: available_on: class: @@ -405,14 +431,16 @@ properties: default: Description index_documentation: displayable, searchable indexing: - - 'description_sim' - - 'description_tesim' + - description_sim + - description_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/description range: http://www.w3.org/2001/XMLSchema#string sample_values: - This is a description. + view: + html_dl: true identifier: available_on: class: @@ -431,14 +459,16 @@ properties: default: Identifier index_documentation: displayable, searchable indexing: - - 'identifier_sim' - - 'identifier_tesim' + - identifier_sim + - identifier_tesim form: primary: false property_uri: http://purl.org/dc/terms/identifier range: http://www.w3.org/2001/XMLSchema#string sample_values: - abc123 + view: + html_dl: true import_url: available_on: class: @@ -459,6 +489,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://example.com/resource1 + view: + html_dl: true keyword: available_on: class: @@ -477,8 +509,8 @@ properties: default: Keyword index_documentation: displayable, searchable indexing: - - 'keyword_sim' - - 'keyword_tesim' + - keyword_sim + - keyword_tesim form: primary: false property_uri: http://schema.org/keywords @@ -486,6 +518,8 @@ properties: sample_values: - Metadata - Repository + view: + html_dl: true label: available_on: class: @@ -505,14 +539,16 @@ properties: default: Label index_documentation: displayable, searchable indexing: - - 'label_sim' - - 'label_tesim' + - label_sim + - label_tesim form: primary: false property_uri: info:fedora/fedora-system:def/model#downloadFilename range: http://www.w3.org/2001/XMLSchema#string sample_values: - file_label.txt + view: + html_dl: true language: available_on: class: @@ -531,8 +567,8 @@ properties: default: Language index_documentation: displayable, searchable indexing: - - 'language_sim' - - 'language_tesim' + - language_sim + - language_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/language @@ -540,6 +576,8 @@ properties: sample_values: - English - Spanish + view: + html_dl: true publisher: available_on: class: @@ -558,14 +596,16 @@ properties: default: Publisher index_documentation: displayable, searchable indexing: - - 'publisher_sim' - - 'publisher_tesim' + - publisher_sim + - publisher_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/publisher range: http://www.w3.org/2001/XMLSchema#string sample_values: - Scholastic + view: + html_dl: true related_url: available_on: class: @@ -584,14 +624,16 @@ properties: default: Related URL index_documentation: displayable, searchable indexing: - - 'related_url_sim' - - 'related_url_tesim' + - related_url_sim + - related_url_tesim form: primary: false property_uri: http://www.w3.org/2000/01/rdf-schema#seeAlso range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://example.com/resource1 + view: + html_dl: true relative_path: available_on: class: @@ -612,7 +654,9 @@ properties: property_uri: http://scholarsphere.psu.edu/ns#relativePath range: http://www.w3.org/2001/XMLSchema#string sample_values: - - /path/to/resource + - "/path/to/resource" + view: + html_dl: true resource_type: available_on: class: @@ -631,8 +675,8 @@ properties: default: Resource Type index_documentation: displayable, searchable indexing: - - 'resource_type_sim' - - 'resource_type_tesim' + - resource_type_sim + - resource_type_tesim form: primary: false property_uri: http://purl.org/dc/terms/type @@ -640,6 +684,8 @@ properties: sample_values: - Article - Conference Proceeding + view: + html_dl: true rights_notes: available_on: class: @@ -658,14 +704,16 @@ properties: default: Rights Notes index_documentation: displayable, searchable indexing: - - 'rights_notes_sim' - - 'rights_notes_tesim' + - rights_notes_sim + - rights_notes_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - Creative Commons license. + view: + html_dl: true rights_statement: available_on: class: @@ -684,14 +732,16 @@ properties: default: Rights Statement index_documentation: displayable, searchable indexing: - - 'rights_statement_sim' - - 'rights_statement_tesim' + - rights_statement_sim + - rights_statement_tesim form: primary: true property_uri: http://www.europeana.eu/schemas/edm/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://rightsstatements.org/vocab/InC/1.0/ + view: + html_dl: true source: available_on: class: @@ -710,8 +760,8 @@ properties: default: Source index_documentation: displayable, searchable indexing: - - 'source_sim' - - 'source_tesim' + - source_sim + - source_tesim form: primary: false property_uri: http://purl.org/dc/terms/source @@ -719,6 +769,8 @@ properties: sample_values: - Original Manuscript - Digital Archive + view: + html_dl: true subject: available_on: class: @@ -737,8 +789,8 @@ properties: default: Subject index_documentation: displayable, searchable indexing: - - 'subject_sim' - - 'subject_tesim' + - subject_sim + - subject_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/subject @@ -746,10 +798,12 @@ properties: sample_values: - Art - Science + view: + html_dl: true target_audience: available_on: class: - - CollectionResource + - Monograph cardinality: minimum: 0 multi_value: true @@ -760,13 +814,14 @@ properties: display_label: default: Target Audience form: - primary: true multiple: true property_uri: http://hyrax-example.com/target_audience range: http://www.w3.org/2001/XMLSchema#string sample_values: - Researchers - Students + view: + html_dl: true department: available_on: class: @@ -788,6 +843,8 @@ properties: sample_values: - Mathematics - History + view: + html_dl: true course: available_on: class: @@ -808,6 +865,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Computer Science 50 + view: + html_dl: true monograph_title: available_on: class: @@ -826,6 +885,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Monograph Title + view: + html_dl: true record_info: available_on: class: @@ -842,7 +903,7 @@ properties: default: Record Info index_documentation: searchable indexing: - - 'record_info_tesim' + - record_info_tesim form: required: true primary: true @@ -850,6 +911,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Record Info + view: + html_dl: true place_of_publication: available_on: class: @@ -871,6 +934,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Place of Publication + view: + html_dl: true genre: available_on: class: @@ -892,6 +957,8 @@ properties: sample_values: - Fiction - Non-Fiction + view: + html_dl: true series_title: available_on: class: @@ -912,26 +979,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Series Title - target_audience: - available_on: - class: - - Monograph - cardinality: - minimum: 0 - multi_value: true - controlled_values: - format: http://www.w3.org/2001/XMLSchema#string - sources: - - 'null' - display_label: - default: Target Audience - form: - multiple: true - property_uri: http://hyrax-example.com/target_audience - range: http://www.w3.org/2001/XMLSchema#string - sample_values: - - Researchers - - Students + view: + html_dl: true table_of_contents: available_on: class: @@ -952,6 +1001,8 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Table of Contents + view: + html_dl: true date_of_issuance: available_on: class: @@ -969,4 +1020,6 @@ properties: property_uri: http://hyrax-example.com/date_of_issuance range: http://www.w3.org/2001/XMLSchema#string sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + html_dl: true diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index 96aa6e53fc..cd1498e1aa 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -3,31 +3,54 @@ module Hyrax module AttributesHelper def view_options_for(presenter) - model_name = presenter.model.model_name.name.constantize - hash = Hyrax::Schema.schema_to_hash_for(model_name) || - Hyrax::Schema.schema_to_hash_for((model_name.to_s + 'Resource').safe_constantize) + model_name = presenter.model.model_name.name - hash.select { |_, val| val['view'].present? } + # @todo: decide if views should be based on current_version or the work's version (presenter.schema_version) + if Hyrax.config.flexible? + Hyrax::Schema.default_schema_loader.view_definitions_for(schema: model_name, version: Hyrax::FlexibleSchema.order("created_at asc").last.id) + else + schema = model_name.constantize.schema || (model_name + 'Resource').safe_constantize.schema + Hyrax::Schema.default_schema_loader.view_definitions_for(schema:) + end end - def conform_options(options) - hash_of_locales = options['view']['label'] || {} + # @param [String] field name + # @param [Hash{"en"=>"Title", "es"=>"Título"}, :html_dl=>true} + def conform_options(field_name, options_hash) + options = HashWithIndifferentAccess.new(options_hash) + hash_of_locales = HashWithIndifferentAccess.new(options)['label'] || {} current_locale = params['locale'] || I18n.locale.to_s - updated_options = options.deep_dup - return updated_options['view'].transform_keys(&:to_sym) if hash_of_locales.is_a?(String) + + unless hash_of_locales.present? + options[:label] = field_to_label(field_name.to_s) + return options + end + + return options_hash if hash_of_locales.is_a?(String) # If the params locale is found in the hash of locales, use that value if hash_of_locales[current_locale].present? - updated_options['view']['label'] = hash_of_locales[current_locale] + options[:label] = hash_of_locales[current_locale] # If the params locale is not found, fall back to english elsif hash_of_locales['en'] - updated_options['view']['label'] = hash_of_locales['en'] + options[:label] = hash_of_locales['en'] # If the params locale is not found and english is not found, use the first value in the hash as a fallback - elsif hash_of_locales.present? && hash_of_locales['en'].nil? && hash_of_locales[current_locale].nil? - updated_options['view']['label'] = hash_of_locales.values.first + elsif hash_of_locales['en'].nil? && hash_of_locales[current_locale].nil? + options[:label] = hash_of_locales.values.first end - updated_options['view'].transform_keys(&:to_sym) + options + end + + def field_to_label(input_string) + # Split the input string by underscores + words = input_string.downcase.split('_') + # Capitalize the first word + if words.any? + words[0] = words[0].capitalize + end + # Join the words into a single string + words.join(' ') end end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 2b420f79cb..eaa5d32f52 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -30,6 +30,10 @@ def initialize(solr_document, current_ability, request = nil) # most all objects implicitly implicitly implement #to_s delegate :to_s, to: :solr_document + def schema_version + solr_document[:schema_version_ssi] + end + def page_title "#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}" end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index 609fdb120d..ea146c7782 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -1,3 +1,3 @@ <% view_options_for(presenter).each do |field, options| %> - <%= presenter.attribute_to_html(field.to_sym, conform_options(options)) %> + <%= presenter.attribute_to_html(field.to_sym, conform_options(field, options)) %> <% end %> diff --git a/lib/hyrax/schema.rb b/lib/hyrax/schema.rb index 8c73522289..d1d73f3eb6 100644 --- a/lib/hyrax/schema.rb +++ b/lib/hyrax/schema.rb @@ -64,21 +64,6 @@ def self.default_schema_loader Hyrax.config.flexible? ? M3SchemaLoader.new : SimpleSchemaLoader.new end - ## - # @param [Hyrax::Resource] work_type - # - # @example Hyrax::Schema.schema_to_hash(Monograph) - # - # @return [Hash{String => Hash}] - def self.schema_to_hash_for(work_type) - return unless work_type.respond_to?(:schema) - - schema = work_type.schema - schema.each_with_object({}) do |property, metadata| - metadata[property.name.to_s] = property.meta - end - end - ## # @param [Symbol] schema_name # From a342eb55a84da8d4fe18787e5c309cb6f23a2b98 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Fri, 28 Jun 2024 10:00:03 -0700 Subject: [PATCH 067/100] Rubocop fixes --- app/forms/hyrax/forms/pcdm_collection_form.rb | 4 ++-- app/forms/hyrax/forms/resource_form.rb | 8 +++----- app/helpers/hyrax/attributes_helper.rb | 4 +++- app/indexers/hyrax/indexers/resource_indexer.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/forms/hyrax/forms/pcdm_collection_form.rb b/app/forms/hyrax/forms/pcdm_collection_form.rb index b07304a880..ed72ca69a1 100644 --- a/app/forms/hyrax/forms/pcdm_collection_form.rb +++ b/app/forms/hyrax/forms/pcdm_collection_form.rb @@ -63,8 +63,8 @@ def required_fields # prominent form real estate def primary_terms terms = _form_field_definitions - .select { |_, definition| definition[:primary] } - .keys.map(&:to_sym) + .select { |_, definition| definition[:primary] } + .keys.map(&:to_sym) terms = [:schema_version] + terms if Hyrax.config.flexible? terms diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index b1e572495a..48fa476b99 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -142,8 +142,8 @@ def model_class # rubocop:disable Rails/Delegate # prominent form real estate def primary_terms terms = _form_field_definitions - .select { |_, definition| definition[:primary] } - .keys.map(&:to_sym) + .select { |_, definition| definition[:primary] } + .keys.map(&:to_sym) terms = [:schema_version] + terms if Hyrax.config.flexible? terms @@ -168,9 +168,7 @@ def schema Definition::Each.new(singleton_class.definitions) end - def schema_version - resource.schema_version - end + delegate :schema_version, to: :resource private diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index 96aa6e53fc..d038e74395 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -5,11 +5,12 @@ module AttributesHelper def view_options_for(presenter) model_name = presenter.model.model_name.name.constantize hash = Hyrax::Schema.schema_to_hash_for(model_name) || - Hyrax::Schema.schema_to_hash_for((model_name.to_s + 'Resource').safe_constantize) + Hyrax::Schema.schema_to_hash_for((model_name.to_s + 'Resource').safe_constantize) hash.select { |_, val| val['view'].present? } end + # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def conform_options(options) hash_of_locales = options['view']['label'] || {} current_locale = params['locale'] || I18n.locale.to_s @@ -29,5 +30,6 @@ def conform_options(options) updated_options['view'].transform_keys(&:to_sym) end + # rubocop:endable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity end end diff --git a/app/indexers/hyrax/indexers/resource_indexer.rb b/app/indexers/hyrax/indexers/resource_indexer.rb index 0e40723adf..71273bc166 100644 --- a/app/indexers/hyrax/indexers/resource_indexer.rb +++ b/app/indexers/hyrax/indexers/resource_indexer.rb @@ -39,7 +39,7 @@ def initialize(resource:) # @api public # @return [HashWithIndifferentAccess] def to_solr - solr_hash = { + { "id": resource.id.to_s, "date_uploaded_dtsi": resource.created_at, "date_modified_dtsi": resource.updated_at, From 50e39e976784bade9a44010d82f6b78d799f2fec Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 28 Jun 2024 13:25:23 -0400 Subject: [PATCH 068/100] Fix view rendering for simple schema --- app/helpers/hyrax/attributes_helper.rb | 14 +++++++++----- app/models/hyrax/flexible_schema.rb | 4 ++++ app/services/hyrax/m3_schema_loader.rb | 8 ++++++++ app/services/hyrax/schema_loader.rb | 8 -------- app/services/hyrax/simple_schema_loader.rb | 7 +++++++ 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index cd1498e1aa..618c765822 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -5,9 +5,11 @@ module AttributesHelper def view_options_for(presenter) model_name = presenter.model.model_name.name - # @todo: decide if views should be based on current_version or the work's version (presenter.schema_version) + # @todo: decide if views should instead be based on the work's stored version (presenter.schema_version) + # => using current means dropped terms from schema could be missing even if they exist on the work (but they'd already be missing on the edit view anyway) + # => using saved means that any view changes can't take effect unless the work(s) needing them are edited & saved if Hyrax.config.flexible? - Hyrax::Schema.default_schema_loader.view_definitions_for(schema: model_name, version: Hyrax::FlexibleSchema.order("created_at asc").last.id) + Hyrax::Schema.default_schema_loader.view_definitions_for(schema: model_name, version: Hyrax::FlexibleSchema.current_schema_id) else schema = model_name.constantize.schema || (model_name + 'Resource').safe_constantize.schema Hyrax::Schema.default_schema_loader.view_definitions_for(schema:) @@ -15,7 +17,7 @@ def view_options_for(presenter) end # @param [String] field name - # @param [Hash{"en"=>"Title", "es"=>"Título"}, :html_dl=>true} + # @param [Hash] a nested hash of view options... {:label=>{"en"=>"Title", "es"=>"Título"}, :html_dl=>true} def conform_options(field_name, options_hash) options = HashWithIndifferentAccess.new(options_hash) hash_of_locales = HashWithIndifferentAccess.new(options)['label'] || {} @@ -24,9 +26,9 @@ def conform_options(field_name, options_hash) unless hash_of_locales.present? options[:label] = field_to_label(field_name.to_s) return options - end + end - return options_hash if hash_of_locales.is_a?(String) + return options_hash if hash_of_locales.is_a?(String) || hash_of_locales.empty? # If the params locale is found in the hash of locales, use that value if hash_of_locales[current_locale].present? @@ -42,6 +44,8 @@ def conform_options(field_name, options_hash) options end + private + def field_to_label(input_string) # Split the input string by underscores words = input_string.downcase.split('_') diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index a1e3a35001..6c2b50dc74 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -6,6 +6,10 @@ def self.current_version order("created_at asc").last.profile end + def self.current_schema_id + order("created_at asc").last.id + end + def title "#{profile['profile']['responsibility_statement']} - version #{id}" end diff --git a/app/services/hyrax/m3_schema_loader.rb b/app/services/hyrax/m3_schema_loader.rb index 4b1f614ae1..0274b15b46 100644 --- a/app/services/hyrax/m3_schema_loader.rb +++ b/app/services/hyrax/m3_schema_loader.rb @@ -8,6 +8,14 @@ module Hyrax # # @see config/metadata_profiles/m3_profile.yaml for an example configuration class M3SchemaLoader < Hyrax::SchemaLoader + def view_definitions_for(schema:, version: 1) + definitions(schema, version).each_with_object({}) do |definition, hash| + next if definition.view_options.empty? + + hash[definition.name] = definition.view_options + end + end + private ## diff --git a/app/services/hyrax/schema_loader.rb b/app/services/hyrax/schema_loader.rb index fc5f53dcf7..074ae056e2 100644 --- a/app/services/hyrax/schema_loader.rb +++ b/app/services/hyrax/schema_loader.rb @@ -45,14 +45,6 @@ def index_rules_for(schema:, version: 1) end end - def view_definitions_for(schema:, version: 1) - definitions(schema, version).each_with_object({}) do |definition, hash| - next if definition.view_options.empty? - - hash[definition.name] = definition.view_options - end - end - ## # @api private class AttributeDefinition diff --git a/app/services/hyrax/simple_schema_loader.rb b/app/services/hyrax/simple_schema_loader.rb index 1597ee96ce..24f5a2bc16 100644 --- a/app/services/hyrax/simple_schema_loader.rb +++ b/app/services/hyrax/simple_schema_loader.rb @@ -8,6 +8,13 @@ module Hyrax # # @see config/metadata/basic_metadata.yaml for an example configuration class SimpleSchemaLoader < Hyrax::SchemaLoader + def view_definitions_for(schema:, version: 1) + schema.each_with_object({}) do |property, metadata| + view_options = property.meta['view'] + metadata[property.name.to_s] = view_options unless view_options.nil? + end + end + def permissive_schema_for_valkrie_adapter metadata_files.each_with_object({}) do |schema_name, ret_hsh| predicate_pairs(ret_hsh, schema_name) From 7311a4edcea41331e73cfd07cdff2789d7f79fb0 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 28 Jun 2024 14:03:59 -0400 Subject: [PATCH 069/100] Rubocop --- app/services/hyrax/simple_schema_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/hyrax/simple_schema_loader.rb b/app/services/hyrax/simple_schema_loader.rb index 24f5a2bc16..0b5851fcd0 100644 --- a/app/services/hyrax/simple_schema_loader.rb +++ b/app/services/hyrax/simple_schema_loader.rb @@ -8,7 +8,7 @@ module Hyrax # # @see config/metadata/basic_metadata.yaml for an example configuration class SimpleSchemaLoader < Hyrax::SchemaLoader - def view_definitions_for(schema:, version: 1) + def view_definitions_for(schema:, _version: 1) schema.each_with_object({}) do |property, metadata| view_options = property.meta['view'] metadata[property.name.to_s] = view_options unless view_options.nil? From c61b682f91acc5b5e222d894eceadc90b43d4583 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Fri, 28 Jun 2024 11:27:37 -0700 Subject: [PATCH 070/100] Rework some partials Move _schema_version into a shared partial Call schema_version off SolrDocument --- .../hyrax/works_controller_behavior.rb | 1 + .../hyrax/dashboard/collections_controller.rb | 1 + app/controllers/hyrax/file_sets_controller.rb | 1 + app/forms/hyrax/forms/resource_form.rb | 2 - .../edit_fields/_schema_version.html.erb | 38 +------------------ app/views/hyrax/file_sets/_form.html.erb | 2 +- .../edit_fields/_schema_version.html.erb | 38 +------------------ .../_schema_version.html.erb | 10 +++-- 8 files changed, 12 insertions(+), 81 deletions(-) rename app/views/{hyrax/file_sets => shared}/_schema_version.html.erb (69%) diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index e65dd1ca32..1c197675f9 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -92,6 +92,7 @@ def show # rubocop:enable Metrics/AbcSize def edit + @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? @admin_set_options = available_admin_sets build_form end diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index 001037a232..f0b03bbecb 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -76,6 +76,7 @@ def show end def edit + @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? form end diff --git a/app/controllers/hyrax/file_sets_controller.rb b/app/controllers/hyrax/file_sets_controller.rb index 4fb3a9ded8..ffc039eff8 100644 --- a/app/controllers/hyrax/file_sets_controller.rb +++ b/app/controllers/hyrax/file_sets_controller.rb @@ -43,6 +43,7 @@ class FileSetsController < ApplicationController # GET /concern/file_sets/:id def edit + @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? initialize_edit_form end diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index 48fa476b99..bd0ca90f87 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -168,8 +168,6 @@ def schema Definition::Each.new(singleton_class.definitions) end - delegate :schema_version, to: :resource - private # OVERRIDE valkyrie 3.0.1 to make schema dynamic diff --git a/app/views/collections/edit_fields/_schema_version.html.erb b/app/views/collections/edit_fields/_schema_version.html.erb index 55469b31dd..b51622b589 100644 --- a/app/views/collections/edit_fields/_schema_version.html.erb +++ b/app/views/collections/edit_fields/_schema_version.html.erb @@ -1,37 +1 @@ -<% if Hyrax.config.flexible? %> - <% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> -
- <% if f.object.schema_version.present? %> -
- Created On Version -

<%= f.object.schema_version.to_f %>

-
- <% end %> -
- Version After Save -

<%= Hyrax::FlexibleSchema.last.id.to_f %>

-
-
- - -<% end %> +<%= render('shared/schema_version', f: f) if Hyrax.config.flexible? %> diff --git a/app/views/hyrax/file_sets/_form.html.erb b/app/views/hyrax/file_sets/_form.html.erb index 31b03177f9..fac8ccfd01 100644 --- a/app/views/hyrax/file_sets/_form.html.erb +++ b/app/views/hyrax/file_sets/_form.html.erb @@ -1,5 +1,5 @@ <%= simple_form_for [main_app, curation_concern], html: { multipart: true, class: 'nav-safety' } do |f| %> - <%= render('schema_version', f: f) if Hyrax.config.flexible? %> + <%= render('shared/schema_version', f: f) if Hyrax.config.flexible? %>
<%= label_tag 'file_set[title][]', t('.title'), class: "string optional" %> diff --git a/app/views/records/edit_fields/_schema_version.html.erb b/app/views/records/edit_fields/_schema_version.html.erb index 55469b31dd..b51622b589 100644 --- a/app/views/records/edit_fields/_schema_version.html.erb +++ b/app/views/records/edit_fields/_schema_version.html.erb @@ -1,37 +1 @@ -<% if Hyrax.config.flexible? %> - <% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> -
- <% if f.object.schema_version.present? %> -
- Created On Version -

<%= f.object.schema_version.to_f %>

-
- <% end %> -
- Version After Save -

<%= Hyrax::FlexibleSchema.last.id.to_f %>

-
-
- - -<% end %> +<%= render('shared/schema_version', f: f) if Hyrax.config.flexible? %> diff --git a/app/views/hyrax/file_sets/_schema_version.html.erb b/app/views/shared/_schema_version.html.erb similarity index 69% rename from app/views/hyrax/file_sets/_schema_version.html.erb rename to app/views/shared/_schema_version.html.erb index 8ae0907b33..570bb2a5cb 100644 --- a/app/views/hyrax/file_sets/_schema_version.html.erb +++ b/app/views/shared/_schema_version.html.erb @@ -1,14 +1,16 @@ -<% updating = (f.object.schema_version.to_f < Hyrax::FlexibleSchema.last.id.to_f) ? 'updating' : '' %> +<% schema_version = SolrDocument.find(f.object.id).schema_version %> +<% updating = (schema_version.to_f < @latest_schema_version) ? 'updating' : '' %> +
- <% if f.object.schema_version.present? %> + <% if schema_version.present? %>
Created On Version -

<%= f.object.schema_version.to_f %>

+

<%= schema_version.to_f %>

<% end %>
Version After Save -

<%= Hyrax::FlexibleSchema.last.id.to_f %>

+

<%= @latest_schema_version %>

From a80636646fcaa036422e4873f47e4b8397d4d786 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Fri, 28 Jun 2024 13:09:16 -0700 Subject: [PATCH 071/100] Change #last.id to #current_schema_id --- app/controllers/concerns/hyrax/works_controller_behavior.rb | 2 +- app/controllers/hyrax/dashboard/collections_controller.rb | 2 +- app/controllers/hyrax/file_sets_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 1c197675f9..02c208f058 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -92,7 +92,7 @@ def show # rubocop:enable Metrics/AbcSize def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? + @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? @admin_set_options = available_admin_sets build_form end diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index f0b03bbecb..a37f856905 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -76,7 +76,7 @@ def show end def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? + @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? form end diff --git a/app/controllers/hyrax/file_sets_controller.rb b/app/controllers/hyrax/file_sets_controller.rb index ffc039eff8..65a2c8e058 100644 --- a/app/controllers/hyrax/file_sets_controller.rb +++ b/app/controllers/hyrax/file_sets_controller.rb @@ -43,7 +43,7 @@ class FileSetsController < ApplicationController # GET /concern/file_sets/:id def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.last.id.to_f if Hyrax.config.flexible? + @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? initialize_edit_form end From 826fa677cc73b03c3a70d21501abf8d4f3993914 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 28 Jun 2024 17:36:00 -0400 Subject: [PATCH 072/100] M3 metadata_profiles Add view details. Try to standardize all 3, with only necessary differences. --- .../config/metadata_profiles/m3_profile.yaml | 211 +++++++---- .../config/metadata_profiles/m3_profile.yaml | 50 ++- config/metadata_profiles/m3_profile.yaml | 357 +++++++++++++++--- 3 files changed, 479 insertions(+), 139 deletions(-) diff --git a/.dassie/config/metadata_profiles/m3_profile.yaml b/.dassie/config/metadata_profiles/m3_profile.yaml index c604814d24..fcbe80c7fd 100644 --- a/.dassie/config/metadata_profiles/m3_profile.yaml +++ b/.dassie/config/metadata_profiles/m3_profile.yaml @@ -4,7 +4,7 @@ profile: date_modified: '2024-06-01' responsibility: https://samvera.org responsibility_statement: Hyrax Initial Profile - type: + type: Initial Profile version: 1 classes: GenericWork: @@ -25,6 +25,8 @@ classes: display_label: PcdmCollection Hyrax::FileSet: display_label: FileSet + Hyrax::PcdmCollection: + display_label: PcdmCollection contexts: flexible_context: display_label: Flexible Metadata Example @@ -50,6 +52,7 @@ properties: - GenericWorkResource - Wings(Hyrax::Resource) - GenericWork + - Monograph cardinality: minimum: 1 multi_value: true @@ -58,15 +61,14 @@ properties: sources: - 'null' definition: - default: Enter a standardized title for display. If only one - title is needed, transcribe the title from the source - itself. + default: Enter a standardized title for display. If only one title is needed, + transcribe the title from the source itself. display_label: default: Title index_documentation: displayable, searchable indexing: - - 'title_sim' - - 'title_tesim' + - title_sim + - title_tesim form: required: true primary: true @@ -91,6 +93,7 @@ properties: - GenericWorkResource - Wings(Hyrax::Resource) - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 @@ -100,7 +103,17 @@ properties: property_uri: http://purl.org/dc/terms/modified range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + label: + de: 'Zuletzt geändert' + en: 'Last modified' + es: 'Última modificación' + fr: 'Dernière modification' + it: 'Ultima modifica' + pt-BR: 'Última modificação' + zh: '最新修改' + html_dl: true date_uploaded: available_on: class: @@ -111,6 +124,7 @@ properties: - GenericWorkResource - Wings(Hyrax::Resource) - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 @@ -120,7 +134,7 @@ properties: property_uri: http://purl.org/dc/terms/dateSubmitted range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' depositor: available_on: class: @@ -131,6 +145,7 @@ properties: - GenericWorkResource - Wings(Hyrax::Resource) - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 @@ -143,7 +158,7 @@ properties: default: Depositor index_documentation: searchable indexing: - - 'depositor_tesim' + - depositor_tesim property_uri: http://id.loc.gov/vocabulary/relators/dpt range: http://www.w3.org/2001/XMLSchema#string sample_values: @@ -151,6 +166,8 @@ properties: creator: available_on: class: + - AdminSet + - AdminSetResource - Hyrax::FileSet - CollectionResource - GenericWorkResource @@ -168,8 +185,8 @@ properties: default: Creator index_documentation: displayable, searchable indexing: - - 'creator_sim' - - 'creator_tesim' + - creator_sim + - creator_tesim form: required: true primary: true @@ -177,6 +194,9 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + render_as: "faceted" + html_dl: true license: available_on: class: @@ -197,14 +217,17 @@ properties: default: License index_documentation: displayable, searchable indexing: - - 'license_sim' - - 'license_tesim' + - license_sim + - license_tesim form: primary: false property_uri: http://purl.org/dc/terms/license range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://creativecommons.org/licenses/by/3.0/us/ + view: + render_as: "external_link" + html_dl: true abstract: available_on: class: @@ -225,14 +248,16 @@ properties: default: Abstract index_documentation: displayable, searchable indexing: - - 'abstract_sim' - - 'abstract_tesim' + - abstract_sim + - abstract_tesim form: primary: false property_uri: http://purl.org/dc/terms/abstract range: http://www.w3.org/2001/XMLSchema#string sample_values: - This is an abstract. + view: + html_dl: true access_right: available_on: class: @@ -252,17 +277,21 @@ properties: default: Access Right index_documentation: displayable, searchable indexing: - - 'access_right_sim' - - 'access_right_tesim' + - access_right_sim + - access_right_tesim form: primary: false property_uri: http://purl.org/dc/terms/accessRights range: http://www.w3.org/2001/XMLSchema#string sample_values: - Open Access + view: + html_dl: true alternative_title: available_on: class: + - AdminSet + - AdminSetResource - CollectionResource - GenericWorkResource - Wings(Hyrax::Resource) @@ -279,14 +308,19 @@ properties: default: Alternative Title index_documentation: displayable, searchable indexing: - - 'alternative_title_sim' - - 'alternative_title_tesim' + - alternative_title_sim + - alternative_title_tesim form: primary: false property_uri: http://purl.org/dc/terms/alternative range: http://www.w3.org/2001/XMLSchema#string sample_values: - Alternate Title Example + view: + label: + en: 'Alternative Title' + es: 'Título Alternativo' + html_dl: true arkivo_checksum: available_on: class: @@ -331,14 +365,17 @@ properties: default: Location index_documentation: displayable, searchable indexing: - - 'based_near_sim' - - 'based_near_tesim' + - based_near_sim + - based_near_tesim form: primary: false property_uri: http://xmlns.com/foaf/0.1/based_near range: http://www.w3.org/2001/XMLSchema#string sample_values: - San Diego, California, United States + view: + label: Based Near + html_dl: true bibliographic_citation: available_on: class: @@ -358,14 +395,16 @@ properties: default: Bibliographic Citation index_documentation: displayable, searchable indexing: - - 'bibliographic_citation_sim' - - 'bibliographic_citation_tesim' + - bibliographic_citation_sim + - bibliographic_citation_tesim form: primary: false property_uri: http://purl.org/dc/terms/bibliographicCitation range: http://www.w3.org/2001/XMLSchema#string sample_values: - - "Doe, J. (2024). Example Citation. Journal of Examples, 12(3), 45-67." + - Doe, J. (2024). Example Citation. Journal of Examples, 12(3), 45-67. + view: + html_dl: true contributor: available_on: class: @@ -386,14 +425,17 @@ properties: default: Contributor index_documentation: displayable, searchable indexing: - - 'contributor_tesim' - - 'contributor_sim' + - contributor_tesim + - contributor_sim form: primary: false property_uri: http://purl.org/dc/elements/1.1/contributor range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + render_as: "faceted" + html_dl: true date_created: available_on: class: @@ -414,18 +456,23 @@ properties: default: Date Created index_documentation: displayable, searchable indexing: - - 'date_created_sim' - - 'date_created_tesim' + - date_created_sim + - date_created_tesim form: primary: false property_uri: http://purl.org/dc/terms/created range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + render_as: "linked" + search_field: 'date_created_tesim' + html_dl: true description: available_on: class: + - AdminSet + - AdminSetResource - Hyrax::FileSet - CollectionResource - GenericWorkResource @@ -443,8 +490,8 @@ properties: default: Description index_documentation: displayable, searchable indexing: - - 'description_sim' - - 'description_tesim' + - description_sim + - description_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/description @@ -471,14 +518,18 @@ properties: default: Identifier index_documentation: displayable, searchable indexing: - - 'identifier_sim' - - 'identifier_tesim' + - identifier_sim + - identifier_tesim form: primary: false property_uri: http://purl.org/dc/terms/identifier range: http://www.w3.org/2001/XMLSchema#string sample_values: - abc123 + view: + render_as: "linked" + search_field: 'identifier_tesim' + html_dl: true import_url: available_on: class: @@ -521,8 +572,8 @@ properties: default: Keyword index_documentation: displayable, searchable indexing: - - 'keyword_sim' - - 'keyword_tesim' + - keyword_sim + - keyword_tesim form: primary: false property_uri: http://schema.org/keywords @@ -530,6 +581,9 @@ properties: sample_values: - Metadata - Repository + view: + render_as: "faceted" + html_dl: true label: available_on: class: @@ -551,8 +605,8 @@ properties: default: Label index_documentation: displayable, searchable indexing: - - 'label_sim' - - 'label_tesim' + - label_sim + - label_tesim form: primary: false property_uri: info:fedora/fedora-system:def/model#downloadFilename @@ -579,8 +633,8 @@ properties: default: Language index_documentation: displayable, searchable indexing: - - 'language_sim' - - 'language_tesim' + - language_sim + - language_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/language @@ -588,6 +642,9 @@ properties: sample_values: - English - Spanish + view: + render_as: "faceted" + html_dl: true publisher: available_on: class: @@ -608,14 +665,17 @@ properties: default: Publisher index_documentation: displayable, searchable indexing: - - 'publisher_sim' - - 'publisher_tesim' + - publisher_sim + - publisher_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/publisher range: http://www.w3.org/2001/XMLSchema#string sample_values: - Scholastic + view: + render_as: "faceted" + html_dl: true related_url: available_on: class: @@ -636,14 +696,17 @@ properties: default: Related URL index_documentation: displayable, searchable indexing: - - 'related_url_sim' - - 'related_url_tesim' + - related_url_sim + - related_url_tesim form: primary: false property_uri: http://www.w3.org/2000/01/rdf-schema#seeAlso range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://example.com/resource1 + view: + render_as: "external_link" + html_dl: true relative_path: available_on: class: @@ -666,7 +729,7 @@ properties: property_uri: http://scholarsphere.psu.edu/ns#relativePath range: http://www.w3.org/2001/XMLSchema#string sample_values: - - /path/to/resource + - "/path/to/resource" resource_type: available_on: class: @@ -687,8 +750,8 @@ properties: default: Resource Type index_documentation: displayable, searchable indexing: - - 'resource_type_sim' - - 'resource_type_tesim' + - resource_type_sim + - resource_type_tesim form: primary: false property_uri: http://purl.org/dc/terms/type @@ -696,6 +759,9 @@ properties: sample_values: - Article - Conference Proceeding + view: + render_as: "faceted" + html_dl: true rights_notes: available_on: class: @@ -716,14 +782,16 @@ properties: default: Rights Notes index_documentation: displayable, searchable indexing: - - 'rights_notes_sim' - - 'rights_notes_tesim' + - rights_notes_sim + - rights_notes_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - Creative Commons license. + view: + html_dl: true rights_statement: available_on: class: @@ -744,14 +812,17 @@ properties: default: Rights Statement index_documentation: displayable, searchable indexing: - - 'rights_statement_sim' - - 'rights_statement_tesim' + - rights_statement_sim + - rights_statement_tesim form: primary: true property_uri: http://www.europeana.eu/schemas/edm/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://rightsstatements.org/vocab/InC/1.0/ + view: + html_dl: true + render_as: "rights_statement" source: available_on: class: @@ -772,8 +843,8 @@ properties: default: Source index_documentation: displayable, searchable indexing: - - 'source_sim' - - 'source_tesim' + - source_sim + - source_tesim form: primary: false property_uri: http://purl.org/dc/terms/source @@ -781,6 +852,8 @@ properties: sample_values: - Original Manuscript - Digital Archive + view: + html_dl: true subject: available_on: class: @@ -801,8 +874,8 @@ properties: default: Subject index_documentation: displayable, searchable indexing: - - 'subject_sim' - - 'subject_tesim' + - subject_sim + - subject_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/subject @@ -810,10 +883,14 @@ properties: sample_values: - Art - Science + view: + render_as: "faceted" + html_dl: true target_audience: available_on: class: - CollectionResource + - Monograph cardinality: minimum: 0 multi_value: true @@ -906,7 +983,7 @@ properties: default: Record Info index_documentation: searchable indexing: - - 'record_info_tesim' + - record_info_tesim form: required: true primary: true @@ -976,26 +1053,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Example Series Title - target_audience: - available_on: - class: - - Monograph - cardinality: - minimum: 0 - multi_value: true - controlled_values: - format: http://www.w3.org/2001/XMLSchema#string - sources: - - 'null' - display_label: - default: Target Audience - form: - multiple: true - property_uri: http://hyrax-example.com/target_audience - range: http://www.w3.org/2001/XMLSchema#string - sample_values: - - Researchers - - Students table_of_contents: available_on: class: @@ -1033,4 +1090,4 @@ properties: property_uri: http://hyrax-example.com/date_of_issuance range: http://www.w3.org/2001/XMLSchema#string sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' diff --git a/.koppie/config/metadata_profiles/m3_profile.yaml b/.koppie/config/metadata_profiles/m3_profile.yaml index 63a6ae3359..00a7f6242c 100644 --- a/.koppie/config/metadata_profiles/m3_profile.yaml +++ b/.koppie/config/metadata_profiles/m3_profile.yaml @@ -4,7 +4,7 @@ profile: date_modified: '2024-06-01' responsibility: https://samvera.org responsibility_statement: Hyrax Initial Profile - type: Flexible with Views + type: Initial Profile version: 1 classes: GenericWork: @@ -17,6 +17,8 @@ classes: display_label: PcdmCollection Hyrax::FileSet: display_label: FileSet + Hyrax::PcdmCollection: + display_label: PcdmCollection contexts: flexible_context: display_label: Flexible Metadata Example @@ -39,6 +41,7 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork + - Monograph cardinality: minimum: 1 multi_value: true @@ -81,6 +84,7 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 @@ -92,7 +96,14 @@ properties: sample_values: - '2024-06-06 21:06:51 +0000' view: - label: Date Modified + label: + de: 'Zuletzt geändert' + en: 'Last modified' + es: 'Última modificación' + fr: 'Dernière modification' + it: 'Ultima modifica' + pt-BR: 'Última modificação' + zh: '最新修改' html_dl: true date_uploaded: available_on: @@ -111,8 +122,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - '2024-06-06 21:06:51 +0000' - view: - html_dl: true depositor: available_on: class: @@ -120,6 +129,7 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 @@ -137,11 +147,10 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson - view: - html_dl: true creator: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet - CollectionResource - GenericWork @@ -167,6 +176,7 @@ properties: sample_values: - Julie Allinson view: + render_as: "faceted" html_dl: true license: available_on: @@ -195,6 +205,7 @@ properties: sample_values: - http://creativecommons.org/licenses/by/3.0/us/ view: + render_as: "external_link" html_dl: true abstract: available_on: @@ -254,6 +265,7 @@ properties: alternative_title: available_on: class: + - Hyrax::AdministrativeSet - CollectionResource - GenericWork - Monograph @@ -277,6 +289,9 @@ properties: sample_values: - Alternate Title Example view: + label: + en: 'Alternative Title' + es: 'Título Alternativo' html_dl: true arkivo_checksum: available_on: @@ -300,8 +315,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - c0855931b7f1aefedb91d31af76873c0 - view: - html_dl: true based_near: available_on: class: @@ -329,6 +342,7 @@ properties: sample_values: - San Diego, California, United States view: + label: Based Near html_dl: true bibliographic_citation: available_on: @@ -384,6 +398,7 @@ properties: sample_values: - Julie Allinson view: + render_as: "faceted" html_dl: true date_created: available_on: @@ -412,6 +427,8 @@ properties: sample_values: - '2024-06-06 21:06:51 +0000' view: + render_as: "linked" + search_field: 'date_created_tesim' html_dl: true description: available_on: @@ -439,8 +456,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - This is a description. - view: - html_dl: true identifier: available_on: class: @@ -468,6 +483,8 @@ properties: sample_values: - abc123 view: + render_as: "linked" + search_field: 'identifier_tesim' html_dl: true import_url: available_on: @@ -489,8 +506,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://example.com/resource1 - view: - html_dl: true keyword: available_on: class: @@ -519,6 +534,7 @@ properties: - Metadata - Repository view: + render_as: "faceted" html_dl: true label: available_on: @@ -547,8 +563,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - file_label.txt - view: - html_dl: true language: available_on: class: @@ -577,6 +591,7 @@ properties: - English - Spanish view: + render_as: "faceted" html_dl: true publisher: available_on: @@ -605,6 +620,7 @@ properties: sample_values: - Scholastic view: + render_as: "faceted" html_dl: true related_url: available_on: @@ -633,6 +649,7 @@ properties: sample_values: - http://example.com/resource1 view: + render_as: "external_link" html_dl: true relative_path: available_on: @@ -655,8 +672,6 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - "/path/to/resource" - view: - html_dl: true resource_type: available_on: class: @@ -685,6 +700,7 @@ properties: - Article - Conference Proceeding view: + render_as: "faceted" html_dl: true rights_notes: available_on: @@ -742,6 +758,7 @@ properties: - http://rightsstatements.org/vocab/InC/1.0/ view: html_dl: true + render_as: "rights_statement" source: available_on: class: @@ -799,6 +816,7 @@ properties: - Art - Science view: + render_as: "faceted" html_dl: true target_audience: available_on: diff --git a/config/metadata_profiles/m3_profile.yaml b/config/metadata_profiles/m3_profile.yaml index 9c77360ae6..206207d61c 100644 --- a/config/metadata_profiles/m3_profile.yaml +++ b/config/metadata_profiles/m3_profile.yaml @@ -4,7 +4,7 @@ profile: date_modified: '2024-06-01' responsibility: https://samvera.org responsibility_statement: Hyrax Initial Profile - type: + type: Initial Profile version: 1 classes: Hyrax::Work: @@ -45,15 +45,14 @@ properties: sources: - 'null' definition: - default: Enter a standardized title for display. If only one - title is needed, transcribe the title from the source - itself. + default: Enter a standardized title for display. If only one title is needed, + transcribe the title from the source itself. display_label: default: Title index_documentation: displayable, searchable indexing: - - 'title_sim' - - 'title_tesim' + - title_sim + - title_tesim form: required: true primary: true @@ -84,7 +83,17 @@ properties: property_uri: http://purl.org/dc/terms/modified range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + label: + de: 'Zuletzt geändert' + en: 'Last modified' + es: 'Última modificación' + fr: 'Dernière modification' + it: 'Ultima modifica' + pt-BR: 'Última modificação' + zh: '最新修改' + html_dl: true date_uploaded: available_on: class: @@ -101,7 +110,7 @@ properties: property_uri: http://purl.org/dc/terms/dateSubmitted range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' depositor: available_on: class: @@ -121,7 +130,7 @@ properties: default: Depositor index_documentation: searchable indexing: - - 'depositor_tesim' + - depositor_tesim property_uri: http://id.loc.gov/vocabulary/relators/dpt range: http://www.w3.org/2001/XMLSchema#string sample_values: @@ -129,7 +138,10 @@ properties: creator: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 1 multi_value: true @@ -141,8 +153,8 @@ properties: default: Creator index_documentation: displayable, searchable indexing: - - 'creator_sim' - - 'creator_tesim' + - creator_sim + - creator_tesim form: required: true primary: true @@ -150,10 +162,16 @@ properties: range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + render_as: "faceted" + html_dl: true license: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -163,20 +181,27 @@ properties: - 'null' display_label: default: License - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'license_tesim' + - license_sim + - license_tesim form: required: false - primary: true + primary: false property_uri: http://purl.org/dc/terms/license range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://creativecommons.org/licenses/by/3.0/us/ + view: + render_as: "external_link" + html_dl: true abstract: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -186,17 +211,104 @@ properties: - 'null' display_label: default: Abstract - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'abstract_tesim' + - abstract_sim + - abstract_tesim + form: + primary: false property_uri: http://purl.org/dc/terms/abstract range: http://www.w3.org/2001/XMLSchema#string sample_values: - This is an abstract. + view: + html_dl: true + access_right: + available_on: + class: + - Hyrax::AdministrativeSet + - Hyrax::PcdmCollection + - Hyrax::Work + cardinality: + minimum: 0 + multi_value: true + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Access Right + index_documentation: displayable, searchable + indexing: + - access_right_sim + - access_right_tesim + form: + primary: false + property_uri: http://purl.org/dc/terms/accessRights + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - Open Access + view: + html_dl: true + alternative_title: + available_on: + class: + - Hyrax::AdministrativeSet + - Hyrax::PcdmCollection + - Hyrax::Work + cardinality: + minimum: 0 + multi_value: true + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Alternative Title + index_documentation: displayable, searchable + indexing: + - alternative_title_sim + - alternative_title_tesim + form: + primary: false + property_uri: http://purl.org/dc/terms/alternative + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - Alternate Title Example + view: + label: + en: 'Alternative Title' + es: 'Título Alternativo' + html_dl: true + arkivo_checksum: + available_on: + class: + - Hyrax::AdministrativeSet + - Hyrax::PcdmCollection + - Hyrax::Work + cardinality: + minimum: 0 + maximum: 1 + multi_value: false + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Arkivo Checksum + form: + primary: false + property_uri: http://scholarsphere.psu.edu/ns#arkivoChecksum + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - c0855931b7f1aefedb91d31af76873c0 based_near: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -208,18 +320,51 @@ properties: default: Location index_documentation: displayable, searchable indexing: - - 'based_near_sim' - - 'based_near_tesim' + - based_near_sim + - based_near_tesim form: primary: false property_uri: http://xmlns.com/foaf/0.1/based_near range: http://www.w3.org/2001/XMLSchema#string sample_values: - San Diego, California, United States + view: + label: Based Near + html_dl: true + bibliographic_citation: + available_on: + class: + - Hyrax::AdministrativeSet + - Hyrax::PcdmCollection + - Hyrax::Work + cardinality: + minimum: 0 + multi_value: true + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Bibliographic Citation + index_documentation: displayable, searchable + indexing: + - bibliographic_citation_sim + - bibliographic_citation_tesim + form: + primary: false + property_uri: http://purl.org/dc/terms/bibliographicCitation + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - Doe, J. (2024). Example Citation. Journal of Examples, 12(3), 45-67. + view: + html_dl: true contributor: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -229,19 +374,26 @@ properties: - 'null' display_label: default: Contributor - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'contributor_tesim' + - contributor_tesim + - contributor_sim form: primary: false property_uri: http://purl.org/dc/elements/1.1/contributor range: http://www.w3.org/2001/XMLSchema#string sample_values: - Julie Allinson + view: + render_as: "faceted" + html_dl: true date_created: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -251,19 +403,27 @@ properties: - 'null' display_label: default: Date Created - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'date_created_tesim' + - date_created_sim + - date_created_tesim form: primary: false property_uri: http://purl.org/dc/terms/created range: http://www.w3.org/2001/XMLSchema#dateTime sample_values: - - "2024-06-06 21:06:51 +0000" + - '2024-06-06 21:06:51 +0000' + view: + render_as: "linked" + search_field: 'date_created_tesim' + html_dl: true description: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -273,9 +433,10 @@ properties: - 'null' display_label: default: Description - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'description_tesim' + - description_sim + - description_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/description @@ -285,7 +446,10 @@ properties: identifier: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -295,19 +459,47 @@ properties: - 'null' display_label: default: Identifier - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'identifier_tesim' + - identifier_sim + - identifier_tesim form: primary: false property_uri: http://purl.org/dc/terms/identifier range: http://www.w3.org/2001/XMLSchema#string sample_values: - abc123 + view: + render_as: "linked" + search_field: 'identifier_tesim' + html_dl: true + import_url: + available_on: + class: + - Hyrax::AdministrativeSet + - Hyrax::PcdmCollection + - Hyrax::Work + cardinality: + minimum: 0 + maximum: 1 + multi_value: false + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Import URL + property_uri: http://scholarsphere.psu.edu/ns#importUrl + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - http://example.com/resource1 keyword: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -319,8 +511,8 @@ properties: default: Keyword index_documentation: displayable, searchable indexing: - - 'keyword_sim' - - 'keyword_tesim' + - keyword_sim + - keyword_tesim form: primary: false property_uri: http://schema.org/keywords @@ -328,6 +520,9 @@ properties: sample_values: - Metadata - Repository + view: + render_as: "faceted" + html_dl: true label: available_on: class: @@ -342,6 +537,12 @@ properties: - 'null' display_label: default: Label + index_documentation: displayable, searchable + indexing: + - label_sim + - label_tesim + form: + primary: false property_uri: info:fedora/fedora-system:def/model#downloadFilename range: http://www.w3.org/2001/XMLSchema#string sample_values: @@ -349,7 +550,10 @@ properties: language: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -359,9 +563,10 @@ properties: - 'null' display_label: default: Language + index_documentation: displayable, searchable indexing: - - 'language_tesim' - index_documentation: searchable + - language_sim + - language_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/language @@ -369,10 +574,16 @@ properties: sample_values: - English - Spanish + view: + render_as: "faceted" + html_dl: true publisher: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -382,19 +593,26 @@ properties: - 'null' display_label: default: Publisher + index_documentation: displayable, searchable indexing: - - 'publisher_tesim' - index_documentation: searchable + - publisher_sim + - publisher_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/publisher range: http://www.w3.org/2001/XMLSchema#string sample_values: - Scholastic + view: + render_as: "faceted" + html_dl: true related_url: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -404,19 +622,26 @@ properties: - 'null' display_label: default: Related URL - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'related_url_tesim' + - related_url_sim + - related_url_tesim form: primary: false property_uri: http://www.w3.org/2000/01/rdf-schema#seeAlso range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://example.com/resource1 + view: + render_as: "external_link" + html_dl: true relative_path: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 maximum: 1 @@ -430,11 +655,14 @@ properties: property_uri: http://scholarsphere.psu.edu/ns#relativePath range: http://www.w3.org/2001/XMLSchema#string sample_values: - - /path/to/resource + - '/path/to/resource' resource_type: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -446,17 +674,25 @@ properties: default: Resource Type index_documentation: displayable, searchable indexing: - - 'resource_type_sim' - - 'resource_type_tesim' + - resource_type_sim + - resource_type_tesim + form: + primary: false property_uri: http://purl.org/dc/terms/type range: http://www.w3.org/2001/XMLSchema#string sample_values: - Article - Conference Proceeding + view: + render_as: "faceted" + html_dl: true rights_notes: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -466,17 +702,25 @@ properties: - 'null' display_label: default: Rights Notes + index_documentation: displayable, searchable indexing: - - 'rights_notes_tesim' - index_documentation: searchable + - rights_notes_sim + - rights_notes_tesim + form: + primary: false property_uri: http://purl.org/dc/elements/1.1/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - Creative Commons license. + view: + html_dl: true rights_statement: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -486,17 +730,26 @@ properties: - 'null' display_label: default: Rights Statement - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'rights_statement_tesim' + - rights_statement_sim + - rights_statement_tesim + form: + primary: true property_uri: http://www.europeana.eu/schemas/edm/rights range: http://www.w3.org/2001/XMLSchema#string sample_values: - http://rightsstatements.org/vocab/InC/1.0/ + view: + html_dl: true + render_as: "rights_statement" source: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -506,18 +759,26 @@ properties: - 'null' display_label: default: Source - index_documentation: searchable + index_documentation: displayable, searchable indexing: - - 'source_tesim' + - source_sim + - source_tesim + form: + primary: false property_uri: http://purl.org/dc/terms/source range: http://www.w3.org/2001/XMLSchema#string sample_values: - Original Manuscript - Digital Archive + view: + html_dl: true subject: available_on: class: + - Hyrax::AdministrativeSet - Hyrax::FileSet + - Hyrax::PcdmCollection + - Hyrax::Work cardinality: minimum: 0 multi_value: true @@ -529,8 +790,8 @@ properties: default: Subject index_documentation: displayable, searchable indexing: - - 'subject_sim' - - 'subject_tesim' + - subject_sim + - subject_tesim form: primary: false property_uri: http://purl.org/dc/elements/1.1/subject @@ -538,3 +799,7 @@ properties: sample_values: - Art - Science + view: + render_as: "faceted" + html_dl: true + \ No newline at end of file From 1348710aff2d97200270077de9171fc9634a0b89 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 28 Jun 2024 15:04:21 -0700 Subject: [PATCH 073/100] =?UTF-8?q?=F0=9F=A7=B9=20[i41]-=20unable=20to=20c?= =?UTF-8?q?reate=20a=20work=20without=20HYRAX=5FFLEXIBLE=20true?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit should fix the reason why we weren't able create works when starting the app without HYRAX_FLEXIBLE. Issue: - https://github.com/scientist-softserv/amigos/issues/41 --- .../config/metadata_profiles/m3_profile.yaml | 1 + app/forms/hyrax/forms/resource_form.rb | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.koppie/config/metadata_profiles/m3_profile.yaml b/.koppie/config/metadata_profiles/m3_profile.yaml index 00a7f6242c..833b0e6082 100644 --- a/.koppie/config/metadata_profiles/m3_profile.yaml +++ b/.koppie/config/metadata_profiles/m3_profile.yaml @@ -112,6 +112,7 @@ properties: - Hyrax::FileSet - CollectionResource - GenericWork + - Monograph cardinality: minimum: 0 maximum: 1 diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index afda49edcc..75eb577f99 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -162,18 +162,30 @@ def display_additional_fields? # OVERRIDE disposable 0.6.3 to make schema dynamic def schema - Definition::Each.new(singleton_class.definitions) + if Hyrax.config.flexible? + Definition::Each.new(self.singleton_class.definitions) + else + super + end end private # OVERRIDE valkyrie 3.0.1 to make schema dynamic def field(field_name) - singleton_class.definitions.fetch(field_name.to_s) + if Hyrax.config.flexible? + self.singleton_class.definitions.fetch(field_name.to_s) + else + super + end end def _form_field_definitions - singleton_class.definitions + if Hyrax.config.flexible? + self.singleton_class.definitions + else + self.class.definitions + end end end end From 750e55493e3634f869125b4f215af1578bec562c Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Sun, 30 Jun 2024 07:12:30 -0700 Subject: [PATCH 074/100] Move setting @latest_schema_version to concern --- .../hyrax/flexible_schema_behavior.rb | 17 +++++ .../hyrax/works_controller_behavior.rb | 2 +- .../hyrax/dashboard/collections_controller.rb | 2 +- app/controllers/hyrax/file_sets_controller.rb | 2 +- app/views/shared/_schema_version.html.erb | 64 ++++++++++--------- 5 files changed, 53 insertions(+), 34 deletions(-) create mode 100644 app/controllers/concerns/hyrax/flexible_schema_behavior.rb diff --git a/app/controllers/concerns/hyrax/flexible_schema_behavior.rb b/app/controllers/concerns/hyrax/flexible_schema_behavior.rb new file mode 100644 index 0000000000..0f4c4afd93 --- /dev/null +++ b/app/controllers/concerns/hyrax/flexible_schema_behavior.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Hyrax + module FlexibleSchemaBehavior + extend ActiveSupport::Concern + + included do + before_action :set_latest_schema_version, only: [:edit] + end + + private + + def set_latest_schema_version + @latest_schema_version = Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? + end + end +end diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 02c208f058..bdeab896d5 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -6,6 +6,7 @@ module WorksControllerBehavior extend ActiveSupport::Concern include Blacklight::Base include Blacklight::AccessControls::Catalog + include Hyrax::FlexibleSchemaBehavior if Hyrax.config.flexible? included do with_themed_layout :decide_layout @@ -92,7 +93,6 @@ def show # rubocop:enable Metrics/AbcSize def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? @admin_set_options = available_admin_sets build_form end diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index a37f856905..a43d9f81ff 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -5,6 +5,7 @@ module Dashboard class CollectionsController < Hyrax::My::CollectionsController include Blacklight::AccessControls::Catalog include Blacklight::Base + include Hyrax::FlexibleSchemaBehavior if Hyrax.config.flexible? configure_blacklight do |config| config.search_builder_class = Hyrax::Dashboard::CollectionsSearchBuilder @@ -76,7 +77,6 @@ def show end def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? form end diff --git a/app/controllers/hyrax/file_sets_controller.rb b/app/controllers/hyrax/file_sets_controller.rb index 65a2c8e058..84a99d4d1d 100644 --- a/app/controllers/hyrax/file_sets_controller.rb +++ b/app/controllers/hyrax/file_sets_controller.rb @@ -6,6 +6,7 @@ class FileSetsController < ApplicationController include Blacklight::Base include Blacklight::AccessControls::Catalog include Hyrax::Breadcrumbs + include Hyrax::FlexibleSchemaBehavior if Hyrax.config.flexible? before_action :authenticate_user!, except: [:show, :citation, :stats] load_and_authorize_resource class: Hyrax.config.file_set_class @@ -43,7 +44,6 @@ class FileSetsController < ApplicationController # GET /concern/file_sets/:id def edit - @latest_schema_version ||= Hyrax::FlexibleSchema.current_schema_id.to_f if Hyrax.config.flexible? initialize_edit_form end diff --git a/app/views/shared/_schema_version.html.erb b/app/views/shared/_schema_version.html.erb index 570bb2a5cb..e4b489b75b 100644 --- a/app/views/shared/_schema_version.html.erb +++ b/app/views/shared/_schema_version.html.erb @@ -1,37 +1,39 @@ -<% schema_version = SolrDocument.find(f.object.id).schema_version %> -<% updating = (schema_version.to_f < @latest_schema_version) ? 'updating' : '' %> +<% if action_name == 'edit' %> + <% schema_version = SolrDocument.find(f.object.id).schema_version %> + <% updating = (schema_version.to_f < @latest_schema_version) ? 'updating' : '' %> -
- <% if schema_version.present? %> -
- Created On Version -

<%= schema_version.to_f %>

+
+ <% if schema_version.present? %> +
+ Created On Version +

<%= schema_version.to_f %>

+
+ <% end %> +
+ Version After Save +

<%= @latest_schema_version %>

- <% end %> -
- Version After Save -

<%= @latest_schema_version %>

-
- + .schema_version h4 { + font-size: 14px; + } + .schema_version span { + font-size: 10px; + } + +<% end %> From 6e1848433219c7a45c712de494a5b77c8882e35b Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Mon, 1 Jul 2024 13:04:40 -0400 Subject: [PATCH 075/100] Fix lint --- app/forms/hyrax/forms/resource_form.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index c0e7b13b10..00e9b7e963 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -166,7 +166,7 @@ def display_additional_fields? # OVERRIDE disposable 0.6.3 to make schema dynamic def schema if Hyrax.config.flexible? - Definition::Each.new(self.singleton_class.definitions) + Definition::Each.new(singleton_class.definitions) else super end @@ -177,7 +177,7 @@ def schema # OVERRIDE valkyrie 3.0.1 to make schema dynamic def field(field_name) if Hyrax.config.flexible? - self.singleton_class.definitions.fetch(field_name.to_s) + singleton_class.definitions.fetch(field_name.to_s) else super end @@ -185,7 +185,7 @@ def field(field_name) def _form_field_definitions if Hyrax.config.flexible? - self.singleton_class.definitions + singleton_class.definitions else self.class.definitions end From 377c62e35f42c7587aefd04df65470d3bb948248 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Mon, 1 Jul 2024 19:19:14 -0400 Subject: [PATCH 076/100] Display based_near_label for based_near term --- .../config/metadata_profiles/m3_profile.yaml | 1 + .../config/metadata_profiles/m3_profile.yaml | 6 +----- app/helpers/hyrax/attributes_helper.rb | 20 ++++++------------- app/views/hyrax/base/_attribute_rows.html.erb | 2 +- config/metadata/basic_metadata.yaml | 1 + config/metadata_profiles/m3_profile.yaml | 1 + 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.dassie/config/metadata_profiles/m3_profile.yaml b/.dassie/config/metadata_profiles/m3_profile.yaml index fcbe80c7fd..f8771baf05 100644 --- a/.dassie/config/metadata_profiles/m3_profile.yaml +++ b/.dassie/config/metadata_profiles/m3_profile.yaml @@ -375,6 +375,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: diff --git a/.koppie/config/metadata_profiles/m3_profile.yaml b/.koppie/config/metadata_profiles/m3_profile.yaml index 833b0e6082..bb005e59ef 100644 --- a/.koppie/config/metadata_profiles/m3_profile.yaml +++ b/.koppie/config/metadata_profiles/m3_profile.yaml @@ -72,11 +72,6 @@ properties: requirement: required sample_values: - Pencil drawn portrait study of woman - view: - label: - en: 'Title' - es: 'Título' - html_dl: true date_modified: available_on: class: @@ -344,6 +339,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index 618c765822..a60b856bab 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -16,6 +16,11 @@ def view_options_for(presenter) end end + def conform_field(field_name, options_hash) + options = HashWithIndifferentAccess.new(options_hash) + HashWithIndifferentAccess.new(options)['render_term'] || field_name + end + # @param [String] field name # @param [Hash] a nested hash of view options... {:label=>{"en"=>"Title", "es"=>"Título"}, :html_dl=>true} def conform_options(field_name, options_hash) @@ -24,7 +29,7 @@ def conform_options(field_name, options_hash) current_locale = params['locale'] || I18n.locale.to_s unless hash_of_locales.present? - options[:label] = field_to_label(field_name.to_s) + options[:label] = field_name.to_s.humanize return options end @@ -43,18 +48,5 @@ def conform_options(field_name, options_hash) options end - - private - - def field_to_label(input_string) - # Split the input string by underscores - words = input_string.downcase.split('_') - # Capitalize the first word - if words.any? - words[0] = words[0].capitalize - end - # Join the words into a single string - words.join(' ') - end end end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index ea146c7782..ba28733857 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -1,3 +1,3 @@ <% view_options_for(presenter).each do |field, options| %> - <%= presenter.attribute_to_html(field.to_sym, conform_options(field, options)) %> + <%= presenter.attribute_to_html(conform_field(field, options), conform_options(field, options)) %> <% end %> diff --git a/config/metadata/basic_metadata.yaml b/config/metadata/basic_metadata.yaml index 35f65b9562..0c15953f3a 100644 --- a/config/metadata/basic_metadata.yaml +++ b/config/metadata/basic_metadata.yaml @@ -49,6 +49,7 @@ attributes: - "based_near_tesim" predicate: http://xmlns.com/foaf/0.1/based_near view: + render_term: 'based_near_label' html_dl: true bibliographic_citation: type: string diff --git a/config/metadata_profiles/m3_profile.yaml b/config/metadata_profiles/m3_profile.yaml index 206207d61c..a0f7682a09 100644 --- a/config/metadata_profiles/m3_profile.yaml +++ b/config/metadata_profiles/m3_profile.yaml @@ -330,6 +330,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: From 42a909987d1b5c3d533a0974323c6423fee54506 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Wed, 3 Jul 2024 17:57:51 -0400 Subject: [PATCH 077/100] Rework menu option --- app/controllers/hyrax/dashboard_controller.rb | 2 +- app/models/concerns/hyrax/ability.rb | 5 ++++- .../hyrax/ability/flexible_metadata_ability.rb | 10 ++++++++++ app/views/hyrax/dashboard/sidebar/_metadata.html.erb | 11 +++++++++++ .../dashboard/sidebar/_repository_content.html.erb | 11 ----------- 5 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 app/models/concerns/hyrax/ability/flexible_metadata_ability.rb create mode 100644 app/views/hyrax/dashboard/sidebar/_metadata.html.erb diff --git a/app/controllers/hyrax/dashboard_controller.rb b/app/controllers/hyrax/dashboard_controller.rb index 4e4bef4500..01c549c86d 100644 --- a/app/controllers/hyrax/dashboard_controller.rb +++ b/app/controllers/hyrax/dashboard_controller.rb @@ -15,7 +15,7 @@ class DashboardController < ApplicationController # @example Add a custom partial to the tasks sidebar block # Hyrax::DashboardController.sidebar_partials[:tasks] << "hyrax/dashboard/sidebar/custom_task" class_attribute :sidebar_partials - self.sidebar_partials = { activity: [], configuration: [], repository_content: [], tasks: [] } + self.sidebar_partials = { activity: [], configuration: ["hyrax/dashboard/sidebar/metadata"], repository_content: [], tasks: [] } def show if can? :read, :admin_dashboard diff --git a/app/models/concerns/hyrax/ability.rb b/app/models/concerns/hyrax/ability.rb index 24ff6bb78f..b566f67333 100644 --- a/app/models/concerns/hyrax/ability.rb +++ b/app/models/concerns/hyrax/ability.rb @@ -55,6 +55,7 @@ module Ability include Hyrax::Ability::PermissionTemplateAbility include Hyrax::Ability::ResourceAbility include Hyrax::Ability::SolrDocumentAbility + include Hyrax::Ability::FlexibleMetadataAbility class_attribute :admin_group_name, :registered_group_name, :public_group_name self.admin_group_name = Hyrax.config.admin_user_group_name @@ -79,7 +80,9 @@ module Ability :permission_template_abilities, :resource_abilities, :solr_document_abilities, - :trophy_abilities] + :trophy_abilities, + :flexible_metadata_abilities + ] end # Samvera doesn't use download user/groups, so make it an alias to read diff --git a/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb b/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb new file mode 100644 index 0000000000..66e903babe --- /dev/null +++ b/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Hyrax + module Ability + module FlexibleMetadataAbility + def flexible_metadata_abilities + can :manage, Hyrax::FlexibleSchema if admin? && Hyrax.config.flexible? + end + end + end +end \ No newline at end of file diff --git a/app/views/hyrax/dashboard/sidebar/_metadata.html.erb b/app/views/hyrax/dashboard/sidebar/_metadata.html.erb new file mode 100644 index 0000000000..5e44ea4ded --- /dev/null +++ b/app/views/hyrax/dashboard/sidebar/_metadata.html.erb @@ -0,0 +1,11 @@ +<%# menu item to be inserted when using flexible metadata %> +<% if current_ability.can? :manage, Hyrax::FlexibleSchema %> + +<% end %> \ No newline at end of file diff --git a/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb b/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb index 1f35a75934..69e2ccc7b5 100644 --- a/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +++ b/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb @@ -14,15 +14,4 @@ <%= t('hyrax.admin.sidebar.works') %> <% end %> - <% if ENV.fetch('HYRAX_FLEXIBLE', false) %> - <% if current_ability.admin? %> - <%= menu.nav_link(hyrax.metadata_profiles_path, - class: "nav-link", - onclick: "dontChangeAccordion(event);", - title: t('hyrax.admin.sidebar.metadata_profiles')) do %> - <%= t('hyrax.admin.sidebar.metadata_profiles') %> - <% end %> - <% end %> - <% end %> - <%= render 'hyrax/dashboard/sidebar/menu_partials', menu: menu, section: :repository_content %> From 17f1e60f0c6d9d6339da8d8c085c6294517eed3e Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Thu, 4 Jul 2024 17:30:37 -0400 Subject: [PATCH 078/100] Rubocop --- app/models/concerns/hyrax/ability.rb | 3 +-- app/models/concerns/hyrax/ability/flexible_metadata_ability.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/hyrax/ability.rb b/app/models/concerns/hyrax/ability.rb index b566f67333..65a4e11a31 100644 --- a/app/models/concerns/hyrax/ability.rb +++ b/app/models/concerns/hyrax/ability.rb @@ -81,8 +81,7 @@ module Ability :resource_abilities, :solr_document_abilities, :trophy_abilities, - :flexible_metadata_abilities - ] + :flexible_metadata_abilities] end # Samvera doesn't use download user/groups, so make it an alias to read diff --git a/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb b/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb index 66e903babe..3c6eef3f21 100644 --- a/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb +++ b/app/models/concerns/hyrax/ability/flexible_metadata_ability.rb @@ -7,4 +7,4 @@ def flexible_metadata_abilities end end end -end \ No newline at end of file +end From 0538efd79d6576a4cc0e12bc79ad3b7db5cf37e5 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 5 Jul 2024 16:41:06 -0400 Subject: [PATCH 079/100] Define 'try' for flexible classes Fixes file set issues. --- app/models/concerns/hyrax/flexibility.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/concerns/hyrax/flexibility.rb b/app/models/concerns/hyrax/flexibility.rb index 1f96672f5b..235b920adb 100644 --- a/app/models/concerns/hyrax/flexibility.rb +++ b/app/models/concerns/hyrax/flexibility.rb @@ -8,6 +8,13 @@ module Flexibility end class_methods do + def try(term) + # This logic is necessary to handle method :try on a class + # otherwise load(attributes) tries to use the term as a schema to load and errors + return nil unless self.respond_to?(term) + self.send(term) + end + ## Override dry-struct 1.6.0 to enable redefining schemas on the fly def attributes(new_schema) keys = new_schema.keys.map { |k| k.to_s.chomp("?").to_sym } From 8d616d35ec1a1a7527f501dd830b77aa464ecbe7 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 5 Jul 2024 17:17:51 -0400 Subject: [PATCH 080/100] Add flexible schema includes for FileSet Resource & form need these lines to function correctly. --- app/forms/hyrax/forms/file_set_form.rb | 1 + app/models/hyrax/file_set.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/forms/hyrax/forms/file_set_form.rb b/app/forms/hyrax/forms/file_set_form.rb index 5c361ead8a..ee530f2fe2 100644 --- a/app/forms/hyrax/forms/file_set_form.rb +++ b/app/forms/hyrax/forms/file_set_form.rb @@ -11,6 +11,7 @@ class FileSetForm < Hyrax::Forms::ResourceForm # previous version of Hyrax, but ideally in the future this metadata will # be configurable. include Hyrax::FormFields(:file_set_metadata) unless Hyrax.config.flexible? + include Hyrax::FormFields('Hyrax::FileSet') if Hyrax.config.flexible? include Hyrax::DepositAgreementBehavior include Hyrax::ContainedInWorksBehavior diff --git a/app/models/hyrax/file_set.rb b/app/models/hyrax/file_set.rb index 1df39ca589..8c15a27579 100644 --- a/app/models/hyrax/file_set.rb +++ b/app/models/hyrax/file_set.rb @@ -51,6 +51,7 @@ module Hyrax class FileSet < Hyrax::Resource include Hyrax::Schema(:core_metadata) unless Hyrax.config.flexible? include Hyrax::Schema(:file_set_metadata) unless Hyrax.config.flexible? + include Hyrax::Schema('Hyrax::FileSet') if Hyrax.config.flexible? def self.model_name(name_class: Hyrax::Name) @_model_name ||= name_class.new(self, nil, 'FileSet') From 742354e54e84e1bed65787c4a97d718a1f201e80 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 5 Jul 2024 16:00:07 -0700 Subject: [PATCH 081/100] [i50] - Schema version number should auto increment ref: - https://github.com/scientist-softserv/amigos/issues/40 --- .../hyrax/flexible_schema_behavior.rb | 2 +- app/forms/hyrax/forms/resource_form.rb | 10 ++- app/views/shared/_schema_version.html.erb | 65 +++++++++---------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/app/controllers/concerns/hyrax/flexible_schema_behavior.rb b/app/controllers/concerns/hyrax/flexible_schema_behavior.rb index 0f4c4afd93..023c45a89d 100644 --- a/app/controllers/concerns/hyrax/flexible_schema_behavior.rb +++ b/app/controllers/concerns/hyrax/flexible_schema_behavior.rb @@ -5,7 +5,7 @@ module FlexibleSchemaBehavior extend ActiveSupport::Concern included do - before_action :set_latest_schema_version, only: [:edit] + before_action :set_latest_schema_version, only: [:new, :edit] end private diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index 00e9b7e963..ea6311823c 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -56,7 +56,8 @@ def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metri if Hyrax.config.flexible? singleton_class.instance_variable_set("@definitions", self.class.definitions) r = resource || deprecated_resource - Hyrax::Schema.default_schema_loader.form_definitions_for(schema: r.class.to_s, version: r.schema_version).map do |field_name, options| + + Hyrax::Schema.default_schema_loader.form_definitions_for(schema: r.class.to_s, version: Hyrax::FlexibleSchema.current_schema_id).map do |field_name, options| singleton_class.property field_name.to_sym, options.merge(display: options.fetch(:display, true), default: []) singleton_class.validates field_name.to_sym, presence: true if options.fetch(:required, false) end @@ -70,6 +71,13 @@ def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metri super() end else + # make a new resource with all of the existing attributes + resource = if Hyrax.config.flexible? + hash = resource.attributes.dup + hash[:schema_version] = Hyrax::FlexibleSchema.current_schema_id + resource.class.new(hash) + end + super(resource) end end # rubocop:enable Metrics/MethodLength diff --git a/app/views/shared/_schema_version.html.erb b/app/views/shared/_schema_version.html.erb index e4b489b75b..870702b9bf 100644 --- a/app/views/shared/_schema_version.html.erb +++ b/app/views/shared/_schema_version.html.erb @@ -1,39 +1,38 @@ -<% if action_name == 'edit' %> - <% schema_version = SolrDocument.find(f.object.id).schema_version %> - <% updating = (schema_version.to_f < @latest_schema_version) ? 'updating' : '' %> +<% schema_version = SolrDocument.find(f.object.id).schema_version if action_name == 'edit' %> +<% schema_version = Hyrax::FlexibleSchema.current_schema_id if action_name == 'new' %> +<% updating = (schema_version.to_f < @latest_schema_version) ? 'updating' : '' %> -
- <% if schema_version.present? %> -
- Created On Version -

<%= schema_version.to_f %>

-
- <% end %> -
- Version After Save -

<%= @latest_schema_version %>

+
+ <% if schema_version.present? %> +
+ Created On Version +

<%= schema_version.to_f %>

+ <% end %> +
+ Version After Save +

<%= @latest_schema_version %>

+
- -<% end %> + .schema_version h4 { + font-size: 14px; + } + .schema_version span { + font-size: 10px; + } + From 3ba1276bb2271a9bbb18a774c0bbf3062c03ab1d Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 5 Jul 2024 16:11:06 -0700 Subject: [PATCH 082/100] Update solr_document_behavior.rb the version from main breaks the application --- app/models/concerns/hyrax/solr_document_behavior.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb index 36523ac68e..0acbfc01f5 100644 --- a/app/models/concerns/hyrax/solr_document_behavior.rb +++ b/app/models/concerns/hyrax/solr_document_behavior.rb @@ -82,9 +82,12 @@ def valkyrie? # Method to return the model def hydra_model(classifier: nil) - model = first('has_model_ssim')&.safe_constantize - model = (first('has_model_ssim')&.+ 'Resource')&.safe_constantize if Hyrax.config.valkyrie_transition? - model || model_classifier(classifier).classifier(self).best_model + model_name = first('has_model_ssim') + valkyrie_model = "#{model_name}Resource".safe_constantize if Hyrax.config.valkyrie_transition + + valkyrie_model || + model_name&.safe_constantize || + model_classifier(classifier).classifier(self).best_model end def depositor(default = '') From 8110efecfaaa20c17a6af4d5d5b46a4375e3e0e1 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 8 Jul 2024 11:50:55 -0700 Subject: [PATCH 083/100] =?UTF-8?q?=F0=9F=A7=B9=20adds=20dynamic=20present?= =?UTF-8?q?er=20and=20reloads=20dynamic=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This committ allows the presenter to be dynamic. Before, the newly added terms would not display on the work's show page because the presenter didn't know about them. Additionally, this should fix the bug where a server restart is required when a new schema is imported. --- .../hyrax/metadata_profiles_controller.rb | 2 ++ app/forms/hyrax/forms/resource_form.rb | 2 ++ app/models/hyrax/flexible_schema.rb | 13 +++++++ .../flexible_schema_presenter_behavior.rb | 23 ++++++++++++ app/presenters/hyrax/work_show_presenter.rb | 36 ++++++++++++++++++- 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 app/presenters/hyrax/flexible_schema_presenter_behavior.rb diff --git a/app/controllers/hyrax/metadata_profiles_controller.rb b/app/controllers/hyrax/metadata_profiles_controller.rb index 3dbd305e9f..d8ff4e3a50 100644 --- a/app/controllers/hyrax/metadata_profiles_controller.rb +++ b/app/controllers/hyrax/metadata_profiles_controller.rb @@ -25,6 +25,8 @@ def import @flexible_schema = Hyrax::FlexibleSchema.create(profile: YAML.safe_load_file(uploaded_io.path)) if @flexible_schema.persisted? + # After importing the profile, reload dynamic methods + Hyrax::WorkShowPresenter.reload_dynamic_methods redirect_to metadata_profiles_path, notice: 'AllinsonFlexProfile was successfully created.' else redirect_to metadata_profiles_path, alert: @flexible_schema.errors.messages.to_s diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index ea6311823c..6a3a36c926 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -54,6 +54,8 @@ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength # match indexers. def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metrics/MethodLength if Hyrax.config.flexible? + # reload dynamic methods + Hyrax::WorkShowPresenter.reload_dynamic_methods singleton_class.instance_variable_set("@definitions", self.class.definitions) r = resource || deprecated_resource diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index 6c2b50dc74..0dc47f5251 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -10,6 +10,19 @@ def self.current_schema_id order("created_at asc").last.id end + # Retrieve the properties for the model / work type + # This is a class method called by the model at class load + # meaning AdminSet is not available and we cannot get the + # contextual dynamic_schema + # Instead we use the default (contextless) dynamic_schema + # which will add all properties available for that class + # @return [Array] property#to_sym + def self.default_properties + self.current_version['properties'].symbolize_keys!.keys + rescue StandardError => e + [] + end + def title "#{profile['profile']['responsibility_statement']} - version #{id}" end diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb new file mode 100644 index 0000000000..81fc79cd3d --- /dev/null +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Hyrax + module FlexibleSchemaPresenterBehavior + extend ActiveSupport::Concern + + included do + extend ClassMethods + end + + module ClassMethods + def delegated_properties + Hyrax::FlexibleSchema.default_properties + end + + def reload_dynamic_methods + if Hyrax.config.flexible? + Hyrax::WorkShowPresenter.new(nil, nil).define_dynamic_methods + end + end + end + end +end \ No newline at end of file diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index eaa5d32f52..34499f1035 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -3,6 +3,7 @@ module Hyrax class WorkShowPresenter include ModelProxy include PresentsAttributes + include Hyrax::FlexibleSchemaPresenterBehavior if Hyrax.config.flexible? ## # @!attribute [w] member_presenter_factory @@ -24,11 +25,44 @@ def initialize(solr_document, current_ability, request = nil) @solr_document = Hyrax::SolrDocument::OrderedMembers.decorate(solr_document) @current_ability = current_ability @request = request + define_dynamic_methods if Hyrax.config.flexible? end + def self.reload_dynamic_methods + if Hyrax.config.flexible? + self.new(nil, nil).define_dynamic_methods + end + end + + def define_dynamic_methods + Hyrax::FlexibleSchema.default_properties.each do |prop| + method_name = prop.to_s + property_details = Hyrax::FlexibleSchema.current_version["properties"][method_name] + next unless property_details + + index_keys = property_details["indexing"] + next unless index_keys + + multi_value = property_details.dig("multi_value") + + unless self.class.method_defined?(method_name) || solr_document.respond_to?(method_name) + self.class.send(:define_method, method_name) do + index_keys.each do |index_key| + value = solr_document[index_key] + return value unless value.blank? + end + multi_value ? [] : "" + end + end + end + end + + # Ensure self.class.delegate(*self.delegated_properties, to: :solr_document) is executed if Hyrax.config.flexible? + self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s - delegate :to_s, to: :solr_document + delegate :to_s, to: :solr_document unless Hyrax.config.flexible? def schema_version solr_document[:schema_version_ssi] From c9c305af3d2cab0e2c4d1eef3ccd3d202193bd97 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 8 Jul 2024 13:11:11 -0700 Subject: [PATCH 084/100] Update work_show_presenter.rb --- app/presenters/hyrax/work_show_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 34499f1035..88ee04ea67 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -58,7 +58,7 @@ def define_dynamic_methods end # Ensure self.class.delegate(*self.delegated_properties, to: :solr_document) is executed if Hyrax.config.flexible? - self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + self.class.delegate(*self.delegated_properties, :to_s, to: :solr_document) if Hyrax.config.flexible? # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From 4ae17255d8ffa36f87ab39024fae6ff10afcfb41 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 8 Jul 2024 14:28:25 -0700 Subject: [PATCH 085/100] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20revert=20breaking?= =?UTF-8?q?=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/presenters/hyrax/work_show_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 88ee04ea67..34499f1035 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -58,7 +58,7 @@ def define_dynamic_methods end # Ensure self.class.delegate(*self.delegated_properties, to: :solr_document) is executed if Hyrax.config.flexible? - self.class.delegate(*self.delegated_properties, :to_s, to: :solr_document) if Hyrax.config.flexible? + self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From 6cb3d2ab132aad280d5397ad3a4c15994e7ffd08 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 8 Jul 2024 15:20:33 -0700 Subject: [PATCH 086/100] =?UTF-8?q?=F0=9F=A7=B9=20reload=20classes=20and?= =?UTF-8?q?=20bust=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hyrax/flexible_schema_presenter_behavior.rb | 8 +++++++- app/presenters/hyrax/work_show_presenter.rb | 11 +++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb index 81fc79cd3d..1ac7ff05f5 100644 --- a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -15,9 +15,15 @@ def delegated_properties def reload_dynamic_methods if Hyrax.config.flexible? + reload_classes Hyrax::WorkShowPresenter.new(nil, nil).define_dynamic_methods end end + + def reload_classes + ActiveSupport::Dependencies.clear + Rails.application.eager_load! + end end end -end \ No newline at end of file +end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 34499f1035..56344679de 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -28,12 +28,6 @@ def initialize(solr_document, current_ability, request = nil) define_dynamic_methods if Hyrax.config.flexible? end - def self.reload_dynamic_methods - if Hyrax.config.flexible? - self.new(nil, nil).define_dynamic_methods - end - end - def define_dynamic_methods Hyrax::FlexibleSchema.default_properties.each do |prop| method_name = prop.to_s @@ -57,8 +51,9 @@ def define_dynamic_methods end end - # Ensure self.class.delegate(*self.delegated_properties, to: :solr_document) is executed if Hyrax.config.flexible? - self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + if Hyrax.config.flexible? + delegate(*delegated_properties, to: :solr_document) + end # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From 67bd29928d3344c73db05e8253b614204ea0012a Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 8 Jul 2024 15:38:06 -0700 Subject: [PATCH 087/100] # remove reload_classes method as it caused other issues --- .koppie/config/environments/development.rb | 1 + .../hyrax/flexible_schema_presenter_behavior.rb | 6 ------ app/presenters/hyrax/work_show_presenter.rb | 10 ++++------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.koppie/config/environments/development.rb b/.koppie/config/environments/development.rb index 21239d8532..570d584c3b 100644 --- a/.koppie/config/environments/development.rb +++ b/.koppie/config/environments/development.rb @@ -5,6 +5,7 @@ # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false + config.reload_classes_only_on_change = false # Do not eager load code on boot. config.eager_load = false diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb index 1ac7ff05f5..dbebb65961 100644 --- a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -15,15 +15,9 @@ def delegated_properties def reload_dynamic_methods if Hyrax.config.flexible? - reload_classes Hyrax::WorkShowPresenter.new(nil, nil).define_dynamic_methods end end - - def reload_classes - ActiveSupport::Dependencies.clear - Rails.application.eager_load! - end end end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 56344679de..f812b72b8f 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -33,12 +33,12 @@ def define_dynamic_methods method_name = prop.to_s property_details = Hyrax::FlexibleSchema.current_version["properties"][method_name] next unless property_details - + index_keys = property_details["indexing"] next unless index_keys - + multi_value = property_details.dig("multi_value") - + unless self.class.method_defined?(method_name) || solr_document.respond_to?(method_name) self.class.send(:define_method, method_name) do index_keys.each do |index_key| @@ -51,9 +51,7 @@ def define_dynamic_methods end end - if Hyrax.config.flexible? - delegate(*delegated_properties, to: :solr_document) - end + self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From 37aceed6367ea8856aa0bea6f029f4fe02d1106a Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 9 Jul 2024 13:34:20 -0700 Subject: [PATCH 088/100] =?UTF-8?q?=F0=9F=90=9B=20remove=20self.class=20fr?= =?UTF-8?q?om=20#delegate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was the reason Hyku couldn't spin up. --- app/presenters/hyrax/work_show_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index f812b72b8f..9b477f3330 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -51,7 +51,7 @@ def define_dynamic_methods end end - self.class.delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From 19e50c546218881eff6e910b83ef6681f75c69ec Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 9 Jul 2024 13:57:29 -0700 Subject: [PATCH 089/100] :gift: add #default_schema to avoid schema not found errors --- app/models/hyrax/flexible_schema.rb | 6 ++++++ app/services/hyrax/m3_schema_loader.rb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index 0dc47f5251..1fa65f3891 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -10,6 +10,12 @@ def self.current_schema_id order("created_at asc").last.id end + def self.default_schema + Hyrax::FlexibleSchema.first_or_create do |f| + f.profile = YAML.safe_load_file(Rails.root.join('config', 'metadata_profiles', 'm3_profile.yaml')) + end + end + # Retrieve the properties for the model / work type # This is a class method called by the model at class load # meaning AdminSet is not available and we cannot get the diff --git a/app/services/hyrax/m3_schema_loader.rb b/app/services/hyrax/m3_schema_loader.rb index 0274b15b46..02bf4d158a 100644 --- a/app/services/hyrax/m3_schema_loader.rb +++ b/app/services/hyrax/m3_schema_loader.rb @@ -22,7 +22,8 @@ def view_definitions_for(schema:, version: 1) # @param [#to_s] schema_name # @return [Enumerable Date: Tue, 9 Jul 2024 15:12:07 -0700 Subject: [PATCH 090/100] :gift: add #create_default_schema A default schema should be created for a tenant, automatically, when one doesn't exist. --- app/models/hyrax/flexible_schema.rb | 2 +- app/services/hyrax/m3_schema_loader.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index 1fa65f3891..f115d300e2 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -10,7 +10,7 @@ def self.current_schema_id order("created_at asc").last.id end - def self.default_schema + def self.create_default_schema Hyrax::FlexibleSchema.first_or_create do |f| f.profile = YAML.safe_load_file(Rails.root.join('config', 'metadata_profiles', 'm3_profile.yaml')) end diff --git a/app/services/hyrax/m3_schema_loader.rb b/app/services/hyrax/m3_schema_loader.rb index 02bf4d158a..afb82b8af7 100644 --- a/app/services/hyrax/m3_schema_loader.rb +++ b/app/services/hyrax/m3_schema_loader.rb @@ -22,7 +22,7 @@ def view_definitions_for(schema:, version: 1) # @param [#to_s] schema_name # @return [Enumerable Date: Wed, 10 Jul 2024 08:50:05 -0700 Subject: [PATCH 091/100] =?UTF-8?q?=F0=9F=A7=B9=20updates=20logic=20for=20?= =?UTF-8?q?#define=5Fdynamic=5Fmethods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previously incorrect logic would prevent methods from being defined properly. --- app/presenters/hyrax/work_show_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 9b477f3330..5cdf1b35b3 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -39,7 +39,7 @@ def define_dynamic_methods multi_value = property_details.dig("multi_value") - unless self.class.method_defined?(method_name) || solr_document.respond_to?(method_name) + unless self.class.method_defined?(method_name) && solr_document.respond_to?(method_name) self.class.send(:define_method, method_name) do index_keys.each do |index_key| value = solr_document[index_key] From 31ab8e312a948cfe203c6e586b8f78606d49273f Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 10 Jul 2024 12:14:45 -0700 Subject: [PATCH 092/100] make #reload_dynamic_methods an instance method --- app/controllers/hyrax/metadata_profiles_controller.rb | 2 +- app/forms/hyrax/forms/resource_form.rb | 2 +- .../hyrax/flexible_schema_presenter_behavior.rb | 8 ++++---- app/presenters/hyrax/work_show_presenter.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/hyrax/metadata_profiles_controller.rb b/app/controllers/hyrax/metadata_profiles_controller.rb index d8ff4e3a50..ba86d4b488 100644 --- a/app/controllers/hyrax/metadata_profiles_controller.rb +++ b/app/controllers/hyrax/metadata_profiles_controller.rb @@ -26,7 +26,7 @@ def import if @flexible_schema.persisted? # After importing the profile, reload dynamic methods - Hyrax::WorkShowPresenter.reload_dynamic_methods + Hyrax::WorkShowPresenter.new(nil,nil).reload_dynamic_methods redirect_to metadata_profiles_path, notice: 'AllinsonFlexProfile was successfully created.' else redirect_to metadata_profiles_path, alert: @flexible_schema.errors.messages.to_s diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index 6a3a36c926..e6bebed4d0 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -55,7 +55,7 @@ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metrics/MethodLength if Hyrax.config.flexible? # reload dynamic methods - Hyrax::WorkShowPresenter.reload_dynamic_methods + Hyrax::WorkShowPresenter.new(nil, nil).reload_dynamic_methods singleton_class.instance_variable_set("@definitions", self.class.definitions) r = resource || deprecated_resource diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb index dbebb65961..1f638ba2a5 100644 --- a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -12,11 +12,11 @@ module ClassMethods def delegated_properties Hyrax::FlexibleSchema.default_properties end + end - def reload_dynamic_methods - if Hyrax.config.flexible? - Hyrax::WorkShowPresenter.new(nil, nil).define_dynamic_methods - end + def reload_dynamic_methods + if Hyrax.config.flexible? + self.class.delegate(*self.class.delegated_properties, to: :solr_document) end end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 5cdf1b35b3..9fada72e2d 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -51,7 +51,7 @@ def define_dynamic_methods end end - delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s From d8ec85ee15dbab37da5a07f65b8a9842cdf2b728 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 10 Jul 2024 14:10:48 -0700 Subject: [PATCH 093/100] reverts changes --- .dassie/.env | 1 - .koppie/config/environments/development.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/.dassie/.env b/.dassie/.env index d0ae43e7a2..a60efa6dad 100644 --- a/.dassie/.env +++ b/.dassie/.env @@ -18,7 +18,6 @@ HYRAX_ANALYTICS=false HYRAX_ANALYTICS_PROVIDER=google HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-webapp/derivatives/ HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine -HYRAX_FLEXIBLE=true HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/ HYRAX_VALKYRIE=true IN_DOCKER=true diff --git a/.koppie/config/environments/development.rb b/.koppie/config/environments/development.rb index 570d584c3b..21239d8532 100644 --- a/.koppie/config/environments/development.rb +++ b/.koppie/config/environments/development.rb @@ -5,7 +5,6 @@ # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false - config.reload_classes_only_on_change = false # Do not eager load code on boot. config.eager_load = false From a6892885ca3c5c6e0f6f64fe134869fe7a0acdbe Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 11 Jul 2024 08:55:39 -0700 Subject: [PATCH 094/100] removr #reload_dynamic_methods --- app/controllers/hyrax/metadata_profiles_controller.rb | 2 -- app/forms/hyrax/forms/resource_form.rb | 2 -- .../hyrax/flexible_schema_presenter_behavior.rb | 6 ------ app/presenters/hyrax/work_show_presenter.rb | 10 ++++++++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/hyrax/metadata_profiles_controller.rb b/app/controllers/hyrax/metadata_profiles_controller.rb index ba86d4b488..3dbd305e9f 100644 --- a/app/controllers/hyrax/metadata_profiles_controller.rb +++ b/app/controllers/hyrax/metadata_profiles_controller.rb @@ -25,8 +25,6 @@ def import @flexible_schema = Hyrax::FlexibleSchema.create(profile: YAML.safe_load_file(uploaded_io.path)) if @flexible_schema.persisted? - # After importing the profile, reload dynamic methods - Hyrax::WorkShowPresenter.new(nil,nil).reload_dynamic_methods redirect_to metadata_profiles_path, notice: 'AllinsonFlexProfile was successfully created.' else redirect_to metadata_profiles_path, alert: @flexible_schema.errors.messages.to_s diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index e6bebed4d0..ea6311823c 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -54,8 +54,6 @@ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength # match indexers. def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metrics/MethodLength if Hyrax.config.flexible? - # reload dynamic methods - Hyrax::WorkShowPresenter.new(nil, nil).reload_dynamic_methods singleton_class.instance_variable_set("@definitions", self.class.definitions) r = resource || deprecated_resource diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb index 1f638ba2a5..b856f0af04 100644 --- a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -13,11 +13,5 @@ def delegated_properties Hyrax::FlexibleSchema.default_properties end end - - def reload_dynamic_methods - if Hyrax.config.flexible? - self.class.delegate(*self.class.delegated_properties, to: :solr_document) - end - end end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 9fada72e2d..69e755cd1b 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -40,13 +40,19 @@ def define_dynamic_methods multi_value = property_details.dig("multi_value") unless self.class.method_defined?(method_name) && solr_document.respond_to?(method_name) - self.class.send(:define_method, method_name) do + # Define the method on the SolrDocument class + Hyrax::SolrDocument::OrderedMembers.send(:define_method, method_name) do index_keys.each do |index_key| - value = solr_document[index_key] + value = self[index_key] return value unless value.blank? end multi_value ? [] : "" end + + # Define the method on the Presenter class + self.class.send(:define_method, method_name) do + @solr_document.send(method_name) + end end end end From d28971050c438251fe2295a81148144c5da9db51 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Mon, 15 Jul 2024 18:30:10 -0400 Subject: [PATCH 095/100] WIP Fix flexible schema on forms reload issue --- app/forms/hyrax/forms/resource_form.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index ea6311823c..362dd583de 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -54,7 +54,7 @@ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength # match indexers. def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metrics/MethodLength if Hyrax.config.flexible? - singleton_class.instance_variable_set("@definitions", self.class.definitions) + singleton_class.schema_definitions = self.class.definitions r = resource || deprecated_resource Hyrax::Schema.default_schema_loader.form_definitions_for(schema: r.class.to_s, version: Hyrax::FlexibleSchema.current_schema_id).map do |field_name, options| @@ -126,8 +126,19 @@ def required_fields=(fields) required_fields end - end + def schema_definitions + @definitions + end + + def schema_definitions=(values) + @definitions = values + end + + def expose_class + @expose_class = Class.new(Disposable::Expose).from(definitions.values) + end + end ## # @param [#to_s] attr # @param [Object] value @@ -174,7 +185,7 @@ def display_additional_fields? # OVERRIDE disposable 0.6.3 to make schema dynamic def schema if Hyrax.config.flexible? - Definition::Each.new(singleton_class.definitions) + Definition::Each.new(singleton_class.schema_definitions) else super end @@ -185,7 +196,7 @@ def schema # OVERRIDE valkyrie 3.0.1 to make schema dynamic def field(field_name) if Hyrax.config.flexible? - singleton_class.definitions.fetch(field_name.to_s) + singleton_class.schema_definitions.fetch(field_name.to_s) else super end @@ -193,7 +204,7 @@ def field(field_name) def _form_field_definitions if Hyrax.config.flexible? - singleton_class.definitions + singleton_class.schema_definitions else self.class.definitions end From 2c6576f9697c907a56279c1795ad287581b75be7 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 16 Jul 2024 09:29:08 -0700 Subject: [PATCH 096/100] :broom: update definitions to schema_definitions --- app/forms/hyrax/forms/resource_form.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index 362dd583de..e2301b1e11 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -109,7 +109,7 @@ def for(deprecated_resource = nil, resource: nil) ## # @return [Array] list of required field names as symbols def required_fields - definitions + schema_definitions .select { |_, definition| definition[:required] } .keys.map(&:to_sym) end @@ -120,9 +120,9 @@ def required_fields # @return [Array] list of required field names as symbols def required_fields=(fields) fields = fields.map(&:to_s) - raise(KeyError) unless fields.all? { |f| definitions.key?(f) } + raise(KeyError) unless fields.all? { |f| schema_definitions.key?(f) } - fields.each { |field| definitions[field].merge!(required: true) } + fields.each { |field| schema_definitions[field].merge!(required: true) } required_fields end @@ -136,7 +136,7 @@ def schema_definitions=(values) end def expose_class - @expose_class = Class.new(Disposable::Expose).from(definitions.values) + @expose_class = Class.new(Disposable::Expose).from(schema_definitions.values) end end ## From 7e7844106a49aaab18a3aa5c2382bca5ce73c5df Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 16 Jul 2024 11:26:43 -0700 Subject: [PATCH 097/100] :broom: [i51] - handle bad profiles Add validations for classes we know are problematic, if missing. --- app/models/hyrax/flexible_schema.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index f115d300e2..1fe3636e52 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Hyrax::FlexibleSchema < ApplicationRecord serialize :profile, coder: YAML + + validate :validate_profile_classes def self.current_version order("created_at asc").last.profile @@ -55,6 +57,24 @@ def profile_created_at private + def validate_profile_classes + required_classes = [ + Hyrax.config.collection_model, + Hyrax.config.file_set_model, + Hyrax.config.admin_set_model + ] + + if profile['classes'].blank? + errors.add(:profile, "Must specify classes") + else + missing_classes = required_classes - profile['classes'].keys + unless missing_classes.empty? + missing_classes_list = missing_classes.join(', ') + errors.add(:profile, "Must include #{missing_classes_list}") + end + end + end + def class_names return @class_names if @class_names @class_names = {} From 3e2c5e79ea8fe5cdddf910ffc4323382e2628392 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Fri, 16 Aug 2024 16:41:54 -0700 Subject: [PATCH 098/100] prevent chicken / egg problem with loading the schema before migrations have been run --- app/services/hyrax/m3_schema_loader.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/hyrax/m3_schema_loader.rb b/app/services/hyrax/m3_schema_loader.rb index afb82b8af7..a38c4debda 100644 --- a/app/services/hyrax/m3_schema_loader.rb +++ b/app/services/hyrax/m3_schema_loader.rb @@ -26,6 +26,9 @@ def definitions(schema_name, version) schema.attributes_for(schema_name).map do |name, config| AttributeDefinition.new(name, config) end + rescue ActiveRecord::StatementInvalid + Rails.logger.error "Skipping definition load for migrations to run" + [] rescue NoMethodError raise UndefinedSchemaError, "Flexible schema not found in version #{version} for #{schema_name}" end From bfd73518172252adbf4ff65bd2d43946acf3c561 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Fri, 16 Aug 2024 16:42:27 -0700 Subject: [PATCH 099/100] always show the current version of a resource, it only updates to new schema on save --- app/helpers/hyrax/attributes_helper.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index a60b856bab..c139b4098d 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -5,11 +5,8 @@ module AttributesHelper def view_options_for(presenter) model_name = presenter.model.model_name.name - # @todo: decide if views should instead be based on the work's stored version (presenter.schema_version) - # => using current means dropped terms from schema could be missing even if they exist on the work (but they'd already be missing on the edit view anyway) - # => using saved means that any view changes can't take effect unless the work(s) needing them are edited & saved if Hyrax.config.flexible? - Hyrax::Schema.default_schema_loader.view_definitions_for(schema: model_name, version: Hyrax::FlexibleSchema.current_schema_id) + Hyrax::Schema.default_schema_loader.view_definitions_for(schema: model_name, version: presenter.solr_document.schema_version) else schema = model_name.constantize.schema || (model_name + 'Resource').safe_constantize.schema Hyrax::Schema.default_schema_loader.view_definitions_for(schema:) @@ -31,7 +28,7 @@ def conform_options(field_name, options_hash) unless hash_of_locales.present? options[:label] = field_name.to_s.humanize return options - end + end return options_hash if hash_of_locales.is_a?(String) || hash_of_locales.empty? From bc14e4d7732ca197921ee9369f469f8b6f830df6 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Fri, 16 Aug 2024 16:42:45 -0700 Subject: [PATCH 100/100] handle deleting fields --- app/forms/hyrax/forms/resource_form.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index e2301b1e11..1ad2a27dac 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -56,7 +56,7 @@ def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metri if Hyrax.config.flexible? singleton_class.schema_definitions = self.class.definitions r = resource || deprecated_resource - + Hyrax::Schema.default_schema_loader.form_definitions_for(schema: r.class.to_s, version: Hyrax::FlexibleSchema.current_schema_id).map do |field_name, options| singleton_class.property field_name.to_sym, options.merge(display: options.fetch(:display, true), default: []) singleton_class.validates field_name.to_sym, presence: true if options.fetch(:required, false) @@ -72,10 +72,15 @@ def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metri end else # make a new resource with all of the existing attributes - resource = if Hyrax.config.flexible? + if Hyrax.config.flexible? hash = resource.attributes.dup hash[:schema_version] = Hyrax::FlexibleSchema.current_schema_id - resource.class.new(hash) + resource = resource.class.new(hash) + # find any fields removed by the new schema + to_remove = self.singleton_class.definitions.select {|k, v| !resource.respond_to?(k) && v.instance_variable_get("@options")[:display]} + to_remove.keys.each do |removed_field| + self.singleton_class.definitions.delete(removed_field) + end end super(resource)