phoenix-lib / nova-nested-tree-attach-many

MIT License
35 stars 14 forks source link

Selecting parent does not result in selection of children ? #11

Closed ThisIsMyFavouriteJar closed 3 years ago

ThisIsMyFavouriteJar commented 3 years ago

Hello, have been experimenting with this package and I really like it so far! I currently run into the following problem though. When I select a parent this does not result in the selection of the children, which does seem to be the case at the documentation of Vue Treeselect. https://vue-treeselect.js.org/#basic-features

When I select "Parent" I expect the children to be selected as well. Currently I have this: image

My db structure looks like this: image

And my code like this: NestedTreeAttachManyField::make('Offer Categories',"fields","App\Nova\TemplateField") ->searchable(true) ->withChildrenKey('children') ->withAlwaysOpen(true) ->withActiveKey(true)

I could not find anything in the documentation about this. Is this possible, or am I doing something wrong? Cheers!

phoenix-lib commented 3 years ago

Hi, the "flatten" parameter is responsible for this option. By default in vue-treeselect flatten is disabled. In my package flatten is enabled.

I'll try to explain:

-- Wallpapers [1] --- Brands [2] ---- Some Brand [3]

When we has structure as in example and select "Wallpapers", visual selected will be three categories but attached will be only "Wallpapers[1]".

-- Wallpapers [1] --- Brands [2] ---- Some Brand [3] ---- Another Brand [4]

When we has structure as in this example and select "Some Brand[3]" attached will be "Some Brand[3]"

But if we select Some Brand [3] and Another Brand [4] attached will be Wallpapers [1].

After tests I enable flatten to avoid confusion when saving.

phoenix-lib commented 3 years ago

If you need the behavior that I described above, write message and I will add method for change it.

ThisIsMyFavouriteJar commented 3 years ago

Hi @phoenix-lib , thank you for the explanation! If it would not be too much effort I would really like to be able to adjust the "flatten" setting from within the options!

phoenix-lib commented 3 years ago

Hi, added method withFlatten - you can use it

Upgrade to 1.4.2 version

ThisIsMyFavouriteJar commented 3 years ago

Works great! Thanks for the effort!