-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for injection of new sections in form progress panel
This commit adds a new code seam allowing for adding new sections to the form progress panel that renders on the right side of the work form. To add a section in an application override the form_progress_sections_for helper method and make sure it gets loaded after Hyrax::HyraxHelperBehavoir (by default included in app/helpers/hyrax_helper.rb). For example: module WorksHelper def form_progress_sections_for(*) super + ["my_new_section"] end end Then add a new partial at app/views/hyrax/base/_form_progress_my_new_section.html.erb. The work form helper spec file was renamed to match the name of the module tested within.
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
# frozen_string_literal: true | ||
module Hyrax | ||
module WorkFormHelper | ||
## | ||
# This helper allows downstream applications and engines to add/remove/reorder the tabs to be | ||
# rendered on the work form. | ||
# | ||
# @example with additional tabs | ||
# Override this helper and ensure that it loads after Hyrax's helpers. | ||
# module WorksHelper | ||
# def form_tabs_for(form:) | ||
# super + ["my_new_tab"] | ||
# end | ||
# end | ||
# Add the new section partial at app/views/hyrax/base/_form_my_new_tab.html.erb | ||
# | ||
# @todo 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. | ||
# @param form [Hyrax::Forms::WorkForm] | ||
# @return [Array<String>] the list of names of tabs to be rendered in the form | ||
def form_tabs_for(form:) | ||
if form.instance_of? Hyrax::Forms::BatchUploadForm | ||
%w[files metadata relationships] | ||
else | ||
%w[metadata files relationships] | ||
end | ||
end | ||
|
||
## | ||
# 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. | ||
# | ||
# @example with additional sections | ||
# Override this helper and ensure that it loads after Hyrax's helpers. | ||
# module WorksHelper | ||
# def form_progress_sections_for(*) | ||
# super + ["my_new_section"] | ||
# end | ||
# end | ||
# Add the new section partial at app/views/hyrax/base/_form_progress_my_new_section.html.erb | ||
# | ||
# @param form [Hyrax::Forms::WorkForm] | ||
# @return [Array<String>] the list of names of sections to be rendered in the form_progress panel | ||
def form_progress_sections_for(*) | ||
[] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters