feat: gérer l'ordre des champs personnalisés
This commit is contained in:
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user