Skip to content

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 base to 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 base within the sort order, regardless of direction; -1 when 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 base from 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 base in place within the sort order.

Types

ParsedSortField

Source

client/lib/utils/sortedFields.js:1

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2