11import { useState , useMemo } from 'react' ;
22import { useParams , useSearchParams } from 'react-router-dom' ;
3- import { ObjectGrid } from '@object-ui/plugin-grid' ;
4- import { ObjectKanban } from '@object-ui/plugin-kanban' ;
5- import { ObjectCalendar } from '@object-ui/plugin-calendar' ;
63import { ObjectGantt } from '@object-ui/plugin-gantt' ;
4+ import { ListView } from '@object-ui/plugin-list' ;
5+ // Import plugins for side-effects (registration)
6+ import '@object-ui/plugin-grid' ;
7+ import '@object-ui/plugin-kanban' ;
8+ import '@object-ui/plugin-calendar' ;
79import { Button , Empty , EmptyTitle , EmptyDescription } from '@object-ui/components' ;
810import { Plus , Calendar as CalendarIcon , Kanban as KanbanIcon , Table as TableIcon , AlignLeft } from 'lucide-react' ;
11+ import type { ListViewSchema } from '@object-ui/types' ;
912
1013export function ObjectView ( { dataSource, objects, onEdit } : any ) {
1114 const { objectName } = useParams ( ) ;
@@ -85,85 +88,59 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
8588 onRowClick : ( record : any ) => onEdit ( record ) , // Default to edit on click
8689 } ;
8790
88- switch ( activeView . type ) {
89- case 'kanban' :
90- return (
91- < ObjectKanban
92- key = { key }
93- { ...commonProps }
94- schema = { {
95- type : 'kanban' ,
96- objectName : objectDef . name ,
97- groupBy : activeView . groupBy || 'status' ,
98- columns : activeView . columns ,
99- cardTitle : objectDef . titleField || 'name' , // Default title field
100- cardFields : activeView . columns
101- } }
102- { ...interactionProps }
103- />
104- ) ;
105- case 'calendar' :
106- return (
107- < ObjectCalendar
108- key = { key }
109- { ...commonProps }
110- schema = { {
111- type : 'calendar' ,
112- objectName : objectDef . name ,
113- dateField : activeView . dateField || 'due_date' ,
114- endField : activeView . endField ,
91+ // Gantt is not yet supported by ListView, handle separately
92+ if ( activeView . type === 'gantt' ) {
93+ return (
94+ < ObjectGantt
95+ key = { key }
96+ { ...commonProps }
97+ schema = { {
98+ type : 'object-grid' ,
99+ objectName : objectDef . name ,
100+ gantt : {
101+ startDateField : activeView . startDateField || 'start_date' ,
102+ endDateField : activeView . endDateField || 'end_date' ,
115103 titleField : activeView . titleField || 'name' ,
104+ progressField : activeView . progressField || 'progress' ,
105+ dependenciesField : activeView . dependenciesField ,
116106 colorField : activeView . colorField ,
117- } }
118- { ...interactionProps }
119- />
120- ) ;
121- case 'gantt' :
122- return (
123- < ObjectGantt
124- key = { key }
125- { ...commonProps }
126- schema = { {
127- type : 'object-grid' ,
128- objectName : objectDef . name ,
129- // Gantt config is read by ObjectGantt via getGanttConfig helper
130- // TypeScript workaround: gantt property not in ObjectGridSchema but supported by implementation
131- gantt : {
132- startDateField : activeView . startDateField || 'start_date' ,
133- endDateField : activeView . endDateField || 'end_date' ,
134- titleField : activeView . titleField || 'name' ,
135- progressField : activeView . progressField || 'progress' ,
136- dependenciesField : activeView . dependenciesField ,
137- colorField : activeView . colorField ,
138- }
139- } as any }
140- { ...interactionProps }
141- />
142- ) ;
143- case 'grid' :
144- default :
145- return (
146- < ObjectGrid
147- key = { key }
148- { ...commonProps }
149- schema = { {
150- type : 'object-grid' ,
151- objectName : objectDef . name ,
152- filterable : true ,
153- columns : getGridColumns ( activeView ) ,
154- filter : activeView . filter ,
155- sort : activeView . sort
156- } }
157- { ...interactionProps }
158- onDelete = { async ( record : any ) => {
159- if ( confirm ( `Delete record?` ) ) {
160- await dataSource . delete ( objectName , record . id || record . _id ) ;
161- setRefreshKey ( k => k + 1 ) ;
162- }
163- } }
164- />
165- ) ;
107+ }
108+ } as any }
109+ { ...interactionProps }
110+ />
111+ ) ;
166112 }
113+
114+ // Use standard ListView for supported types
115+ const listViewSchema : ListViewSchema = {
116+ type : 'list-view' ,
117+ objectName : objectDef . name ,
118+ viewType : activeView . type ,
119+ fields : activeView . columns ,
120+ filters : activeView . filter ,
121+ sort : activeView . sort ,
122+ options : {
123+ kanban : {
124+ groupField : activeView . groupBy || 'status' ,
125+ titleField : objectDef . titleField || 'name' ,
126+ cardFields : activeView . columns
127+ } ,
128+ calendar : {
129+ startDateField : activeView . dateField || 'due_date' ,
130+ endDateField : activeView . endField ,
131+ titleField : activeView . titleField || 'name' ,
132+ }
133+ }
134+ } ;
135+
136+ return (
137+ < ListView
138+ key = { key }
139+ schema = { listViewSchema }
140+ className = "h-full"
141+ { ...interactionProps }
142+ />
143+ ) ;
167144 } ;
168145
169146 return (
@@ -217,12 +194,7 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
217194
218195 { /* Right: View Options (Placeholder for now) */ }
219196 < div className = "flex items-center gap-2 hidden md:flex" >
220- < Button variant = "ghost" size = "sm" className = "h-8 text-muted-foreground" >
221- < span className = "text-xs" > Filter</ span >
222- </ Button >
223- < Button variant = "ghost" size = "sm" className = "h-8 text-muted-foreground" >
224- < span className = "text-xs" > Sort</ span >
225- </ Button >
197+ { /* Filter/Sort are handled by ListView now */ }
226198 </ div >
227199 </ div >
228200
@@ -234,4 +206,4 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
234206 </ div >
235207 </ div >
236208 ) ;
237- }
209+ }
0 commit comments