From 6930f7fdc71d693fb049a580eb9b7fc8cbafbba4 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Fri, 13 Oct 2023 12:34:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Add=20to=20Collection=20fo?= =?UTF-8?q?r=20page=202+=20of=20works?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, when you were on page 2 of your works and selected a work to add to a collection, the query for available collections would use the page 2 as part of the collection query. This would mean the first 100 collections (default page size) that you had access to add works to were skipped. With this commit, we omit the query parameters from the works page and then query collections. Related to: - https://github.com/samvera/hyrax/pull/5972 - https://github.com/samvera/hyrax/issues/5969 - https://github.com/scientist-softserv/adventist-dl/issues/625 Co-authored-by: LaRita Robinson --- .../hyrax/my/works_controller_decorator.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/controllers/hyrax/my/works_controller_decorator.rb diff --git a/app/controllers/hyrax/my/works_controller_decorator.rb b/app/controllers/hyrax/my/works_controller_decorator.rb new file mode 100644 index 000000000..2817729e9 --- /dev/null +++ b/app/controllers/hyrax/my/works_controller_decorator.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +## +# OVERRIDE Hyrax 3.5.0; when Hyrax hits v4.0.0 we can remove this. +# @see https://github.com/samvera/hyrax/pull/5972 +module Hyrax + module My + module WorksControllerDecorator + def collection_service + cloned = clone + cloned.params = {} + Hyrax::CollectionsService.new(cloned) + end + end + end +end + +Hyrax::My::WorksController.prepend(Hyrax::My::WorksControllerDecorator)