mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(feat) if a child category is selected, with every sibling of it, we dont automatically select its parent
This commit is contained in:
parent
b1135f6df0
commit
1f7f9be37d
@ -80,8 +80,10 @@ export default class ProductLib {
|
||||
let list = [...currentSelection];
|
||||
const children = allCategories
|
||||
.filter(el => el.parent_id === category.id);
|
||||
/*
|
||||
const siblings = allCategories
|
||||
.filter(el => el.parent_id === category.parent_id && el.parent_id !== null);
|
||||
*/
|
||||
|
||||
if (operation === 'add') {
|
||||
list.push(category);
|
||||
@ -89,10 +91,12 @@ export default class ProductLib {
|
||||
// if a parent category is selected, we automatically select all its children
|
||||
list = [...Array.from(new Set([...list, ...children]))];
|
||||
}
|
||||
/*
|
||||
if (siblings.length && siblings.every(el => list.includes(el))) {
|
||||
// if a child category is selected, with every sibling of it, we automatically select its parent
|
||||
list.push(allCategories.find(p => p.id === siblings[0].parent_id));
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
list.splice(list.indexOf(category), 1);
|
||||
const parent = allCategories.find(p => p.id === category.parent_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user