mirror of
https://github.com/hexastack/hexabot
synced 2025-02-23 04:48:51 +00:00
Merge pull request #768 from yassine-sallemi/fix/category-bulk-delete-toast-message
fix: appropriate toast message on category bulk delete
This commit is contained in:
commit
8ef4307c58
@ -54,15 +54,20 @@ export class CategoryRepository extends BaseRepository<
|
|||||||
criteria: TFilterQuery<Category>,
|
criteria: TFilterQuery<Category>,
|
||||||
) {
|
) {
|
||||||
criteria = query.getQuery();
|
criteria = query.getQuery();
|
||||||
const ids = Array.isArray(criteria._id) ? criteria._id : [criteria._id];
|
const ids = Array.isArray(criteria._id?.$in)
|
||||||
|
? criteria._id.$in
|
||||||
|
: Array.isArray(criteria._id)
|
||||||
|
? criteria._id
|
||||||
|
: [criteria._id];
|
||||||
|
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
const associatedBlocks = await this.blockService.findOne({
|
const associatedBlocks = await this.blockService.findOne({
|
||||||
category: id,
|
category: id,
|
||||||
});
|
});
|
||||||
if (associatedBlocks) {
|
if (associatedBlocks) {
|
||||||
|
const category = await this.findOne({ _id: id });
|
||||||
throw new ForbiddenException(
|
throw new ForbiddenException(
|
||||||
`Category ${id} has blocks associated with it`,
|
`Category ${category?.label || id} has blocks associated with it`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user