Repository navigation
fix(plugin-detail): record page body tables total only declared-additive columns, not ordinals - #29966
Merged
Conversation
…olumns A record page body table totalled every currency/number/integer/decimal column, so ordinals such as a version number or an instalment number were summed. A currency column now totals only when its counted rows share one known currency (the cell's own resolveFieldCurrency), and a number column only when the record's own object rolls it up with sum. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfSkDtGdeCZgsqhyHH
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfSkDtGdeCZgsqhyHH
Contributor
Author
|
domain:ui#1 · os-support-ai · session_01WGufzjDyeFwq6AuFu3vwTd 维护者速读(席位终稿)
席位核对 · ACCEPT · head
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Yibo Wang · project thread
Fixes #29943
Clause-②: no
Metadata-protocol: none
维护者速读
currency)列在本页各行同一币种时合计并按该币种显示;普通数字列只有在父对象声明了对该列sum的汇总字段时才合计;其余列不合计,没有可合计的列时整行不画。BodyTableTotals一处,不发新请求、不加 spec 键;回滚即还原本 PR。ui/packages/plugin-detail/src/RelatedList.tsx的BodyTableTotals与新增的rolledUpSumFields/agreedRowCurrency;ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx新增的 objectstack#29943 用例组。pnpm --dir ui exec vitest run packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx,预期 12 个测试全部通过(序号列无合计、金额列按 € 合计、父对象 sum 汇总的数字列才合计、混合币种无合计)。What changes
BodyTableTotals(the totals line under a body table of the default record page, objectstack#27055 Target 8) totalled every column typedcurrency | number | integer | decimal. Target 8 promised "a totals row for numeric columns", and the type alone cannot tell an ordinal from a quantity:clm_contract_version.version_noandclm_payment_plan.seqareField.numberwithscale: 0. The line now totals only what something already declared additive:currency, every counted row in one known currencycurrencyConfig.defaultCurrency ?? currencywhatever the modeformatCurrency(the cell's formatter)currency, rows in different currencies, or one row's currency unknowndefaultCurrency)number/integer/decimal, the parent object rolls it up withsumnumber/integer/decimal, no such roll-up (ordinals, and amounts stored asnumber)When no column qualifies the line is not drawn, as before.
Which currency a row is in. Each counted row resolves through
@object-ui/i18n'sresolveFieldCurrency(def, tenantCurrency, row), the reader the currency cell and the grid footer (useColumnSummary) already share: the field's code undercurrencyMode: 'fixed', the tenant default (useLocalization().currency) underdynamic, the row's sibling code field (currencyConfig.currencyField) underrecord. One consequence for a fixture that carriedcurrencyConfig: { defaultCurrency: 'USD' }with no mode: the spec parses that todynamicand does not readdefaultCurrencythere, so the total now shows the tenant default, the same currency the column's cells display. The old reader ignored the mode and could print a total in a currency the cells above it did not show. The existing #27055 fixture now declarescurrencyMode: 'fixed'.Which number columns a roll-up declares additive (the reader used).
rolledUpSumFieldsreads the record page's own object schema fromuseRecordContext().objectSchema, whichRecordDetailViewprovides (objectSchema={objectDef}) aroundRecordPageColumns, the only place a body table is drawn. A parent field counts when it istype: 'summary'withsummaryOperations.function === 'sum',summaryOperations.objectnaming this list's object (api || objectName), andsummaryOperations.fieldnaming the column. Both field-container shapes the metadata API serves are read.relationshipFieldis not compared, because which foreign key a sum runs through does not change whether the child column adds up. No fetch was added: the parent schema was already in context (the PM's mechanism assumption holds).Tests
New top-level
describein the existing body-table harness,RelatedList.bodyTable-27055.test.tsx(hotclm's payment-plan fixture):seqnumberwithscale: 0,version_nointeger) with no roll-up: no totals line at all;fixedEURcurrencycolumn beside the ordinals totals€60.25andseqstays untotalled;numbercolumn the parent rolls up withsum: totalled383,000.5(map-shaped and array-shaped parent fields);countroll-up, amaxroll-up, and asumover another object: not totalled;record-mode amount whose rows all carryEURtotals€600.00; mixedEUR/USDrows: no total; one row with a blank code: no total;dynamicamount totals in the tenant default (CNYviaLocalizationProvider) and gets no total without one;quantity(anumberwith no roll-up) is no longer totalled, thefixedUSDtotalreads$65.50.Ablation. The fix commit restored to the old type set (the gate line
if (!isCurrency && !(ROLLED_UP_FIELD_TYPES.has(def.type) && rolledUp.has(key))) continue;replaced byif (!isCurrency && !ROLLED_UP_FIELD_TYPES.has(def.type)) continue;, i.e. every number column totalled) throughscripts/ablation-replace.mjs: anchor 1 → 0, blob4270c0b477d1→d31d47e2ca1d; 5 tests red, including "totals no ordinal column — and draws no line when nothing else adds up" and the #27055 case. Restored: blob == HEAD4270c0b477d1,git diff HEADempty. The test imports../RelatedListfrom source, so no build sat between the mutation and the run.Acceptance notes
planned_amount/actual_amountarenumberfields whose currency lives on the parent contract'scurrency_code. Under this rule they get no total unless the contract declares asummaryfield that sums them; with such a roll-up they total as plain numbers, with no currency symbol, because anumbercolumn carries no currency of its own. The way to get a currency-formatted total is the spec's own: declare the amount ascurrencywithcurrencyMode: 'record'and acurrencyFieldon the child row. The parent'scurrency_codeis not read, because ADR-0144 D2 puts arecord-mode amount's code on the amount's own object. I could not open the hotclm screenshots or metadata from this container (the path in the order is not in this project's shared folder), so this reading comes from the card text.record-mode amount whose code column is not drawn. An authored-column related list projects ($select) only the drawn columns plus predicate operands, so arecord-mode amount whosecurrencyFieldis not among the columns arrives without its code. The total then reads as unknown and is not drawn (honest, not wrong). The cell above it has the same gap. Adding the code field to the projection is a fetch change outside this card. Reported in the report, not filed.Metadata-protocol: none.app-shell/.../ResourceEditPage.tsx; no open PR touchesui/packages/plugin-detail/**beside this one.Verification
All on head
ad05c644(shared box; lock VERDICT lines quoted).Build, type-check, vitest
pnpm --workspace-concurrency=2 --filter "@object-ui/plugin-detail^..." build: VERDICT command-exit 0 (6m04s)pnpm --filter @object-ui/plugin-detail type-check(tsc --noEmit && tsc -p tsconfig.test.json): VERDICT command-exit 0pnpm --filter @object-ui/plugin-detail build, thenpnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/: VERDICT command-exit 0 · Test Files 369 passed | 1 skipped (370) · Tests 3250 passed | 18 skipped (3268)pnpm --dir ui exec vitest run packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx: 12 passed (12)Derived gates (`dispatch-gates --commands`, 35 lines, then `--ran`)
node scripts/pm/dispatch-gates.mjs --ran FILE --repo objectstack-ai/objectstack: exit 0, "Run reconciliation — 35 derived, 35 run, 0 NOT-MEASURED, 0 UNRUN."Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintwas not run locally: the repo-wide lint is the CI run.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzfSkDtGdeCZgsqhyHH