church-website/src/collections/Highlight.ts
2025-03-12 15:08:13 +01:00

74 lines
No EOL
1.3 KiB
TypeScript

import { CollectionConfig } from 'payload'
import { hide, isAdminOrEmployee } from '@/collections/access/admin'
export const Highlight: CollectionConfig = {
slug: 'highlight',
labels: {
singular: {
de: "Highlight"
},
plural: {
de: "Highlights"
}
},
fields: [
{
name: 'from',
type: 'date',
required: true,
label: {
de: "Anzeigen von"
}
},
{
name: 'until',
type: 'date',
required: true,
label: {
de: "Anzeigen bis"
}
},
{
name: 'date',
type: 'date',
required: true,
label: {
de: 'Datum'
}
},
{
name: 'link',
type: 'relationship',
relationTo: ['event', 'blog', 'worship'],
admin: {
allowCreate: false,
allowEdit: false,
sortOptions: {
"event": "-createdAt",
"blog": "-createdAt",
"worship": "-date",
}
},
required: false
},
{
name: 'text',
type: 'textarea',
required: true,
maxLength: 144,
label: {
de: "Nachricht"
}
}
],
admin: {
useAsTitle: 'text',
hidden: hide
},
access: {
read: () => true,
create: isAdminOrEmployee(),
update: isAdminOrEmployee(),
delete: isAdminOrEmployee(),
}
}