cms.c2sgmbh/src/collections/Navigations.ts
Martin Porwoll 6aed5a39d3 feat: convert SiteSettings and Navigation from Globals to tenant-specific Collections
- SiteSettings is now a Collection with multi-tenant support
- Navigation is now Navigations Collection with multi-tenant support
- Both added to multiTenantPlugin collections config
- Allows each tenant to have their own site settings and navigation
- API endpoints change from /api/globals/* to /api/site-settings and /api/navigations

BREAKING CHANGE: Frontends need to update API calls from globals to collections

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 22:24:05 +00:00

165 lines
4.1 KiB
TypeScript

import type { CollectionConfig } from 'payload'
export const Navigations: CollectionConfig = {
slug: 'navigations',
labels: {
singular: 'Navigation',
plural: 'Navigationen',
},
admin: {
useAsTitle: 'title',
group: 'Einstellungen',
description: 'Navigationsmenüs pro Tenant',
},
access: {
read: () => true,
create: ({ req }) => Boolean(req.user?.isSuperAdmin),
update: ({ req }) => Boolean(req.user),
delete: ({ req }) => Boolean(req.user?.isSuperAdmin),
},
fields: [
{
name: 'title',
type: 'text',
label: 'Titel',
required: true,
defaultValue: 'Hauptnavigation',
admin: {
description: 'Interner Name zur Identifikation',
},
},
{
name: 'mainMenu',
type: 'array',
label: 'Hauptmenü',
fields: [
{
name: 'label',
type: 'text',
label: 'Bezeichnung',
required: true,
localized: true,
},
{
name: 'type',
type: 'select',
label: 'Typ',
defaultValue: 'page',
options: [
{ label: 'Seite', value: 'page' },
{ label: 'Eigener Link', value: 'custom' },
{ label: 'Untermenü', value: 'submenu' },
],
},
{
name: 'page',
type: 'relationship',
label: 'Seite',
relationTo: 'pages',
admin: {
condition: (data, siblingData) => siblingData?.type === 'page',
},
},
{
name: 'url',
type: 'text',
label: 'URL',
admin: {
condition: (data, siblingData) => siblingData?.type === 'custom',
},
},
{
name: 'openInNewTab',
type: 'checkbox',
label: 'In neuem Tab öffnen',
defaultValue: false,
},
{
name: 'submenu',
type: 'array',
label: 'Untermenü',
admin: {
condition: (data, siblingData) => siblingData?.type === 'submenu',
},
fields: [
{
name: 'label',
type: 'text',
label: 'Bezeichnung',
required: true,
localized: true,
},
{
name: 'linkType',
type: 'select',
label: 'Link-Typ',
defaultValue: 'page',
options: [
{ label: 'Seite', value: 'page' },
{ label: 'Eigener Link', value: 'custom' },
],
},
{
name: 'page',
type: 'relationship',
label: 'Seite',
relationTo: 'pages',
admin: {
condition: (data, siblingData) => siblingData?.linkType === 'page',
},
},
{
name: 'url',
type: 'text',
label: 'URL',
admin: {
condition: (data, siblingData) => siblingData?.linkType === 'custom',
},
},
],
},
],
},
{
name: 'footerMenu',
type: 'array',
label: 'Footer-Menü',
fields: [
{
name: 'label',
type: 'text',
label: 'Bezeichnung',
required: true,
localized: true,
},
{
name: 'linkType',
type: 'select',
label: 'Link-Typ',
defaultValue: 'page',
options: [
{ label: 'Seite', value: 'page' },
{ label: 'Eigener Link', value: 'custom' },
],
},
{
name: 'page',
type: 'relationship',
label: 'Seite',
relationTo: 'pages',
admin: {
condition: (data, siblingData) => siblingData?.linkType === 'page',
},
},
{
name: 'url',
type: 'text',
label: 'URL',
admin: {
condition: (data, siblingData) => siblingData?.linkType === 'custom',
},
},
],
},
],
}