-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobjectstack.config.ts
More file actions
131 lines (128 loc) · 3.32 KB
/
objectstack.config.ts
File metadata and controls
131 lines (128 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { defineStack } from '@objectstack/spec';
import { ObjectSchema, Field } from '@objectstack/spec/data';
import { App } from '@objectstack/spec/ui';
/**
* Task Object Definition — uses ObjectSchema.create + Field.* for spec compliance
*/
export const TaskObject = ObjectSchema.create({
name: 'task',
label: 'Task',
description: 'Task management object',
icon: 'check-square',
titleFormat: '{subject}',
enable: {
apiEnabled: true,
trackHistory: false,
feeds: false,
activities: false,
mru: true,
},
fields: {
subject: Field.text({ label: 'Subject', required: true }),
priority: Field.number({ label: 'Priority', defaultValue: 5 }),
is_completed: Field.boolean({ label: 'Completed', defaultValue: false }),
created_at: Field.datetime({ label: 'Created At', readonly: true }),
},
});
/**
* Task Actions — complete, toggle, and delete operations
*/
export const TaskActions = [
{
name: 'task_complete',
label: 'Mark Complete',
icon: 'check-circle-2',
type: 'api' as const,
target: 'task_complete',
locations: ['record_header' as const, 'list_item' as const, 'list_toolbar' as const],
visible: 'is_completed === false',
bulkEnabled: true,
refreshAfter: true,
successMessage: 'Task completed',
},
{
name: 'task_reopen',
label: 'Reopen Task',
icon: 'rotate-ccw',
type: 'api' as const,
target: 'task_reopen',
locations: ['record_header' as const, 'list_item' as const],
visible: 'is_completed === true',
refreshAfter: true,
successMessage: 'Task reopened',
},
{
name: 'task_delete',
label: 'Delete Task',
icon: 'trash-2',
type: 'api' as const,
target: 'task_delete',
locations: ['record_more' as const, 'list_toolbar' as const],
variant: 'danger' as const,
bulkEnabled: true,
confirmText: 'Are you sure you want to delete this task?',
refreshAfter: true,
successMessage: 'Task deleted',
},
];
/**
* App Configuration — Standard ObjectStackDefinition format
*/
export default defineStack({
objects: [
TaskObject
],
views: [
{
listViews: {
all_tasks: {
name: 'all_tasks',
label: 'All Tasks',
type: 'grid' as const,
data: { provider: 'object' as const, object: 'task' },
columns: ['subject', 'priority', 'is_completed', 'created_at'],
sort: [{ field: 'created_at', order: 'desc' as const }],
},
},
},
],
actions: [
...TaskActions,
],
apps: [
App.create({
name: 'task_app',
label: 'Task Management',
description: 'MSW + React CRUD Example with ObjectStack',
icon: 'check-square',
branding: {
primaryColor: '#3b82f6',
logo: '/assets/logo.png',
},
navigation: [
{
id: 'group_tasks',
type: 'group',
label: 'Tasks',
icon: 'list-todo',
children: [
{
id: 'nav_tasks',
type: 'object',
objectName: 'task',
label: 'My Tasks',
icon: 'check-circle-2'
}
]
}
]
})
],
manifest: {
id: 'com.example.msw-todo',
version: '1.0.0',
type: 'app',
name: 'Task Management',
description: 'MSW + React CRUD Example with ObjectStack',
},
});