Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESSI-1336] Resolve bugs loading dynamic schema #301

Merged
merged 5 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/extensions/allinson_flex/prepend_work_dynamic_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

module Extensions
module AllinsonFlex
module PrependWorkDynamicSchema
# @todo remove after issue is resolved within allinson_flex
# modified from allinson_flex, to resolve issue #61
def dynamic_schema
@dynamic_schema ||= ::AllinsonFlex::DynamicSchema.find_by(id: self.dynamic_schema_id) || self.dynamic_schema_service(update: true)&.dynamic_schema
end

# @todo remove after issue is resolved within allinson_flex
# method from allinson_flex, to resolve issue #63
def initialize(attributes = nil, &_block)
init_internals
attributes = attributes.dup if attributes # can't dup nil in Ruby 2.3
id = attributes && (attributes.delete(:id) || attributes.delete('id'))
@ldp_source = build_ldp_resource(id)
raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
self.dynamic_schema_id = attributes&.delete(:dynamic_schema_id)
load_allinson_flex ## This is the new part
assign_attributes(attributes) if attributes
assert_content_model
load_attached_files

yield self if block_given?
_run_initialize_callbacks
end

end
end
end
4 changes: 4 additions & 0 deletions lib/extensions/allinson_flex_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
include AllinsonFlex::AdminSetBehavior
end

Hyrax.config.registered_curation_concern_types.each do |klass|
klass.constantize.prepend Extensions::AllinsonFlex::PrependWorkDynamicSchema
end

# controllers
Hyrax::Admin::PermissionTemplatesController.prepend Extensions::AllinsonFlex::PrependPermissionTemplatesController

Expand Down