* feat: add the collapse style css + a script for the intercepting the bootstrap event * chore: remove old code * Add some guards for missing elements and simplify show/hide collapse interaction * Update app/assets/stylesheets/admin.scss Co-authored-by: rhymes <rhymes@hey.com> Co-authored-by: rhymes <rhymes@hey.com>
31 lines
774 B
JavaScript
31 lines
774 B
JavaScript
import { Controller } from 'stimulus';
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
export default class SidebarController extends Controller {
|
|
static targets = ['submenu'];
|
|
|
|
disableCurrentNavItem() {
|
|
if (this.submenuTargets.length > 0) {
|
|
const activeMenuId = this.submenuTargets.filter((item) =>
|
|
item.classList.contains('show'),
|
|
)[0]?.id;
|
|
|
|
if (activeMenuId) {
|
|
const activeButton = document.getElementById(`${activeMenuId}_button`);
|
|
activeButton.setAttribute('disabled', true);
|
|
}
|
|
}
|
|
}
|
|
|
|
expandDropdown() {
|
|
this.closeOtherMenus();
|
|
}
|
|
|
|
closeOtherMenus() {
|
|
this.submenuTargets.map((item) => {
|
|
if (item.classList.contains('show')) {
|
|
item.classList.remove('show');
|
|
}
|
|
});
|
|
}
|
|
}
|