Skip to content

Commit e13807a

Browse files
committed
Add Event object and integrate into CRM stack; enhance Account, Opportunity, Product, and Project objects with new fields and views
1 parent 14fa038 commit e13807a

File tree

7 files changed

+102
-17
lines changed

7 files changed

+102
-17
lines changed

examples/crm/objectstack.config.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ProductObject } from './src/objects/product.object';
77
import { OrderObject } from './src/objects/order.object';
88
import { UserObject } from './src/objects/user.object';
99
import { ProjectObject } from './src/objects/project.object';
10+
import { EventObject } from './src/objects/event.object';
1011

1112
export default defineStack({
1213
objects: [
@@ -16,7 +17,8 @@ export default defineStack({
1617
ProductObject,
1718
OrderObject,
1819
UserObject,
19-
ProjectObject
20+
ProjectObject,
21+
EventObject
2022
],
2123
apps: [
2224
App.create({
@@ -55,6 +57,12 @@ export default defineStack({
5557
objectName: 'project_task',
5658
label: 'Projects'
5759
},
60+
{
61+
id: 'nav_events',
62+
type: 'object',
63+
objectName: 'event',
64+
label: 'Calendar'
65+
},
5866
{
5967
id: 'nav_sales',
6068
type: 'group',
@@ -247,9 +255,9 @@ export default defineStack({
247255
object: 'account',
248256
mode: 'upsert',
249257
records: [
250-
{ _id: "1", name: "TechCorp" },
251-
{ _id: "2", name: "Software Inc" },
252-
{ _id: "3", name: "Good Grief LLC" }
258+
{ _id: "1", name: "TechCorp", industry: "Technology", type: "Customer", billing_address: "100 Tech Blvd, Silicon Valley, CA", website: "https://techcorp.com", phone: "555-0100" },
259+
{ _id: "2", name: "Software Inc", industry: "Technology", type: "Partner", billing_address: "200 Cloud Way, Seattle, WA", website: "https://softwareinc.com", phone: "555-0200" },
260+
{ _id: "3", name: "Good Grief LLC", industry: "Retail", type: "Customer", billing_address: "300 Peanut Ave, Minneapolis, MN", website: "https://peanuts.com", phone: "555-0300" }
253261
]
254262
},
255263
{
@@ -309,9 +317,11 @@ export default defineStack({
309317
object: 'product',
310318
mode: 'upsert',
311319
records: [
312-
{ _id: "p1", sku: 'PROD-001', name: 'Laptop', category: 'Electronics', price: 1299.99, stock: 15 },
313-
{ _id: "p2", sku: 'PROD-002', name: 'Mouse', category: 'Electronics', price: 29.99, stock: 120 },
314-
{ _id: "p3", sku: 'PROD-003', name: 'Desk Chair', category: 'Furniture', price: 249.99, stock: 8 }
320+
{ _id: "p1", sku: 'PROD-001', name: 'Laptop', category: 'Electronics', price: 1299.99, stock: 15, image: 'https://images.unsplash.com/photo-1496181133206-80ce9b88a853?w=300&q=80' },
321+
{ _id: "p2", sku: 'PROD-002', name: 'Wireless Mouse', category: 'Electronics', price: 29.99, stock: 120, image: 'https://images.unsplash.com/photo-1527864550417-7fd91fc51a46?w=300&q=80' },
322+
{ _id: "p3", sku: 'PROD-003', name: 'Ergonomic Chair', category: 'Furniture', price: 249.99, stock: 8, image: 'https://images.unsplash.com/photo-1505843490538-5133c6c7d0e1?w=300&q=80' },
323+
{ _id: "p4", sku: 'PROD-004', name: 'Standing Desk', category: 'Furniture', price: 499.99, stock: 20, image: 'https://images.unsplash.com/photo-1595515106969-1ce29566ff1c?w=300&q=80' },
324+
{ _id: "p5", sku: 'PROD-005', name: 'Noise Cancelling Headphones', category: 'Electronics', price: 199.99, stock: 45, image: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=300&q=80' }
315325
]
316326
},
317327
{
@@ -326,12 +336,22 @@ export default defineStack({
326336
object: 'project_task',
327337
mode: 'upsert',
328338
records: [
329-
{ _id: "t1", name: "Requirements Gathering", start_date: new Date("2024-01-01"), end_date: new Date("2024-01-14"), progress: 100, status: 'Completed', color: '#10b981' },
330-
{ _id: "t2", name: "System Design", start_date: new Date("2024-01-15"), end_date: new Date("2024-02-15"), progress: 100, status: 'Completed', color: '#3b82f6' },
331-
{ _id: "t3", name: "Implementation", start_date: new Date("2024-02-16"), end_date: new Date("2024-04-30"), progress: 65, status: 'In Progress', color: '#8b5cf6' },
332-
{ _id: "t4", name: "Quality Assurance", start_date: new Date("2024-05-01"), end_date: new Date("2024-05-30"), progress: 0, status: 'Planned', color: '#f59e0b' },
333-
{ _id: "t5", name: "User Acceptance", start_date: new Date("2024-06-01"), end_date: new Date("2024-06-15"), progress: 0, status: 'Planned', color: '#f43f5e' },
334-
{ _id: "t6", name: "Go Live", start_date: new Date("2024-06-20"), end_date: new Date("2024-06-20"), progress: 0, status: 'Planned', color: '#ef4444' }
339+
{ _id: "t1", name: "Requirements Gathering", start_date: new Date("2024-01-01"), end_date: new Date("2024-01-14"), progress: 100, status: 'Completed', color: '#10b981', priority: 'High' },
340+
{ _id: "t2", name: "System Design", start_date: new Date("2024-01-15"), end_date: new Date("2024-02-15"), progress: 100, status: 'Completed', color: '#3b82f6', priority: 'High', dependencies: 't1' },
341+
{ _id: "t3", name: "Implementation", start_date: new Date("2024-02-16"), end_date: new Date("2024-04-30"), progress: 65, status: 'In Progress', color: '#8b5cf6', priority: 'High', dependencies: 't2' },
342+
{ _id: "t4", name: "Quality Assurance", start_date: new Date("2024-05-01"), end_date: new Date("2024-05-30"), progress: 0, status: 'Planned', color: '#f59e0b', priority: 'Medium', dependencies: 't3' },
343+
{ _id: "t5", name: "User Acceptance", start_date: new Date("2024-06-01"), end_date: new Date("2024-06-15"), progress: 0, status: 'Planned', color: '#f43f5e', priority: 'Medium', dependencies: 't4' },
344+
{ _id: "t6", name: "Go Live", start_date: new Date("2024-06-20"), end_date: new Date("2024-06-20"), progress: 0, status: 'Planned', color: '#ef4444', priority: 'Critical', dependencies: 't5' }
345+
]
346+
},
347+
{
348+
object: 'event',
349+
mode: 'upsert',
350+
records: [
351+
{ _id: "e1", subject: "Weekly Standup", start: new Date("2024-02-05T09:00:00"), end: new Date("2024-02-05T10:00:00"), location: "Conference Room A", type: "Meeting", description: "Team synchronization" },
352+
{ _id: "e2", subject: "Client Call - TechCorp", start: new Date("2024-02-06T14:00:00"), end: new Date("2024-02-06T15:00:00"), location: "Zoom", type: "Call", description: "Project update" },
353+
{ _id: "e3", subject: "Project Review", start: new Date("2024-02-08T10:00:00"), end: new Date("2024-02-08T11:30:00"), location: "Board Room", type: "Meeting", description: "Milestone review" },
354+
{ _id: "e4", subject: "Lunch with Partners", start: new Date("2024-02-09T12:00:00"), end: new Date("2024-02-09T13:30:00"), location: "Downtown Cafe", type: "Other", description: "Networking" }
335355
]
336356
}
337357
]

examples/crm/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from './objects/product.object';
55
export * from './objects/order.object';
66
export * from './objects/user.object';
77
export * from './objects/project.object';
8+
export * from './objects/event.object';
89
export { default as config } from '../objectstack.config';

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ export const AccountObject = ObjectSchema.create({
1212
annual_revenue: Field.currency({ label: 'Annual Revenue' }),
1313
website: Field.url({ label: 'Website' }),
1414
phone: Field.text({ label: 'Phone' }),
15+
billing_address: Field.textarea({ label: 'Billing Address' }),
1516
owner: Field.lookup('user', { label: 'Owner' })
1617
},
1718
list_views: {
1819
all: {
1920
label: 'All Accounts',
2021
columns: ['name', 'industry', 'type', 'phone', 'website']
2122
},
23+
map_view: {
24+
label: 'Account Map',
25+
type: 'map',
26+
locationField: 'billing_address',
27+
titleField: 'name'
28+
} as any,
2229
customers: {
2330
label: 'Customers',
2431
columns: ['name', 'industry', 'annual_revenue'],
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec/data';
2+
3+
export const EventObject = ObjectSchema.create({
4+
name: 'event',
5+
label: 'Event',
6+
icon: 'calendar',
7+
fields: {
8+
subject: Field.text({ label: 'Subject', required: true }),
9+
start: Field.datetime({ label: 'Start', required: true }),
10+
end: Field.datetime({ label: 'End', required: true }),
11+
location: Field.text({ label: 'Location' }),
12+
description: Field.textarea({ label: 'Description' }),
13+
participants: Field.lookup('contact', { label: 'Participants', multiple: true }),
14+
type: Field.select(['Meeting', 'Call', 'Email', 'Other'], { label: 'Type' })
15+
},
16+
list_views: {
17+
all: {
18+
label: 'All Events',
19+
columns: ['subject', 'start', 'end', 'location', 'type']
20+
},
21+
calendar: {
22+
label: 'Calendar',
23+
type: 'calendar',
24+
startDateField: 'start',
25+
endDateField: 'end',
26+
titleField: 'subject',
27+
defaultView: 'month'
28+
} as any
29+
}
30+
});

examples/crm/src/objects/opportunity.object.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ export const OpportunityObject = ObjectSchema.create({
3333
label: 'Pipeline',
3434
type: 'kanban',
3535
columns: ['name', 'amount', 'account'],
36-
groupBy: 'stage'
37-
}
36+
groupField: 'stage',
37+
titleField: 'name',
38+
cardFields: ['amount', 'account', 'close_date']
39+
} as any,
40+
chart: {
41+
label: 'By Stage',
42+
type: 'chart',
43+
chartType: 'bar',
44+
xAxisField: 'stage',
45+
yAxisFields: ['amount'],
46+
aggregation: 'sum'
47+
} as any
3848
}
3949
});

examples/crm/src/objects/product.object.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export const ProductObject = ObjectSchema.create({
2222
label: 'Low Stock',
2323
columns: ['name', 'stock', 'price'],
2424
filter: [['stock', '<', 10]]
25-
}
25+
},
26+
gallery: {
27+
label: 'Product Gallery',
28+
type: 'gallery',
29+
columns: ['name', 'category', 'price'],
30+
imageField: 'image',
31+
titleField: 'name',
32+
subtitleField: 'category'
33+
} as any
2634
}
2735
});

examples/crm/src/objects/project.object.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ProjectObject = ObjectSchema.create({
1414
manager: Field.lookup('user', { label: 'Manager' }),
1515
description: Field.textarea({ label: 'Description' }),
1616
color: Field.text({ label: 'Color' }), // For Gantt bar color
17+
dependencies: Field.text({ label: 'Dependencies' }), // Comma separated IDs
1718
},
1819
list_views: {
1920
all: {
@@ -30,7 +31,15 @@ export const ProjectObject = ObjectSchema.create({
3031
endDateField: 'end_date',
3132
titleField: 'name',
3233
progressField: 'progress',
34+
dependenciesField: 'dependencies',
3335
colorField: 'color',
34-
} as any // Cast to allow extra properties if type definition is strict
36+
} as any, // Cast to allow extra properties if type definition is strict
37+
timeline_view: {
38+
label: 'Timeline',
39+
type: 'timeline',
40+
dateField: 'start_date',
41+
titleField: 'name',
42+
columns: ['status', 'priority']
43+
} as any
3544
}
3645
});

0 commit comments

Comments
 (0)