Skip to content

Commit

Permalink
Changes for disabling Orchid
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Simpson committed Feb 19, 2024
1 parent 364be47 commit 27a1aab
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
19 changes: 19 additions & 0 deletions app/controllers/hyku_knapsack/note_form_behavior.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module HykuKnapsack
module NoteFormBehavior
extend ActiveSupport::Concern

included do
self.terms += [:note]

delegate :note, to: :model
end

class_methods do
def build_permitted_params
super.tap { |permitted_params| permitted_params << [:note] }
end
end
end
end
2 changes: 1 addition & 1 deletion app/forms/hyrax/una_open_educational_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Hyrax
class UnaOpenEducationalResourceForm < Hyrax::Forms::WorkForm
include Hyrax::DOI::DataCiteDOIFormBehavior

include HykuKnapsack::WorkForm
include Hyku::Plugin::Schema::Yaml::WorkForm
include Hyku::Plugin::Schema::Yaml::Hyrax::FormFields(:una_open_educational_resource)

self.model_class = ::UnaOpenEducationalResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def contributor_list
# TODO: Add view_context and use link_to and image_tag instead of <%== in the view
# TODO: Need to normalize ids in the work model in order for these methods to work in all cases (and stay simple)
class PersonOrOrganization < Struct.new(:display_name, :orcid, :isni, :ror, :grid, :wikidata)
include Hyrax::Orcid::OrcidHelper
#include Hyrax::Orcid::OrcidHelper

def orcid_url
"https://orcid.org/#{validate_orcid(orcid)}" if orcid.present?
Expand Down
23 changes: 23 additions & 0 deletions app/presenters/concerns/hyku_knapsack/presenter_delegatable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module HykuKnapsack
module PresenterDelegatable
extend ActiveSupport::Concern

def self.delegated_methods
raise NotImplementedError, "delegated_methods must return an array of method names"
end

included do
# Check if any other concerns have registered methods before delegating, which prevents
# concerns like Hyrax::DOI::DOIPresenterBehavior trying to register a helper `doi` method
# which is not called, as we already delegated the method and it could not be overwritten.
delegated_methods.each { |method| delegate(method, to: :solr_document) unless instance_methods.include?(method) }

# NOTE:
# I hate this being here, and wonder if it wouldn't be better to just include it on every
# presenter than needs to delegate isbn?
alias_method :isbns, :isbn if respond_to?(:delegated_methods) && delegated_methods.include?(:isbn)
end
end
end

0 comments on commit 27a1aab

Please sign in to comment.