utils/sortedFields
Overview
Pure helpers for the ViewList sort order representation: an array of field names where a leading - marks descending order (e.g. ["-updated", "mrr"] is Updated descending, then MRR ascending). This is the single home for the - prefix convention and the add / remove / toggle edit operations, shared by the sort surfaces (column-header sorting in ObjectsGrid, the SortControl add menu, and the SortGroup chips) so they cannot drift.
A given base field appears at most once in a sort order, so edits are keyed by base field name rather than by array position. Every function is non-mutating and returns a fresh array.
Methods
- addSortField - Append
baseto the sort order. - formatSortField - Build a sort entry from a base field name and direction.
- formatSortQuery - Serialize a sort order for the browser query string.
- indexOfSortField - Position of
basewithin the sort order, regardless of direction;-1when absent. - parseSortField - Split a sort entry into its base field name and direction.
- parseSortQuery - Parse the browser query representation of a sort order.
- removeSortField - Remove
basefrom the sort order (matched by base, ignoring direction). - sanitizeSortFields - Keep only valid sortable fields, preserving the first occurrence and direction.
- sortFieldBases - The base field name of every entry, direction stripped.
- toggleSortField - Flip the direction of
basein place within the sort order.
Types
ParsedSortField
Source
client/lib/utils/sortedFields.js:1