Class: Hyrax::Forms::PcdmCollectionForm

Inherits:
Valkyrie::ChangeSet
  • Object
show all
Defined in:
app/forms/hyrax/forms/pcdm_collection_form.rb

Overview

Constant Summary collapse

BannerInfoPrepopulator =
lambda do |_options|
  self.banner_info ||= begin
    banner_info = CollectionBrandingInfo.where(collection_id: id.to_s, role: "banner")
    banner_file = File.split(banner_info.first.local_path).last unless banner_info.empty?
    alttext = banner_info.first.alt_text unless banner_info.empty?
    file_location = banner_info.first.local_path unless banner_info.empty?
    relative_path = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
    { file: banner_file, full_path: file_location, relative_path: relative_path, alttext: alttext }
  end
end
LogoInfoPrepopulator =
lambda do |_options|
  self.logo_info ||= begin
    logos_info = CollectionBrandingInfo.where(collection_id: id.to_s, role: "logo")

    logos_info.map do |logo_info|
      logo_file = File.split(logo_info.local_path).last
      relative_path = "/" + logo_info.local_path.split("/")[-4..-1].join("/")
      alttext = logo_info.alt_text
      linkurl = logo_info.target_url
      { file: logo_file, full_path: logo_info.local_path, relative_path: relative_path, alttext: alttext, linkurl: linkurl }
    end
  end
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.model_classObject



52
53
54
# File 'app/forms/hyrax/forms/pcdm_collection_form.rb', line 52

def model_class
  Hyrax::PcdmCollection
end

.required_fieldsArray<Symbol>

Returns list of required field names as symbols.

Returns:

  • (Array<Symbol>)

    list of required field names as symbols



58
59
60
61
62
# File 'app/forms/hyrax/forms/pcdm_collection_form.rb', line 58

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’



84
85
86
# File 'app/forms/hyrax/forms/pcdm_collection_form.rb', line 84

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



68
69
70
71
72
# File 'app/forms/hyrax/forms/pcdm_collection_form.rb', line 68

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’



76
77
78
79
80
# File 'app/forms/hyrax/forms/pcdm_collection_form.rb', line 76

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