Skip to content

Commit f4d568b

Browse files
fix(plugin-report,plugin-dashboard): report, chart and table drills list the records a filtered measure counted (#30651)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuUdRNQVD3k9LXPSp1pEBp9r)_ Fixes #30615 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:报表(表格行、小计行、矩阵单元格)和看板(图表、表格、交叉表)的下钻,现在除了点中的分组和组件/报表筛选,还会叠加服务器给的该度量范围(drillScopes),点开列出的就是数字统计的那些记录。 - 为什么改:带条件的度量(如「已付款发票数」)以前点开会列出整个分组的记录,数字是 0 却列出 4 张发票,读者会不再信任看板。 - 风险与回滚:只动 plugin-report 和 plugin-dashboard 的下钻;没有范围条目的度量(派生度量等)和没有 drillScopes 的应答不再给下钻;一行里多个度量范围不一致时改为按单元格下钻。回滚即 revert 本 PR。 - 先看:ui/packages/plugin-dashboard/src/DatasetWidget.tsx 的 openDrill、表格行/单元格和 chartDrillMeasure;ui/packages/plugin-report/src/DatasetReportRenderer.tsx 的 drill / drillCell;两个新的小文件 measureDrill.ts、measureDrillScope.ts。 - 两分钟验证:打开 app-showcase 的 Revenue Pulse (filtered) 看板,在 Paid Rate by Status 表的 Sent 行点 Paid Invoices(0),抽屉应为空;点同一行的 Invoices(4),应列出 4 张 sent 发票;Paid Rate 单元格不可点。 - 需要你做的:无,席位落地。 ## What changes - **The drill composes three legs, not two.** The list filter is the clicked bucket AND the widget or report filter AND the answer's `drillScopes` entry for the measure the click stands for (PR #30596's sidecar). A `{}` entry hands the widget or report filter back untouched, so a drill on an unfiltered measure is byte-identical to the drill it was before. - **What a click stands for.** A chart mark: its series' measure (a pivoted chart: its one measure; a mark with no series key: the one measure a single-series chart draws; a `MEASURE__compare` series: nothing, it has no entry). A cross-tab or matrix cell: its column's measure. A table row, a report line or a subtotal line: every measure it holds. - **A table row whose measures select different records drills cell by cell.** When every measure of the row shares one scope, the row drills as before (`dataset-drill-row`). Otherwise the row is not a drill target, and each measure cell with an entry is (`dataset-drill-cell`), drilling that measure's records. This is the case on `table_rate_by_status`: `invoice_count` (`{}`) beside `paid_count` (`status = paid`). - **No list that does not match the number** (the #30080 ruling, comment 6631202970). A measure with no entry (derived, or a scope naming a relationship path) is not clickable; neither is anything on an answer that carries an `object` but no `drillScopes`; a chart none of whose drawn measures has an entry gets no click handler. - `ui/packages/plugin-dashboard/src/measureDrill.ts` (new, internal): `sharedMeasureDrillScope` and `scopeDrillFilter`, reading entries with the merged `readMeasureDrillScope` from `metricDrill.ts` (unchanged). `ui/packages/plugin-report/src/measureDrillScope.ts` (new, internal): the same two plus `measureDrillScope`, since plugin-report does not depend on plugin-dashboard. Neither is exported from a package entry; `@object-ui/core` is untouched. - One root changeset: `@object-ui/plugin-report` and `@object-ui/plugin-dashboard`, patch. ## Why A dataset number is computed under the dataset's `filter`, the measure's `filter` and the widget filter. The drills composed only the last one with the bucket, so a filtered measure drilled to a superset. The server now states the missing two per measure (PR #30596); the KPI tile reads them since PR #30634. This PR makes the report, chart, table and cross-tab drills read them too. ## What the drill does when the answer has no `drillScopes` (the reading the claim asked for) - Measured on the server: `queryDataset` sets `drillScopes` on every dataset answer that has rows (`analytics-service.ts`, the block after the drill ranges). It is absent on (1) an answer with no rows, where there is nothing to click; (2) a draft-preview answer, which returns before `dimensionFields`, `drillRawRows` and `drillRanges` are set, so the widget's `canDrill` is already false there, and the Studio report preview passes no `onDrill`; (3) a cube query answer, which these consumers never request (they call `queryDataset` only). - So on every answer a current server sends, "no `drillScopes`" never meets a clickable bucket. The consumers treat a missing map like a missing entry: no drill (the tile's rule in PR #30634). - One exception, kept on purpose: a report answer with no `object` (a server older than ADR-0021 D2) still hands `ReportView` its group-key fallback drill, unchanged, as `drill: omits objectFilter when the server returns no drill metadata (older server)` pins. ## Tests On `f9543126` (the head): - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-report/`: Test Files 33 passed (33), Tests 313 passed, 7 skipped. VERDICT command-exit 0. - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-dashboard/`: Test Files 203 passed (203), Tests 1957 passed, 6 skipped. VERDICT command-exit 0. - `pnpm --filter @object-ui/plugin-report --filter @object-ui/plugin-dashboard run type-check` (`tsc --noEmit` and `tsc -p tsconfig.test.json` each): VERDICT command-exit 0. - New pins, each a top-level `describe` in a shared harness: - `plugin-report/src/__tests__/DatasetReportRenderer.test.tsx`, "measure drill scopes (#30615)": a filtered measure cell carries its scope; a `{}` cell carries bucket and report scope only; a derived measure offers no drill; an answer with an object and no `drillScopes` offers no drill; a line of one filtered measure drills as a line with its scope; a matrix cell carries its measure's scope and a no-entry measure's cell is not clickable. - `plugin-dashboard/src/__tests__/DatasetWidget.test.tsx`, "table drill — measure drill scopes (#30615)": the same five table cases plus the cross-tab cell, asserting the `$filter` the drawer's list sends. - `plugin-dashboard/src/__tests__/DatasetWidget.chartBucketIdentity.test.tsx`, "chart drill — measure drill scopes (#30615)": a filtered series bar, a `{}` series bar, a no-entry series (opens nothing) and an answer with no `drillScopes` (no click handler). - Existing drill fixtures gained a `drillScopes` entry of `{}` for their measures (17 test files), which is what a current server answers for a plain measure; their assertions are unchanged. <details><summary>Ablations (two, one per package, on the scope leg)</summary> Both through `node scripts/ablation-replace.mjs` under the verify lock, replacing ` return composeDrillFilter(runtimeFilter, scope);` with ` return runtimeFilter;` (anchor 1 to 0 each), restored to the HEAD blob with `git diff HEAD` empty. ui vitest resolves `@object-ui/*` to source, so there is no dist leg. - `plugin-dashboard/src/measureDrill.ts` (blob db75569 to 902425afed01, re-run on `f9543126`): Tests 4 failed, 74 passed over `DatasetWidget.test.tsx` and `DatasetWidget.chartBucketIdentity.test.tsx`: the filtered bar, the filtered table cell, the one-scope row, the cross-tab cell. - `plugin-report/src/measureDrillScope.ts` (blob 3ada35c to e47abefae51b): Tests 3 failed, 48 passed over `DatasetReportRenderer.test.tsx`: the filtered cell, the one-scope line, the matrix cell. </details> ## Acceptance notes - **The drawer's "Open in list" escape hatch still widens a filtered-measure drill (not fixed here, outside the file surface).** Measured live on the same cell after this change: the drawer lists 0 records, and "Open in list" navigates to `showcase_invoice/data?filter[issued_on][gte]=2026-08-07&filter[issued_on][lte]=2026-11-05&filter[status]=sent`, which lists the 4 sent invoices. `serializeDrillFilterParams` (`ui/packages/app-shell/src/views/drillUrlFilters.ts`) writes one URL param per field with `params.set`, so the scope's `status = paid` is overwritten by the bucket's `status = sent`, and a list comparand (`$in`, `$nin`) is skipped. Reported to the seat for a card. - `ReportView`'s group-key fallback is now reached only for a report answer with no `object`; it is unchanged. - The two small helpers are deliberately package-local copies: a shared one belongs in `@object-ui/core`, which this claim keeps read only. - `drillRawTotals` is not passed through `@object-ui/data-objectstack`: no totals row or total cell drills on any of these surfaces, so nothing reads it. ## Verification <details><summary>Live: app-showcase Revenue Pulse (filtered), table "Paid Rate by Status", en-US, 1440 wide</summary> `objectstack dev --fresh --seed-admin` app-showcase plus the Console vite dev server. The answer's `drillScopes`: `{ invoice_count: {}, paid_count: { status: 'paid' } }`, no `paid_rate` entry. Rows: Paid (Invoices 3, Paid Invoices 3, Paid Rate 100.0%), Sent (4, 0, 0.0%). The seed has no `open` status; the Sent row is the card's case. Before (`14c67d44`, main with PR #30634): both rows carry `dataset-drill-row`. Every cell of the Sent row opens the same list, `issued_on` window AND `status = sent`: 4 records, all `sent`, including under Paid Invoices (number 0) and Paid Rate. After (`ca694112`; the one later commit `f9543126` only drops a duplicate type alias): no row carries `dataset-drill-row`; Invoices and Paid Invoices cells carry `dataset-drill-cell`, Paid Rate cells none. - Sent / Paid Invoices (0): list filter window AND `status = paid` AND `status = sent`: 0 records. - Sent / Invoices (4), the unfiltered control: window AND `status = sent`: 4 records, all `sent`. - Paid / Paid Invoices (3): 3 records, all `paid`. Paid / Invoices (3): 3 records. - Paid Rate (derived): no drawer opens. </details> <details><summary>Gates on f954312</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 35 families on `f9543126` (the same list as on `ca694112`). Each ran with its exit code captured before any pipe; all 35 exit 0. `--ran` reconciliation: 35 derived, 35 run, 0 NOT-MEASURED, 0 UNRUN. Also `pnpm --dir ui run check:spec-symbols`: exit 0. The first pass, on `ca694112`, was red on one family: `pnpm --dir ui exec vitest run scripts/` failed `one-authority-per-exported-name-6273.test.ts`, because both new helpers declared a type named `MeasureDrillScope`. `f9543126` removes the dashboard's alias (plugin-report keeps the name); the family re-ran green there (Test Files 170 passed, 2 skipped; Tests 4970 passed), and the 34 other families re-ran on `f9543126` too. Families CI runs are read from this PR's check-runs. </details> Branch: `claude/project-thread-8u6mg4` is the card thread's platform-assigned branch (claim 6667494492, amendment 6667568430), not the `claude/issue-30615-*` convention. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUBrAU6n2ZJWk6VmTV --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bd65cb6 commit f4d568b

22 files changed

Lines changed: 638 additions & 31 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/plugin-report': patch
3+
'@object-ui/plugin-dashboard': patch
4+
---
5+
6+
fix(plugin-report,plugin-dashboard): a report, chart, table or cross-tab drill on a filtered measure lists the records the number counted
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A drill used to list the clicked bucket AND the report or widget filter only. The number also carries the dataset's own `filter` and the measure's own `filter`, so a drill on a filtered measure listed a superset: on the app-showcase Revenue Pulse dashboard, the Paid Invoices cell of the Sent row reads 0 and its drill listed all 4 sent invoices. The drill now also ANDs in the answer's `drillScopes` entry for the measure it stands for (the server's per-measure list filter; `{}` adds nothing, so a drill on an unfiltered measure is unchanged).
12+
13+
- **What a click stands for.** A chart mark stands for its series' measure (a pivoted chart for its one measure), a cross-tab or matrix cell for its column's measure, and a table row for every measure it holds.
14+
- **A table row whose measures select different records drills cell by cell.** When the row's measures all share one scope (one measure, or several plain ones), the row drills as before. Otherwise each measure cell with a scope is its own drill target (test id `dataset-drill-cell`) and the row is not.
15+
- **No list that does not match the number.** A measure with no `drillScopes` entry (a derived measure, or a scope naming a relationship path) offers no drill, and neither does any measure of an answer that carries no `drillScopes`. A comparison (`<measure>__compare`) series opens nothing. A chart none of whose drawn measures has an entry gets no click handler.
16+
- **Unchanged:** a report answer with no `object` (a server older than ADR-0021 D2) still hands the host its group-key fallback drill.

