Skip to content

Commit c5dc817

Browse files
committed
fix(ui): a toggle column's footer offers counts only; say what a second shared pick does
L2 7049212622 on #35919. The spec's boolean class is `boolean` and `toggle`, so a toggle column no longer offers Sum, Average, Min or Max. The changeset says that, until #35932, a second pick on a shared view before Publish replaces the first in the draft. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVb7fsaFeMStucvNWA
1 parent ad2d94c commit c5dc817

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎.changeset/35702-footer-calculation-row.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Metadata-protocol: none
1212

1313
A list's table view now always ends in one footer row, aligned with the columns and held at the bottom of the table: the record count in its first cell, and under each column its calculation, if any, written as the calculation's name in the secondary text colour and the figure in the normal one, with a space and no colon (`Sum ¥1,234,500`). A `min` / `max` over a date reads Earliest / Latest. The list's own "N records" line at the foot of the page is gone from a table that draws this row; the data-cap notice stays there. A grouped table, the phone's card list and every other view type are unchanged.
1414

15-
A reader who may change the open view clicks a cell to pick the column's calculation from one menu that lists what the field type allows (sum and average on numbers and amounts, earliest and latest on dates, the counts on any field), the current one ticked and None last. The console saves it as the column's `summary` on the view, and nothing else of the reader's layout. On a personal view it is saved at once and stays drawn. On a shared view the console saved, a reader who may edit it saves it as a draft through the view settings' own save: the draft save reloads the list, which then draws the published view again, so the pick shows for a moment and comes back once the draft is published, for every reader (#35932). The menu is offered on the columns the view itself declares; a column the reader added for themselves and a view that declares no columns draw the figures with no menu. A pick that is not saved is taken back, with the refusal said (a view a read-only package ships is refused this way: its changes go to the package's customization). A reader who may not change the view sees the figures and no menu.
15+
A reader who may change the open view clicks a cell to pick the column's calculation from one menu that lists what the field type allows (sum and average on numbers and amounts, earliest and latest on dates, the counts on any field), the current one ticked and None last. The console saves it as the column's `summary` on the view, and nothing else of the reader's layout. On a personal view it is saved at once and stays drawn. On a shared view the console saved, a reader who may edit it saves it as a draft through the view settings' own save: the draft save reloads the list, which then draws the published view again, so the pick shows for a moment and is drawn again, for every reader, once the draft is published. Until #35932, each pick's draft is built on the published view, so a second pick before Publish replaces the first in the draft: only the latest pick is published. The menu is offered on the columns the view itself declares; a column the reader added for themselves and a view that declares no columns draw the figures with no menu. A pick that is not saved is taken back, with the refusal said (a view a read-only package ships is refused this way: its changes go to the package's customization). A reader who may not change the view sees the figures and no menu.
1616

1717
New host props, all optional and never authored metadata: `ObjectGrid` takes `residentSummaryRow`, `onColumnSummaryPick(field, summary)` (answer `false` to have the pick taken back), `summaryPickFields` and `onResidentSummaryRowChange(drawn)`; `ListView` takes `onColumnSummaryPick` and `columnSummaryPickFields`. `ColumnSummaryResult` gains `name` and `text`, the two halves of its `label`. `@object-ui/i18n` adds the `grid.summary` keys `earliest`, `latest`, `pageName`, `calculate`, `none`, `menuPercentEmpty` and `menuPercentFilled` in every pack.

‎ui/packages/plugin-grid/src/__tests__/footerCalculationPicker-35702.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ describe('offeredColumnSummaries (objectstack#35702)', () => {
5353
expect(isTemporalSummaryField({ type: 'date' })).toBe(true);
5454
expect(isTemporalSummaryField({ type: 'number' })).toBe(false);
5555
});
56-
it('offers a boolean no sum, average or extremes', () => {
57-
expect(offeredColumnSummaries({ type: 'boolean' }).filter((s) => ['sum', 'avg', 'min', 'max'].includes(s))).toEqual([]);
56+
it.each(['boolean', 'toggle'])('offers a %s no sum, average or extremes', (type) => {
57+
expect(offeredColumnSummaries({ type }).filter((s) => ['sum', 'avg', 'min', 'max'].includes(s))).toEqual([]);
58+
expect(offeredColumnSummaries({ type })).toContain('count_filled');
5859
});
5960
it('offers an unknown field the counts it can draw, never count_unique', () => {
6061
expect(offeredColumnSummaries(undefined)).toEqual(['count_filled', 'count_empty', 'percent_filled', 'percent_empty']);

‎ui/packages/plugin-grid/src/useColumnSummary.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,16 @@ export const useSummaryTranslation = createSafeTranslation(
161161
* the footer withholds) likewise.
162162
*/
163163
const MENU_AGGREGATES: ReadonlyArray<ColumnSummaryType> = ['sum', 'avg', 'min', 'max'];
164+
/** The spec's boolean class (`BOOLEAN_AGGREGATE_FIELD_TYPES`): `toggle` is a boolean too. */
165+
const BOOLEAN_FIELD_TYPES: ReadonlySet<string> = new Set(['boolean', 'toggle']);
164166
const MENU_COUNTS: ReadonlyArray<ColumnSummaryType> = [
165167
'count_unique', 'count_filled', 'count_empty', 'percent_filled', 'percent_empty',
166168
];
167169
export function offeredColumnSummaries(
168170
field: ({ type?: string } & NonNullable<Parameters<typeof recordCurrencyField>[0]>) | undefined,
169171
): ColumnSummaryType[] {
170172
const type = field?.type;
171-
const numeric = !!type && type !== 'boolean' && !recordCurrencyField(field);
173+
const numeric = !!type && !BOOLEAN_FIELD_TYPES.has(type) && !recordCurrencyField(field);
172174
return [
173175
...(numeric ? MENU_AGGREGATES.filter((m) => isAggregateCompatibleWithFieldType(m, type!)) : []),
174176
...MENU_COUNTS.filter((m) => m !== 'count_unique' || (!!type && isAggregateCompatibleWithFieldType('count_distinct', type))),

0 commit comments

Comments
 (0)