diff --git a/app/services/hyrax/solr_query_service_decorator.rb b/app/services/hyrax/solr_query_service_decorator.rb index e7e5d5adc..32bfc6c33 100644 --- a/app/services/hyrax/solr_query_service_decorator.rb +++ b/app/services/hyrax/solr_query_service_decorator.rb @@ -1,11 +1,11 @@ -# OVERRIDE: Hyrax 3.4.1 changes GET request to POST to allow for larger query size +# OVERRIDE: Hyrax 3.6.0 changes GET request to POST to allow for larger query size # frozen_string_literal: true module Hyrax module SolrQueryServiceDecorator - def get - solr_service.post(build) + def get(*args) + solr_service.post(build, *args) end end end diff --git a/app/services/hyrax/workflow/permission_query.rb b/app/services/hyrax/workflow/permission_query.rb index 8ac3f2ecd..d2a3d67fe 100644 --- a/app/services/hyrax/workflow/permission_query.rb +++ b/app/services/hyrax/workflow/permission_query.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# OVERRIDE Hyrax v3.4.2 Expand functionality for Groups with Roles Feature +# OVERRIDE Hyrax v3.6.0 Expand functionality for Groups with Roles Feature # @see https://github.com/samvera/hyku/wiki/Groups-with-Roles-Feature # rubocop:disable Metrics/ModuleLength module Hyrax @@ -73,7 +73,8 @@ def scope_permitted_workflow_actions_available_for_current_state(user:, entity:) # @param role [Object] that can be converted into a Sipity::Role # @return [ActiveRecord::Relation] augmented with # - def scope_agents_associated_with_entity_and_role(entity:, role:) # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/MethodLength + def scope_agents_associated_with_entity_and_role(entity:, role:) entity = Sipity::Entity(entity) role = Sipity::Role(role) @@ -196,7 +197,8 @@ def scope_processing_agents_for(user:) # # @return [ActiveRecord::Relation] # - def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + def scope_entities_for_the_user(user:, page: 1, per_page: nil, workflow_state_filter: nil) entities = Sipity::Entity.arel_table workflow_state_actions = Sipity::WorkflowStateAction.arel_table workflow_states = Sipity::WorkflowState.arel_table @@ -229,13 +231,34 @@ def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize entity_specific_where = where_builder.call(entity_responsibilities).and( entities[:id].eq(entity_responsibilities[:entity_id]) ) + entity_specific_where = filter_by_workflow_state(entity_specific_where, workflow_states, workflow_state_filter) if workflow_state_filter workflow_specific_where = where_builder.call(workflow_responsibilities) + workflow_specific_where = filter_by_workflow_state(workflow_specific_where, workflow_states, workflow_state_filter) if workflow_state_filter - Sipity::Entity.where( + result = Sipity::Entity.where( entities[:id].in(entity_specific_joins.where(entity_specific_where)) .or(entities[:id].in(workflow_specific_joins.where(workflow_specific_where))) ) + # Apply paging if provided + if per_page.nil? + result + else + result.page(page).per(per_page) + end end + + # @api private + # + # Append a filter by workflow state name to the provided where builder. + # If the filter begins with a !, it will filter to states not equal to the filter. + def filter_by_workflow_state(where_builder, workflow_states, filter) + if filter.start_with?('!') + where_builder.and(workflow_states[:name].not_eq(filter[1..-1])) + else + where_builder.and(workflow_states[:name].eq(filter)) + end + end + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength # @api public @@ -251,7 +274,8 @@ def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize # @param entity an object that can be converted into a Sipity::Entity # @return [ActiveRecord::Relation] # - def scope_users_for_entity_and_roles(entity:, roles:) # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + def scope_users_for_entity_and_roles(entity:, roles:) entity = Sipity::Entity(entity) role_ids = Array.wrap(roles).map { |role| Sipity::Role(role).id } user_polymorphic_type = ::User.base_class @@ -347,7 +371,7 @@ def scope_processing_workflow_roles_for_user_and_workflow(user:, workflow:) # @param user [User] # @param entity an object that can be converted into a Sipity::Entity # @return [ActiveRecord::Relation] - def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:) + def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:) # rubocop:disable Metrics/MethodLength entity = Sipity::Entity(entity) agent_scope = scope_processing_agents_for(user: user) @@ -386,7 +410,7 @@ def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:) # @param entity an object that can be converted into a Sipity::Entity # @return [ActiveRecord::Relation] # - def scope_permitted_entity_workflow_state_actions(user:, entity:) + def scope_permitted_entity_workflow_state_actions(user:, entity:) # rubocop:disable Metrics/MethodLength entity = Sipity::Entity(entity) workflow_state_actions = Sipity::WorkflowStateAction permissions = Sipity::WorkflowStateActionPermission @@ -446,5 +470,4 @@ def scope_workflow_actions_available_for_current_state(entity:) end end end -end -# rubocop:enable Metrics/ModuleLength +end \ No newline at end of file diff --git a/app/views/hyrax/admin/workflows/index.html.erb b/app/views/hyrax/admin/workflows/index.html.erb index 7a163562b..659b74e34 100644 --- a/app/views/hyrax/admin/workflows/index.html.erb +++ b/app/views/hyrax/admin/workflows/index.html.erb @@ -1,95 +1,70 @@ -<%# OVERRIDE: Hyrax v3.5.0 to show the user/depositor's display_name if available %> +<%# OVERRIDE: Hyrax v3.6.0 to show the user/depositor's display_name if available %> + <% provide :page_header do %> -

