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.
Instance Method Summary collapse
- #available_parent_collections(scope:) ⇒ Object
- #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.
39 40 41 42 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 39 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
8 9 10 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 8 def scope @scope end |
Instance Method Details
#available_parent_collections(scope:) ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 121 def available_parent_collections(scope:) return @available_parents if @available_parents.present? collection = Collection.find(id) colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil) @available_parents = colls.map do |col| { "id" => col.id, "title_first" => col.title.first } end @available_parents.to_json end |
#banner_info ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 77 def @banner_info ||= begin # Find Banner filename = CollectionBrandingInfo.where(collection_id: id).where(role: "banner") = File.split(.first.local_path).last 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 } end end |
#display_additional_fields? ⇒ Boolean
Do not display additional fields if there are no secondary terms
104 105 106 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 104 def display_additional_fields? secondary_terms.any? end |
#list_child_collections ⇒ Object
117 118 119 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 117 def list_child_collections collection_member_service.available_member_subcollections.documents end |
#list_parent_collections ⇒ Object
113 114 115 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 113 def list_parent_collections collection.member_of_collections end |
#logo_info ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 88 def logo_info @logo_info ||= begin # Find Logo filename, alttext, linktext logos_info = CollectionBrandingInfo.where(collection_id: id).where(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
44 45 46 47 48 49 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 44 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
57 58 59 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 57 def primary_terms [:title, :description] end |
#secondary_terms ⇒ Object
Terms that appear within the accordion
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 62 def secondary_terms [: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.
52 53 54 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 52 def select_files Hash[all_files_with_access] end |
#thumbnail_title ⇒ Object
108 109 110 111 |
# File 'app/forms/hyrax/forms/collection_form.rb', line 108 def thumbnail_title return unless model.thumbnail model.thumbnail.title.first end |