Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor view dependency on AdminSetOptionsPresenter into a helper #5041

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/helpers/hyrax/work_form_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# frozen_string_literal: true
module Hyrax
module WorkFormHelper
##
# @todo this implementation hits database backends (solr) and is invoked
# from views. refactor to avoid
# @return [Array<Array<String, String, Hash>] options for the admin set drop down.
def admin_set_options
service = Hyrax::AdminSetService.new(controller)

Hyrax::AdminSetOptionsPresenter.new(service).select_options
end

##
# This helper allows downstream applications and engines to add/remove/reorder the tabs to be
# rendered on the work form.
Expand Down
3 changes: 1 addition & 2 deletions app/views/hyrax/base/_form_relationships.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<% if Flipflop.assign_admin_set? %>
<%# TODO: avoid direct dependency on AdminSetService and AdminSetOptionsPresenter in the view!! make the controller provide the options! %>
<%= f.input :admin_set_id, as: :select,
include_blank: false,
collection: Hyrax::AdminSetOptionsPresenter.new(Hyrax::AdminSetService.new(controller)).select_options,
collection: admin_set_options,
input_html: { class: 'form-control' } %>
<% end %>

Expand Down