Class: Hyrax::Forms::AdministrativeSetForm

Inherits:
ResourceForm show all
Defined in:
app/forms/hyrax/forms/administrative_set_form.rb

Overview

Constant Summary collapse

AdminSetMembersPopulator =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

lambda do |**_options|
  self.member_ids =
    if model.new_record
      []
    else
      Hyrax
        .query_service
        .find_inverse_references_by(property: :admin_set_id, resource: model)
        .map(&:id)
    end
end

Constants inherited from ResourceForm

ResourceForm::LockKeyPrepopulator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResourceForm

#[]=, for, #initialize, #model_class, required_fields=

Methods inherited from ChangeSet

for

Constructor Details

This class inherits a constructor from Hyrax::Forms::ResourceForm

Class Method Details

.model_classObject



33
34
35
# File 'app/forms/hyrax/forms/administrative_set_form.rb', line 33

def model_class
  Hyrax::AdministrativeSet
end

.required_fieldsArray<Symbol>

Returns list of required field names as symbols.

Returns:

  • (Array<Symbol>)

    list of required field names as symbols



39
40
41
42
43
# File 'app/forms/hyrax/forms/administrative_set_form.rb', line 39

def required_fields
  definitions
    .select { |_, definition| definition[:required] }
    .keys.map(&:to_sym)
end

Instance Method Details

#display_additional_fields?Boolean

Returns whether there are terms to display ‘below-the-fold’.

Returns:

  • (Boolean)

    whether there are terms to display ‘below-the-fold’



65
66
67
# File 'app/forms/hyrax/forms/administrative_set_form.rb', line 65

def display_additional_fields?
  secondary_terms.any?
end

#primary_termsArray<Symbol>

Returns terms for display ‘above-the-fold’, or in the most prominent form real estate.

Returns:

  • (Array<Symbol>)

    terms for display ‘above-the-fold’, or in the most prominent form real estate



49
50
51
52
53
# File 'app/forms/hyrax/forms/administrative_set_form.rb', line 49

def primary_terms
  _form_field_definitions
    .select { |_, definition| definition[:primary] }
    .keys.map(&:to_sym)
end

#secondary_termsArray<Symbol>

Returns terms for display ‘below-the-fold’.

Returns:

  • (Array<Symbol>)

    terms for display ‘below-the-fold’



57
58
59
60
61
# File 'app/forms/hyrax/forms/administrative_set_form.rb', line 57

def secondary_terms
  _form_field_definitions
    .select { |_, definition| definition[:display] && !definition[:primary] }
    .keys.map(&:to_sym)
end