Skip to content

Commit 9ca0076

Browse files
Copilothotlong
andcommitted
Split views and actions into per-object files under src/views/ and src/actions/
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 0897265 commit 9ca0076

18 files changed

Lines changed: 728 additions & 680 deletions

examples/crm/objectstack.config.ts

Lines changed: 32 additions & 680 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const AccountActions = [
2+
{
3+
name: 'account_send_email',
4+
label: 'Send Email',
5+
icon: 'mail',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
params: [
9+
{ name: 'to', label: 'To Email', type: 'email' as const, required: true },
10+
{ name: 'subject', label: 'Subject', type: 'text' as const, required: true },
11+
{ name: 'body', label: 'Message', type: 'textarea' as const },
12+
],
13+
successMessage: 'Email sent successfully',
14+
},
15+
{
16+
name: 'account_assign_owner',
17+
label: 'Assign Owner',
18+
icon: 'user-plus',
19+
type: 'api' as const,
20+
locations: ['record_header' as const, 'list_item' as const],
21+
params: [
22+
{ name: 'owner_id', label: 'New Owner', type: 'lookup' as const, required: true },
23+
],
24+
refreshAfter: true,
25+
successMessage: 'Owner assigned successfully',
26+
},
27+
{
28+
name: 'account_merge',
29+
label: 'Merge Accounts',
30+
icon: 'git-merge',
31+
type: 'api' as const,
32+
locations: ['record_more' as const],
33+
confirmText: 'Are you sure you want to merge these accounts? This action cannot be undone.',
34+
variant: 'danger' as const,
35+
refreshAfter: true,
36+
},
37+
];
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const ContactActions = [
2+
{
3+
name: 'contact_send_email',
4+
label: 'Send Email',
5+
icon: 'mail',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
params: [
9+
{ name: 'subject', label: 'Subject', type: 'text' as const, required: true },
10+
{ name: 'body', label: 'Message', type: 'textarea' as const },
11+
],
12+
successMessage: 'Email sent successfully',
13+
},
14+
{
15+
name: 'contact_convert_to_customer',
16+
label: 'Convert to Customer',
17+
icon: 'user-check',
18+
type: 'api' as const,
19+
locations: ['record_header' as const],
20+
confirmText: 'Convert this contact to a customer?',
21+
refreshAfter: true,
22+
successMessage: 'Contact converted to customer',
23+
},
24+
{
25+
name: 'contact_log_call',
26+
label: 'Log a Call',
27+
icon: 'phone',
28+
type: 'api' as const,
29+
locations: ['record_header' as const, 'list_item' as const],
30+
params: [
31+
{ name: 'call_subject', label: 'Subject', type: 'text' as const, required: true },
32+
{ name: 'call_notes', label: 'Notes', type: 'textarea' as const },
33+
{ name: 'call_duration', label: 'Duration (min)', type: 'number' as const },
34+
],
35+
successMessage: 'Call logged successfully',
36+
},
37+
];
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export const EventActions = [
2+
{
3+
name: 'event_send_invitation',
4+
label: 'Send Invitation',
5+
icon: 'send',
6+
type: 'api' as const,
7+
locations: ['record_header' as const],
8+
params: [
9+
{ name: 'message', label: 'Optional Message', type: 'textarea' as const },
10+
],
11+
successMessage: 'Invitation sent to all participants',
12+
},
13+
{
14+
name: 'event_mark_completed',
15+
label: 'Mark as Completed',
16+
icon: 'check-circle',
17+
type: 'api' as const,
18+
locations: ['record_header' as const],
19+
confirmText: 'Mark this event as completed?',
20+
refreshAfter: true,
21+
successMessage: 'Event marked as completed',
22+
},
23+
{
24+
name: 'event_cancel',
25+
label: 'Cancel Event',
26+
icon: 'x-circle',
27+
type: 'api' as const,
28+
locations: ['record_more' as const],
29+
variant: 'danger' as const,
30+
params: [
31+
{ name: 'cancel_reason', label: 'Cancellation Reason', type: 'text' as const },
32+
{ name: 'notify_participants', label: 'Notify Participants', type: 'boolean' as const },
33+
],
34+
confirmText: 'Are you sure you want to cancel this event?',
35+
refreshAfter: true,
36+
successMessage: 'Event cancelled',
37+
},
38+
];
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export const OpportunityActions = [
2+
{
3+
name: 'opportunity_change_stage',
4+
label: 'Change Stage',
5+
icon: 'arrow-right-circle',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
params: [
9+
{
10+
name: 'new_stage', label: 'New Stage', type: 'select' as const, required: true,
11+
options: [
12+
{ label: 'Prospecting', value: 'prospecting' },
13+
{ label: 'Qualification', value: 'qualification' },
14+
{ label: 'Proposal', value: 'proposal' },
15+
{ label: 'Negotiation', value: 'negotiation' },
16+
{ label: 'Closed Won', value: 'closed_won' },
17+
{ label: 'Closed Lost', value: 'closed_lost' },
18+
],
19+
},
20+
],
21+
refreshAfter: true,
22+
successMessage: 'Stage updated successfully',
23+
},
24+
{
25+
name: 'opportunity_mark_won',
26+
label: 'Mark as Won',
27+
icon: 'trophy',
28+
type: 'api' as const,
29+
locations: ['record_header' as const],
30+
variant: 'primary' as const,
31+
confirmText: 'Mark this opportunity as Closed Won?',
32+
refreshAfter: true,
33+
successMessage: 'Opportunity marked as won!',
34+
},
35+
{
36+
name: 'opportunity_mark_lost',
37+
label: 'Mark as Lost',
38+
icon: 'x-circle',
39+
type: 'api' as const,
40+
locations: ['record_more' as const],
41+
variant: 'danger' as const,
42+
params: [
43+
{ name: 'loss_reason', label: 'Reason for Loss', type: 'text' as const, required: true },
44+
],
45+
confirmText: 'Mark this opportunity as Closed Lost?',
46+
refreshAfter: true,
47+
},
48+
];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export const OrderActions = [
2+
{
3+
name: 'order_change_status',
4+
label: 'Change Status',
5+
icon: 'refresh-cw',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
params: [
9+
{
10+
name: 'new_status', label: 'New Status', type: 'select' as const, required: true,
11+
options: [
12+
{ label: 'Draft', value: 'draft' },
13+
{ label: 'Pending', value: 'pending' },
14+
{ label: 'Paid', value: 'paid' },
15+
{ label: 'Shipped', value: 'shipped' },
16+
{ label: 'Delivered', value: 'delivered' },
17+
{ label: 'Cancelled', value: 'cancelled' },
18+
],
19+
},
20+
],
21+
refreshAfter: true,
22+
successMessage: 'Order status updated',
23+
},
24+
{
25+
name: 'order_generate_invoice',
26+
label: 'Generate Invoice',
27+
icon: 'file-text',
28+
type: 'api' as const,
29+
locations: ['record_header' as const],
30+
confirmText: 'Generate an invoice for this order?',
31+
successMessage: 'Invoice generated successfully',
32+
},
33+
{
34+
name: 'order_mark_shipped',
35+
label: 'Mark as Shipped',
36+
icon: 'truck',
37+
type: 'api' as const,
38+
locations: ['record_header' as const],
39+
params: [
40+
{ name: 'tracking_number', label: 'Tracking Number', type: 'text' as const, required: true },
41+
{ name: 'carrier', label: 'Carrier', type: 'text' as const },
42+
],
43+
refreshAfter: true,
44+
successMessage: 'Order marked as shipped',
45+
},
46+
];
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const ProductActions = [
2+
{
3+
name: 'product_toggle_active',
4+
label: 'Toggle Active',
5+
icon: 'toggle-left',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
refreshAfter: true,
9+
successMessage: 'Product status updated',
10+
},
11+
{
12+
name: 'product_update_price',
13+
label: 'Update Price',
14+
icon: 'dollar-sign',
15+
type: 'api' as const,
16+
locations: ['record_header' as const],
17+
params: [
18+
{ name: 'new_price', label: 'New Price', type: 'currency' as const, required: true },
19+
],
20+
refreshAfter: true,
21+
successMessage: 'Price updated successfully',
22+
},
23+
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export const ProjectActions = [
2+
{
3+
name: 'task_change_status',
4+
label: 'Change Status',
5+
icon: 'circle-check',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'list_item' as const],
8+
params: [
9+
{
10+
name: 'new_status', label: 'New Status', type: 'select' as const, required: true,
11+
options: [
12+
{ label: 'Planned', value: 'planned' },
13+
{ label: 'In Progress', value: 'in_progress' },
14+
{ label: 'Completed', value: 'completed' },
15+
{ label: 'On Hold', value: 'on_hold' },
16+
],
17+
},
18+
],
19+
refreshAfter: true,
20+
successMessage: 'Task status updated',
21+
},
22+
{
23+
name: 'task_assign',
24+
label: 'Assign User',
25+
icon: 'user-plus',
26+
type: 'api' as const,
27+
locations: ['record_header' as const, 'list_item' as const],
28+
params: [
29+
{ name: 'assignee_id', label: 'Assignee', type: 'lookup' as const, required: true },
30+
],
31+
refreshAfter: true,
32+
successMessage: 'Task assigned successfully',
33+
},
34+
];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export const UserActions = [
2+
{
3+
name: 'user_reset_password',
4+
label: 'Reset Password',
5+
icon: 'key',
6+
type: 'api' as const,
7+
locations: ['record_header' as const, 'record_more' as const],
8+
confirmText: 'Send a password reset link to this user?',
9+
successMessage: 'Password reset email sent',
10+
},
11+
{
12+
name: 'user_deactivate',
13+
label: 'Deactivate User',
14+
icon: 'user-x',
15+
type: 'api' as const,
16+
locations: ['record_more' as const],
17+
variant: 'danger' as const,
18+
confirmText: 'Are you sure you want to deactivate this user?',
19+
refreshAfter: true,
20+
successMessage: 'User deactivated',
21+
},
22+
];

examples/crm/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,20 @@ export * from './objects/order.object';
66
export * from './objects/user.object';
77
export * from './objects/project.object';
88
export * from './objects/event.object';
9+
export * from './views/account.view';
10+
export * from './views/contact.view';
11+
export * from './views/opportunity.view';
12+
export * from './views/product.view';
13+
export * from './views/order.view';
14+
export * from './views/user.view';
15+
export * from './views/event.view';
16+
export * from './views/project.view';
17+
export * from './actions/account.actions';
18+
export * from './actions/contact.actions';
19+
export * from './actions/opportunity.actions';
20+
export * from './actions/product.actions';
21+
export * from './actions/order.actions';
22+
export * from './actions/user.actions';
23+
export * from './actions/project.actions';
24+
export * from './actions/event.actions';
925
export { default as config } from '../objectstack.config';

0 commit comments

Comments
 (0)