You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
willaengine/resources/js/Global/mixins/global.js

53 lines
1.7 KiB

import { mapActions } from "vuex";
import globalStore from "@Global/store";
import authStore from "@Core/store";
import permissionList from "@Global/utils/Permissions/list";
import { UserService } from "@Global/services/storage.services";
const global = {
methods: {
$_getPath(subPath = "") {
const path = process.env.MIX_PUSHER_APP_PUBLIC_PATH
? process.env.MIX_PUSHER_APP_PUBLIC_PATH
: "/";
return path + subPath;
},
//Modal
...mapActions("modal", [
"$_dialog",
"$_helper",
"$_openModalStack",
"$_closeModalStack"
]),
//Permission
$_hasPermission(permission, owner = false, module = null) {
let currentModule = module ? module : globalStore.state.common.current_module;
let permissions = authStore.state.auth.permissions;
let multiPermission = permission.split("|");
let siteOwner = UserService.get().is_owner == "true";
for (const iterator of multiPermission) {
if (iterator == "") {
return true;
}
permission = permissionList[iterator];
if (
siteOwner ||
owner ||
(permission &&
permissions[currentModule] &&
Object.values(permissions[currentModule]).includes(
permission
))
) {
return true;
}
}
return false;
}
}
};
export { global };