flarum / flarum/issue-archive

ItemList API improvements

Open
#159 1 comment 0 reactions 1 assignee View on GitHub

@davwheat is already working on this.

Since Aug 18, 2021.

org/keep
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Is your feature request related to a problem? Please describe.
ItemList currently serves as an ordered associative structure, with order determined by integer "positions". It would be convenient and more self-documenting if items could be inserted relative to other items. For instance:

  • items.after('delete').add('something', hello)
  • items.before('delete').add('something', hello)
  • items.after('delete', 10).add() // specify a fallback priority
  • items.after(['foo', 'bar'], 10).add() // specify multiple items to add after

Initially proposed in https://github.com/flarum/core/issues/1317

Describe the solution you'd like
We'd need to include a modified topological sort (like https://github.com/flarum/core/pull/2317), that also includes support for integer-based priority.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.