Skip to content

Commit 49c8a79

Browse files
authored
Merge pull request #151 from objectstack-ai/copilot/optimize-examples-for-new-protocol
2 parents ed44200 + d082151 commit 49c8a79

File tree

9 files changed

+50
-546
lines changed

9 files changed

+50
-546
lines changed

examples/crm/src/domains/crm/account.object.ts

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const Account = ObjectSchema.create({
66
pluralLabel: 'Accounts',
77
icon: 'building',
88
description: 'Companies and organizations doing business with us',
9-
nameField: 'name',
9+
titleFormat: '{account_number} - {name}',
10+
compactLayout: ['account_number', 'name', 'type', 'owner'],
1011

1112
fields: {
1213
// AutoNumber field - Unique account identifier
@@ -131,81 +132,10 @@ export const Account = ObjectSchema.create({
131132
apiEnabled: true, // Expose via REST/GraphQL
132133
apiMethods: ['get', 'list', 'create', 'update', 'delete', 'search', 'export'], // Whitelist allowed API operations
133134
files: true, // Allow file attachments
134-
feedEnabled: true, // Enable activity feed/chatter
135+
feeds: true, // Enable activity feed/chatter (Chatter-like)
136+
activities: true, // Enable tasks and events tracking
135137
trash: true, // Recycle bin support
136-
},
137-
138-
// List Views - Different visualization types
139-
list_views: {
140-
all: {
141-
label: 'All Accounts',
142-
type: 'grid',
143-
columns: ['account_number', 'name', 'type', 'industry', 'annual_revenue', 'owner'],
144-
sort: [{ field: 'name', order: 'asc' }],
145-
searchableFields: ['name', 'account_number', 'phone', 'website'],
146-
},
147-
my_accounts: {
148-
label: 'My Accounts',
149-
type: 'grid',
150-
columns: ['name', 'type', 'industry', 'annual_revenue', 'last_activity_date'],
151-
filter: [['owner', '=', '{current_user}']],
152-
sort: [{ field: 'last_activity_date', order: 'desc' }],
153-
},
154-
active_customers: {
155-
label: 'Active Customers',
156-
type: 'grid',
157-
columns: ['name', 'industry', 'annual_revenue', 'number_of_employees'],
158-
filter: [
159-
['type', '=', 'customer'],
160-
['is_active', '=', true]
161-
],
162-
},
163-
by_type: {
164-
label: 'Accounts by Type',
165-
type: 'kanban',
166-
columns: ['name', 'industry', 'annual_revenue'],
167-
kanban: {
168-
groupByField: 'type',
169-
summarizeField: 'annual_revenue',
170-
columns: ['name', 'industry', 'owner'],
171-
}
172-
}
173-
},
174-
175-
// Form Views
176-
form_views: {
177-
default: {
178-
type: 'tabbed',
179-
sections: [
180-
{
181-
label: 'Account Information',
182-
columns: 2,
183-
fields: ['account_number', 'name', 'type', 'industry', 'owner', 'parent_account', 'is_active']
184-
},
185-
{
186-
label: 'Financial Information',
187-
columns: 2,
188-
fields: ['annual_revenue', 'number_of_employees']
189-
},
190-
{
191-
label: 'Contact Details',
192-
columns: 2,
193-
fields: ['phone', 'website', 'brand_color']
194-
},
195-
{
196-
label: 'Location & Address',
197-
columns: 2,
198-
fields: ['billing_address', 'office_location']
199-
},
200-
{
201-
label: 'Additional Information',
202-
columns: 1,
203-
collapsible: true,
204-
collapsed: true,
205-
fields: ['description', 'last_activity_date']
206-
}
207-
]
208-
}
138+
mru: true, // Track Most Recently Used
209139
},
210140

211141
// Validation Rules

examples/crm/src/domains/crm/case.object.ts

Lines changed: 6 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -174,113 +174,16 @@ export const Case = ObjectSchema.create({
174174
searchable: true,
175175
apiEnabled: true,
176176
files: true,
177-
feedEnabled: true,
177+
feeds: true, // Enable social feed, comments, and mentions
178+
activities: true, // Enable tasks and events tracking
178179
trash: true,
180+
mru: true, // Track Most Recently Used
179181
},
180182

181-
nameField: 'subject',
183+
titleFormat: '{case_number} - {subject}',
184+
compactLayout: ['case_number', 'subject', 'account', 'status', 'priority'],
182185

183-
list_views: {
184-
all: {
185-
label: 'All Cases',
186-
type: 'grid',
187-
columns: ['case_number', 'subject', 'account', 'contact', 'status', 'priority', 'owner'],
188-
sort: [{ field: 'created_date', order: 'desc' }],
189-
searchableFields: ['case_number', 'subject', 'description'],
190-
},
191-
my_cases: {
192-
label: 'My Cases',
193-
type: 'grid',
194-
columns: ['case_number', 'subject', 'account', 'status', 'priority'],
195-
filter: [['owner', '=', '{current_user}']],
196-
sort: [{ field: 'priority', order: 'desc' }],
197-
},
198-
open_cases: {
199-
label: 'Open Cases',
200-
type: 'grid',
201-
columns: ['case_number', 'subject', 'account', 'status', 'priority', 'owner'],
202-
filter: [['is_closed', '=', false]],
203-
sort: [{ field: 'priority', order: 'desc' }],
204-
},
205-
critical_cases: {
206-
label: 'Critical Cases',
207-
type: 'grid',
208-
columns: ['case_number', 'subject', 'account', 'contact', 'status', 'owner'],
209-
filter: [
210-
['priority', '=', 'critical'],
211-
['is_closed', '=', false],
212-
],
213-
sort: [{ field: 'created_date', order: 'asc' }],
214-
},
215-
escalated_cases: {
216-
label: 'Escalated Cases',
217-
type: 'grid',
218-
columns: ['case_number', 'subject', 'account', 'priority', 'escalation_reason', 'owner'],
219-
filter: [['is_escalated', '=', true]],
220-
},
221-
by_status: {
222-
label: 'Cases by Status',
223-
type: 'kanban',
224-
columns: ['case_number', 'subject', 'account', 'priority'],
225-
filter: [['is_closed', '=', false]],
226-
kanban: {
227-
groupByField: 'status',
228-
columns: ['case_number', 'subject', 'contact', 'priority'],
229-
}
230-
},
231-
sla_violations: {
232-
label: 'SLA Violations',
233-
type: 'grid',
234-
columns: ['case_number', 'subject', 'account', 'sla_due_date', 'owner'],
235-
filter: [['is_sla_violated', '=', true]],
236-
sort: [{ field: 'sla_due_date', order: 'asc' }],
237-
}
238-
},
239-
240-
form_views: {
241-
default: {
242-
type: 'tabbed',
243-
sections: [
244-
{
245-
label: 'Case Information',
246-
columns: 2,
247-
fields: ['case_number', 'subject', 'type', 'origin', 'priority', 'status', 'owner'],
248-
},
249-
{
250-
label: 'Customer Information',
251-
columns: 2,
252-
fields: ['account', 'contact'],
253-
},
254-
{
255-
label: 'Description',
256-
columns: 1,
257-
fields: ['description'],
258-
},
259-
{
260-
label: 'Resolution',
261-
columns: 1,
262-
fields: ['resolution', 'customer_rating', 'customer_feedback', 'customer_signature'],
263-
},
264-
{
265-
label: 'SLA & Metrics',
266-
columns: 2,
267-
fields: ['created_date', 'first_response_date', 'closed_date', 'resolution_time_hours', 'sla_due_date', 'is_sla_violated'],
268-
},
269-
{
270-
label: 'Escalation',
271-
columns: 2,
272-
collapsible: true,
273-
fields: ['is_escalated', 'escalation_reason', 'parent_case'],
274-
},
275-
{
276-
label: 'Internal Information',
277-
columns: 1,
278-
collapsible: true,
279-
fields: ['internal_notes'],
280-
}
281-
]
282-
}
283-
},
186+
// Removed: list_views and form_views belong in UI configuration, not object definition
284187

285188
validations: [
286189
{

examples/crm/src/domains/crm/contact.object.ts

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -123,84 +123,15 @@ export const Contact = ObjectSchema.create({
123123
searchable: true,
124124
apiEnabled: true,
125125
files: true,
126-
feedEnabled: true,
126+
feeds: true, // Enable social feed, comments, and mentions
127+
activities: true, // Enable tasks and events tracking
127128
trash: true,
129+
mru: true, // Track Most Recently Used
128130
},
129131

130-
// Name field configuration
131-
nameField: 'full_name',
132-
133-
// List Views
134-
list_views: {
135-
all: {
136-
label: 'All Contacts',
137-
type: 'grid',
138-
columns: ['full_name', 'account', 'title', 'email', 'phone', 'owner'],
139-
sort: [{ field: 'last_name', order: 'asc' }],
140-
searchableFields: ['first_name', 'last_name', 'email', 'phone'],
141-
},
142-
my_contacts: {
143-
label: 'My Contacts',
144-
type: 'grid',
145-
columns: ['full_name', 'account', 'title', 'email', 'phone'],
146-
filter: [['owner', '=', '{current_user}']],
147-
},
148-
primary_contacts: {
149-
label: 'Primary Contacts',
150-
type: 'grid',
151-
columns: ['full_name', 'account', 'title', 'email', 'phone'],
152-
filter: [['is_primary', '=', true]],
153-
},
154-
by_department: {
155-
label: 'By Department',
156-
type: 'kanban',
157-
columns: ['full_name', 'account', 'title', 'email'],
158-
kanban: {
159-
groupByField: 'department',
160-
columns: ['full_name', 'title', 'email', 'phone'],
161-
}
162-
},
163-
birthdays: {
164-
label: 'Birthdays',
165-
type: 'calendar',
166-
columns: ['full_name', 'account', 'phone'],
167-
calendar: {
168-
startDateField: 'birthdate',
169-
titleField: 'full_name',
170-
colorField: 'department',
171-
}
172-
}
173-
},
174-
175-
// Form Views
176-
form_views: {
177-
default: {
178-
type: 'simple',
179-
sections: [
180-
{
181-
label: 'Contact Information',
182-
columns: 2,
183-
fields: ['salutation', 'first_name', 'last_name', 'full_name', 'account', 'title', 'department'],
184-
},
185-
{
186-
label: 'Contact Details',
187-
columns: 2,
188-
fields: ['email', 'phone', 'mobile', 'reports_to', 'owner'],
189-
},
190-
{
191-
label: 'Mailing Address',
192-
columns: 2,
193-
fields: ['mailing_street', 'mailing_city', 'mailing_state', 'mailing_postal_code', 'mailing_country'],
194-
},
195-
{
196-
label: 'Additional Information',
197-
columns: 2,
198-
collapsible: true,
199-
fields: ['birthdate', 'lead_source', 'is_primary', 'do_not_call', 'email_opt_out', 'description'],
200-
}
201-
]
202-
}
203-
},
132+
// Display configuration
133+
titleFormat: '{full_name}',
134+
compactLayout: ['full_name', 'email', 'account', 'phone'],
204135

205136
// Validation Rules
206137
validations: [

0 commit comments

Comments
 (0)