<%= t('.header') %>

+

<%= t('.header') %>

<% end %>
-
- -
-
-
-
-
- - - - - - - - - - - <% @status_list.each do |document| %> - - - - - - - <% end %> - -
WorkDepositorSubmission DateStatus
- <%= link_to document, [main_app, document] %> - - <%# OVERRIDE: show the user/depositor's display_name if available %> - <% user = User.find_by(email: document.depositor) %> - <%= user&.display_name.presence %> - - <%= document.date_modified %> - - <%= document.workflow_state %> -
-
-
-
-
-
-
-
-
- - - - - - - - - - - <% @published_list.each do |document| %> - - - - - - <% end %> - -
WorkDepositorSubmission DateStatus
- <%= link_to document, [main_app, document] %> - - <%# OVERRIDE: show the user/depositor's display_name if available %> - <% user = User.find_by(email: document.depositor) %> - <%= user&.display_name.presence %> - - <%= document.date_modified %> - - <%= document.workflow_state %> -
-
+
+ <%= render 'tabs' %> +
+ + <% if @response.viewing_under_review? %> + <%= I18n.t('hyrax.admin.workflows.index.works_under_review', total_count: @response.total_count).html_safe %> + <% else %> + <%= I18n.t('hyrax.admin.workflows.index.works_published', total_count: @response.total_count).html_safe %> + <% end %> + +
+
+
+
+
+ <%= form_tag hyrax.admin_workflows_path, method: :get, class: 'per_page' do %> +
+ <%= t('hyrax.dashboard.my.sr.results_per_page') %> + <%= label_tag :per_page do %> + Show <%= select_tag :per_page, options_for_select(Hyrax.config.range_for_number_of_results_to_display_per_page.map(&:to_s), h(params[:per_page])), title: "entries" %> per page + <% end %> + <%= render_hash_as_hidden_fields(search_state.params_for_search.except(:per_page, :sort, :utf8)) %> +
+ <% end %>
+

<%= t('.works_listing') %>

+ + + + + + + + + + + <% @response.docs.each do |document| %> + + + + + + + <% end %> + +
<%= t(".heading.work") %><%= t(".heading.depositor") %><%= t(".heading.submission_date") %><%= t(".heading.status") %>
+ <%= link_to document, [main_app, document] %> + + <%# OVERRIDE: show the user/depositor's display_name if available %> + <% user = User.find_by(email: document.depositor) %> + <%= user&.display_name.presence %> + + <%= document.date_modified %> + + <%= document.workflow_state %> +
+ <%= render 'hyrax/my/results_pagination' %>