Skip to content

Commit

Permalink
Merge pull request #793 from scientist-softserv/i773-form-fix
Browse files Browse the repository at this point in the history
🐛 Remove PDF.js related fields from form
  • Loading branch information
ShanaLMoore authored Sep 15, 2023
2 parents 090d286 + bbcf03c commit 8cf3a38
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
7 changes: 7 additions & 0 deletions app/forms/hyrax/pdf_form_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ module PdfFormBehavior
extend ActiveSupport::Concern

included do
class_attribute :hidden_terms

self.terms += %i[show_pdf_viewer show_pdf_download_button]
self.hidden_terms = %i[show_pdf_viewer show_pdf_download_button]
end

def hidden?(key)
hidden_terms.include? key.to_sym
end
end
end
31 changes: 16 additions & 15 deletions app/views/records/edit_fields/_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<%# OVERRIDE: HydraEditor 5.0.5 support dynamic labels and hints for custom worktypes %>
<%# Avoid NoMethod error when rendering partial in Collection or batch edit form %>
<%# Hide unwanted fields from the form %>
<% return if f.object.try(:hidden?, key) %>
<% record = f.object.model %>
<% if f.object.multiple? key %>
<%= f.input key,
as: :multi_value,
label: label_for(term: key, record_class: record.class),
hint: hint_for(term: key, record_class: record.class),
input_html: { class: 'form-control' },
required: f.object.required?(key) %>
<% else %>
<%= f.input key,
label: label_for(term: key, record_class: record.class),
hint: hint_for(term: key, record_class: record.class),
required: f.object.required?(key) %>
<% end %>

<% record = f.object.model %>
<% if f.object.multiple? key %>
<%= f.input key,
as: :multi_value,
label: label_for(term: key, record_class: record.class),
hint: hint_for(term: key, record_class: record.class),
input_html: { class: 'form-control' },
required: f.object.required?(key) %>
<% else %>
<%= f.input key,
label: label_for(term: key, record_class: record.class),
hint: hint_for(term: key, record_class: record.class),
required: f.object.required?(key) %>
<% end %>

0 comments on commit 8cf3a38

Please sign in to comment.