Created
February 24, 2019 16:36
-
-
Save Imperat/9749d89f4caec2cefab9fe11b05e379e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
name: 'permission-control', | |
props: ['permission-name'], | |
render() { | |
// EDITABLE case. Don't change anything and just render control as is. | |
if (userHasPermission(this.permissionName, EDITABLE)) { | |
return this.$slots.default[0]; | |
} | |
// If user has no EDITABLE permission, but he has 'VISIBLE', | |
// let's change "disabled" prop value to the true | |
if (userHasPermission(this.permissionName, VISIBLE)) { | |
this.$slots.default[0].componentOptions.propsData.disabled = true; | |
return this.$slots.default[0]; | |
} | |
// User has permission for nothing! Let's don't show him anything! | |
return null; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment