This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Multiselect with selected nodes always open (vue) #51
Labels
Comments
Hi @jago86,
Do you mean being able to select multiple folders, plus with a maximum of one file selected inside each folder? If so, I think that you try to use the strategies: {
selection: [
'multiple',
(item, selection, neighbours) => {
// If deselected
if(!selection.includes(item)) {
return selection
}
if (!item.children && neighbours) {
return [
// Exclude file siblings
...selection.filter(
node => node.children || !(neighbours.includes(node))
),
item
]
}
return [
...selection,
item
]
}
],
click: ['select'],
fold: ['no-child-selection'],
} I made a little fiddle to demonstrate. Hope that will help! |
Thanks @elbywan !! Is more or less what I want. I added some changes to adjust to my needs: strategies() {
return {
selection: [
'multiple',
(item, selection, neighbours, ancestors) => {
// If deselected
if(!selection.includes(item)) {
return [
...selection,
...ancestors,
];
}
return [
// Exclude file siblings
...selection.filter(
node => node.children || !(neighbours.includes(node))
),
// Include item itself
item,
// Include the ancestors
...ancestors
];
},
(item, selection, neighbours, ancestors) => {
// If deselected
if(!selection.includes(item)) {
// If deselected item is a file, don't allow deselection
if(!item.children) {
return [
...selection,
item,
];
}
// If deselected item is a folder, exclude their children
if (item.children) {
return [
...selection.filter((node) => {
return !item.children.includes( node );
}),
];
}
}
return selection;
},
],
click: ['select'],
fold: [
// 'not-selected',
'no-child-selection',
]
};
} Thanks a lot |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, I'm trying to build a folders system. Nodes with children are my folders and nodes without children are my files. I need to open multiple folder nodes (multiselection ), but with only one file item selected at the same time.
So I tried to made some strategies to acomplish these behaivor:
The isSelected method:
This works more or less how I expected. However lets say that I'm having these structure
When the folder A is selected I can open/close folder B and select any of the items inside. But when for example item A1 is selected and I pick folder B or any other element inside of B, the folder A is closed because the selection losts any reference to A or any of it's items.
Any idea about how I can mantain the folder A opened?
The text was updated successfully, but these errors were encountered: