Skip to content

Commit fa4156b

Browse files
committed
feat: add ProjectObject schema and integrate Gantt view support in ObjectView
1 parent 0d4e166 commit fa4156b

6 files changed

Lines changed: 76 additions & 2 deletions

File tree

apps/console/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@object-ui/plugin-calendar": "workspace:*",
3434
"@object-ui/plugin-dashboard": "workspace:*",
3535
"@object-ui/plugin-form": "workspace:*",
36+
"@object-ui/plugin-gantt": "workspace:*",
3637
"@object-ui/plugin-grid": "workspace:*",
3738
"@object-ui/plugin-kanban": "workspace:*",
3839
"@object-ui/react": "workspace:*",

apps/console/src/components/ObjectView.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { useParams, useSearchParams } from 'react-router-dom';
33
import { ObjectGrid } from '@object-ui/plugin-grid';
44
import { ObjectKanban } from '@object-ui/plugin-kanban';
55
import { ObjectCalendar } from '@object-ui/plugin-calendar';
6+
import { ObjectGantt } from '@object-ui/plugin-gantt';
67
import { Button, Tabs, TabsList, TabsTrigger } from '@object-ui/components';
7-
import { Plus, Calendar as CalendarIcon, Kanban as KanbanIcon, Table as TableIcon } from 'lucide-react';
8+
import { Plus, Calendar as CalendarIcon, Kanban as KanbanIcon, Table as TableIcon, AlignLeft } from 'lucide-react';
89

910
export function ObjectView({ dataSource, objects, onEdit }: any) {
1011
const { objectName } = useParams();
@@ -110,10 +111,33 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
110111
dateField: activeView.dateField || 'due_date',
111112
endField: activeView.endField,
112113
titleField: activeView.titleField || 'name',
114+
colorField: activeView.colorField,
113115
}}
114116
{...interactionProps}
115117
/>
116118
);
119+
case 'gantt':
120+
return (
121+
<ObjectGantt
122+
key={key}
123+
{...commonProps}
124+
schema={{
125+
type: 'gantt',
126+
objectName: objectDef.name,
127+
filter: {
128+
gantt: {
129+
startDateField: activeView.startDateField || 'start_date',
130+
endDateField: activeView.endDateField || 'end_date',
131+
titleField: activeView.titleField || 'name',
132+
progressField: activeView.progressField || 'progress',
133+
dependenciesField: activeView.dependenciesField,
134+
colorField: activeView.colorField,
135+
}
136+
}
137+
}}
138+
{...interactionProps}
139+
/>
140+
);
117141
case 'grid':
118142
default:
119143
return (
@@ -160,6 +184,7 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
160184
{v.type === 'kanban' && <KanbanIcon className="mr-2 h-3.5 w-3.5" />}
161185
{v.type === 'calendar' && <CalendarIcon className="mr-2 h-3.5 w-3.5" />}
162186
{v.type === 'grid' && <TableIcon className="mr-2 h-3.5 w-3.5" />}
187+
{v.type === 'gantt' && <AlignLeft className="mr-2 h-3.5 w-3.5" />}
163188
{v.label}
164189
</TabsTrigger>
165190
))}

examples/crm/objectstack.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { OpportunityObject } from './src/objects/opportunity.object';
66
import { ProductObject } from './src/objects/product.object';
77
import { OrderObject } from './src/objects/order.object';
88
import { UserObject } from './src/objects/user.object';
9+
import { ProjectObject } from './src/objects/project.object';
910

1011
export default defineStack({
1112
objects: [
@@ -14,7 +15,8 @@ export default defineStack({
1415
OpportunityObject,
1516
ProductObject,
1617
OrderObject,
17-
UserObject
18+
UserObject,
19+
ProjectObject
1820
],
1921
apps: [
2022
App.create({
@@ -47,6 +49,12 @@ export default defineStack({
4749
objectName: 'opportunity',
4850
label: 'Opportunities'
4951
},
52+
{
53+
id: 'nav_projects',
54+
type: 'object',
55+
objectName: 'project_task',
56+
label: 'Projects'
57+
},
5058
{
5159
id: 'nav_sales',
5260
type: 'group',

examples/crm/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export * from './objects/opportunity.object';
44
export * from './objects/product.object';
55
export * from './objects/order.object';
66
export * from './objects/user.object';
7+
export * from './objects/project.object';
78
export { default as config } from '../objectstack.config';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec/data';
2+
3+
export const ProjectObject = ObjectSchema.create({
4+
name: 'project_task',
5+
label: 'Project Task',
6+
icon: 'clipboard-list',
7+
fields: {
8+
name: Field.text({ label: 'Task Name', required: true, searchable: true }),
9+
start_date: Field.date({ label: 'Start Date', required: true }),
10+
end_date: Field.date({ label: 'End Date', required: true }),
11+
progress: Field.percent({ label: 'Progress' }),
12+
status: Field.select(['Planned', 'In Progress', 'Completed', 'On Hold'], { label: 'Status' }),
13+
priority: Field.select(['High', 'Medium', 'Low'], { label: 'Priority' }),
14+
manager: Field.lookup('user', { label: 'Manager' }),
15+
description: Field.textarea({ label: 'Description' }),
16+
color: Field.text({ label: 'Color' }), // For Gantt bar color
17+
},
18+
list_views: {
19+
all: {
20+
label: 'All Tasks',
21+
columns: ['name', 'status', 'progress', 'start_date', 'end_date', 'priority', 'manager'],
22+
sort: [['start_date', 'asc']]
23+
},
24+
gantt_view: {
25+
label: 'Gantt View',
26+
type: 'gantt',
27+
columns: ['name', 'start_date', 'end_date', 'progress'],
28+
// Standard Gantt configuration mapped to specific fields
29+
startDateField: 'start_date',
30+
endDateField: 'end_date',
31+
titleField: 'name',
32+
progressField: 'progress',
33+
colorField: 'color',
34+
} as any // Cast to allow extra properties if type definition is strict
35+
}
36+
});

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)