forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.ts
41 lines (40 loc) · 1.29 KB
/
schema.ts
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
import { createSchema, list } from '@keystone-next/keystone';
import { checkbox, relationship, text, timestamp } from '@keystone-next/keystone/fields';
import { json, select } from '@keystone-next/keystone/fields';
export const lists = createSchema({
Task: list({
fields: {
label: text({ isRequired: true }),
priority: select({
dataType: 'enum',
options: [
{ label: 'Low', value: 'low' },
{ label: 'Medium', value: 'medium' },
{ label: 'High', value: 'high' },
],
}),
isComplete: checkbox(),
assignedTo: relationship({ ref: 'Person.tasks', many: false }),
finishBy: timestamp(),
// We've added a json field which implements custom views in the Admin UI
relatedLinks: json({
ui: {
views: require.resolve('./fields/related-links/components.tsx'),
createView: { fieldMode: 'edit' },
listView: { fieldMode: 'hidden' },
itemView: { fieldMode: 'edit' },
},
}),
},
defaultIsFilterable: true,
defaultIsOrderable: true,
}),
Person: list({
fields: {
name: text({ isRequired: true }),
tasks: relationship({ ref: 'Task.assignedTo', many: true }),
},
defaultIsFilterable: true,
defaultIsOrderable: true,
}),
});