Skip to content

Commit 465e0b7

Browse files
authored
Merge pull request #134 from objectstack-ai/copilot/add-object-view-layout
2 parents 9ea2dce + 4718255 commit 465e0b7

File tree

16 files changed

+1467
-1
lines changed

16 files changed

+1467
-1
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# ObjectView Demo
2+
3+
A comprehensive demonstration of the `ObjectView` component, which integrates `ObjectTable` and `ObjectForm` into a complete, ready-to-use CRUD interface.
4+
5+
## Features
6+
7+
- **Integrated Table and Form**: Seamless combination of list view and create/edit forms
8+
- **Multiple Layout Modes**: Switch between drawer and modal layouts for form display
9+
- **Search Functionality**: Search across all records
10+
- **Filter Builder**: Placeholder for advanced filtering capabilities
11+
- **CRUD Operations**: Complete Create, Read, Update, Delete functionality
12+
- **Bulk Actions**: Select multiple rows and perform bulk delete
13+
- **Auto-refresh**: Table automatically refreshes after form submission
14+
- **Mock Data Source**: Demonstrates with in-memory mock data
15+
16+
## Running the Demo
17+
18+
```bash
19+
# From the root of the repository
20+
pnpm install
21+
pnpm --filter @examples/object-view-demo dev
22+
```
23+
24+
Then open your browser to `http://localhost:5173`
25+
26+
## Usage
27+
28+
The demo showcases:
29+
30+
1. **Drawer Mode (Default)**: Forms slide in from the right side
31+
2. **Modal Mode**: Forms appear in a centered modal dialog
32+
33+
### Actions
34+
35+
- **Create**: Click the "Create" button in the toolbar
36+
- **View**: Click on any row in the table
37+
- **Edit**: Click the "Edit" button in the actions column
38+
- **Delete**: Click the "Delete" button (with confirmation)
39+
- **Bulk Delete**: Select multiple rows using checkboxes and click "Delete Selected"
40+
- **Search**: Type in the search box to filter records
41+
- **Filters**: Click the "Filters" button to toggle the filter panel (placeholder)
42+
- **Refresh**: Click the refresh button to reload the table
43+
44+
## Component Overview
45+
46+
The `ObjectView` component combines:
47+
48+
- **ObjectTable**: Auto-generated table with schema-based columns
49+
- **ObjectForm**: Auto-generated form with schema-based fields
50+
- **Drawer/Modal**: Configurable overlay components for form display
51+
- **Search Bar**: Built-in search functionality
52+
- **Filter Panel**: Placeholder for future filter builder integration
53+
- **Toolbar**: Actions bar with create, refresh, and filter buttons
54+
55+
## Schema Configuration
56+
57+
```typescript
58+
const schema: ObjectViewSchema = {
59+
type: 'object-view',
60+
objectName: 'users',
61+
layout: 'drawer', // or 'modal'
62+
showSearch: true,
63+
showFilters: true,
64+
showCreate: true,
65+
operations: {
66+
create: true,
67+
read: true,
68+
update: true,
69+
delete: true,
70+
},
71+
table: {
72+
fields: ['name', 'email', 'status', 'role'],
73+
selectable: 'multiple',
74+
},
75+
form: {
76+
fields: ['name', 'email', 'status', 'role'],
77+
layout: 'vertical',
78+
},
79+
};
80+
```
81+
82+
## Next Steps
83+
84+
- Integrate real ObjectQL backend
85+
- Implement advanced filtering with FilterBuilder
86+
- Add pagination controls
87+
- Add export/import functionality
88+
- Add custom actions and bulk operations
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>ObjectView Demo - ObjectUI</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@examples/object-view-demo",
3+
"private": true,
4+
"license": "MIT",
5+
"version": "0.0.0",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "vite",
9+
"build": "tsc -b && vite build",
10+
"lint": "eslint .",
11+
"preview": "vite preview"
12+
},
13+
"dependencies": {
14+
"@object-ui/types": "workspace:*",
15+
"@object-ui/core": "workspace:*",
16+
"@object-ui/react": "workspace:*",
17+
"@object-ui/components": "workspace:*",
18+
"@object-ui/plugin-object": "workspace:*",
19+
"@object-ui/data-objectql": "workspace:*",
20+
"react": "^18.3.1",
21+
"react-dom": "^18.3.1",
22+
"lucide-react": "^0.562.0"
23+
},
24+
"devDependencies": {
25+
"@eslint/js": "^9.39.1",
26+
"@types/node": "^25.0.9",
27+
"@types/react": "^18.3.12",
28+
"@types/react-dom": "^18.3.1",
29+
"@vitejs/plugin-react": "^5.1.2",
30+
"autoprefixer": "^10.4.23",
31+
"eslint": "^9.39.2",
32+
"eslint-plugin-react-hooks": "^7.0.1",
33+
"eslint-plugin-react-refresh": "^0.4.24",
34+
"globals": "^16.5.0",
35+
"postcss": "^8.5.6",
36+
"tailwindcss": "^3.4.19",
37+
"typescript": "~5.9.3",
38+
"typescript-eslint": "^8.46.4",
39+
"vite": "^7.3.1"
40+
}
41+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
export default {
10+
plugins: {
11+
tailwindcss: {},
12+
autoprefixer: {},
13+
},
14+
}

0 commit comments

Comments
 (0)