diff --git a/lib/extensions/extensions.rb b/lib/extensions/extensions.rb index 76e7e3ba..9116ce5c 100644 --- a/lib/extensions/extensions.rb +++ b/lib/extensions/extensions.rb @@ -93,7 +93,7 @@ def attribute_will_change!(attr) Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CreateWithFilesOrderedMembersActor Hyrax::Actors::BaseActor.prepend Extensions::Hyrax::Actors::BaseActor::UndoAttributeArrayWrap Hyrax::Actors::FileSetActor.prepend Extensions::Hyrax::Actors::FileSetActor::CreateContent - +Hyrax::Actors::ApplyOrderActor.prepend Extensions::Hyrax::Actors::ApplyOrderActor::AddMembersSingleSave # .jp2 conversion settings Hydra::Derivatives.kdu_compress_path = ESSI.config.dig(:essi, :kdu_compress_path) diff --git a/lib/extensions/hyrax/actors/apply_order_actor/add_members_single_save.rb b/lib/extensions/hyrax/actors/apply_order_actor/add_members_single_save.rb new file mode 100644 index 00000000..0e664ea8 --- /dev/null +++ b/lib/extensions/hyrax/actors/apply_order_actor/add_members_single_save.rb @@ -0,0 +1,22 @@ +# modified from hyrax: #save! call moved outside of loop +module Extensions + module Hyrax + module Actors + module ApplyOrderActor + module AddMembersSingleSave + def add_new_work_ids_not_already_in_curation_concern(env, ordered_member_ids) + (ordered_member_ids - env.curation_concern.ordered_member_ids).each do |work_id| + work = ::ActiveFedora::Base.find(work_id) + if can_edit_both_works?(env, work) + env.curation_concern.ordered_members << work + else + env.curation_concern.errors[:ordered_member_ids] << "Works can only be related to each other if user has ability to edit both." + end + end + env.curation_concern.save! + end + end + end + end + end +end