Skip to content

Commit

Permalink
feat: toggle user role funcitonality
Browse files Browse the repository at this point in the history
user role toggling show up routes filter how it works
  • Loading branch information
lbwa committed Oct 9, 2018
1 parent c4f759b commit 29d56d9
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/components/App/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
@click="toggleAside"
></i>
<div class="header__info header__info__align">
<el-switch
style="display: block"
v-model="isAdmin"
:active-color="activeColor"
:inactive-color="inactiveColor"
active-text="admin"
inactive-text="user">
</el-switch>
<el-tooltip
effect="dark"
content="Source code"
Expand Down Expand Up @@ -35,6 +43,8 @@

<script>
import HeaderPopover from 'COMPONENTS/App/HeaderPopover'
import { mapActions } from 'vuex'
export default {
props: {
height: {
Expand All @@ -43,10 +53,34 @@ export default {
}
},
data () {
return {
isAdmin: true,
activeColor: '#13ce66',
inactiveColor: '#3273dc'
}
},
computed: {
currentRole () {
return this.isAdmin ? 'admin' : 'user'
}
},
methods: {
toggleAside () {
this.$emit('toggleAside')
}
},
toggleUserRole () {
this.createExtraRoutes({ role: [this.currentRole] })
},
...mapActions('login', [
'createExtraRoutes'
])
},
watch: {
'currentRole': 'toggleUserRole'
},
components: {
Expand Down

0 comments on commit 29d56d9

Please # to comment.