Workflow Toolbar
WorkflowToolbar is the list header row above every workflow list (change orders, purchase orders, jobs, RFIs), and it is the standard for every list page (issue 6660). One row, aligned right: search, the record count, the page’s end slot, the expand/collapse icon, then the List / Grid switch at the far right. The current view’s switch button is a paint palette, Customize board: in Grid view it opens Sort and Card fields, in List view Group by. Every workflow page uses it unchanged, so search, count, sort and group behave the same everywhere. Spec: Deborah, in docs/UI_UX_PATTERNS_OVERVIEW.md and issue 6660.
The toolbar is fully controlled. The page filters, sorts and groups; the toolbar only draws the controls and reports the picks.
Live demo
| PO | Vendor | Job | Total |
|---|---|---|---|
| PO-1041 | Ferguson | Oak Hollow Clubhouse | $4,820 |
| PO-1042 | Core & Main | Wells Branch Senior Living | $12,950 |
| PO-1043 | Viking Supply | Round Rock Denny's | $2,310 |
| PO-1044 | Ferguson | Riverbend Phase 2 | $8,075 |
Behavior
- Order, aligned right: search, record count, the page’s
endSlot, the expand/collapse icon (List view only), then the List / Grid switch at the far right. No Sort or Group by select sits in the row. - Customize board is the current view’s switch button, drawn as a paint palette with that tooltip. In Grid view it opens Sort (one dropdown) and Card fields (toggle badges; Title is always on). In List view it opens Group by. The other view’s button still switches.
viewMenu(the page’s card fields and the person’s pick) is required. - Search has its own X. The X shows only when there is text, clears the box and returns focus to it; Escape in the box clears it too. The browser’s own X is hidden. Search has no debounce; which fields it matches is the page’s (job name, job number, client, and vendor where the page has one).
matchesWorkflowSearch(query, fields)is the shared rule: case-insensitive, trimmed, every word in some field. - Count reads
X of Xwhen nothing is narrowed andY of Xonce a search or filter is, where X is every record and Y the records showing. It is announced politely. No records reads0 of 0. - Sort (Grid view, in Customize board) lists Newest, the contact label, the date label, Amount, then the page’s own options, always in that order. Newest, Date and Amount run high to low; Contact runs A to Z; a record with no value sorts last. The List view has no Sort control: it sorts by clicking a column head (
GroupedTable). The Grid choice is kept and applies again on switching back. - Group by (List view, in Customize board) offers Job, the contact label, Status and No grouping. The page builds its groups from the choice. In Grid view it is hidden and ignored: the Grid is always by status.
- Expand all / Collapse all are one animated icon, in the List view only, when the page passes
collapseand more than one group exists (groupCount). - Phone and tablet. The toolbar wraps by the width it is given: search and count on the first line at tablet width; at phone width the search is full width with the count under it, and the switch and the expand/collapse icon take the 44px tap height. Nothing scrolls sideways.
The sort contract
A page tells sortWorkflowRows how to read its own rows. The List’s column-head sort uses the same function, so both order rows alike.
| Page | contact | date | amount |
|---|---|---|---|
| Change Orders | client name | submitted date | change order total |
| Purchase Orders | vendor name | issue date | PO total |
| Jobs | client name | start date | contract value |
Extra sorts a page keeps (Days in stage, Stage order on Jobs) go in pageSortOptions with a key starting page: and a reader under page in the sort fields. A page key runs high to low for numbers and A to Z for text; pageDirection overrides either. A page with no amount (RFIs) passes omitSort={["amount"]}; Newest and Contact can never be omitted.
Wiring the List’s Expand all / Collapse all
The toolbar does not import GroupedTable. The page holds the collapse state with useGroupCollapse and gives the buttons to the toolbar and the state to the table:
const collapse = useGroupCollapse(groups.map((g) => g.key));
<WorkflowToolbar {...toolbarProps} groupCount={groups.length} collapse={collapse}/><GroupedTable key={group} groups={groups} collapsed={collapse.collapsed} onCollapsedChange={collapse.onCollapsedChange} bulkControls="none"/>Saving the choices
useWorkflowToolbarSetting(sectionKey) in apps/web saves the view, the Grid sort and the List grouping per person under <section>.toolbar (defaults Grid, Newest, Status) and returns { view, sort, group, setView, setSort, setGroup }. The search text is not saved: keep it in the query string (q) so the browser’s back button works. The section’s key must be registered in apps/web/server/platform/me/_view-keys.ts.
Usage
import { WorkflowToolbar, matchesWorkflowSearch, sortWorkflowRows } from "@beacon/design-system";
const { view, sort, group, setView, setSort, setGroup } = useWorkflowToolbarSetting("change-orders");
<WorkflowToolbar noun="change orders" search={q} onSearchChange={setQ} totalCount={all.length} shownCount={shown.length} view={view} onViewChange={setView} sort={sort} onSortChange={setSort} contactLabel="Client" dateLabel="Submitted" group={group} onGroupChange={setGroup} viewMenu={{ cardFields, visibleFields, onVisibleFieldsChange: setVisibleFields }}/>;Props
| Prop | Type | Description |
|---|---|---|
noun | string | ”change orders”: the placeholder reads “Search change orders”. |
search, onSearchChange | string, (next) => void | The search text, held by the page. |
totalCount, shownCount | number | X (every record) and Y (records showing). |
view, onViewChange | "list" | "cards" | The List / Grid switch. |
sort, onSortChange | WorkflowSortKey | The Grid sort, picked in Customize board: newest, contact, date, amount or page:<name>. |
contactLabel | string | Names the Contact sort and group: Vendor, Client, Recipient, With. |
dateLabel | string | The page’s meaning of Date: Issued, Needed by, Start date. |
pageSortOptions | { key, label }[] | Extra sorts after Amount; keys start page:. |
group, onGroupChange | WorkflowGroupKey | The List grouping, picked in Customize board: job, contact, status or none. |
groupOptions | WorkflowGroupKey[] | Default all four; drop job where the list is already one job. |
groupLabels | Partial<Record<WorkflowGroupKey, string>> | Renames a grouping for a page with no job or contact: Hub > Guide activity’s Job slot reads Function. |
pageGroupOptions | { key, label }[] | The page’s own groupings (Inventory’s Category, the Parts List’s Manufacturer), after Status and before No grouping; keys start page:. group and onGroupChange then take those keys too. |
collapse, groupCount | useGroupCollapse(), number | List only; the icon is hidden without collapse or with one group. |
omitSort | ("date" | "amount")[] | A page with no date or no amount drops that option. |
endSlot | ReactNode | Page buttons left of the expand/collapse icon and the switch (rare: Jobs’ Summarize board). |
viewMenu | { cardFields, visibleFields, onVisibleFieldsChange } | Required. The Customize board menu’s Card fields. |
Do and don’t
- Do use it as it is on every workflow list. A page that needs something else puts it in
endSlot,pageSortOptionsorpageGroupOptions. - Don’t build a hand-made row of search, sort and view controls. The old sort sets (Newest, Waiting longest, Amount; Newest, Amount, Vendor; Stage order, Days in stage, Value, Name) go away when a page adopts this.
- Don’t put a Sort or Group by select in the row; they live in Customize board, Sort for Grid and Group by for List.