Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/35878-list-toolbar-two-rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@object-ui/plugin-list': patch
'@object-ui/plugin-grid': patch
'@object-ui/i18n': patch
---

feat(list): the list page's toolbar is two rows: 「Object / View ▾ · View settings … Search · New · ⋮」 and a resident condition row

Clause-②: yes (widening)
Metadata-protocol: none

The console's object list drew three rows above the table: the object's name with ⋮ More and New, the view bar with Filter N, Sort N, Options and search, and a condition row that appeared only once a sort or filter was set. It now draws two:

- The view bar starts with the object's icon and name, 「/」 and the view switcher, then 「View settings」. Its right end is the search, the page's toolbar actions, New, and ⋮ More last at the right edge. While rows are selected the right end shows what the selection offers, and ⋮ More keeps its place and its icon (⋮, also in the selection face).
- The Filter N and Sort N buttons are gone from the bar. The condition row is always there: with nothing set it shows dashed 「Sort」 and 「Filter」 buttons; a sort of any number of levels is one chip, 「Sorted by X」 with 「+N」 for the further levels, which opens the sort panel; each filter is its own chip with ×, followed by 「+」. The row's right end is 「Personalized」 and 「Reset」 while the list differs from its view. The table no longer moves down when the first condition is set.
- 「Options」 is renamed 「View settings」 and sits beside the view name. Its first level shows the content itself: the view's name, the shown columns (drag to reorder, the eye to hide) and 「+ Add column」, then Layout, Group, Row height and Row color where offered, and Save, Restore defaults and export in its footer. The More level and its inline edit switch, and Refresh, are gone.
- As the list narrows, 「View settings」 folds to its icon first, then the word 「Personalized」 goes, then 「Reset」 folds to its icon. The condition row stays one line and scrolls sideways.

For hosts of `ListView`: two optional host props, `toolbarTrailing(tools)` (the bar's right end, given the list's search) and `conditionRowEnd` (the condition row's right end, drawn in place of the row's own Reset). A host that passes neither gets the search alone at the bar's end and the row's own Reset.
40 changes: 24 additions & 16 deletions docs/qa/platform-checklist/areas/records-forms.json

Large diffs are not rendered by default.

