Class: Hyrax::Forms::CollectionForm
- Inherits:
-
Object
- Object
- Hyrax::Forms::CollectionForm
- Includes:
- HydraEditor::Form, HydraEditor::Form::Permissions
- Defined in:
- app/forms/hyrax/forms/collection_form.rb
Overview
rubocop:disable Metrics/ClassLength
Direct Known Subclasses
Defined Under Namespace
Classes: ProxyScope
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Used by the search builder.
Class Method Summary collapse
-
.build_permitted_params ⇒ Array
This describes the parameters we are expecting to receive from the client.
Instance Method Summary collapse
- #banner_info ⇒ Object
-
#display_additional_fields? ⇒ Boolean
Do not display additional fields if there are no secondary terms.
-
#initialize(model, current_ability, repository) ⇒ CollectionForm
constructor
A new instance of CollectionForm.
- #list_child_collections ⇒ Object
- #list_parent_collections ⇒ Object
- #logo_info ⇒ Object
- #permission_template ⇒ Object
-
#primary_terms ⇒ Object
Terms that appear above the accordion.
-
#secondary_terms ⇒ Object
Terms that appear within the accordion.
-
#select_files ⇒ Hash
All FileSets in the collection, file.to_s is the key, file.id is the value.
- #thumbnail_title ⇒ Object
Constructor Details
#initialize(model, current_ability, repository) ⇒ CollectionForm
Returns a new instance of CollectionForm.
47 48 49 50 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 47 def initialize(model, current_ability, repository) super(model) @scope = ProxyScope.new(current_ability, repository, blacklight_config) end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Used by the search builder
9 10 11 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 9 def scope @scope end |
Class Method Details
.build_permitted_params ⇒ Array
This describes the parameters we are expecting to receive from the client
40 41 42 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 40 def self.build_permitted_params super + [{ based_near_attributes: [:id, :_destroy] }] end |
Instance Method Details
#banner_info ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 86 def @banner_info ||= begin # Find Banner filename = CollectionBrandingInfo.where(collection_id: id, role: "banner") = File.split(.first.local_path).last unless .empty? alttext = .first.alt_text unless .empty? file_location = .first.local_path unless .empty? relative_path = "/" + .first.local_path.split("/")[-4..-1].join("/") unless .empty? { file: , full_path: file_location, relative_path: relative_path, alttext: alttext } end end |
#display_additional_fields? ⇒ Boolean
Do not display additional fields if there are no secondary terms
115 116 117 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 115 def display_additional_fields? secondary_terms.any? end |
#list_child_collections ⇒ Object
128 129 130 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 128 def list_child_collections collection_member_service.available_member_subcollections.documents end |
#list_parent_collections ⇒ Object
124 125 126 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 124 def list_parent_collections collection.member_of_collections end |
#logo_info ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 98 def logo_info @logo_info ||= begin # Find Logo filename, alttext, linktext logos_info = CollectionBrandingInfo.where(collection_id: id, 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 |
#permission_template ⇒ Object
52 53 54 55 56 57 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 52 def @permission_template ||= begin template_model = PermissionTemplate.find_or_create_by(source_id: model.id) PermissionTemplateForm.new(template_model) end end |
#primary_terms ⇒ Object
Terms that appear above the accordion
65 66 67 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 65 def primary_terms [:title, :description] end |
#secondary_terms ⇒ Object
Terms that appear within the accordion
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 70 def secondary_terms [:alternative_title, :creator, :contributor, :keyword, :license, :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url, :resource_type] end |
#select_files ⇒ Hash
Returns All FileSets in the collection, file.to_s is the key, file.id is the value.
60 61 62 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 60 def select_files Hash[all_files_with_access] end |
#thumbnail_title ⇒ Object
119 120 121 122 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 119 def thumbnail_title return unless model.thumbnail model.thumbnail.title.first end |