platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
763 stars 288 forks source link

Fix nested with collection filtering #463

Closed difernandez closed 1 year ago

difernandez commented 1 year ago

Motivation / Background

This Pull Request has been created because when we replaced select 2 with slim select, a small functionality went missing: in the nested_select, using the collection option in a level that has a parent should only include elements that belong to the selected parent when searching

Detail

This Pull Request restores that functionality, and adds a test for it. It does so by adding to every option the id of it's parent in an attribute with the same name as the parent, and then in the js it checks for options that match the parentId of the select.

Additional information

Video of the fix working

https://user-images.githubusercontent.com/12057523/234010680-40b3d235-2d9c-42d1-b0d8-42b033f6bf46.mov

Checklist

Before submitting the PR make sure the following are checked: