feat(locations): add showOnLokatsii visibility flag + page filter
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions

Add checkbox field to control whether a location card appears on /lokatsii.
Default true so existing entries remain visible. Filter added to getLocations query.
Migration 20260610_140000 adds show_on_lokatsii boolean column with DEFAULT true.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-06-10 13:52:27 +01:00
parent 4bb321366c
commit 0ab98cdd3a
5 changed files with 86 additions and 88 deletions

View file

@ -0,0 +1,15 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "locations"
ADD COLUMN IF NOT EXISTS "show_on_lokatsii" boolean DEFAULT true;
`)
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "locations"
DROP COLUMN IF EXISTS "show_on_lokatsii";
`)
}

View file

@ -2,6 +2,7 @@ import * as migration_20260515_153940 from './20260515_153940'
import * as migration_20260515_162527 from './20260515_162527'
import * as migration_20260518_104929 from './20260518_104929'
import * as migration_20260518_115657 from './20260518_115657'
import * as migration_20260610_140000 from './20260610_140000'
export const migrations = [
{
@ -24,4 +25,9 @@ export const migrations = [
down: migration_20260518_115657.down,
name: '20260518_115657',
},
{
up: migration_20260610_140000.up,
down: migration_20260610_140000.down,
name: '20260610_140000',
},
]

View file

@ -68,6 +68,7 @@ async function getLocations(): Promise<LocationCMS[]> {
sort: 'sort',
limit: 20,
overrideAccess: true,
where: { showOnLokatsii: { equals: true } },
})
return result.docs as unknown as LocationCMS[]
} catch {

View file

@ -13,7 +13,15 @@ export const Locations: CollectionConfig = {
},
admin: {
useAsTitle: 'name',
defaultColumns: ['name', 'slug', 'showDetailPage', 'showInMenu', 'showOnHome', 'sort'],
defaultColumns: [
'name',
'slug',
'showOnLokatsii',
'showDetailPage',
'showInMenu',
'showOnHome',
'sort',
],
group: 'Каталог',
},
fields: [
@ -35,6 +43,12 @@ export const Locations: CollectionConfig = {
fields: [{ name: 'image', type: 'upload', relationTo: 'media' }],
},
{ name: 'href', type: 'text', admin: { description: 'Зовнішнє посилання (якщо є)' } },
{
name: 'showOnLokatsii',
type: 'checkbox',
defaultValue: true,
admin: { description: 'Показувати карточку на сторінці /lokatsii' },
},
{ name: 'showInMenu', type: 'checkbox', defaultValue: true },
{ name: 'showOnHome', type: 'checkbox', defaultValue: true },
{ name: 'sort', type: 'number', defaultValue: 0 },

View file

@ -580,6 +580,10 @@ export interface Location {
* Зовнішнє посилання (якщо є)
*/
href?: string | null
/**
* Показувати карточку на сторінці /lokatsii
*/
showOnLokatsii?: boolean | null
showInMenu?: boolean | null
showOnHome?: boolean | null
sort?: number | null
@ -1402,6 +1406,7 @@ export interface LocationsSelect<T extends boolean = true> {
id?: T
}
href?: T
showOnLokatsii?: T
showInMenu?: T
showOnHome?: T
sort?: T
@ -1735,12 +1740,35 @@ export interface HomePage {
*/
backgroundImage?: (number | null) | Media
}
/**
* Перетягніть для зміни порядку. Додайте або видаліть розділ. Зніміть «Показувати» розділ зникне без видалення.
*/
sections?:
| {
type:
| 'locations'
| 'whyParents'
| 'video'
| 'birthday'
| 'gallery'
| 'reviews'
| 'faq'
| 'news'
| 'map'
enabled?: boolean | null
id?: string | null
}[]
| null
sectionTitles?: {
locations?: string | null
whyParents?: string | null
birthday?: string | null
gallery?: string | null
reviews?: string | null
/**
* Посилання на сторінку відгуків Google
*/
googleReviewUrl?: string | null
news?: string | null
}
whyParents?: {
@ -1776,6 +1804,14 @@ export interface HomePage {
}
birthdayIntro?: {
text?: string | null
/**
* Фоновий паттерн для не-featured карток (зелений фон).
*/
patternGreen?: (number | null) | Media
/**
* Фоновий паттерн для featured картки (оранжевий фон).
*/
patternOrange?: (number | null) | Media
}
news?: {
title?: string | null
@ -2080,9 +2116,7 @@ export interface BirthdayPage {
heroImage?: (number | null) | Media
heroTitle?: string | null
heroSubtitle?: string | null
heroCta?: string | null
packageSectionTitle?: string | null
packageSectionSubtitle?: string | null
packageItems?:
| {
title: string
@ -2109,58 +2143,12 @@ export interface BirthdayPage {
| null
whyVideos?:
| {
src: string
poster?: string | null
video: number | Media
poster?: (number | null) | Media
label?: string | null
id?: string | null
}[]
| null
workingHours?: string | null
pricingSectionTitle?: string | null
pricingPackages?:
| {
/**
* Підпис над ціною
*/
label: string
/**
* Напр. "1 500 грн"
*/
price: string
/**
* Примітка під ціною
*/
note?: string | null
ctaLabel?: string | null
ctaHref?: string | null
id?: string | null
}[]
| null
entranceSectionTitle?: string | null
entrancePrices?:
| {
label: string
price: string
note?: string | null
ctaLabel?: string | null
ctaHref?: string | null
id?: string | null
}[]
| null
freeInclusions?: string | null
entertainmentSectionTitle?: string | null
entertainmentPackages?:
| {
/**
* Напр. "Тривалість 1 год"
*/
label: string
price: string
ctaLabel?: string | null
ctaHref?: string | null
id?: string | null
}[]
| null
formTitle?: string | null
formSubtitle?: string | null
/**
@ -2460,6 +2448,13 @@ export interface HomePageSelect<T extends boolean = true> {
| {
backgroundImage?: T
}
sections?:
| T
| {
type?: T
enabled?: T
id?: T
}
sectionTitles?:
| T
| {
@ -2468,6 +2463,7 @@ export interface HomePageSelect<T extends boolean = true> {
birthday?: T
gallery?: T
reviews?: T
googleReviewUrl?: T
news?: T
}
whyParents?:
@ -2508,6 +2504,8 @@ export interface HomePageSelect<T extends boolean = true> {
| T
| {
text?: T
patternGreen?: T
patternOrange?: T
}
news?:
| T
@ -2735,9 +2733,7 @@ export interface BirthdayPageSelect<T extends boolean = true> {
heroImage?: T
heroTitle?: T
heroSubtitle?: T
heroCta?: T
packageSectionTitle?: T
packageSectionSubtitle?: T
packageItems?:
| T
| {
@ -2759,45 +2755,11 @@ export interface BirthdayPageSelect<T extends boolean = true> {
whyVideos?:
| T
| {
src?: T
video?: T
poster?: T
label?: T
id?: T
}
workingHours?: T
pricingSectionTitle?: T
pricingPackages?:
| T
| {
label?: T
price?: T
note?: T
ctaLabel?: T
ctaHref?: T
id?: T
}
entranceSectionTitle?: T
entrancePrices?:
| T
| {
label?: T
price?: T
note?: T
ctaLabel?: T
ctaHref?: T
id?: T
}
freeInclusions?: T
entertainmentSectionTitle?: T
entertainmentPackages?:
| T
| {
label?: T
price?: T
ctaLabel?: T
ctaHref?: T
id?: T
}
formTitle?: T
formSubtitle?: T
form?: T