You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5e8e243
Browse filesBrowse the repository at this point in the historyBrowse files
feat(console): a footer calculation is a part of the list draft; a package view's refused save says why in the reader's words (#36212)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu3R6vTvrF8uP9Z2MFVbqmJV)_
repo:objectstack#1 · os-sales · session_01L6bhgX7ez5A7JDsmzTy9Ks
Fixes#36194Fixes#36195
Clause-②: yes (widening) — two new keys in every `@object-ui/i18n`
locale pack (`console.objectView.personalizedParts.summaries`,
`console.objectView.saveRefused.packaged`); zh-Hant regenerated; nothing
removed or renamed. `ListView` / `ObjectGrid` props unchanged (doc
comments only).
Metadata-protocol: none
## 维护者速读
-
列表底部选、换、去掉一列的统计:马上显示结果,不再写进视图或个人视图;和筛选排序一样算草稿,出现「放弃」「保存」,「保存」菜单的未保存列表多一项「统计」。「放弃」还原;「保存到这个视图」(自己的视图)和「另存为我的视图」把统计一起存进去。
- 包里带的视图(比如
HotCRM「全部客户」)、没有权限改的共享视图:照样能选统计,进草稿,「保存」里只有「另存为我的视图」。任何时候都不会再出现卡上那段英文报错。
- 服务端拒绝保存包里带的视图时,提示改成一句中文(11
种语言都有):「这个视图来自应用包,不能直接修改,可以另存为我的视图。」其它拒绝照旧显示服务端那句话(那些是写给人看的,已有测试钉着)。
- 卡上那段报错的来历:包可写的判断要等包列表读回来,列表为了不和页面抢网络,要等页面请求安静下来(最多 8
秒)才读;这之前判断按设计放行,底部入口就直接写了视图。统计改成草稿后,这段时间里底部不再写任何东西。
## What changes
**A footer calculation is a draft part** (`objectViewListRenderer.tsx`,
`listDraftStore.ts`, `columnSummaryWrite.ts`, `ObjectView.tsx`)
- `ListDraft` gains `summaries` (column → calculation, `null` = None
over a column the view sums); an emptied part is no part. It lives
exactly as the other parts (#35955 item 4: kept on a record round trip,
dropped on another view or object and on a reload).
- The renderer lays the draft's calculations over the columns it hands
`ListView` (`columnsWithSummaries`), so the grid draws them at once, and
`onColumnSummaryPick` only patches the draft and answers `true`. A pick
equal to the column's own calculation (`columnSummaryOf`) drops the
column from the draft.
- The menu is offered (`columnSummaryPickFields`) on the columns the
list draws, the reader's added fields included: the columns a saved body
carries. Where the list holds no draft (an environment list, no open
view) nothing is offered (`listViewActions.draftsSummaries`).
- Removed: `handlePickPersonalViewSummary` (wrote the reader's own view
at once) and `handlePickSharedViewSummary` (wrote the shared view's
draft, `PUT /meta/view/<name>?mode=draft`). No footer pick writes
anything now.
- The Save menu's unsaved list names it: host-side part `summaries`
(`ListDraftActions`' `ListPersonalizationPart` gains it; `ListView`'s
own vocabulary is untouched), pushed in `objectViewListUrlState.ts` like
`columns`.
- Saves carry it: `PersonalViewListState.summaries`, laid by
`buildPersonalViewConfig` on the columns it keeps (after added fields,
order and hidden columns). Callers: Save to this view (own view), Save
as my view, the switcher's create card with "include current".
**A view the reader cannot change in place** — the same "can save in
place" reading as the filter and the Save menu, no second rule: the Save
menu offers Save to this view on the reader's own view only (on `main`),
so a package's view and a non-admin's shared view get Save as my view
alone. With #36123 merged in, its shared-view Save to this view keeps
its own test (`canSaveToSharedView`, now waiting for the package list:
small call 5) and stores the calculations too.
**A refused save of a package's view** (`viewSaveRefusal.ts`,
`objectViewViewCrud.tsx`, `ObjectView.tsx`)
- `viewSaveRefusalText(err, t)`: `code === 'NOT_OVERRIDABLE'` (the
door's close on an item a package ships,
`protocol-packaged-base-refusal.ts`) →
`console.objectView.saveRefused.packaged`; anything else →
`formatMetadataError` as before. Used at every view-write toast on the
object page except delete (view settings save, create, rename, pin, set
default, personal create / save / save as).
**Docs**: `content/docs/ui/views.mdx` § "A user's list state never
writes the view". Changeset `36194-footer-calculation-draft.md`.
## Small calls made in this thread (Sales 22:19:27Z rule; seat agreed
22:51Z)
1. The menu is offered on every column the list draws, not only the ones
the view declares: the draft can carry a calculation on any column the
saved body keeps (#35702's declared-only limit existed because the pick
wrote the view).
2. A reader who is no admin gets the menu on a shared view too (their
pick is their draft; Save as my view keeps it). The card's "no entry for
a reader without permission" acceptance line predates the fold; the
brief settles it as "into the draft, Save as my view alone".
3. Only `NOT_OVERRIDABLE` is reworded. Other refusals (403 permission,
422 field issues, pin / default / rename) keep the door's message, which
objectui#11583 / #12417 pin as worded for the person saving.
4. The switcher's create card carries the calculations only with
"include current", as it does the filter and sort.
5. **Done after #36123 merged:** its 「保存到这个视图」 on a shared view stays
hidden while the package list is unread, and for a package listed
read-only (`usePackageSaveRead`: the same session-held read as
`usePackageRefusesSaves`, with the in-flight state told apart; a failed
read or an unlisted package still offers it, as today). Reason measured
below: the unread window is where the card's error came from.
## Root cause of the card's error (measured, client-side)
HotCRM 6.5.0 on `main` (`fa304140`), console from this tree's `ui/`
against it: the server's package list reports `app.objectstack.hotcrm`
`writable: false`, and `crm_account.all_accounts`'s row carries
`_packageId: app.objectstack.hotcrm`. The reading is right once read;
but `fetchSessionPackages` waits for the page's own requests to go quiet
(up to 8 s) before it reads, and until then `usePackageRefusesSaves`
fails open by design. Measured at 1440: the list drew with 「+ 添加统计」 at
7.2 s, the package list answered at 8.0 s, and the entry went. A pick
inside that window sent the `PUT ?mode=draft` the card shows. With this
PR the pick writes nothing in any window.
## Tests
- `ObjectView.footerCalculationDraft-36194.test.tsx` (7, renamed from
`ObjectView.readOnlyPackageView-35933.test.tsx`; real `ObjectView`,
`ListView` stand-in that draws the condition row's end, every non-GET
`fetch` recorded): a pick is drawn, writes nothing, Save names it,
picking None again drops it; Discard takes it off; the reader's own view
stores it only on Save to this view; a view that declares no columns
gets the menu on the drawn columns and Save as my view stores it; a
package's view: drawn, no write, Save offers Save as my view alone,
which stores it; the package list unread: still a draft; a non-admin on
a shared view: a draft, Save as my view alone.
- `__tests__/footerCalculationDraft-36194.test.ts` (9):
`columnsWithSummaries` / `columnSummaryOf`; the draft store's empty
part; `buildPersonalViewConfig` stores calculations on kept columns
(added kept, hidden dropped) in a body `ListViewSchema` accepts;
`viewSaveRefusalText` (package refusal reworded, a 403 keeps the door's
words, issues keep the list).
- `AppContent.draftSaveKeepsList-35932.test.tsx` (8, adapted): the pick
no longer writes, so the refresh pulse a draft save announces is
announced by the test (`emitMetadataRefresh`); no skeleton, no remount,
picks drawn through it; a reader's pick is offered (their draft).
## Verification
Local at head (`claude/project-thread-8r2qm4`):
- `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView
packages/app-shell/src/views/__tests__
packages/app-shell/src/views/ListDraftActions
packages/app-shell/src/views/personalViews
packages/app-shell/src/console/__tests__/AppContent packages/i18n
packages/plugin-list/src packages/plugin-grid/src/__tests__` → 797
files, 8404 passed / 13 skipped; the 7 failures of that run were the
first version of the refusal helper (it also reworded every 403) and a
stale zh-Hant; both fixed, and the three files re-run green
(`ObjectView.viewWriteRefusal-11583`,
`ObjectView.createViewRefusal-11578`, `packages/i18n` 106 files).
- `@object-ui/app-shell` `type-check` (both `tsc --noEmit` and
`tsconfig.test.json`): exit 0.
- `eslint` on every changed file: 0 errors.
- The whole app-shell package is left to CI's shards.
## Since the first L1-b read (`ef54913f` → `efa7c4f0`)
- Merged `main` twice (#36128, then #36123). Resolutions: the renderer's
memo deps take #36128's `openReferencedRecord` and keep this PR's drop
of `summaryPickKey`; `ObjectView`, `personalViews`, `listDraftStore` and
`views.mdx` keep both sides (calculations beside #36123's layout and row
colour).
- The shared-view Save to this view passes `summaries` to
`layListStateOverView`, which lays them after the added, ordered and
hidden columns; it still writes neither the reader's row height nor
column widths.
- Small call 5: `usePackageSaveRead` in `useStudioDesignGate.ts`
(`unread` / `refuses` / `takes`); `canSaveToSharedView` asks for
`takes`.
- L1-b N1: `viewSaveRefusalText` reads the code with `errorCodeIs`.
- Tests: three new cases in `ObjectView.sharedViewSave-35955.test.tsx`
(a pick on a shared view writes nothing and Save to this view stores it
with the view's own row height; unread package list hides the save, the
answer offers it; a failed read offers it). Local: 203 files / 1769
tests green (ObjectView*, the gate hook, `views/__tests__`, the console
draft test); app-shell type-check 0; eslint 0 errors.
## Evidence (HotCRM 6.5.0, 1440×900,
`/mnt/project-files/build-seat1/36194-36195/`)
- Before: `before-1440-{light,dark}-hotcrm-pick-refused.png` — 「全部客户」,
the package list held 15 s to show the window, a 「去重」 pick: `PUT
…/crm_account.all_accounts?mode=draft`, the English refusal toast.
- After (same hold): `after-1440-{light,dark}-hotcrm-pick-in-draft.png`
(「去重 9」 drawn, 「放弃」「保存」, no write),
`after-1440-{light,dark}-hotcrm-save-menu.png` (「未保存的改动: 统计」, 「另存为我的视图」
alone), `after-1440-light-hotcrm-discarded.png`,
`after-1440-light-saved-as-my-view.png` (「全部客户 副本」 keeps 「去重 9」),
`after-1440-light-my-view-save-menu.png` (own view: 「保存到这个视图」 offered),
`after-1440-light-my-view-after-reload.png` (saved 「非空 9」 survives a
reload; the only write of the run: `PATCH
/api/v1/data/sys_personal_view/<id>`).
## Overlap
`overlap-check.mjs` @ `efa7c4f0`: merges cleanly with `main`
(`af2361ee`, #36123 and #36128 in); textual conflict with #36133 only
(`listDraftStore.ts`, `objectViewListRenderer.tsx`).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgX7ez5A7JDsmzTy9Ks
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgX7ez5A7JDsmzTy9Ks -->
Co-authored-by: Claude <noreply@anthropic.com>
feat(console): a footer calculation is a part of the list's draft; a refused save of a package's view says why in the reader's words
7
+
8
+
Clause-②: yes (widening) — new keys in every `@object-ui/i18n` locale pack: `console.objectView.personalizedParts.summaries` and `console.objectView.saveRefused.packaged`; nothing removed or renamed
9
+
Metadata-protocol: none
10
+
11
+
On a Console object list, picking, changing or removing a column's footer calculation (「+ 添加统计」) applies at once and writes nothing. It used to be saved at once: on the reader's own view straight into it, on a shared view as a draft of the view (`PUT /api/v1/meta/view/<name>?mode=draft`), which the server refuses on a view an app package ships.
12
+
13
+
- The calculation is a part of the list's draft, like the sort and the filter: **Discard** and **Save** appear, Save's menu names it (「统计」), and Discard takes it off. The draft lives as long as the others: kept on opening a record and coming back, dropped on another view, object or a reload.
14
+
-**Save to this view** (on the reader's own view, or on a shared view an admin may edit) and **Save as my view** store it on the columns the saved view keeps.
15
+
-**Save to this view** on a shared view is offered only once the Console has read that the view's package takes saves: not while that read is in flight (on a slow start the list draws seconds before it lands) nor for a package it lists read-only. A failed read, or a package the list leaves out, still offers it as before.
16
+
- On a view the reader cannot change in place (one an app package ships, or a shared view of a reader who is no admin), the pick goes into the draft too and Save offers **Save as my view** alone.
17
+
- The menu is offered on every column the saved view would carry: the columns the list draws and the fields the reader added.
18
+
- When the server refuses to save a view an app package ships (`NOT_OVERRIDABLE`), the toast says in the reader's language that the view comes with an app package, cannot be changed directly and can be saved as the reader's own view. The server's text goes to the console only. Every other refusal is said as before.
0 commit comments