Skip to content

Commit 991ad32

Browse files
Copilothuangyiirene
andcommitted
Fix App branding schema and add new field types to examples
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent dd141b2 commit 991ad32

File tree

7 files changed

+118
-52
lines changed

7 files changed

+118
-52
lines changed

examples/crm/objectstack.config.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default App.create({
1616
label: 'CRM App',
1717
description: 'Comprehensive CRM example demonstrating all ObjectStack Protocol features',
1818
version: '2.0.0',
19+
icon: 'briefcase',
1920

2021
// All objects in the app
2122
objects: [
@@ -85,17 +86,10 @@ export default App.create({
8586
// Reports
8687
reports: Object.values(CrmReports),
8788

88-
// App-level settings
89-
settings: {
90-
theme: {
91-
primaryColor: '#4169E1',
92-
logo: '/assets/crm-logo.png',
93-
},
94-
features: {
95-
enableGlobalSearch: true,
96-
enableNotifications: true,
97-
enableMobileApp: true,
98-
enableOfflineMode: true,
99-
}
89+
// App-level branding
90+
branding: {
91+
primaryColor: '#4169E1',
92+
logo: '/assets/crm-logo.png',
93+
favicon: '/assets/crm-favicon.ico',
10094
}
10195
});

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const Account = ObjectSchema.create({
66
pluralLabel: 'Accounts',
77
icon: 'building',
88
description: 'Companies and organizations doing business with us',
9+
nameField: 'name',
910

1011
fields: {
1112
// AutoNumber field - Unique account identifier
@@ -69,12 +70,18 @@ export const Account = ObjectSchema.create({
6970
label: 'Website',
7071
}),
7172

72-
// Address fields
73-
billing_street: Field.textarea({ label: 'Billing Street' }),
74-
billing_city: Field.text({ label: 'Billing City' }),
75-
billing_state: Field.text({ label: 'Billing State/Province' }),
76-
billing_postal_code: Field.text({ label: 'Billing Postal Code' }),
77-
billing_country: Field.text({ label: 'Billing Country' }),
73+
// Structured Address field (new field type)
74+
billing_address: Field.address({
75+
label: 'Billing Address',
76+
addressFormat: 'international',
77+
}),
78+
79+
// Office Location (new field type)
80+
office_location: Field.location({
81+
label: 'Office Location',
82+
displayMap: true,
83+
allowGeocoding: true,
84+
}),
7885

7986
// Relationship fields
8087
owner: Field.lookup('user', {
@@ -104,13 +111,21 @@ export const Account = ObjectSchema.create({
104111
readonly: true,
105112
}),
106113

107-
// Formula field - combines first and last name
108-
full_address: Field.formula({
109-
label: 'Full Billing Address',
110-
expression: 'CONCAT(billing_street, ", ", billing_city, ", ", billing_state, " ", billing_postal_code, ", ", billing_country)',
114+
// Brand color (new field type)
115+
brand_color: Field.color({
116+
label: 'Brand Color',
117+
colorFormat: 'hex',
118+
presetColors: ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'],
111119
}),
112120
},
113121

122+
// Database indexes for performance
123+
indexes: [
124+
{ fields: ['name'], unique: false },
125+
{ fields: ['owner'], unique: false },
126+
{ fields: ['type', 'is_active'], unique: false },
127+
],
128+
114129
// Enable advanced features
115130
enable: {
116131
trackHistory: true, // Track field changes
@@ -176,12 +191,12 @@ export const Account = ObjectSchema.create({
176191
{
177192
label: 'Contact Details',
178193
columns: 2,
179-
fields: ['phone', 'website']
194+
fields: ['phone', 'website', 'brand_color']
180195
},
181196
{
182-
label: 'Billing Address',
197+
label: 'Location & Address',
183198
columns: 2,
184-
fields: ['billing_street', 'billing_city', 'billing_state', 'billing_postal_code', 'billing_country', 'full_address']
199+
fields: ['billing_address', 'office_location']
185200
},
186201
{
187202
label: 'Additional Information',

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,21 @@ export const Case = ObjectSchema.create({
133133
}),
134134

135135
// Customer satisfaction
136-
customer_rating: Field.select(['⭐ Very Dissatisfied', '⭐⭐ Dissatisfied', '⭐⭐⭐ Neutral', '⭐⭐⭐⭐ Satisfied', '⭐⭐⭐⭐⭐ Very Satisfied'], {
137-
label: 'Customer Rating',
136+
customer_rating: Field.rating(5, {
137+
label: 'Customer Satisfaction',
138+
description: 'Customer satisfaction rating (1-5 stars)',
138139
}),
139140

140141
customer_feedback: Field.textarea({
141142
label: 'Customer Feedback',
142143
}),
143144

145+
// Customer signature (for case resolution acknowledgment)
146+
customer_signature: Field.signature({
147+
label: 'Customer Signature',
148+
description: 'Digital signature acknowledging case resolution',
149+
}),
150+
144151
// Internal notes
145152
internal_notes: Field.markdown({
146153
label: 'Internal Notes',
@@ -155,6 +162,15 @@ export const Case = ObjectSchema.create({
155162
}),
156163
},
157164

165+
// Database indexes for performance
166+
indexes: [
167+
{ fields: ['case_number'], unique: true },
168+
{ fields: ['account'], unique: false },
169+
{ fields: ['owner'], unique: false },
170+
{ fields: ['status'], unique: false },
171+
{ fields: ['priority'], unique: false },
172+
],
173+
158174
enable: {
159175
trackHistory: true,
160176
searchable: true,
@@ -245,7 +261,7 @@ export const Case = ObjectSchema.create({
245261
{
246262
label: 'Resolution',
247263
columns: 1,
248-
fields: ['resolution', 'customer_rating', 'customer_feedback'],
264+
fields: ['resolution', 'customer_rating', 'customer_feedback', 'customer_signature'],
249265
},
250266
{
251267
label: 'SLA & Metrics',

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

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ export const Lead = ObjectSchema.create({
8080
]
8181
},
8282

83-
rating: {
84-
type: 'select',
85-
label: 'Rating',
86-
options: [
87-
{ label: 'Hot', value: 'hot', color: '#FF0000' },
88-
{ label: 'Warm', value: 'warm', color: '#FFA500' },
89-
{ label: 'Cold', value: 'cold', color: '#4169E1' },
90-
]
91-
},
83+
rating: Field.rating(5, {
84+
label: 'Lead Score',
85+
description: 'Lead quality score (1-5 stars)',
86+
allowHalf: true,
87+
}),
9288

9389
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement', 'Cold Call'], {
9490
label: 'Lead Source',
@@ -127,12 +123,11 @@ export const Lead = ObjectSchema.create({
127123
readonly: true,
128124
}),
129125

130-
// Address
131-
street: Field.textarea({ label: 'Street' }),
132-
city: Field.text({ label: 'City' }),
133-
state: Field.text({ label: 'State/Province' }),
134-
postal_code: Field.text({ label: 'Postal Code' }),
135-
country: Field.text({ label: 'Country' }),
126+
// Address (using new address field type)
127+
address: Field.address({
128+
label: 'Address',
129+
addressFormat: 'international',
130+
}),
136131

137132
// Additional Info
138133
annual_revenue: Field.currency({
@@ -148,6 +143,12 @@ export const Lead = ObjectSchema.create({
148143
label: 'Description',
149144
}),
150145

146+
// Custom notes with rich text formatting
147+
notes: Field.richtext({
148+
label: 'Notes',
149+
description: 'Rich text notes with formatting',
150+
}),
151+
151152
// Flags
152153
do_not_call: Field.boolean({
153154
label: 'Do Not Call',
@@ -160,6 +161,14 @@ export const Lead = ObjectSchema.create({
160161
}),
161162
},
162163

164+
// Database indexes for performance
165+
indexes: [
166+
{ fields: ['email'], unique: true },
167+
{ fields: ['owner'], unique: false },
168+
{ fields: ['status'], unique: false },
169+
{ fields: ['company'], unique: false },
170+
],
171+
163172
enable: {
164173
trackHistory: true,
165174
searchable: true,
@@ -235,13 +244,13 @@ export const Lead = ObjectSchema.create({
235244
{
236245
label: 'Address',
237246
columns: 2,
238-
fields: ['street', 'city', 'state', 'postal_code', 'country'],
247+
fields: ['address'],
239248
},
240249
{
241250
label: 'Additional Information',
242251
columns: 2,
243252
collapsible: true,
244-
fields: ['do_not_call', 'email_opt_out', 'description'],
253+
fields: ['do_not_call', 'email_opt_out', 'description', 'notes'],
245254
},
246255
{
247256
label: 'Conversion Information',
@@ -273,10 +282,10 @@ export const Lead = ObjectSchema.create({
273282

274283
workflows: [
275284
{
276-
name: 'auto_qualify_hot_leads',
285+
name: 'auto_qualify_high_score_leads',
277286
objectName: 'lead',
278287
triggerType: 'on_create_or_update',
279-
criteria: 'rating = "hot" AND status = "new"',
288+
criteria: 'rating >= 4 AND status = "new"',
280289
active: true,
281290
actions: [
282291
{
@@ -288,16 +297,16 @@ export const Lead = ObjectSchema.create({
288297
],
289298
},
290299
{
291-
name: 'notify_owner_on_hot_lead',
300+
name: 'notify_owner_on_high_score_lead',
292301
objectName: 'lead',
293302
triggerType: 'on_create_or_update',
294-
criteria: 'ISCHANGED(rating) AND rating = "hot"',
303+
criteria: 'ISCHANGED(rating) AND rating >= 4.5',
295304
active: true,
296305
actions: [
297306
{
298307
name: 'email_owner',
299308
type: 'email_alert',
300-
template: 'hot_lead_notification',
309+
template: 'high_score_lead_notification',
301310
recipients: ['{owner.email}'],
302311
}
303312
],

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const Opportunity = ObjectSchema.create({
66
pluralLabel: 'Opportunities',
77
icon: 'dollar-sign',
88
description: 'Sales opportunities and deals in the pipeline',
9+
nameField: 'name',
910

1011
fields: {
1112
// Basic Information
@@ -126,6 +127,15 @@ export const Opportunity = ObjectSchema.create({
126127
}),
127128
},
128129

130+
// Database indexes for performance
131+
indexes: [
132+
{ fields: ['name'], unique: false },
133+
{ fields: ['account'], unique: false },
134+
{ fields: ['owner'], unique: false },
135+
{ fields: ['stage'], unique: false },
136+
{ fields: ['close_date'], unique: false },
137+
],
138+
129139
// Enable advanced features
130140
enable: {
131141
trackHistory: true, // Critical for tracking stage changes

examples/todo/objectstack.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export default App.create({
66
label: 'Todo App',
77
description: 'A simple Todo example demonstrating ObjectStack Protocol',
88
version: '1.0.0',
9+
icon: 'check-square',
10+
branding: {
11+
primaryColor: '#10B981',
12+
logo: '/assets/todo-logo.png',
13+
},
914
objects: [
1015
TodoTask
1116
],

examples/todo/src/domains/todo/task.object.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,32 @@ export const TodoTask = ObjectSchema.create({
44
name: 'todo_task',
55
label: 'Todo Task',
66
icon: 'check-square',
7+
nameField: 'subject',
78
enable: {
89
apiEnabled: true,
10+
trackHistory: true,
911
},
1012
fields: {
1113
subject: Field.text({ required: true }),
1214
due_date: Field.date(),
1315
is_completed: Field.boolean({ defaultValue: false }),
14-
priority: Field.select(['High', 'Normal', 'Low'], {
15-
defaultValue: 'Normal'
16+
priority: Field.rating(3, {
17+
label: 'Priority',
18+
description: 'Task priority (1-3 stars)',
19+
}),
20+
category_color: Field.color({
21+
label: 'Category Color',
22+
colorFormat: 'hex',
23+
presetColors: ['#FF0000', '#00FF00', '#0000FF', '#FFFF00'],
24+
}),
25+
code_snippet: Field.code('javascript', {
26+
label: 'Code Snippet',
27+
description: 'Optional code to implement',
28+
lineNumbers: true,
29+
}),
30+
notes: Field.richtext({
31+
label: 'Notes',
32+
description: 'Rich text notes with formatting',
1633
}),
1734
},
1835
// actions: {

0 commit comments

Comments
 (0)