100 changes: 56 additions & 44 deletions ui/e2e/list-condition-row-35549.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { uiRoot } from '../scripts/ui-root.mjs';
* GEOMETRY and INTERACTION pin for the list's condition row (objectstack#35549
* filter, objectstack#35550 sort), on the REAL list: `ListView` with its
* toolbar, the `list-condition-row` slot objectstack#35548 laid under the view
* bar, and the grid. The Filter and Sort triggers open the shared field list;
* the slot holds the sort chips, then the reader's filter chips, 「Add filter」
* and 「Reset」; with nothing to show it takes no height at all.
* bar, and the grid. Since objectstack#35878 the slot is resident: the one
* sort chip (the dashed 「Sort」 with nothing set), then the reader's filter
* chips and 「+」 (the dashed 「Filter」 with none), and 「Reset」; it keeps its
* 40 px whether or not a condition is set, so the table does not move.
*
* ## Why a Playwright spec and not a vitest test
*
* "Takes no height", "one row of 24 px chips" and "a real drag reorders" are
* layout and pointer facts; happy-dom lays nothing out and fires no native
* drag. The vitest pins (`plugin-list/src/conditions/__tests__/
* "Keeps its height", "one row of 24 px chips" and "chips on one line" are
* layout facts; happy-dom lays nothing out. The vitest pins (`plugin-list/src/conditions/__tests__/
* listConditions.test.tsx`, `ListView.conditionRow-35549.test.tsx`) hold the
* logic; this spec holds it in Chromium. The bundling follows
* `e2e/list-header-narrow-35446.spec.ts`.
Expand Down Expand Up @@ -255,7 +255,7 @@ async function mount(page: Page): Promise<void> {
);
await page.goto('http://localhost/list-condition-row');
await page.addScriptTag({ content: bundle, type: 'module' });
await page.getByTestId('toolbar-filter-trigger').waitFor({ state: 'attached', timeout: 30_000 });
await page.getByTestId('condition-add-filter').waitFor({ state: 'attached', timeout: 30_000 });
await page.getByTestId('data-table-summary-lead').waitFor({ state: 'attached', timeout: 30_000 });
await style(page);
}
Expand All @@ -267,6 +267,8 @@ async function click(page: Page, testId: string): Promise<void> {
}

const slot = (page: Page) => page.getByTestId('list-condition-row');
/** The resident row's height (`min-h-10`, objectstack#35878). */
const ROW_HEIGHT = 40;
const slotHeight = (page: Page) => slot(page).evaluate((el) => el.getBoundingClientRect().height);
/** The number the grid's footer row leads with (objectstack#35702), once the list has answered. */
const count = async (page: Page) => (await page.getByTestId('data-table-summary-lead').textContent())?.match(/\d+/)?.[0];
Expand All @@ -279,30 +281,34 @@ test.describe('list condition row under the view bar (objectstack#35549, objects
bundle = await bundlePage();
});

test('CONTROL: with no sort and no filter the row takes no height', async ({ page }) => {
// objectstack#35878: the row is resident. With nothing set it holds the
// dashed 「Sort」 and 「Filter」 and keeps its height, so the table never
// moves when the first condition is set or after Reset.
test('CONTROL: with no sort and no filter the row is drawn with dashed Sort and Filter, 40 px tall', async ({ page }) => {
test.setTimeout(120_000);
await mount(page);
await expect.poll(() => count(page)).toBe('12');
expect(await slotHeight(page)).toBe(0);
expect(await slot(page).evaluate((el) => el.childElementCount)).toBe(0);
expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT);
await expect(page.getByTestId('condition-sort')).toHaveAttribute('data-levels', '0');
await expect(page.getByTestId('condition-sort')).toHaveText('Sort');
await expect(page.getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true');
await expect(page.getByTestId('condition-add-filter')).toHaveText('Filter');
});

test('filter: Filter → Stage → Negotiation is three clicks; the chip names field and value, reopens on click, × removes', async ({ page }) => {
test.setTimeout(120_000);
await mount(page);
await expect.poll(() => count(page)).toBe('12');
await click(page, 'toolbar-filter-trigger');
await click(page, 'condition-add-filter');
await click(page, 'filter-panel-fields-item-stage');
await page.getByTestId('filter-panel-values-option-negotiation').getByRole('checkbox').click();
await style(page);
// applied on the pick: no Apply button, the list asks again at once
await expect.poll(() => count(page)).toBe('3');
const chip = page.getByTestId('filter-chip-stage');
await expect(chip).toHaveText(/Stage: Negotiation/);
// the row is one line of 24 px chips: 24 + 2 × 6 padding + 1 border
const h = await slotHeight(page);
expect(h).toBeGreaterThanOrEqual(36);
expect(h).toBeLessThanOrEqual(38);
// the row is one line of 24 px chips at its resident height (min-h-10)
expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT);
const chipBox = await chip.boundingBox();
expect(Math.round(chipBox!.height)).toBe(24);
await page.keyboard.press('Escape');
Expand All @@ -315,34 +321,51 @@ test.describe('list condition row under the view bar (objectstack#35549, objects
await page.keyboard.press('Escape');
await click(page, 'filter-chip-remove-stage');
await expect.poll(() => count(page)).toBe('12');
expect(await slotHeight(page)).toBe(0);
// the row stays, back to its dashed 「Filter」, at the same height
expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT);
await expect(page.getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true');
});

test('sort: Sort → Descending → Amount is three clicks; chips come before filter chips; a drag reorders; a handle in a chip panel reorders; a header menu pick shows as a chip; Reset restores', async ({ page }) => {
// objectstack#35878: a sort of any number of levels is ONE chip, 「Sorted by
// X」 with 「+N」, before the filter chips. With no sort the dashed 「Sort」
// opens the sort panel; with one, the chip opens every level in one panel
// (objectstack#35876), where a level is added and a handle reorders.
test('sort: Sort → Descending → Amount is three clicks; one chip with +N comes before the filter chips; its panel adds a level and a handle reorders; a header menu pick shows on it; Reset restores', async ({ page }) => {
test.setTimeout(120_000);
await mount(page);
await expect.poll(() => count(page)).toBe('12');
await click(page, 'toolbar-sort-trigger');
await click(page, 'condition-sort');
await click(page, 'sort-panel-order-desc');
await click(page, 'sort-panel-fields-item-amount');
expect(await sortNow(page)).toEqual(['amount:desc']);
await expect(page.getByTestId('sort-chip-open-amount')).toHaveText('Amount');
await expect(page.getByTestId('sort-chip-open-amount')).toHaveAttribute('title', 'High → Low');
// a second level
await click(page, 'toolbar-sort-trigger');
await click(page, 'sort-panel-fields-item-stage');
expect(await sortNow(page)).toEqual(['amount:desc', 'stage:asc']);
// a filter chip joins after the sort chips
await click(page, 'toolbar-filter-trigger');
const sortChip = page.getByTestId('condition-sort');
await expect(sortChip).toHaveAttribute('data-levels', '1');
await expect(sortChip).toHaveText('Sorted by Amount');
// a second level, from the chip's panel of every level: still one chip, now carrying +1
await click(page, 'condition-sort');
const panel = page.getByTestId('sort-chip-panel');
await panel.getByRole('button', { name: 'Add sort' }).click();
await expect.poll(async () => (await sortNow(page)).length).toBe(2);
const levels = await sortNow(page);
expect(levels[0]).toBe('amount:desc');
await expect(sortChip).toHaveAttribute('data-levels', '2');
await expect(page.getByTestId('sort-chip-more')).toHaveText('+1');
// a real drag of the second level's handle onto the first row puts it first
await expect(panel.getByTestId('sort-builder-handle')).toHaveCount(2);
await panel.getByTestId('sort-builder-handle').nth(1).dragTo(panel.getByTestId('sort-builder-row').first());
await expect.poll(() => sortNow(page)).toEqual([levels[1], levels[0]]);
await page.keyboard.press('Escape');
// a filter chip joins after the sort chip
await click(page, 'condition-add-filter');
await click(page, 'filter-panel-fields-item-stage');
await page.getByTestId('filter-panel-values-option-proposal').getByRole('checkbox').click();
await page.keyboard.press('Escape');
await style(page);
const order = await page.getByTestId('condition-chips').evaluate((row) =>
[...row.querySelectorAll('[data-testid^="sort-chip-"][data-priority], [data-testid^="filter-chip-"]:not([data-testid*="-open-"]):not([data-testid*="-remove-"])')]
[...row.querySelectorAll('[data-testid="condition-sort"], [data-testid^="filter-chip-"]:not([data-testid*="-open-"]):not([data-testid*="-remove-"])')]
.map((el) => el.getAttribute('data-testid')),
);
expect(order).toEqual(['sort-chip-amount', 'sort-chip-stage', 'filter-chip-stage']);
expect(order).toEqual(['condition-sort', 'filter-chip-stage']);
// all chips on one line, Reset at the right end of the slot
const tops = await page.getByTestId('condition-chips').evaluate((row) =>
[...new Set([...row.children].map((el) => Math.round(el.getBoundingClientRect().top)))],
Expand All @@ -351,33 +374,22 @@ test.describe('list condition row under the view bar (objectstack#35549, objects
const reset = await page.getByTestId('condition-reset').boundingBox();
const slotBox = await slot(page).boundingBox();
expect(slotBox!.x + slotBox!.width - (reset!.x + reset!.width)).toBeLessThanOrEqual(17);
// a real drag: the second sort chip onto the first
await page.getByTestId('sort-chip-stage').dragTo(page.getByTestId('sort-chip-amount'));
expect(await sortNow(page)).toEqual(['stage:asc', 'amount:desc']);
// a chip opens every level in one panel (objectstack#35876); a real drag of
// the second level's handle onto the first row puts it first
await click(page, 'sort-chip-open-stage');
const panel = page.getByTestId('sort-chip-panel');
await expect(panel.getByTestId('sort-builder-handle')).toHaveCount(2);
expect(await sortNow(page)).toEqual(['stage:asc', 'amount:desc']);
await panel.getByTestId('sort-builder-handle').nth(1).dragTo(panel.getByTestId('sort-builder-row').first());
await expect.poll(() => sortNow(page)).toEqual(['amount:desc', 'stage:asc']);
await page.keyboard.press('Escape');
// Reset puts the list back as saved: no sort, no filter
// Reset puts the list back as saved: no sort, no filter, the same row height
await click(page, 'condition-reset');
expect(await sortNow(page)).toEqual([]);
await expect.poll(() => count(page)).toBe('12');
expect(await slotHeight(page)).toBe(0);
expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT);
await expect(sortChip).toHaveAttribute('data-levels', '0');
// a click on a column header opens its menu and sorts nothing
// (objectstack#35876); the entry chosen there sorts, and the row shows it
// as a chip
// on the one chip
await page.getByRole('columnheader', { name: /Amount/ }).click();
const columnMenu = page.getByTestId('column-context-menu');
await expect(columnMenu).toBeVisible();
expect(await sortNow(page)).toEqual([]);
await columnMenu.getByRole('menuitem', { name: 'Sort descending' }).click();
await style(page);
await expect(page.getByTestId('sort-chip-amount')).toBeVisible();
await expect(sortChip).toHaveText(/^Sorted by Amount/);
expect(await sortNow(page)).toEqual(['amount:desc']);
});
});
Loading
Loading