Add isParent boolean to tags
This commit is contained in:
@ -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
|
||||
},
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 (
|
||||
<div>
|
||||
|
||||
@ -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 (
|
||||
<div>
|
||||
|
||||
@ -22,11 +22,7 @@ const artworkItems = [
|
||||
{
|
||||
title: "Tags",
|
||||
href: "/tags",
|
||||
},
|
||||
{
|
||||
title: "Animals",
|
||||
href: "/animals",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
// const portfolioItems = [
|
||||
|
||||
@ -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
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="isParent"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
||||
<div className="space-y-0.5">
|
||||
<FormLabel>Is parent tag</FormLabel>
|
||||
<FormDescription></FormDescription>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
||||
@ -26,6 +26,7 @@ export default function NewTagForm({ categories, allTags }: { categories: ArtCat
|
||||
description: "",
|
||||
categoryIds: [],
|
||||
parentId: null,
|
||||
isParent: false,
|
||||
showOnAnimalPage: false,
|
||||
aliases: [],
|
||||
}
|
||||
@ -150,6 +151,23 @@ export default function NewTagForm({ categories, allTags }: { categories: ArtCat
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="isParent"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
||||
<div className="space-y-0.5">
|
||||
<FormLabel>Is parent tag</FormLabel>
|
||||
<FormDescription></FormDescription>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
||||
@ -5,6 +5,7 @@ export const tagSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
categoryIds: z.array(z.string()).optional(),
|
||||
parentId: z.string().nullable().optional(),
|
||||
isParent: z.boolean(),
|
||||
showOnAnimalPage: z.boolean(),
|
||||
|
||||
aliases: z
|
||||
|
||||
Reference in New Issue
Block a user