Skip to content

Commit

Permalink
feat: set unique on adding field if mode 2 is in use. closes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 14, 2024
1 parent 9193071 commit 0a021c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/routes/app.asset-manager.$asset.add_.$field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ export const action = async ({request, params}: ActionFunctionArgs) => {
where: {assetId: params.asset!}
})

const uniqueCount = await prisma.assetField.count({
where: {fieldId: params.field!, unique: 2}
})

const newField = await prisma.assetField.create({
data: {
assetId: params.asset!,
fieldId: params.field!,
helperText: helper,
order: parseInt(order),
displayOnTable: displayOnTable === 'on'
displayOnTable: displayOnTable === 'on',
unique: uniqueCount > 0 ? 2 : 0
}
})

Expand Down

0 comments on commit 0a021c7

Please sign in to comment.