Skip to content

Commit

Permalink
fix: Load menu without child nodes. (PanJiaChen#2491)
Browse files Browse the repository at this point in the history
* fix: Load menu without child nodes.

* fix imports
  • Loading branch information
EdwinBetanc0urt authored Jul 25, 2024
1 parent 7076751 commit 3e27886
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/router/modules/ADempiere/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import store from '@/store'
import Layout from '@/layout'

// Constants
import staticRoutes from '@/router/modules/ADempiere/staticRoutes.js'
import STATIC_ROUTES from '@/router/modules/ADempiere/staticRoutes.js'
import { NOTICE_WINDOW_ID } from '@/utils/ADempiere/dictionary/dashboard'

// API Request Methods
Expand All @@ -31,7 +31,7 @@ import { requestMenu } from '@/api/ADempiere/security/index.ts'
// Utils and Helper Methods
import { convertAction } from '@/utils/ADempiere/dictionary/menu'
import { getCurrentOrganization } from '@/utils/ADempiere/auth'
import { isEmptyValue, recursiveTreeSearch } from '@/utils/ADempiere'
import { isEmptyValue, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'

/**
* Get Menu from server
Expand Down Expand Up @@ -69,7 +69,7 @@ export function loadMainMenu({
})

const children = []
if (optionMenu.meta.isSummary) {
if (optionMenu.meta.isSummary && !isEmptyValue(menuElement.children)) {
menuElement.children.forEach(menu => {
const childsSumaryConverted = getChildFromAction({
menu,
Expand Down Expand Up @@ -101,7 +101,7 @@ export function loadMainMenu({
})
const permiseStactiRoutes = hidenStaticRoutes({
dynamicRoutes: asyncRoutesMap,
staticRoutes,
staticRoutes: STATIC_ROUTES,
permiseRole: role
})
const menuRoutes = permiseStactiRoutes
Expand All @@ -112,10 +112,10 @@ export function loadMainMenu({

resolve(menuRoutes)
}).catch(error => {
console.warn(`Error getting menu: ${error.message}. Code: ${error.code}.`)
console.error(`Error getting menu: ${error.message}. Code: ${error.code}.`)
const permiseStactiRoutes = hidenStaticRoutes({
dynamicRoutes: [],
staticRoutes,
staticRoutes: STATIC_ROUTES,
permiseRole: role
})
const menuRoutes = permiseStactiRoutes
Expand Down Expand Up @@ -171,7 +171,7 @@ function getChildFromAction({ menu, index, clientId, roleId, organizationId }) {
children: []
}

if (isIndex) {
if (isIndex && !isEmptyValue(menu.children)) {
menu.children.forEach(child => {
const menuConverted = getChildFromAction({
menu: child,
Expand Down

0 comments on commit 3e27886

Please sign in to comment.