Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/mighty-hotels-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@example/erp": patch
"@genseki/react": patch
---

Feat: Reorder relation field
51 changes: 32 additions & 19 deletions examples/erp/genseki/collections/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,33 @@ export const fields = builder.fields('post', (fb) => ({
hidden: true,
description: 'The date the post was created',
}),
postTags: fb.relations('postTags', (fb) => ({
type: 'create' as const,
label: 'Tags',
fields: fb.fields('postTag', (fb) => ({
remark: fb.columns('remark', {
type: 'text',
label: 'Remark',
}),
tag: fb.relations('tag', (fb) => ({
type: 'connect' as const,
deselectable: false,
fields: fb.fields('tag', (fb) => ({
name: fb.columns('name', {
type: 'text',
label: 'Name',
}),
postTags: fb.relations(
'postTags',
(fb) => ({
type: 'create' as const,
label: 'Tags',
options: 'postTags',
fields: fb.fields('postTag', (fb) => ({
remark: fb.columns('remark', {
type: 'text',
label: 'Remark',
}),
tag: fb.relations('tag', (fb) => ({
type: 'connect' as const,
fields: fb.fields('tag', (fb) => ({
name: fb.columns('name', {
type: 'text',
label: 'Name',
}),
})),
options: 'tag',
})),
options: 'tag',
})),
})),
})),
}),
{
orderColumn: 'order',
}
),
postDetail: fb.relations('detail', (fb) => ({
type: 'create' as const,
label: 'Detail',
Expand Down Expand Up @@ -205,6 +211,13 @@ export const options = builder.options(fields, {
options: tags.map((tag) => ({ label: tag.name, value: tag.id })),
}
},
postTags: async () => {
const postTags = await prisma.postTag.findMany()
return {
disabled: false,
options: postTags.map((pt) => ({ label: pt.id, value: pt.id })),
}
},
})

export const postsCollection = createPlugin('posts', (app) => {
Expand Down
1 change: 1 addition & 0 deletions examples/erp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@tiptap/extension-text-style": "^2.14.0",
"@tiptap/extension-underline": "^2.14.0",
"@tiptap/starter-kit": "^2.14.0",
"lexorank": "^1.0.5",
"next": "15.2.2",
"next-themes": "^0.4.6",
"postcss": "^8.5.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- Added the required column `order` to the `PostTag` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "PostTag" ADD COLUMN "order" TEXT NOT NULL;
2 changes: 2 additions & 0 deletions examples/erp/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ model PostTag {
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)

order String

createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
Expand Down
1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"deepmerge-ts": "^7.1.5",
"defu": "^6.1.4",
"input-otp": "^1.4.2",
"lexorank": "^1.0.5",
"motion": "^12.7.4",
"nuqs": "^2.4.3",
"radix3": "^1.1.2",
Expand Down
Loading
Loading