Skip to content

Commit 9d12193

Browse files
authored
demo(app-showcase): 批量编辑增强的可操作示例(多选/日期/可搜索选人)(#2185) (#2548)
* demo(app-showcase): bulk multi-select edit on the Project grid (#2185) Exercises the objectui BulkActionDialog multi-select fix (objectstack-ai/objectui#2186) end-to-end in a real running app: - project.object.ts: add `labels` (multiselect, fixed options) and `team_members` (multi-user) — the two shapes the bulk dialog could not set before #2185 (its picker collapsed to a single value / overwrote the array). - project.view.ts: add the two columns and three `bulkActionDefs`: • set_labels → multi-select on a `select` param (array patch) • assign_team → multi-select on a `lookup` param (sys_user) • reschedule → the new `date` control + a single-select Verified in objectstack dev: select rows → each action writes an array (or date) patch to all selected records; labels/team_members/end_date persist server-side. * demo(app-showcase): add single-lookup bulk action (reassign_account) Exercises the searchable single-lookup picker (objectui#2186): a `lookup` param with no `multiple` now renders a searchable reference combobox over showcase_account, not a bare dropdown. Verified in objectstack dev — select rows → Reassign Account → search/pick one → every selected project's `account` is set to the single chosen id.
1 parent 996c548 commit 9d12193

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

examples/app-showcase/src/objects/project.object.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ export const Project = ObjectSchema.create({
5656
start_date: Field.date({ label: 'Start Date' }),
5757
end_date: Field.date({ label: 'Target End Date' }),
5858
owner: Field.text({ label: 'Owner', maxLength: 200 }),
59+
// Multi-value fields — the payload for the grid's *bulk-edit* showcase. A
60+
// multiselect (fixed options) and a multi-user field are exactly the two
61+
// shapes that, before #2185, the bulk dialog could not set: its people /
62+
// select picker collapsed to a single value and overwrote the array. The
63+
// list view's `bulkActionDefs` below now sets both with real multi-select
64+
// controls, writing an array patch.
65+
labels: {
66+
type: 'multiselect',
67+
label: 'Labels',
68+
options: [
69+
{ label: 'Frontend', value: 'frontend', color: '#3B82F6' },
70+
{ label: 'Backend', value: 'backend', color: '#8B5CF6' },
71+
{ label: 'Design', value: 'design', color: '#EC4899' },
72+
{ label: 'QA', value: 'qa', color: '#F59E0B' },
73+
{ label: 'DevOps', value: 'devops', color: '#10B981' },
74+
],
75+
},
76+
team_members: Field.user({ label: 'Team Members', multiple: true }),
5977
// Roll-up summaries — recomputed server-side whenever a child task is
6078
// inserted / updated / deleted (FK auto-detected: showcase_task.project).
6179
task_count: Field.summary({

examples/app-showcase/src/views/project.view.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,98 @@ export const ProjectViews = defineView({
1515
{ field: 'account' },
1616
{ field: 'status' },
1717
{ field: 'health' },
18+
{ field: 'labels' },
19+
{ field: 'team_members' },
1820
{ field: 'budget' },
1921
{ field: 'budget_remaining' },
2022
{ field: 'end_date' },
2123
],
24+
// Rich bulk-edit definitions (#2185) — select rows, then "set the same
25+
// value on all of them" through the BulkActionDialog. Each def exercises a
26+
// control the dialog gained in #2185:
27+
// • set_labels → multi-select on a `select` param (fixed options)
28+
// • assign_team → multi-select on a `lookup` param (users; array patch)
29+
// • reassign_account → single-select on a `lookup` param (searchable
30+
// reference picker, not a bare dropdown)
31+
// • reschedule → the new `date` control + a single-select together
32+
bulkActionDefs: [
33+
{
34+
name: 'set_labels',
35+
label: 'Set Labels',
36+
operation: 'update',
37+
confirmText: 'Set these labels on every selected project?',
38+
params: [
39+
{
40+
name: 'labels',
41+
label: 'Labels',
42+
type: 'select',
43+
multiple: true,
44+
required: true,
45+
options: [
46+
{ label: 'Frontend', value: 'frontend' },
47+
{ label: 'Backend', value: 'backend' },
48+
{ label: 'Design', value: 'design' },
49+
{ label: 'QA', value: 'qa' },
50+
{ label: 'DevOps', value: 'devops' },
51+
],
52+
},
53+
],
54+
},
55+
{
56+
name: 'assign_team',
57+
label: 'Assign Team',
58+
operation: 'update',
59+
confirmText: 'Assign these team members to every selected project?',
60+
params: [
61+
{
62+
name: 'team_members',
63+
label: 'Team Members',
64+
type: 'lookup',
65+
object: 'sys_user',
66+
multiple: true,
67+
labelField: 'name',
68+
required: true,
69+
},
70+
],
71+
},
72+
{
73+
name: 'reassign_account',
74+
label: 'Reassign Account',
75+
operation: 'update',
76+
confirmText: 'Move every selected project to this account?',
77+
params: [
78+
{
79+
name: 'account',
80+
label: 'Account',
81+
type: 'lookup',
82+
object: 'showcase_account',
83+
labelField: 'name',
84+
required: true,
85+
},
86+
],
87+
},
88+
{
89+
name: 'reschedule',
90+
label: 'Reschedule',
91+
operation: 'update',
92+
confirmText: 'Apply this schedule/status to every selected project?',
93+
params: [
94+
{ name: 'end_date', label: 'Target End Date', type: 'date' },
95+
{
96+
name: 'status',
97+
label: 'Status',
98+
type: 'select',
99+
options: [
100+
{ label: 'Planned', value: 'planned' },
101+
{ label: 'Active', value: 'active' },
102+
{ label: 'On Hold', value: 'on_hold' },
103+
{ label: 'Completed', value: 'completed' },
104+
{ label: 'Cancelled', value: 'cancelled' },
105+
],
106+
},
107+
],
108+
},
109+
],
22110
},
23111
listViews: {
24112
by_status: {

0 commit comments

Comments
 (0)