From 48114f391a56c9fdce71fd26926c4c84f5684d79 Mon Sep 17 00:00:00 2001 From: Citali Date: Sun, 21 Dec 2025 21:57:16 +0100 Subject: [PATCH] Add isParent boolean to tags --- .../20251221205656_artwork_7/migration.sql | 2 ++ prisma/schema.prisma | 1 + src/actions/tags/createTag.ts | 1 + src/actions/tags/updateTag.ts | 3 ++- src/app/tags/[id]/page.tsx | 2 +- src/app/tags/new/page.tsx | 2 +- src/components/global/TopNav.tsx | 6 +----- src/components/tags/EditTagForm.tsx | 18 ++++++++++++++++++ src/components/tags/NewTagForm.tsx | 18 ++++++++++++++++++ src/schemas/artworks/tagSchema.ts | 1 + 10 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 prisma/migrations/20251221205656_artwork_7/migration.sql diff --git a/prisma/migrations/20251221205656_artwork_7/migration.sql b/prisma/migrations/20251221205656_artwork_7/migration.sql new file mode 100644 index 0000000..b47d9d3 --- /dev/null +++ b/prisma/migrations/20251221205656_artwork_7/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "ArtTag" ADD COLUMN "isParent" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 59def6a..68c4edb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -103,6 +103,7 @@ model ArtTag { name String @unique slug String @unique + isParent Boolean @default(false) showOnAnimalPage Boolean @default(false) description String? diff --git a/src/actions/tags/createTag.ts b/src/actions/tags/createTag.ts index 051a47d..073be71 100644 --- a/src/actions/tags/createTag.ts +++ b/src/actions/tags/createTag.ts @@ -22,6 +22,7 @@ export async function createTag(formData: TagFormInput) { name: data.name, slug: tagSlug, description: data.description, + isParent: data.isParent, showOnAnimalPage: data.showOnAnimalPage, parentId }, diff --git a/src/actions/tags/updateTag.ts b/src/actions/tags/updateTag.ts index 7d9181e..5ae9b25 100644 --- a/src/actions/tags/updateTag.ts +++ b/src/actions/tags/updateTag.ts @@ -32,7 +32,8 @@ export async function updateTag(id: string, rawData: TagFormInput) { data: { name: data.name, slug: tagSlug, - description: data.description, + description: data.description, + isParent: data.isParent, showOnAnimalPage: data.showOnAnimalPage, parentId, categories: data.categoryIds diff --git a/src/app/tags/[id]/page.tsx b/src/app/tags/[id]/page.tsx index 6f81840..8145fb4 100644 --- a/src/app/tags/[id]/page.tsx +++ b/src/app/tags/[id]/page.tsx @@ -14,7 +14,7 @@ export default async function PortfolioTagsEditPage({ params }: { params: { id: }) const categories = await prisma.artCategory.findMany({ include: { tags: true }, orderBy: { sortIndex: "asc" } }); - const tags = await prisma.artTag.findMany({ orderBy: { sortIndex: "asc" } }); + const tags = await prisma.artTag.findMany({ where: { isParent: true }, orderBy: { sortIndex: "asc" } }); return (
diff --git a/src/app/tags/new/page.tsx b/src/app/tags/new/page.tsx index 87c23d2..9e37e9b 100644 --- a/src/app/tags/new/page.tsx +++ b/src/app/tags/new/page.tsx @@ -3,7 +3,7 @@ import { prisma } from "@/lib/prisma"; export default async function PortfolioTagsNewPage() { const categories = await prisma.artCategory.findMany({ include: { tags: true }, orderBy: { sortIndex: "asc" } }); - const tags = await prisma.artTag.findMany({ orderBy: { sortIndex: "asc" } }); + const tags = await prisma.artTag.findMany({ where: { isParent: true }, orderBy: { sortIndex: "asc" } }); return (
diff --git a/src/components/global/TopNav.tsx b/src/components/global/TopNav.tsx index f3682f4..60fef72 100644 --- a/src/components/global/TopNav.tsx +++ b/src/components/global/TopNav.tsx @@ -22,11 +22,7 @@ const artworkItems = [ { title: "Tags", href: "/tags", - }, - { - title: "Animals", - href: "/animals", - }, + } ] // const portfolioItems = [ diff --git a/src/components/tags/EditTagForm.tsx b/src/components/tags/EditTagForm.tsx index 3b8b7f8..dce3b05 100644 --- a/src/components/tags/EditTagForm.tsx +++ b/src/components/tags/EditTagForm.tsx @@ -25,6 +25,7 @@ export default function EditTagForm({ tag, categories, allTags }: { tag: ArtTag description: tag.description || "", categoryIds: tag.categories?.map(cat => cat.id) ?? [], parentId: (tag as any).parentId ?? null, + isParent: tag.isParent ?? false, showOnAnimalPage: tag.showOnAnimalPage ?? false, aliases: tag.aliases?.map(a => a.alias) ?? [] } @@ -149,6 +150,23 @@ export default function EditTagForm({ tag, categories, allTags }: { tag: ArtTag )} /> +
+ ( + +
+ Is parent tag + +
+ + + +
+ )} + /> +
)} /> +
+ ( + +
+ Is parent tag + +
+ + + +
+ )} + /> +