Skip to content

Commit 4e9fdfa

Browse files
os-zhuangclaude
andauthored
feat(showcase): 演示作用于选中记录的批量 action (#4201)
* feat(showcase): demonstrate bulk actions over a selection `bulkActions` — naming declared object actions so each SELECTED record is fanned out through the action runner — had no example in the showcase. It is also the only way to declare a bulk action: `action.bulkEnabled` was retired in spec 17 (#3896 close-out, #4054) precisely because nothing consumed it, and its tombstone prescribes this key. Adds a `bulk_actions` named view on showcase_task — the selection-bar twin of the existing `legacy_row_actions` fixture — naming both an action whose work is a sandboxed script (showcase_mark_done, via the platform action route) and one that is a custom endpoint (showcase_recalc_estimate, whose already-declared `recordIdParam` carries each record's id). Neither is a field patch, which is what distinguishes this from project.view.ts's `bulkActionDefs`: those mass-EDIT through the data API, this dispatches a real action per record. Verified in a browser against this app: selecting all 10 tasks and running each button issues 10 POSTs (one per record, all 200) to /api/v1/actions/showcase_task/showcase_mark_done and /api/v1/showcase/recalc respectively, and the records change server-side. No console errors. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(showcase): translate the new view label, add the release-nothing changeset The zh-CN bundle must carry every declared label — the i18n coverage ratchet counts untranslated declared strings per example and refused the 456 → 457 growth. And objectstack requires a changeset per PR; an empty one is the sanctioned declaration for a change that releases nothing (the showcase package is private). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 64489f8 commit 4e9fdfa

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
---
3+
4+
Showcase-only: a `bulk_actions` view on `showcase_task` demonstrating
5+
`bulkActions` (declared object actions fanned out over the selected records),
6+
plus the UI tour note distinguishing it from `bulkActionDefs`. Releases
7+
nothing — `@objectstack/example-showcase` is private.

examples/app-showcase/src/docs/showcase_tour_ui.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ canonical example of each linked from that page.
5757
surface.
5858
- `src/ui/actions/` — the ActionType × location matrix (script / url /
5959
modal / flow / api / form), visible as buttons across Task screens.
60+
- Actions over a SELECTION come in two flavours, one view each: Task's
61+
**Bulk Actions** names declared actions in `bulkActions`, and each selected
62+
record is fanned out through the action runner (a script and a custom
63+
endpoint, neither of them a field patch); Project's `bulkActionDefs` instead
64+
mass-EDITS through the data API. `action.bulkEnabled` is not a third way —
65+
it was retired in spec 17 and its tombstone points at `bulkActions`.
6066

6167
## Themes
6268

examples/app-showcase/src/system/translations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export const ShowcaseTranslationBundle = {
231231
map: { label: '工作地点地图' },
232232
chart: { label: '工时按状态分布' },
233233
legacy_row_actions: { label: '旧式行操作' },
234+
bulk_actions: { label: '批量操作' },
234235
},
235236
},
236237
showcase_account: {

examples/app-showcase/src/ui/views/task.view.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,42 @@ export const TaskViews = defineView({
107107
rowActions: ['showcase_recalc_estimate', 'showcase_quick_view'],
108108
},
109109

110+
// ── Bulk actions — one declared action over the SELECTED records ──────
111+
// The selection-bar twin of `legacy_row_actions` above, and — unlike that
112+
// fixture — the CANONICAL authoring form, not a legacy one. `bulkActions`
113+
// is the only way to declare a bulk action: `action.bulkEnabled` was
114+
// retired in spec 17 (#3896 close-out) precisely because nothing ever
115+
// consumed it, and its tombstone prescribes this key instead.
116+
//
117+
// Complements `project.view.ts`'s `bulkActionDefs`, which is the OTHER
118+
// bulk vocabulary: inline defs that mass-EDIT records through the data
119+
// API (`operation: 'update'` + a patch). Here the selected records are
120+
// instead fanned out through the action runner, one dispatch each, so an
121+
// action that is not a field patch at all — a script, a custom endpoint —
122+
// works over a selection. Both names are already declared on the object:
123+
//
124+
// `showcase_mark_done` — type `script`; its sandboxed body flips
125+
// `done`/`progress` per record via the platform action route.
126+
// `showcase_recalc_estimate` — type `api`; POSTs the showcase's own
127+
// `/api/v1/showcase/recalc`, with `recordIdParam: 'recordId'` (already
128+
// declared for the row surface) carrying each record's id.
129+
//
130+
// Neither declares `list_toolbar`: a bulk action is not a toolbar action,
131+
// it needs a selection. Naming it here is the whole declaration.
132+
bulk_actions: {
133+
label: 'Bulk Actions',
134+
type: 'grid',
135+
data,
136+
columns: [
137+
{ field: 'title' },
138+
{ field: 'assignee' },
139+
{ field: 'estimate_hours' },
140+
{ field: 'progress' },
141+
{ field: 'done' },
142+
],
143+
bulkActions: ['showcase_mark_done', 'showcase_recalc_estimate'],
144+
},
145+
110146
// 0 ── Tabular ───────────────────────────────────────────────────────
111147
// ADR-0021 Phase 2: replaces the former `showcase_task_list` report
112148
// (a flat record list — a ListView concern, not analytics).

0 commit comments

Comments
 (0)