diff --git a/app/controllers/hyrax/data_sets_controller.rb b/app/controllers/hyrax/data_sets_controller.rb index 7522aeb2..a85686b4 100644 --- a/app/controllers/hyrax/data_sets_controller.rb +++ b/app/controllers/hyrax/data_sets_controller.rb @@ -14,7 +14,6 @@ class DataSetsController < DeepblueController delegate :show_presenter, to: :class before_action :assign_date_coverage, only: %i[create update] - before_action :assign_admin_set, only: %i[create update] before_action :workflow_destroy, only: [:destroy] before_action :provenance_log_update_before, only: [:update] before_action :visiblity_changed, only: [:update] @@ -85,15 +84,6 @@ def assign_date_coverage params[PARAMS_KEY]['date_coverage'] = cov_interval ? cov_interval.edtf : "" end - def assign_admin_set - admin_sets = Hyrax::AdminSetService.new(self).search_results(:deposit) - admin_sets.each do |admin_set| - if admin_set.id != "admin_set/default" - params[PARAMS_KEY]['admin_set_id'] = admin_set.id - end - end - end - # end date_coverage ## Globus diff --git a/app/presenters/hyrax/admin_set_options_presenter.rb b/app/presenters/hyrax/admin_set_options_presenter.rb deleted file mode 100644 index 31780dbc..00000000 --- a/app/presenters/hyrax/admin_set_options_presenter.rb +++ /dev/null @@ -1,79 +0,0 @@ -module Hyrax - # Presents the options for the AdminSet widget on the create/edit form - class AdminSetOptionsPresenter - def initialize(service) - @service = service - end - - # Return AdminSet selectbox options based on access type - # @param [Symbol] access :deposit, :read, or :edit - def select_options(access = :deposit) - @service.search_results(access).map do |admin_set| - [admin_set.to_s, admin_set.id, data_attributes(admin_set)] - end - end - - - def select_options_default_admin(access = :deposit) - a = [] - @service.search_results(access).each do |admin_set| - if admin_set.id == "admin_set/default" - a << [admin_set.to_s, admin_set.id, data_attributes(admin_set)] - end - end - a - end - - - def select_options_non_default_admin(access = :deposit) - a = [] - @service.search_results(access).each do |admin_set| - if admin_set.id != "admin_set/default" - a << [admin_set.to_s, admin_set.id, data_attributes(admin_set)] - end - end - a - end - - - private - - # Create a hash of HTML5 'data' attributes. These attributes are added to select_options and - # later utilized by Javascript to limit new Work options based on AdminSet selected - def data_attributes(admin_set) - # Get permission template associated with this AdminSet (if any) - permission_template = PermissionTemplate.find_by(source_id: admin_set.id) - - # Only add data attributes if permission template exists - return {} unless permission_template - attributes_for(permission_template: permission_template) - end - - # all PermissionTemplate release & visibility data attributes (if not blank or false) - def attributes_for(permission_template:) - {}.tap do |attrs| - attrs['data-sharing'] = sharing?(permission_template: permission_template) - # Either add "no-delay" (if immediate release) or a specific release date, but not both. - if permission_template.release_no_delay? - attrs['data-release-no-delay'] = true - elsif permission_template.release_date.present? - attrs['data-release-date'] = permission_template.release_date - end - attrs['data-release-before-date'] = true if permission_template.release_before_date? - attrs['data-visibility'] = permission_template.visibility if permission_template.visibility.present? - end - end - - # Does the workflow for the currently selected permission template allow sharing? - def sharing?(permission_template:) - wf = workflow(permission_template: permission_template) - return false unless wf - wf.allows_access_grant? - end - - def workflow(permission_template:) - return unless permission_template.active_workflow - Sipity::Workflow.find_by!(id: permission_template.active_workflow.id) - end - end -end diff --git a/app/views/hyrax/base/_form_relationships.html.erb b/app/views/hyrax/base/_form_relationships.html.erb deleted file mode 100644 index 524642a3..00000000 --- a/app/views/hyrax/base/_form_relationships.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% if Flipflop.assign_admin_set? %> - <%# TODO: consider `Hyrax::AdminSetOptionsPresenter.select_options_for(controller: controller)` instead %> - <% if curation_concern.class.to_s == "DataSet" %> - <%= f.input :admin_set_id, as: :select, - include_blank: false, - collection: Hyrax::AdminSetOptionsPresenter.new(Hyrax::AdminSetService.new(controller)).select_options_non_default_admin, - input_html: { class: 'form-control' } %> - <% else %> - <%= f.input :admin_set_id, as: :select, - include_blank: false, - collection: Hyrax::AdminSetOptionsPresenter.new(Hyrax::AdminSetService.new(controller)).select_options_default_admin, - input_html: { class: 'form-control' } %> - <% end %> -<% end %> - -<%= render 'form_in_works', f: f %> -<%= render 'form_member_of_collections', f: f %> -