# Code maintenance DREAM-786 - Extend sortable-lists for admin surfaces and migrate project attributes

Project: Stream Design System
Status: closed
URL: https://community.openproject.org/work_packages/DREAM-786

## OPEN POINTS

_No work packages_

## Subtasks

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Designer | Julia Racsko |
| Developers | Alexander Coles |
| Requires doc change | No |
| Date |  |
| Priority | Medium |
| Target versions | 17.8.0 |
| Sprint |  |
| Backlog bucket |  |
| Module | Frontend components and Primer design system, Modules and project features / Project attributes |
| Accessibility | No |
| List |  |
| Labels |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| Work |  |
| Remaining work |  |

## Description

## What to build

Extend the shared `sortable-lists` suite and prove the extended contract by migrating the complete Administration → Projects → Project attributes surface: ordering sections and ordering/moving fields within sections.

The shared frontend work must:

  - support multiple sortable item types under one root, with accepted types scoped to each destination list;

  - resolve move URLs per item type;

  - resolve source rows independently of HTML tag name;

  - expose an explicit server-response policy so `optimistic=true` is opt-in for Backlogs' event-only contract rather than sent by every consumer; and

  - keep optimistic DOM placement, rollback, announcements, auto-scroll, busy handling, move-menu gating, and Turbo morph healing reusable.

The backend work establishes two relative-anchor ordering primitives:

  - an `acts_as_list` move-after helper; and

  - an array-order insert-after-key helper.

The wire remains `list_type` + `list_id` + `prev_id`. A blank `prev_id` means move to top. A nonblank unknown/out-of-scope anchor or a self-reference returns 422 without mutation. Destination changes and reordering are transactional.

The project-attribute migration is the vertical proof for both helper families: sections exercise `acts_as_list`; fields within sections exercise array-backed ordering and cross-list movement. Existing update/replace Turbo streams use `method="morph"` to reconcile the server's canonical order.

The reusable contract is documented through <mention class="mention" data-id="DREAM-774" data-type="work_package" data-text="#DREAM-774">#DREAM-774</mention> before later clusters adopt it broadly.

### Acceptance criteria (technical)

- [ ] One root can host section and field item types without either type being accepted by the wrong list.
- [ ] Move URLs resolve by item type and remain same-origin relative URLs.
- [ ] List rows work when rendered as `<li>`, table rows, or BorderBox rows.
- [ ] The event-only `optimistic=true` request flag is opt-in; admin morph-reconciled requests do not send it.
- [ ] Shared backend helpers implement blank-to-top, strict unknown/self-anchor rejection, scoped anchor lookup, and transactional cross-list movement.
- [ ] Project attribute sections can be reordered by drag and directional menu.
- [ ] Project custom fields can be reordered within a section and moved between sections, including empty sections.
- [ ] Section and field responses morph the existing component boundaries and reconcile canonical server order without breaking subsequent dragging.
- [ ] Failures leave persisted and visible order consistent and expose the existing error UI.
- [ ] Project-attribute creation, editing, deletion, display-representation controls, and action menus remain functional.
- [ ] Frontend unit/integration, service/request, component, and feature tests cover both ordering families and post-morph dragging.
- [ ] <mention class="mention" data-id="DREAM-774" data-type="work_package" data-text="#DREAM-774">#DREAM-774</mention> is updated to document the extended contract before downstream clusters begin adoption.

### Hints for QA

Please do a smoke test of *Administration \> Projects \> Project attributes* (drag and drop of sections and individual project attributes). There are no significant visual changes with this migration, except for the cursors (the move/crosshairs cursor is replaced by grab/grabbing/hand cursors).
