Created
April 20, 2017 18:15
-
-
Save MichaelSitter/8700c86e00ee6ae4410362a80342e274 to your computer and use it in GitHub Desktop.
Sample component for test exercise
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
<template> | |
<div class="team-management"> | |
<div v-if="!hasPermission('account:write')"> | |
Please contact your team administrator. | |
</div> | |
<div v-if="hasPermission('account:write')"> | |
Team Administration | |
</div> | |
<button :disabled="!hasPermission('user:create')">Add Team Member</button> | |
<button :disabled="!hasPermission('user:delete')">Remove Team Member</button> | |
<input type="check" v-model="includeDisabled">Include Disabled</input> | |
<table v-if="hasPermission('team:view')"> | |
<tr v-for="member in filteredTeam"> | |
{{member.name}} | |
</tr> | |
</table> | |
</div> | |
</template> | |
<script> | |
export default { | |
data: () => { | |
this.includeDisabled = false | |
}, | |
created: () => { | |
this.team = this.$store.state.account.team | |
this.permissions = this.$store.state.user.permissions | |
}, | |
computed: () => { | |
hasPermission: requiredPermission => { | |
return this.permissions.contains(requiredPermission) | |
}, | |
filteredTeam: () => { | |
if (this.includeDisabled) { | |
return this.team | |
} | |
return this.team.filter(m => m.enabled) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment