feature: image cards in group
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
Benno Tielen 2026-04-16 11:16:43 +02:00
parent d66e5ad289
commit c4060dad0c
5 changed files with 22691 additions and 2 deletions

View file

@ -8,6 +8,7 @@ import { DonationBlock } from '@/collections/blocks/Donation'
import { ButtonBlock } from '@/collections/blocks/Button'
import { YoutubePlayerBlock } from '@/collections/blocks/YoutubePlayer'
import { isPublishedPublic } from '@/collections/access/public'
import { ImageCardsBlock } from '@/collections/blocks/ImageCards'
export const Groups: CollectionConfig = {
slug: 'group',
@ -84,7 +85,8 @@ export const Groups: CollectionConfig = {
DonationBlock,
YoutubePlayerBlock,
ContactformBlock,
ButtonBlock
ButtonBlock,
ImageCardsBlock,
]
}
],

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,115 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TABLE "group_blocks_image_cards_items" (
"_order" integer NOT NULL,
"_parent_id" varchar NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"title" varchar,
"image_id" uuid,
"custom_link" varchar
);
CREATE TABLE "group_blocks_image_cards" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"_path" text NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"block_name" varchar
);
CREATE TABLE "group_rels" (
"id" serial PRIMARY KEY NOT NULL,
"order" integer,
"parent_id" uuid NOT NULL,
"path" varchar NOT NULL,
"pages_id" uuid,
"group_id" uuid
);
CREATE TABLE "_group_v_blocks_image_cards_items" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"title" varchar,
"image_id" uuid,
"custom_link" varchar,
"_uuid" varchar
);
CREATE TABLE "_group_v_blocks_image_cards" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"_path" text NOT NULL,
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"_uuid" varchar,
"block_name" varchar
);
CREATE TABLE "_group_v_rels" (
"id" serial PRIMARY KEY NOT NULL,
"order" integer,
"parent_id" uuid NOT NULL,
"path" varchar NOT NULL,
"pages_id" uuid,
"group_id" uuid
);
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-04-19T09:09:53.986Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-04-19T09:09:54.280Z';
ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-05-16T09:09:54.338Z';
ALTER TABLE "group_blocks_image_cards_items" ADD CONSTRAINT "group_blocks_image_cards_items_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
ALTER TABLE "group_blocks_image_cards_items" ADD CONSTRAINT "group_blocks_image_cards_items_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."group_blocks_image_cards"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "group_blocks_image_cards" ADD CONSTRAINT "group_blocks_image_cards_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."group"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "group_rels" ADD CONSTRAINT "group_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."group"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "group_rels" ADD CONSTRAINT "group_rels_pages_fk" FOREIGN KEY ("pages_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "group_rels" ADD CONSTRAINT "group_rels_group_fk" FOREIGN KEY ("group_id") REFERENCES "public"."group"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "_group_v_blocks_image_cards_items" ADD CONSTRAINT "_group_v_blocks_image_cards_items_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
ALTER TABLE "_group_v_blocks_image_cards_items" ADD CONSTRAINT "_group_v_blocks_image_cards_items_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."_group_v_blocks_image_cards"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "_group_v_blocks_image_cards" ADD CONSTRAINT "_group_v_blocks_image_cards_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."_group_v"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "_group_v_rels" ADD CONSTRAINT "_group_v_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."_group_v"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "_group_v_rels" ADD CONSTRAINT "_group_v_rels_pages_fk" FOREIGN KEY ("pages_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "_group_v_rels" ADD CONSTRAINT "_group_v_rels_group_fk" FOREIGN KEY ("group_id") REFERENCES "public"."group"("id") ON DELETE cascade ON UPDATE no action;
CREATE INDEX "group_blocks_image_cards_items_order_idx" ON "group_blocks_image_cards_items" USING btree ("_order");
CREATE INDEX "group_blocks_image_cards_items_parent_id_idx" ON "group_blocks_image_cards_items" USING btree ("_parent_id");
CREATE INDEX "group_blocks_image_cards_items_image_idx" ON "group_blocks_image_cards_items" USING btree ("image_id");
CREATE INDEX "group_blocks_image_cards_order_idx" ON "group_blocks_image_cards" USING btree ("_order");
CREATE INDEX "group_blocks_image_cards_parent_id_idx" ON "group_blocks_image_cards" USING btree ("_parent_id");
CREATE INDEX "group_blocks_image_cards_path_idx" ON "group_blocks_image_cards" USING btree ("_path");
CREATE INDEX "group_rels_order_idx" ON "group_rels" USING btree ("order");
CREATE INDEX "group_rels_parent_idx" ON "group_rels" USING btree ("parent_id");
CREATE INDEX "group_rels_path_idx" ON "group_rels" USING btree ("path");
CREATE INDEX "group_rels_pages_id_idx" ON "group_rels" USING btree ("pages_id");
CREATE INDEX "group_rels_group_id_idx" ON "group_rels" USING btree ("group_id");
CREATE INDEX "_group_v_blocks_image_cards_items_order_idx" ON "_group_v_blocks_image_cards_items" USING btree ("_order");
CREATE INDEX "_group_v_blocks_image_cards_items_parent_id_idx" ON "_group_v_blocks_image_cards_items" USING btree ("_parent_id");
CREATE INDEX "_group_v_blocks_image_cards_items_image_idx" ON "_group_v_blocks_image_cards_items" USING btree ("image_id");
CREATE INDEX "_group_v_blocks_image_cards_order_idx" ON "_group_v_blocks_image_cards" USING btree ("_order");
CREATE INDEX "_group_v_blocks_image_cards_parent_id_idx" ON "_group_v_blocks_image_cards" USING btree ("_parent_id");
CREATE INDEX "_group_v_blocks_image_cards_path_idx" ON "_group_v_blocks_image_cards" USING btree ("_path");
CREATE INDEX "_group_v_rels_order_idx" ON "_group_v_rels" USING btree ("order");
CREATE INDEX "_group_v_rels_parent_idx" ON "_group_v_rels" USING btree ("parent_id");
CREATE INDEX "_group_v_rels_path_idx" ON "_group_v_rels" USING btree ("path");
CREATE INDEX "_group_v_rels_pages_id_idx" ON "_group_v_rels" USING btree ("pages_id");
CREATE INDEX "_group_v_rels_group_id_idx" ON "_group_v_rels" USING btree ("group_id");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "group_blocks_image_cards_items" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "group_blocks_image_cards" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "group_rels" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "_group_v_blocks_image_cards_items" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "_group_v_blocks_image_cards" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "_group_v_rels" DISABLE ROW LEVEL SECURITY;
DROP TABLE "group_blocks_image_cards_items" CASCADE;
DROP TABLE "group_blocks_image_cards" CASCADE;
DROP TABLE "group_rels" CASCADE;
DROP TABLE "_group_v_blocks_image_cards_items" CASCADE;
DROP TABLE "_group_v_blocks_image_cards" CASCADE;
DROP TABLE "_group_v_rels" CASCADE;
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-04-19T12:20:19.986Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-04-19T12:20:20.277Z';
ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-05-13T12:20:20.339Z';`)
}

