Skip to content

Commit faca542

Browse files
Copilothotlong
andcommitted
Add comprehensive implementation guide for UI showcase examples
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 30c12d1 commit faca542

1 file changed

Lines changed: 350 additions & 0 deletions

File tree

Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
# UI Showcase Examples - Implementation Guide
2+
3+
## Overview
4+
5+
This directory contains comprehensive examples demonstrating ObjectStack's UI capabilities, including FormView (类似 Salesforce Page Layout), PageSchema (类似 Salesforce Lightning Record Page / FlexiPage), and component properties.
6+
7+
## 📋 What's Included
8+
9+
### 1. FormView Examples (`src/views/lead.view.ts`)
10+
11+
#### All 6 Form Layout Types
12+
13+
1. **Simple Layout** (`form` and `quick_create`)
14+
- Basic sectioned forms
15+
- Collapsible sections
16+
- 1-4 column layouts per section
17+
- Example: Contact information form with multiple sections
18+
19+
2. **Tabbed Layout** (`detail_form`)
20+
- Multiple tabs for complex data organization
21+
- Each tab can have different column configurations
22+
- Example: General, Qualification, Address, Details tabs
23+
24+
3. **Wizard Layout** (`lead_conversion_wizard`)
25+
- Step-by-step guided process
26+
- Multi-step data collection
27+
- Review step at the end
28+
- Example: Lead conversion process
29+
30+
4. **Split Layout** (`split_edit`)
31+
- Master-detail split view
32+
- Primary info on one side, extended details on the other
33+
- Example: Quick info + detailed fields
34+
35+
5. **Drawer Layout** (`quick_edit_drawer`)
36+
- Side panel form
37+
- Typically single column
38+
- Perfect for quick edits from list views
39+
- Example: Quick edit form
40+
41+
6. **Modal Layout** (`status_update_modal`)
42+
- Dialog-based form
43+
- Focused quick actions
44+
- Example: Status update dialog
45+
46+
#### Advanced Form Features
47+
48+
**Section Configuration:**
49+
```typescript
50+
{
51+
label: 'Contact Information',
52+
collapsible: true, // Can be collapsed
53+
collapsed: false, // Initial state
54+
columns: 2, // 1, 2, 3, or 4 columns
55+
fields: [...]
56+
}
57+
```
58+
59+
**Field-Level Controls:**
60+
```typescript
61+
{
62+
field: 'first_name',
63+
required: true, // Override field required status
64+
readonly: false, // Make field read-only
65+
hidden: false, // Hide field
66+
colSpan: 2, // Span 2 columns (1-4)
67+
visibleOn: 'status != "new"', // Conditional visibility
68+
dependsOn: 'country', // Cascading dependency
69+
widget: 'star_rating', // Custom widget override
70+
placeholder: 'Enter first name',
71+
helpText: 'The lead\'s first name'
72+
}
73+
```
74+
75+
### 2. PageSchema Examples (`src/pages/`)
76+
77+
#### Page Types
78+
79+
1. **Record Page** (`lead_detail.page.ts`)
80+
- Template: `header-sidebar-main`
81+
- Components: highlights, details, tabs, accordion, related lists
82+
- Features: AI chat, activity timeline, field history
83+
- Regions: header, sidebar, main
84+
85+
2. **Home Page** (`home.page.ts`)
86+
- Template: `three-column`
87+
- Components: KPIs, recent items, quick create
88+
- Features: Dashboard widgets, quick access
89+
- Regions: header, left_sidebar, main, right_sidebar
90+
91+
3. **App Page** (`app_launcher.page.ts`)
92+
- Template: `centered`
93+
- Components: global search, app grid
94+
- Features: Application launcher
95+
- Regions: header, main
96+
97+
4. **Utility Page** (`utility_bar.page.ts`)
98+
- Template: `utility-bar`
99+
- Components: notifications, chat, notes, search
100+
- Features: Floating utility panels
101+
- Regions: utilities
102+
103+
#### Component Types Demonstrated
104+
105+
**Record Context Components:**
106+
- `record:details` - Field display with 1-4 columns
107+
```typescript
108+
{
109+
type: 'record:details',
110+
properties: {
111+
columns: '2',
112+
layout: 'auto', // or 'custom'
113+
fields: ['name', 'email', 'phone'] // optional override
114+
}
115+
}
116+
```
117+
118+
- `record:highlights` - Key field highlights (1-7 fields)
119+
```typescript
120+
{
121+
type: 'record:highlights',
122+
properties: {
123+
fields: ['status', 'rating', 'owner', 'email'],
124+
layout: 'horizontal' // or 'vertical'
125+
}
126+
}
127+
```
128+
129+
- `record:related_list` - Related records list
130+
```typescript
131+
{
132+
type: 'record:related_list',
133+
properties: {
134+
objectName: 'task',
135+
relationshipField: 'lead_id',
136+
columns: ['subject', 'status', 'due_date'],
137+
sort: [{ field: 'due_date', order: 'asc' }],
138+
limit: 10,
139+
filter: [['status', '!=', 'completed']],
140+
showViewAll: true,
141+
actions: ['new_task', 'edit']
142+
}
143+
}
144+
```
145+
146+
- `record:activity` - Activity timeline
147+
- `record:path` - Status path/progress indicator
148+
149+
**Structural Components:**
150+
- `page:header` - Page header with title, breadcrumb, actions
151+
- `page:tabs` - Tabbed content areas
152+
- `page:accordion` - Collapsible panels
153+
- `page:card` - Card containers
154+
155+
**AI Components:**
156+
- `ai:chat_window` - AI assistant integration
157+
```typescript
158+
{
159+
type: 'ai:chat_window',
160+
properties: {
161+
mode: 'sidebar', // 'float', 'sidebar', or 'inline'
162+
agentId: 'sales_assistant',
163+
context: {
164+
recordType: 'lead',
165+
recordId: '{record.id}'
166+
}
167+
}
168+
}
169+
```
170+
171+
#### Page Features
172+
173+
**Component Visibility Rules:**
174+
```typescript
175+
{
176+
type: 'ai:chat_window',
177+
visibility: 'status == "qualified" OR status == "contacted"'
178+
}
179+
```
180+
181+
**Profile Assignment:**
182+
```typescript
183+
{
184+
assignedProfiles: ['sales_user', 'sales_manager', 'system_administrator']
185+
}
186+
```
187+
188+
**Page Variables:**
189+
```typescript
190+
variables: [
191+
{
192+
name: 'showHistory',
193+
type: 'boolean',
194+
defaultValue: false
195+
}
196+
]
197+
```
198+
199+
### 3. List Views (`src/views/lead.view.ts`)
200+
201+
Demonstrates multiple list view types:
202+
203+
1. **Grid View** (`all_leads`) - Standard data table with:
204+
- Enhanced column configuration
205+
- Quick filters (Salesforce-style)
206+
- Row/bulk actions
207+
- Inline editing
208+
- Export options
209+
210+
2. **Kanban View** (`kanban_by_status`) - Board layout
211+
3. **Calendar View** (`calendar_by_created`) - Calendar display
212+
4. **Gallery View** (`gallery_view`) - Card/masonry layout
213+
214+
## 🎯 Key Patterns
215+
216+
### Pattern 1: Conditional Field Visibility
217+
218+
```typescript
219+
{
220+
field: 'owner',
221+
visibleOn: 'status == "contacted" OR status == "qualified"'
222+
}
223+
```
224+
225+
### Pattern 2: Cascading Dependencies
226+
227+
```typescript
228+
{
229+
field: 'state',
230+
dependsOn: 'country' // State options based on country selection
231+
}
232+
```
233+
234+
### Pattern 3: Custom Widgets
235+
236+
```typescript
237+
{
238+
field: 'rating',
239+
widget: 'star_rating' // Use custom star rating widget
240+
}
241+
```
242+
243+
### Pattern 4: Multi-Column Spanning
244+
245+
```typescript
246+
{
247+
field: 'description',
248+
colSpan: 2 // Span 2 columns in a 2-column layout
249+
}
250+
```
251+
252+
### Pattern 5: Component Composition in Pages
253+
254+
```typescript
255+
regions: [
256+
{
257+
name: 'main',
258+
components: [
259+
{
260+
type: 'page:tabs',
261+
properties: {
262+
items: [
263+
{
264+
label: 'Details',
265+
children: [
266+
{
267+
type: 'record:details',
268+
properties: { columns: '2' }
269+
}
270+
]
271+
}
272+
]
273+
}
274+
}
275+
]
276+
}
277+
]
278+
```
279+
280+
## 🚀 Usage Examples
281+
282+
### Using a Named Form View
283+
284+
```typescript
285+
// In your navigation config
286+
navigation: {
287+
mode: 'page',
288+
view: 'detail_form' // Reference the named form view
289+
}
290+
```
291+
292+
### Switching Between Form Layouts
293+
294+
```typescript
295+
// Simple form for quick create
296+
formViews: {
297+
quick_create: { type: 'simple', ... },
298+
299+
// Wizard for complex process
300+
conversion: { type: 'wizard', ... },
301+
302+
// Drawer for quick edit
303+
quick_edit: { type: 'drawer', ... }
304+
}
305+
```
306+
307+
### Profile-Based Page Assignment
308+
309+
```typescript
310+
// Assign different pages to different profiles
311+
{
312+
name: 'lead_detail_sales',
313+
assignedProfiles: ['sales_user'],
314+
...
315+
},
316+
{
317+
name: 'lead_detail_admin',
318+
assignedProfiles: ['system_administrator'],
319+
...
320+
}
321+
```
322+
323+
## 📐 Best Practices
324+
325+
1. **Form Sections**: Use 1-2 columns for most forms, 3-4 for compact displays
326+
2. **Field Spanning**: Use colSpan for full-width text areas and descriptions
327+
3. **Collapsible Sections**: Collapse less frequently used sections by default
328+
4. **Conditional Visibility**: Use visibleOn for dynamic forms that adapt to data
329+
5. **Dependencies**: Use dependsOn for cascading field relationships
330+
6. **Named Views**: Create multiple named views for different user scenarios
331+
7. **Page Templates**: Choose appropriate templates based on layout needs
332+
8. **Component Composition**: Nest components logically within regions
333+
9. **ARIA Attributes**: Always include accessibility attributes
334+
10. **Profile Assignment**: Assign pages to appropriate user profiles
335+
336+
## 🔍 Reference
337+
338+
- **Naming Convention**: All identifiers (object names, field names, view names) use `snake_case`
339+
- **Configuration Properties**: All config keys use `camelCase` (e.g., `colSpan`, `visibleOn`)
340+
- **Salesforce Equivalents**:
341+
- FormView → Page Layout
342+
- PageSchema → Lightning Record Page / FlexiPage
343+
- Components → Lightning Components
344+
- Regions → Component regions in Lightning pages
345+
346+
## 📚 Related Documentation
347+
348+
- See `packages/spec/src/ui/view.zod.ts` for complete FormView schema
349+
- See `packages/spec/src/ui/page.zod.ts` for complete PageSchema
350+
- See `packages/spec/src/ui/component.zod.ts` for all component property schemas

0 commit comments

Comments
 (0)