Skip to content

Bug/74773 closed work packages are still considered to be part of the bucket#23302

Open
dombesz wants to merge 4 commits into
devfrom
bug/74773-closed-work-packages-are-still-considered-to-be-part-of-the-bucket
Open

Bug/74773 closed work packages are still considered to be part of the bucket#23302
dombesz wants to merge 4 commits into
devfrom
bug/74773-closed-work-packages-are-still-considered-to-be-part-of-the-bucket

Conversation

@dombesz
Copy link
Copy Markdown
Contributor

@dombesz dombesz commented May 21, 2026

Note

This is a remake of an accidentally merged PR #23295

Ticket

https://community.openproject.org/wp/74773

What are you trying to accomplish?

Not consider excluded work packages from the list when moving a work package up or down on the list.

What approach did you choose and why?

  • Rely on the prev_id instead of the position when rendering move up/down menu items. Position was unreliable, because we do exclude items from the list for example, closed work packages and excluded work package types. This feature will also enable us to render move up/down buttons with correct actions when filtering of work packages will be implemented in the sprints page.
  • Implement a work package scope that loads prev_prev_id, prev_id and next_id on the database level. So each filtered work package scope can have its own neighbouring ids included. This is required for rendering the correct prev_id for move up/down actions.
  • Remove the now redundant max_position from the menu component argument. Rely on the prev_id, next_id instead in the first_item?, last_item? methods.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@dombesz dombesz force-pushed the bug/74773-closed-work-packages-are-still-considered-to-be-part-of-the-bucket branch from 46c7de1 to 771a3d5 Compare May 21, 2026 10:47
@dombesz dombesz requested a review from Copilot May 21, 2026 10:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses incorrect move up/down behavior in Backlogs lists when some work packages are excluded (e.g., closed statuses or excluded types), by switching from position-based logic to neighbor-ID-based logic computed from the actually displayed scope.

Changes:

  • Add a with_backlogs_neighbours scope that computes prev_prev_id, prev_id, and next_id at the database level using window functions.
  • Update the Backlogs work package card menu to determine first/last items via neighbor IDs (and remove the max_position argument).
  • Extend/update specs to cover neighbor computation and the new move menu behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
modules/backlogs/app/models/work_packages/scopes/with_backlogs_neighbours.rb Introduces the window-function-based neighbor ID scope used to drive move actions.
modules/backlogs/lib/open_project/backlogs/patches/work_package_patch.rb Registers the new scope on WorkPackage within the Backlogs patch.
modules/backlogs/app/controllers/backlogs/work_packages_controller.rb Loads the menu work package enriched with neighbor IDs; ensures base query is ordered by position.
modules/backlogs/app/components/backlogs/work_package_card_menu_component.rb Removes max_position and switches move/first/last logic to neighbor IDs + prev_id-based moves.
modules/backlogs/spec/models/work_packages/scopes/with_backlogs_neighbours_spec.rb Adds unit coverage for correct neighbor IDs under different filtered scopes.
modules/backlogs/spec/components/backlogs/work_package_card_menu_component_spec.rb Updates component specs to validate move menu behavior and submitted params based on neighbor IDs.
modules/backlogs/lib/open_project/backlogs/patches/project_patch.rb Removes redundant manual include (engine patching handles inclusion).
modules/backlogs/lib/open_project/backlogs/patches/permitted_params_patch.rb Adds frozen_string_literal: true and removes redundant manual include.

Comment thread modules/backlogs/app/models/work_packages/scopes/with_backlogs_neighbours.rb Outdated
dombesz and others added 2 commits May 21, 2026 15:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dombesz dombesz force-pushed the bug/74773-closed-work-packages-are-still-considered-to-be-part-of-the-bucket branch from 0143179 to b2fe43f Compare May 21, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants