Currently, every menu that allows to toggle individual columns/categories has it's own implementation.
What to do:
1. Create a global reusable component that implements that should:
- Support cases when grid has regular columnDefs only and columnDefs with categories.
- Not display items that are always visible/hidden.
- Have it's own default button markup which can be replaced by transclusion slot.
- Automatically enable groups during previous groupping when user groups by such item (old implementation had such an issue, see admin users list for live example). For example, if first grouping was by column User with column Email hidden, and then user switches to Email grouping, Email column should become visible in grid and should be hidden from menu.
- Scroll enabled column/category into view. If category has multiple columns, scroll to first column of the set. When multiple columns/categories are enabled, do not scroll anywhere.
2. Use new component where appropriate and remove old copypasted code.