Skip to content
Snippets Groups Projects
Commit 03a79765 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Introduce method for permission checking

parent c227040c
No related branches found
No related tags found
1 merge request!1123Resolve "Finalise Vuetify app as SPA"
......@@ -212,24 +212,13 @@
<router-view
v-if="
!$route.meta.permission ||
(permissionResults &&
permissionResults.find(
(p) => p.name === $route.meta.permission
) &&
permissionResults.find((p) => p.name === $route.meta.permission)
.result)
!$route.meta.permission || checkPermission($route.meta.permission)
"
/>
<message-box
type="error"
v-else-if="
permissionResults &&
permissionResults.find(
(p) => p.name === $route.meta.permission
) &&
permissionResults.find((p) => p.name === $route.meta.permission)
.result === false
permissionResults && !checkPermission($route.meta.permission)
"
>
{{ $t("base.no_permission") }}
......@@ -390,7 +379,7 @@ export default {
this.$data.permissionNames = permArray;
},
buildMenu(routes, menuKey, permissionResults) {
buildMenu(routes, menuKey) {
let menu = {};
// Top-level entries
......@@ -401,9 +390,7 @@ export default {
route.meta[menuKey] &&
!route.parent &&
(route.meta.permission
? permissionResults.find((p) => p.name === route.meta.permission) &&
permissionResults.find((p) => p.name === route.meta.permission)
.result
? this.checkPermission(route.meta.permission)
: true)
) {
let menuItem = {
......@@ -426,9 +413,7 @@ export default {
route.parent.name &&
route.parent.name in menu &&
(route.meta.permission
? permissionResults.find((p) => p.name === route.meta.permission) &&
permissionResults.find((p) => p.name === route.meta.permission)
.result
? this.checkPermission(route.meta.permission)
: true)
) {
let menuItem = {
......@@ -443,6 +428,13 @@ export default {
return Object.values(menu);
},
checkPermission(permissionName) {
return (
this.permissionResults &&
this.permissionResults.find((p) => p.name === permissionName) &&
this.permissionResults.find((p) => p.name === permissionName).result
);
},
},
apollo: {
systemProperties: gqlSystemProperties,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment