You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
663 B
JavaScript

export const filterOpenMenu = (user, item) => {
const isAdmin = +user.is_superadmin === 1
if ('items' in item) {
let items = []
if (isAdmin) {
items = item.items
} else {
items = item.items.filter(item => user.role.permissions.find(p => p.name === item.permission) ? item : null)
}
if (items.length > 0) {
let activeItem = items.map(item => route().current(item.active))
item.open = activeItem.includes(true)
item.items = items.filter(item => item.show ? item : null)
return item
}
}
if (isAdmin) {
return item
}
}