fix: préciser les erreurs de suppression des ressources
This commit is contained in:
@@ -126,13 +126,29 @@ export class ComposantsService {
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (
|
const blockingReasons: string[] = [];
|
||||||
machineLinksCount > 0 ||
|
|
||||||
documentsCount > 0 ||
|
if (machineLinksCount > 0) {
|
||||||
customFieldValuesCount > 0
|
blockingReasons.push(
|
||||||
) {
|
`${machineLinksCount} liaison${machineLinksCount > 1 ? 's' : ''} machine`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (documentsCount > 0) {
|
||||||
|
blockingReasons.push(
|
||||||
|
`${documentsCount} document${documentsCount > 1 ? 's' : ''}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (customFieldValuesCount > 0) {
|
||||||
|
blockingReasons.push(
|
||||||
|
`${customFieldValuesCount} valeur${customFieldValuesCount > 1 ? 's' : ''} de champ personnalisé`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockingReasons.length > 0) {
|
||||||
throw new ConflictException(
|
throw new ConflictException(
|
||||||
'Impossible de supprimer ce composant car il possède des éléments liés.',
|
`Impossible de supprimer ce composant car il possède encore: ${blockingReasons.join(
|
||||||
|
', ',
|
||||||
|
)}. Supprimez ou détachez ces éléments avant de réessayer.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,13 +150,29 @@ export class PiecesService {
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (
|
const blockingReasons: string[] = [];
|
||||||
machineLinksCount > 0 ||
|
|
||||||
documentsCount > 0 ||
|
if (machineLinksCount > 0) {
|
||||||
customFieldValuesCount > 0
|
blockingReasons.push(
|
||||||
) {
|
`${machineLinksCount} liaison${machineLinksCount > 1 ? 's' : ''} machine`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (documentsCount > 0) {
|
||||||
|
blockingReasons.push(
|
||||||
|
`${documentsCount} document${documentsCount > 1 ? 's' : ''}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (customFieldValuesCount > 0) {
|
||||||
|
blockingReasons.push(
|
||||||
|
`${customFieldValuesCount} valeur${customFieldValuesCount > 1 ? 's' : ''} de champ personnalisé`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockingReasons.length > 0) {
|
||||||
throw new ConflictException(
|
throw new ConflictException(
|
||||||
'Impossible de supprimer cette pièce car elle possède des éléments liés.',
|
`Impossible de supprimer cette pièce car elle possède encore: ${blockingReasons.join(
|
||||||
|
', ',
|
||||||
|
)}. Supprimez ou détachez ces éléments avant de réessayer.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user