Skip to content

feat: positives-on-top order for the Value column sort (v0.6.6) - #30

Merged
macedot merged 11 commits into
masterfrom
feature/sort
Sep 3, 2026
Merged

macedot merged 11 commits into
masterfrom
feature/sort

Conversation

@macedot

@macedot macedot commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #29 (which landed column sorting + drag-and-drop reordering in v0.6.4). This PR adds a fourth state to the Value column's sort cycle and bumps the version to 0.6.6.

New: positives-on-top Value order (±)

Clicking the Value header now cycles through four states:

Click Order Indicator aria-sort
1 Ascending (most negative first) ascending
2 Descending (largest first) descending
3 Positives on top ± other
4 Clear sort none

The positives-on-top mode groups by sign and applies sort(x) if x > 0 else sort(abs(x)) within each block — incomes ascending, then zeros, then expenses by descending absolute value, so magnitudes mirror around the zero line:

+100, +3000, 0, -1200, -50

The rule is applied per sign block, not globally — a global abs-key transform would let a small expense jump above a larger income, breaking the "positives on top" guarantee. Period and Freq keep their two-state cycle.

Everything from #29 still holds: sorted/dragged order persists to localStorage, dragging a row clears any active sort, and sorting re-runs the simulation so the results Items order follows.

Testing

  • Unit: 15 tests in src/eventSort.test.js (76 total) — ordering, zero placement, sign-group guarantee, 4-state cycle, stability, no input mutation
  • E2E: sort test imports a second income event so every Value state is distinctly asserted; aria-sort asserted per state; 18/18 passing
  • lint, typecheck, knip, jscpd green; coverage above thresholds
  • API.md regenerated (docs script includes src/eventSort.js)

Version

0.6.4 → 0.6.6 in package.json, package-lock.json, and the header badge.

Note: the commit list shows some pre-#29 commits (e53df30, 29013d3, the sim-horizon fix) — their content is already on master via #29/#27 squash merges, so the net diff is only the changes described above.

…tinue

Importing events where a bounded event (e.g. a loan) ended later than the
default period set the simulation end exactly at that endDate, silently
truncating open-ended events: an open-ended salary lost its payment in the
month after the loan's last payment, and the whole result stopped there.

When open-ended events exist, the auto-expanded period now extends one
month past the last bounded endDate (clamped to month length) so their
recurrence stays visible beyond it. Bounded-only and open-ended-only
imports behave exactly as before.
…able

- Sort Period/Freq/Value columns: click cycles asc -> desc -> clear,
  with aria-sort state and per-theme active accent styling
- Reorder rows manually via native HTML5 drag and drop; dragging clears
  any active column sort
- Extract pure comparators to src/eventSort.js (stable sort, open-ended
  events last, frequency ranked by recurrence length)
- Sorted/dragged order persists to localStorage; table re-simulates so
  results Items follow the new order
- Unit tests (12) + E2E tests for sorting and drag reorder
- Fourth state in the Value click cycle: asc -> desc -> positive-first
  -> clear (Period/Freq keep the two-state cycle)
- Groups positive values on top, zeros next, negative values at the
  bottom, ascending within each block
- Active indicator +- and aria-sort=other; tooltip announces the
  next state (positives on top)
- Unit + E2E coverage for the extended cycle
- Within-block rule is now sort(x) if x > 0 else sort(abs(x)):
  incomes ascending, then zeros, then expenses by ascending
  absolute value (largest expense last)
- The rule applies within each sign block, so a small expense
  cannot jump above a larger income
- E2E sort test imports a second income event so every
  Value-sort state is distinctly asserted
- Expenses (and zeros) now order by abs(x) descending: the largest
  expense sits right below the zero line and magnitudes mirror
  around it (+100, +3000, 0, -1200, -50)
- Sign blocks stay intact; positives still sort by x ascending
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deploying cashflow-js with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5354b3d
Status: ✅  Deploy successful!
Preview URL: https://8a2a92a8.cashflow-js.pages.dev
Branch Preview URL: https://feature-sort.cashflow-js.pages.dev

View logs

@macedot
macedot merged commit 8096e6a into master Sep 3, 2026
3 checks passed
@macedot
macedot deleted the feature/sort branch September 3, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant