Skip to content

Commit 4106b4a

Browse files
committed
Add support for additional view types in ListView and ViewSwitcher
1 parent 603da9f commit 4106b4a

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

packages/plugin-list/src/ListView.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,46 @@ export const ListView: React.FC<ListViewProps> = ({
128128
yAxisFields: schema.options?.chart?.yAxisFields || ['value'],
129129
...(schema.options?.chart || {}),
130130
};
131+
case 'spreadsheet':
132+
return {
133+
type: 'object-spreadsheet',
134+
...baseProps,
135+
...(schema.options?.spreadsheet || {}),
136+
};
137+
case 'gallery':
138+
return {
139+
type: 'object-gallery',
140+
...baseProps,
141+
imageField: schema.options?.gallery?.imageField,
142+
titleField: schema.options?.gallery?.titleField || 'name',
143+
subtitleField: schema.options?.gallery?.subtitleField,
144+
...(schema.options?.gallery || {}),
145+
};
146+
case 'timeline':
147+
return {
148+
type: 'object-timeline',
149+
...baseProps,
150+
dateField: schema.options?.timeline?.dateField || 'created_at',
151+
titleField: schema.options?.timeline?.titleField || 'name',
152+
...(schema.options?.timeline || {}),
153+
};
154+
case 'gantt':
155+
return {
156+
type: 'object-gantt',
157+
...baseProps,
158+
startDateField: schema.options?.gantt?.startDateField || 'start_date',
159+
endDateField: schema.options?.gantt?.endDateField || 'end_date',
160+
progressField: schema.options?.gantt?.progressField || 'progress',
161+
dependenciesField: schema.options?.gantt?.dependenciesField || 'dependencies',
162+
...(schema.options?.gantt || {}),
163+
};
164+
case 'map':
165+
return {
166+
type: 'object-map',
167+
...baseProps,
168+
locationField: schema.options?.map?.locationField || 'location',
169+
...(schema.options?.map || {}),
170+
};
131171
default:
132172
return baseProps;
133173
}

packages/plugin-list/src/ViewSwitcher.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,30 @@
88

99
import * as React from 'react';
1010
import { cn, ToggleGroup, ToggleGroupItem } from '@object-ui/components';
11-
import { Grid, List, LayoutGrid, Calendar, BarChart3 } from 'lucide-react';
11+
import {
12+
Grid,
13+
List,
14+
LayoutGrid,
15+
Calendar,
16+
BarChart3,
17+
Table2, // spreadsheet
18+
Images, // gallery
19+
Activity, // timeline
20+
GanttChartSquare, // gantt
21+
Map, // map
22+
} from 'lucide-react';
1223

13-
export type ViewType = 'grid' | 'list' | 'kanban' | 'calendar' | 'chart';
24+
export type ViewType =
25+
| 'grid'
26+
| 'list'
27+
| 'kanban'
28+
| 'calendar'
29+
| 'chart'
30+
| 'spreadsheet'
31+
| 'gallery'
32+
| 'timeline'
33+
| 'gantt'
34+
| 'map';
1435

1536
export interface ViewSwitcherProps {
1637
currentView: ViewType;
@@ -25,6 +46,11 @@ const VIEW_ICONS: Record<ViewType, React.ReactNode> = {
2546
kanban: <LayoutGrid className="h-4 w-4" />,
2647
calendar: <Calendar className="h-4 w-4" />,
2748
chart: <BarChart3 className="h-4 w-4" />,
49+
spreadsheet: <Table2 className="h-4 w-4" />,
50+
gallery: <Images className="h-4 w-4" />,
51+
timeline: <Activity className="h-4 w-4" />,
52+
gantt: <GanttChartSquare className="h-4 w-4" />,
53+
map: <Map className="h-4 w-4" />,
2854
};
2955

3056
const VIEW_LABELS: Record<ViewType, string> = {
@@ -33,6 +59,11 @@ const VIEW_LABELS: Record<ViewType, string> = {
3359
kanban: 'Kanban',
3460
calendar: 'Calendar',
3561
chart: 'Chart',
62+
spreadsheet: 'Spreadsheet',
63+
gallery: 'Gallery',
64+
timeline: 'Timeline',
65+
gantt: 'Gantt',
66+
map: 'Map',
3667
};
3768

3869
export const ViewSwitcher: React.FC<ViewSwitcherProps> = ({

packages/types/src/objectql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ export interface ListViewSchema extends BaseSchema {
688688
objectName: string;
689689

690690
/** View Type (grid, kanban, etc) */
691-
viewType?: 'grid' | 'kanban' | 'calendar' | 'gantt' | 'map' | 'chart';
691+
viewType?: 'grid' | 'list' | 'kanban' | 'calendar' | 'gantt' | 'map' | 'chart' | 'spreadsheet' | 'gallery' | 'timeline';
692692

693693
/** Fields to fetch/display */
694694
fields?: string[];

0 commit comments

Comments
 (0)