Skip to content

Commit

Permalink
Exclude configured terms from valkyrie batch edit.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsitu committed Sep 5, 2023
1 parent 50f629e commit 26062de
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/forms/hyrax/forms/resource_batch_edit_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class ResourceBatchEditForm < Hyrax::Forms::ResourceForm
self.required_fields = []
self.model_class = Hyrax.primary_work_type

# Terms that need to exclude from batch edit
class_attribute :terms_excluded
self.terms_excluded = [:abstract, :label, :source]

# Contains a list of titles of all the works in the batch
attr_accessor :names

Expand All @@ -29,14 +33,14 @@ def terms
end

def self.terms
return Hyrax::Forms::BatchEditForm.terms if self.model_class < ActiveFedora::Base
return Hyrax::Forms::BatchEditForm.terms if model_class < ActiveFedora::Base

primary_terms = definitions.select { |_, definition| definition[:primary] }
.keys.map(&:to_sym)
secondary_terms = definitions.select { |_, definition| definition[:display] && !definition[:primary] }
.keys.map(&:to_sym)
terms_primary = definitions.select { |_, definition| definition[:primary] }
.keys.map(&:to_sym)
terms_secondary = definitions.select { |_, definition| definition[:display] && !definition[:primary] }
.keys.map(&:to_sym)

primary_terms + secondary_terms
(terms_primary + terms_secondary) - terms_excluded
end

attr_reader :batch_document_ids
Expand Down

0 comments on commit 26062de

Please sign in to comment.