feat: positives-on-top order for the Value column sort (v0.6.6) - #30
Merged
Merged
Conversation
…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
Deploying cashflow-js with
|
| Latest commit: |
5354b3d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8a2a92a8.cashflow-js.pages.dev |
| Branch Preview URL: | https://feature-sort.cashflow-js.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
aria-sortascendingdescendingothernoneThe 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: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
src/eventSort.test.js(76 total) — ordering, zero placement, sign-group guarantee, 4-state cycle, stability, no input mutationaria-sortasserted per state; 18/18 passingAPI.mdregenerated (docs script includessrc/eventSort.js)Version
0.6.4 → 0.6.6 in package.json, package-lock.json, and the header badge.