View file

@ -33,6 +33,7 @@ import * as migration_20260410_124639 from './20260410_124639';
import * as migration_20260413_093410_search from './20260413_093410_search';
import * as migration_20260413_094618_search_pages from './20260413_094618_search_pages';
import * as migration_20260413_122020 from './20260413_122020';
import * as migration_20260416_090954_group_image_cards from './20260416_090954_group_image_cards';
export const migrations = [
{
@ -208,6 +209,11 @@ export const migrations = [
{
up: migration_20260413_122020.up,
down: migration_20260413_122020.down,
name: '20260413_122020'
name: '20260413_122020',
},
{
up: migration_20260416_090954_group_image_cards.up,
down: migration_20260416_090954_group_image_cards.down,
name: '20260416_090954_group_image_cards'
},
];

View file

@ -731,6 +731,29 @@ export interface Group {
blockName?: string | null;
blockType: 'button';
}
| {
items: {
title: string;
image: string | Media;
link?:
| ({
relationTo: 'pages';
value: string | Page;
} | null)
| ({
relationTo: 'group';
value: string | Group;
} | null);
/**
* Alternative zu "Verknüpfung". Nur eins von beiden kann gesetzt werden.
*/
customLink?: string | null;
id?: string | null;
}[];
id?: string | null;
blockName?: string | null;
blockType: 'imageCards';
}
)[]
| null;
updatedAt: string;
@ -1774,6 +1797,21 @@ export interface GroupSelect<T extends boolean = true> {
id?: T;
blockName?: T;
};
imageCards?:
| T
| {
items?:
| T
| {
title?: T;
image?: T;
link?: T;
customLink?: T;
id?: T;
};
id?: T;
blockName?: T;
};
};
updatedAt?: T;
createdAt?: T;