Skip to content

Commit

Permalink
Fix: Notice Dashboard Access (PanJiaChen#2321)
Browse files Browse the repository at this point in the history
* Fix: Notice

* Fix: Notice

* Fix: Notice

* Update menu.js

* Update menu.js

---------

Co-authored-by: Edwin Betancourt <[email protected]>
  • Loading branch information
Ricargame and EdwinBetanc0urt authored Jun 6, 2024
1 parent 943126d commit 31bbdcb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/router/modules/ADempiere/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import Layout from '@/layout'

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

// API Request Methods
import { requestMenu } from '@/api/ADempiere/security/index.ts'

// Utils and Helper Methods
import { convertAction } from '@/utils/ADempiere/dictionary/menu'
import { getCurrentClient, getCurrentOrganization, getCurrentRole } from '@/utils/ADempiere/auth'
import { isEmptyValue } from '@/utils/ADempiere'
import { isEmptyValue, recursiveTreeSearch } from '@/utils/ADempiere'

/**
* Get Menu from server
Expand Down Expand Up @@ -104,6 +105,9 @@ export function loadMainMenu({
const menuRoutes = permiseStactiRoutes
.concat(asyncRoutesMap)

// hidden/show dashboards
validateShow(asyncRoutesMap)

resolve(menuRoutes)
}).catch(error => {
console.warn(`Error getting menu: ${error.message}. Code: ${error.code}.`)
Expand Down Expand Up @@ -262,3 +266,21 @@ function hidenStaticRoutes({ dynamicRoutes, staticRoutes, permiseRole }) {
}
})
}

function validateShow(dynamicRoutes) {
const isNoticeWindowAccess = recursiveTreeSearch({
treeData: dynamicRoutes,
attributeValue: 'window_' + NOTICE_WINDOW_ID,
attributeName: 'meta',
secondAttribute: 'containerKey',
attributeChilds: 'children'
})
let dashboardsAccess = ['BC', 'LC', 'notices']
if (isEmptyValue(isNoticeWindowAccess)) {
dashboardsAccess = dashboardsAccess.filter(item => item !== 'notices')
}
store.dispatch('settings/changeSetting', {
key: 'panelRight',
value: dashboardsAccess
})
}
2 changes: 1 addition & 1 deletion src/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const state = {
fullGridMode: !isEmptyValue(localStorage.getItem('fullGridMode')) ? convertStringToBoolean(localStorage.getItem('fullGridMode')) : fullGridMode,
showMenu: true,
panelLeft: ['PC', 'userfavorites', 'recentItems'],
panelRight: ['BC', 'LC', 'notices']
panelRight: []
}

const mutations = {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/ADempiere/dictionary/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

export const NOTICE_WINDOW_ID = 193

export const UNSUPPORTED_DASHBOARDS = [
'favourites',
'performance',
Expand Down

0 comments on commit 31bbdcb

Please sign in to comment.