Module: Hyrax::WorkFormHelper
- Included in:
- HyraxHelperBehavior
- Defined in:
- app/helpers/hyrax/work_form_helper.rb
Instance Method Summary collapse
-
#admin_set_options ⇒ Array<Array<String, String, Hash>] options for the admin set drop down.
Array<Array<String, String, Hash>] options for the admin set drop down.
-
#embargo_release_date_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#form_file_set_select_for(parent:) ⇒ Array<Hash{String => String}>
Constructs a hash for a form ‘select`.
-
#form_progress_sections_for ⇒ Array<String>
This helper allows downstream applications and engines to add additional sections to be rendered after the visibility section in the Save Work panel on the work form.
-
#form_tab_label_for(form:, tab:) ⇒ String
This helper allows downstream applications and engines to change the label of tabs to be rendered on the work form.
-
#form_tabs_for(form:) ⇒ Array<String>
This helper allows downstream applications and engines to add/remove/reorder the tabs to be rendered on the work form.
-
#full_collections_errors(form:) ⇒ String
This helper retrieves errors based on form type.
-
#in_works_ids_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#lease_expiration_date_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#ordered_member_ids_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#visibility_after_embargo_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#visibility_after_lease_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
-
#visibility_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
Instance Method Details
#admin_set_options ⇒ Array<Array<String, String, Hash>] options for the admin set drop down.
this implementation hits database backends (solr) and is invoked from views. refactor to avoid
Returns Array<Array<String, String, Hash>] options for the admin set drop down.
8 9 10 11 12 13 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 8 def return @admin_set_options. if @admin_set_options service = Hyrax::AdminSetService.new(controller) Hyrax::AdminSetOptionsPresenter.new(service). end |
#embargo_release_date_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
148 149 150 151 152 153 154 155 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 148 def (form:) case form when Hyrax::ChangeSet form.errors[:embargo_release_date] else form.model.errors[:embargo_release_date] end end |
#form_file_set_select_for(parent:) ⇒ Array<Hash{String => String}>
Constructs a hash for a form ‘select`.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 89 def form_file_set_select_for(parent:) return parent.select_files if parent.respond_to?(:select_files) return {} unless parent.respond_to?(:member_ids) file_sets = Hyrax::PcdmMemberPresenterFactory.new(parent, nil).file_set_presenters file_sets.each_with_object({}) do |presenter, hash| hash[presenter.title_or_label] = presenter.id end end |
#form_progress_sections_for ⇒ Array<String>
This helper allows downstream applications and engines to add additional sections to be rendered after the visibility section in the Save Work panel on the work form.
78 79 80 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 78 def form_progress_sections_for(*) [] end |
#form_tab_label_for(form:, tab:) ⇒ String
This helper allows downstream applications and engines to change the label of tabs to be rendered on the work form.
59 60 61 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 59 def form_tab_label_for(form:, tab:) # rubocop:disable Lint/UnusedMethodArgument t("hyrax.works.form.tab.#{tab}") end |
#form_tabs_for(form:) ⇒ Array<String>
The share tab isn’t included because it wasn’t in guts4form. guts4form should be cleaned up so share is treated the same as other tabs and can be included below.
This helper allows downstream applications and engines to add/remove/reorder the tabs to be rendered on the work form.
32 33 34 35 36 37 38 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 32 def form_tabs_for(form:) if form.instance_of? Hyrax::Forms::BatchUploadForm %w[files metadata relationships] else %w[metadata files relationships] end end |
#full_collections_errors(form:) ⇒ String
This helper retrieves errors based on form type.
204 205 206 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 204 def full_collections_errors(form:) form.full_error(:collections) || form.full_error(:member_of_collection_ids) end |
#in_works_ids_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
106 107 108 109 110 111 112 113 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 106 def in_works_ids_errors_for(form:) case form when Hyrax::ChangeSet form.errors[:in_works_ids] else form.model.errors[:in_works_ids] end end |
#lease_expiration_date_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
176 177 178 179 180 181 182 183 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 176 def lease_expiration_date_errors_for(form:) case form when Hyrax::ChangeSet form.errors[:lease_expiration_date_errors] else form.model.errors[:lease_expiration_date_errors] end end |
#ordered_member_ids_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
120 121 122 123 124 125 126 127 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 120 def ordered_member_ids_errors_for(form:) case form when Hyrax::ChangeSet form.errors[:ordered_member_ids] else form.model.errors[:ordered_member_ids] end end |
#visibility_after_embargo_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
162 163 164 165 166 167 168 169 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 162 def (form:) case form when Hyrax::ChangeSet form.errors[:visibility_after_embargo] else form.model.errors[:visibility_after_embargo] end end |
#visibility_after_lease_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
190 191 192 193 194 195 196 197 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 190 def visibility_after_lease_errors_for(form:) case form when Hyrax::ChangeSet form.errors[:visibility_after_lease] else form.model.errors[:visibility_after_lease] end end |
#visibility_errors_for(form:) ⇒ String
This helper retrieves errors based on form type.
134 135 136 137 138 139 140 141 |
# File 'app/helpers/hyrax/work_form_helper.rb', line 134 def visibility_errors_for(form:) case form when Hyrax::ChangeSet form.errors[:visibility] else form.model.errors[:visibility] end end |