- Users: added role field (admin/editor), role field locked to adminOnly update - SiteSettings, AnnouncementBar, PopupAnnouncement: update restricted to adminOnly - Added src/access/adminOnly.ts helper
142 lines
4.2 KiB
TypeScript
142 lines
4.2 KiB
TypeScript
import type { GlobalConfig } from 'payload'
|
|
import { adminOnly } from '../access/adminOnly'
|
|
|
|
export const SiteSettings: GlobalConfig = {
|
|
slug: 'site-settings',
|
|
label: 'Webbplatsinställningar',
|
|
access: {
|
|
update: adminOnly,
|
|
read: () => true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'headerCodeInjection',
|
|
type: 'group',
|
|
label: 'Kodinjektion (Head)',
|
|
fields: [
|
|
{
|
|
name: 'enabled',
|
|
type: 'checkbox',
|
|
label: 'Aktivera kodinjektion i <head>',
|
|
defaultValue: false,
|
|
},
|
|
{
|
|
name: 'code',
|
|
type: 'code',
|
|
label: 'Kod att injicera i <head>',
|
|
admin: {
|
|
language: 'html',
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
description: 'Klistra in <script>, <link>, <meta> eller <style>-taggar här.',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'footerCodeInjection',
|
|
type: 'group',
|
|
label: 'Kodinjektion (Footer)',
|
|
fields: [
|
|
{
|
|
name: 'enabled',
|
|
type: 'checkbox',
|
|
label: 'Aktivera kodinjektion före </body>',
|
|
defaultValue: false,
|
|
},
|
|
{
|
|
name: 'code',
|
|
type: 'code',
|
|
label: 'Kod att injicera före </body>',
|
|
admin: {
|
|
language: 'html',
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
description: 'Script-taggar som ska laddas i slutet av sidan.',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'cookieConsent',
|
|
type: 'group',
|
|
label: 'Cookie-samtycke',
|
|
fields: [
|
|
{
|
|
name: 'enabled',
|
|
type: 'checkbox',
|
|
label: 'Visa cookie-banner',
|
|
defaultValue: true,
|
|
},
|
|
{
|
|
name: 'privacyPolicyUrl',
|
|
type: 'text',
|
|
label: 'Länk till integritetspolicy',
|
|
defaultValue: '/integritetspolicy',
|
|
admin: {
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
},
|
|
},
|
|
{
|
|
name: 'acceptedDays',
|
|
type: 'select',
|
|
label: 'Hur länge sparas "Acceptera"-val',
|
|
defaultValue: '365',
|
|
admin: {
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
description:
|
|
'Hur många dagar besökarens accept-val sparas innan bannern visas igen. "Webbläsarsession" = försvinner när fliken/webbläsaren stängs.',
|
|
},
|
|
options: [
|
|
{ label: 'Webbläsarsession (session)', value: '0' },
|
|
{ label: '30 dagar', value: '30' },
|
|
{ label: '90 dagar', value: '90' },
|
|
{ label: '180 dagar', value: '180' },
|
|
{ label: '365 dagar (rekommenderat)', value: '365' },
|
|
],
|
|
},
|
|
{
|
|
name: 'declinedDays',
|
|
type: 'select',
|
|
label: 'Hur länge sparas "Avvisa"-val',
|
|
defaultValue: '30',
|
|
admin: {
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
description:
|
|
'Hur många dagar bannern döljs när besökaren avvisat. Efter detta visas bannern igen. Kortare tid = fler chanser att få samtycke.',
|
|
},
|
|
options: [
|
|
{ label: 'Webbläsarsession (session)', value: '0' },
|
|
{ label: '7 dagar', value: '7' },
|
|
{ label: '14 dagar', value: '14' },
|
|
{ label: '30 dagar (rekommenderat)', value: '30' },
|
|
{ label: '90 dagar', value: '90' },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'matomo',
|
|
type: 'group',
|
|
label: 'Matomo Analytics',
|
|
fields: [
|
|
{
|
|
name: 'enabled',
|
|
type: 'checkbox',
|
|
label: 'Aktivera Matomo',
|
|
defaultValue: false,
|
|
},
|
|
{
|
|
name: 'code',
|
|
type: 'code',
|
|
label: 'Matomo tracking-kod',
|
|
admin: {
|
|
language: 'javascript',
|
|
condition: (_, siblingData) => Boolean(siblingData?.enabled),
|
|
description:
|
|
'Klistra in spårningskoden från Matomo (Administration → Tracking Code). Samtyckesgating läggs till automatiskt — du behöver inte ändra något i koden.',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|