feat: gérer l'ordre des champs personnalisés

This commit is contained in:
Matthieu
2025-10-28 18:08:08 +01:00
parent 635ea0e84e
commit 9f522a6dbb
15 changed files with 134 additions and 27 deletions

View File

@@ -209,12 +209,20 @@ export class CustomFieldsService {
if (existingField) {
targetCustomFieldId = existingField.id;
} else {
const normalizedType = (customFieldType || 'text').trim() || 'text';
const normalizedRequired = !!customFieldRequired;
const orderScope = { [customFieldTypeField]: typeId } as const;
const nextOrderIndex = await this.prisma.customField.count({
where: orderScope,
});
const createdField = await this.prisma.customField.create({
data: {
name: normalizedName,
type: (customFieldType || 'text').trim() || 'text',
required: !!customFieldRequired,
type: normalizedType,
required: normalizedRequired,
options: normalizedOptions,
orderIndex: nextOrderIndex,
[customFieldTypeField]: typeId,
},
});