Skip to content

Commit

Permalink
🐛 Remove PDF.js related fields from form
Browse files Browse the repository at this point in the history
The `show_pdf_viewer` and `show_pdf_download_button` fields were showing
up on the form so this commit will remove them.
  • Loading branch information
kirkkwang committed Sep 15, 2023
1 parent 1d4cc3d commit 5992780
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 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
30 changes: 16 additions & 14 deletions app/views/records/edit_fields/_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<%# 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 %>
<% 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 %>
<% return if f.object.try(:hidden?, key) == false %>
<% 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 5992780

Please sign in to comment.