‎ui/packages/plugin-dashboard/src/DatasetWidget.tsx‎

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import {
106106
} from './metricTile';
107107
import { DrillDownDrawer } from './DrillDownDrawer';
108108
import { metricDrillFilter, readMeasureDrillScope } from './metricDrill';
109+
import { sharedMeasureDrillScope, scopeDrillFilter } from './measureDrill';
109110
import { specDefaultWidgetType } from './widgetDispatch';
110111
import { DASHBOARD_WIDGET_MULTI_MEASURE_TYPES } from '@objectstack/spec/ui';
111112

@@ -1314,8 +1315,14 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
13141315
// objectstack-ai/objectstack#1752: a date-only widget has no equality drill dim but still drills by the
13151316
// server's per-row date RANGE, so the presence of ranges makes it drillable too.
13161317
const canDrill = !!drillObject && (drillDims.length > 0 || !!drillRanges?.length);
1317-
const openDrill = (index: number, title: string) => {
1318+
// objectstack-ai/objectstack#30615 — a drill stands for the MEASURES the
1319+
// clicked mark or cell shows: a chart mark its series' measure, a cross-tab
1320+
// cell its column's, a table row every measure it holds. It opens only when
1321+
// the answer's `drillScopes` states one record list for them (`./measureDrill`).
1322+
const openDrill = (index: number, title: string, measures: readonly string[]) => {
13181323
if (!drillObject) return;
1324+
const scope = sharedMeasureDrillScope(state, measures);
1325+
if (!scope) return;
13191326
// objectui#10789 — composing the widget's filter with the clicked bucket
13201327
// lowers both through the throwing converter form. A widget filter the
13211328
// dataset query carried to the server can still be one this layer refuses
@@ -1326,7 +1333,8 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
13261333
// drill handler). Only a `FilterOperatorError` is caught.
13271334
let merged: Record<string, unknown>;
13281335
try {
1329-
merged = buildDrillFilter(drillRawRows?.[index], drillDims, dimensionFields ?? {}, runtimeFilter, drillRanges?.[index]);
1336+
// The clicked bucket AND the widget filter AND the measure's scope.
1337+
merged = buildDrillFilter(drillRawRows?.[index], drillDims, dimensionFields ?? {}, scopeDrillFilter(runtimeFilter, scope), drillRanges?.[index]);
13301338
} catch (error) {
13311339
if (!(error instanceof FilterOperatorError)) throw error;
13321340
console.warn(`[DatasetWidget] drill-down refused — the drilled list cannot be scoped: ${error.message}`);
@@ -1682,15 +1690,15 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
16821690
{cellCols.map((cc) => {
16831691
const index = pivot.cellIndex.get(pivotCellKey(rh.id, cc.col.id));
16841692
const fr = index != null ? state.rows[index] : undefined;
1685-
const clickable = canDrill && index != null;
1693+
const clickable = canDrill && index != null && readMeasureDrillScope(state, cc.measure) !== undefined;
16861694
const title = [...rh.labels, cc.col.label].filter(Boolean).join(' / ');
16871695
return (
16881696
<td
16891697
key={`${cc.col.id}-${cc.measure}`}
16901698
// A drillable cell is a 44 px touch target below `sm` (#29078).
16911699
className={cn('px-2 py-1 text-right tabular-nums whitespace-nowrap', clickable && 'cursor-pointer hover:bg-accent/40 max-sm:h-11 max-sm:min-w-11')}
16921700
data-testid={clickable ? 'dataset-drill-cell' : undefined}
1693-
onClick={clickable ? () => openDrill(index as number, title) : undefined}
1701+
onClick={clickable ? () => openDrill(index as number, title, [cc.measure]) : undefined}
16941702
>
16951703
{fr ? fmtMeasure(fr[cc.measure], cc.measure) : '—'}
16961704
{compareStack(fr, cc.measure)}
@@ -1739,6 +1747,16 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
17391747

17401748
// table (and a 1-dimension pivot) → a flat grouped table.
17411749
const columns = [...dimensions, ...measureColumns];
1750+
// objectstack-ai/objectstack#30615 — a row stands for every measure it
1751+
// holds, so the ROW drills only when they share one scope. Otherwise each
1752+
// measure cell with a scope of its own drills its own records, and a
1753+
// measure with none (a derived one) is not clickable. `cellDrills()` with
1754+
// no measure answers whether ANY cell of a row drills.
1755+
const lineDrills = canDrill && sharedMeasureDrillScope(state, values) !== undefined;
1756+
const cellDrills = (measure: string | undefined): boolean =>
1757+
canDrill && !lineDrills && (measure === undefined
1758+
? values.some((m) => readMeasureDrillScope(state, m) !== undefined)
1759+
: readMeasureDrillScope(state, measure) !== undefined);
17421760

17431761
// ── Which columns are NUMBERS (objectui#5827) ─────────────────────────
17441762
// Right-alignment is a claim about the values, so it is decided from them.
@@ -1922,7 +1940,9 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
19221940
</tr>
19231941
</thead>
19241942
<tbody>
1925-
{orderedEntries.map(({ row, index }) => (
1943+
{orderedEntries.map(({ row, index }) => {
1944+
const rowTitle = drillDims.map((d) => formatDimensionValue(row[d], displayLocale)).filter(Boolean).join(' / ');
1945+
return (
19261946
<tr
19271947
key={index}
19281948
// Hover feedback on EVERY row, not only a drillable one — the
@@ -1931,25 +1951,39 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
19311951
// drillable row keeps its stronger accent fill: `cn` runs
19321952
// tailwind-merge, so the later `hover:bg-accent/40` replaces
19331953
// `hover:bg-muted/40` rather than stacking with it.
1934-
className={cn('border-t transition-colors hover:bg-muted/40', canDrill && 'cursor-pointer hover:bg-accent/40')}
1935-
data-testid={canDrill ? 'dataset-drill-row' : undefined}
1936-
onClick={canDrill ? () => openDrill(index, drillDims.map((d) => formatDimensionValue(row[d], displayLocale)).filter(Boolean).join(' / ')) : undefined}
1954+
className={cn('border-t transition-colors hover:bg-muted/40', lineDrills && 'cursor-pointer hover:bg-accent/40')}
1955+
data-testid={lineDrills ? 'dataset-drill-row' : undefined}
1956+
onClick={lineDrills ? () => openDrill(index, rowTitle, values) : undefined}
19371957
>
19381958
{columns.map((c) => {
19391959
// A comparison column formats as the measure it compares.
19401960
const measure = compareOf(c) ?? (values.includes(c) ? c : undefined);
1961+
// objectstack-ai/objectstack#30615 — when the row's measures
1962+
// are no one list, each measure cell drills its OWN records.
1963+
const cellDrill = values.includes(c) && cellDrills(c);
19411964
return (
19421965
// A drillable row is a 44 px touch target below `sm` (#29078);
19431966
// a `td`'s height is its floor, so the row grows to it.
1944-
<td key={c} className={cn('px-2 py-1 whitespace-nowrap tabular-nums', numericColumns.has(c) && 'text-right', canDrill && 'max-sm:h-11')}>
1967+
<td
1968+
key={c}
1969+
className={cn(
1970+
'px-2 py-1 whitespace-nowrap tabular-nums',
1971+
numericColumns.has(c) && 'text-right',
1972+
(lineDrills || cellDrills(undefined)) && 'max-sm:h-11',
1973+
cellDrill && 'cursor-pointer hover:bg-accent/40 max-sm:min-w-11',
1974+
)}
1975+
data-testid={cellDrill ? 'dataset-drill-cell' : undefined}
1976+
onClick={cellDrill ? () => openDrill(index, rowTitle, [c]) : undefined}
1977+
>
19451978
{measure
19461979
? formatMeasure(row[c], measureField(measure)?.format, measureCellCurrency(measureField(measure), state.rows[index]), measureField(measure)?.percentScale, displayLocale)
19471980
: formatDimensionValue(row[c], displayLocale)}
19481981
</td>
19491982
);
19501983
})}
19511984
</tr>
1952-
))}
1985+
);
1986+
})}
19531987
</tbody>
19541988
{/* The totals row lives in `tfoot`, OUTSIDE `orderedEntries`
19551989
entirely — not as a special case inside the sort. Three
@@ -2191,6 +2225,19 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
21912225
// underneath any explicit author map.
21922226
const chartPresentation = chartConfigPresentation(widget?.chartConfig, categoryColors);
21932227

2228+
// objectstack-ai/objectstack#30615 — the measure a clicked mark stands for.
2229+
// A pivoted chart carries one measure, its series being the second
2230+
// dimension's groups. Otherwise the series key IS the measure: a key that
2231+
// names no declared measure (a `<measure>__compare` series, the earlier
2232+
// window, which `drillScopes` gives no entry) stands for no record list. A
2233+
// mark with no series key belongs to the one measure a single-series chart
2234+
// draws.
2235+
const chartDrillMeasure = (seriesKey: unknown): string | undefined => {
2236+
if (pivotedSeries) return values[0];
2237+
if (typeof seriesKey === 'string' && seriesKey !== '') return values.includes(seriesKey) ? seriesKey : undefined;
2238+
return renderedMeasures.length === 1 ? renderedMeasures[0] : undefined;
2239+
};
2240+
21942241
// Map a clicked chart segment back to its dataset row, then drill through to
21952242
// the underlying records — same governed path the table/pivot rows use.
21962243
const handleChartDrill = (ev: ChartSegmentClickEvent) => {
@@ -2219,13 +2266,19 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden }: {
22192266
const pivoted = dimensions.length >= 2 && values.length === 1;
22202267
const seriesTitle = ev?.seriesLabel ?? ev?.series;
22212268
const title = [ev?.category, pivoted ? seriesTitle : undefined].filter(Boolean).map(String).join(' / ');
2222-
openDrill(idx, title);
2269+
const measure = chartDrillMeasure(ev?.series);
2270+
if (measure === undefined) return;
2271+
openDrill(idx, title, [measure]);
22232272
};
22242273

22252274
// The `chart` schema renders through either ChartRenderer (reads `onChartClick`)
22262275
// or ObjectChart (reads `onSegmentClick` and suppresses its own object-drill) —
22272276
// pass both so the segment click drills regardless of which is registered.
2228-
const chartDrill = canDrill ? handleChartDrill : undefined;
2277+
// …and offered only when at least one drawn measure has a record list.
2278+
const chartDrillable = canDrill && (pivotedSeries ? values.slice(0, 1) : renderedMeasures).some(
2279+
(m) => readMeasureDrillScope(state, m) !== undefined,
2280+
);
2281+
const chartDrill = chartDrillable ? handleChartDrill : undefined;
22292282
return (
22302283
<div className={cn('relative h-full w-full min-h-[220px]')}>
22312284
{refreshBar}

‎ui/packages/plugin-dashboard/src/__tests__/DashboardPhoneTouchTargets-29078.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ describe('#29078 — the dataset table and pivot are 44 px touch targets on a ph
135135
fields,
136136
object: 'crm_account',
137137
dimensionFields: { industry: 'industry' },
138+
drillScopes: { account_count: {}, task_count: {} },
138139
drillRawRows: [{ industry: 'fin' }, { industry: 'tech' }],
139140
})),
140141
});
@@ -180,6 +181,7 @@ describe('#29078 — the dataset table and pivot are 44 px touch targets on a ph
180181
rows: [{ status: 'Open', priority: 'High', task_count: 2 }],
181182
object: 'task',
182183
dimensionFields: { status: 'status', priority: 'priority' },
184+
drillScopes: { account_count: {}, task_count: {} },
183185
drillRawRows: [{ status: 'open', priority: 'high' }],
184186
})),
185187
};

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.chartBucketIdentity.test.tsx‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const datasetOf = (rows: Array<Record<string, unknown>>, rawRows: Array<Record<s
8787
],
8888
object: 'crm_opportunity',
8989
dimensionFields: { owner_name: 'owner_id' },
90+
drillScopes: { deals: {} },
9091
drillRawRows: rawRows,
9192
})),
9293
});
@@ -259,3 +260,64 @@ describe('DatasetWidget — a bucket drills to ITS OWN rows (objectui#4508)', ()
259260
await waitFor(() => expect(lastFilter()).toEqual({ owner_id: { $null: true } }));
260261
});
261262
});
263+
264+
// ── objectstack-ai/objectstack#30615 — a chart mark lists ITS measure's records ──
265+
// The app-showcase `revenue-pulse` shape: `invoice_count` (scope `{}`) beside
266+
// `paid_count` (`filter: { status: 'paid' }`), one series per measure.
267+
describe('DatasetWidget chart drill — measure drill scopes (#30615)', () => {
268+
const invoices = (drillScopes?: Record<string, Record<string, unknown>>) => ({
269+
queryDataset: vi.fn(async () => ({
270+
rows: [{ status: 'Sent', invoice_count: 4, paid_count: 0 }],
271+
fields: [
272+
{ name: 'status', type: 'text', label: 'Status' },
273+
{ name: 'invoice_count', type: 'number', label: 'Invoices' },
274+
{ name: 'paid_count', type: 'number', label: 'Paid Invoices' },
275+
],
276+
object: 'showcase_invoice',
277+
dimensionFields: { status: 'status' },
278+
drillRawRows: [{ status: 'sent' }],
279+
...(drillScopes ? { drillScopes } : {}),
280+
})),
281+
});
282+
const renderBars = (src: ReturnType<typeof invoices>) =>
283+
render(
284+
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false, resources: {} }}>
285+
<DatasetWidget
286+
widget={{ type: 'bar', dataset: 'invoices', dimensions: ['status'], values: ['invoice_count', 'paid_count'], filter: { region: 'emea' } }}
287+
dataSource={src as any}
288+
/>
289+
</I18nProvider>,
290+
);
291+
const SCOPES = { invoice_count: {}, paid_count: { status: 'paid' } };
292+
293+
it('a filtered measure bar lists bucket AND widget filter AND the measure scope', async () => {
294+
installMetaRouter();
295+
renderBars(invoices(SCOPES));
296+
await waitFor(() => expect(chartRows()).toHaveLength(1));
297+
capturedChartProps.onSegmentClick({ category: 'Sent', series: 'paid_count' });
298+
await waitFor(() => expect(drillFilters.length).toBeGreaterThan(0));
299+
expect(lastFilter()).toEqual({ $and: [{ $and: [{ region: 'emea' }, { status: 'paid' }] }, { status: 'sent' }] });
300+
});
301+
302+
it('an unfiltered measure bar (`{}`) lists bucket AND widget filter only', async () => {
303+
installMetaRouter();
304+
renderBars(invoices(SCOPES));
305+
await waitFor(() => expect(chartRows()).toHaveLength(1));
306+
capturedChartProps.onSegmentClick({ category: 'Sent', series: 'invoice_count' });
307+
await waitFor(() => expect(drillFilters.length).toBeGreaterThan(0));
308+
expect(lastFilter()).toEqual({ $and: [{ region: 'emea' }, { status: 'sent' }] });
309+
});
310+
311+
it('a series with no entry opens nothing, and an answer with no drillScopes offers no chart drill', async () => {
312+
installMetaRouter();
313+
renderBars(invoices({ invoice_count: {} }));
314+
await waitFor(() => expect(chartRows()).toHaveLength(1));
315+
capturedChartProps.onSegmentClick({ category: 'Sent', series: 'paid_count' });
316+
expect(drillFilters).toHaveLength(0);
317+
cleanup();
318+
renderBars(invoices());
319+
await waitFor(() => expect(chartRows()).toHaveLength(1));
320+
expect(capturedChartProps.onSegmentClick).toBeUndefined();
321+
expect(capturedChartProps.onChartClick).toBeUndefined();
322+
});
323+
});

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.declaredNullLabel-25330.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const auditDataset = (userNullLabel?: string, actionNullLabel?: string) => ({
8282
],
8383
object: 'sys_audit_log',
8484
dimensionFields: pivot ? { user_id: 'user_id', action: 'action' } : { user_id: 'user_id' },
85+
drillScopes: { event_count: {} },
8586
drillRawRows: pivot
8687
? [{ user_id: 'usr_dev', action: 'login' }, { user_id: null, action: 'create' }]
8788
: [{ user_id: 'usr_dev' }, { user_id: null }],

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.drillTitleLabel.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const datasetOf = (
102102
// Both dimensions drill, so the filter names the clicked GROUP as well as
103103
// the clicked bucket — which is what makes a wrong series visible.
104104
dimensionFields: { status: 'status_id', priority: 'priority_id' },
105+
drillScopes: { est_hours: {} },
105106
drillRawRows: rawRows,
106107
})),
107108
});
@@ -307,6 +308,7 @@ describe('DatasetWidget — the drill title reads the series LABEL (objectui#468
307308
],
308309
object: 'proj_task',
309310
dimensionFields: { status: 'status_id' },
311+
drillScopes: { est_hours: {} },
310312
drillRawRows: [{ status: 'st-backlog' }],
311313
})),
312314
} as any}

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.localSelectI18n.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const serverResolvedTable = () =>
173173
],
174174
object: 'crm_opportunity',
175175
dimensionFields: { sales_channel: 'sales_channel', competitor_name: 'competitor_name' },
176+
drillScopes: { deals: {} },
176177
drillRawRows: [
177178
{ sales_channel: 'domestic', competitor_name: 'orion' },
178179
{ sales_channel: 'export', competitor_name: 'cabot' },

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.nullCategoryI18n.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const nullKeyedDataset = () => ({
108108
],
109109
object: 'crm_opportunity',
110110
dimensionFields: { owner_name: 'owner_id' },
111+
drillScopes: { deals: {} },
111112
drillRawRows: [{ owner_name: 'user-ada' }, { owner_name: null }],
112113
})),
113114
});
@@ -125,6 +126,7 @@ const fullyKeyedDataset = () => ({
125126
],
126127
object: 'crm_opportunity',
127128
dimensionFields: { owner_name: 'owner_id' },
129+
drillScopes: { deals: {} },
128130
drillRawRows: [{ owner_name: 'user-ada' }, { owner_name: 'user-grace' }],
129131
})),
130132
});

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.optionLabelI18n.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ const valueKeyedChart = () =>
159159
],
160160
object: 'crm_opportunity',
161161
dimensionFields: { competitor_name: 'competitor_name' },
162+
drillScopes: { deals: {}, total: {} },
162163
drillRawRows: [
163164
{ competitor_name: 'orion' },
164165
{ competitor_name: 'cabot' },
@@ -179,6 +180,7 @@ const serverResolvedChart = () =>
179180
],
180181
object: 'crm_opportunity',
181182
dimensionFields: { competitor_name: 'competitor_name' },
183+
drillScopes: { deals: {}, total: {} },
182184
drillRawRows: [{ competitor_name: 'orion' }, { competitor_name: 'cabot' }],
183185
});
184186

‎ui/packages/plugin-dashboard/src/__tests__/DatasetWidget.selectOptionOrder-11809.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const datasetOf = (rows: Array<Record<string, unknown>>) => ({
127127
fields: FIELDS,
128128
object: 'showcase_task',
129129
dimensionFields: { status: 'status', priority: 'priority', area: 'area' },
130+
drillScopes: { task_count: {} },
130131
drillRawRows: rows,
131132
})),
132133
});

0 commit comments

Comments
 (0)