fix: fix user view routing, refactor users view

This commit is contained in:
woothu
2020-03-19 13:00:04 +01:00
parent b9d9b6a124
commit e1972c2cea
4 changed files with 61 additions and 68 deletions
+11 -1
View File
@@ -26,6 +26,16 @@
import usersData from './UsersData'
export default {
name: 'User',
beforeRouteEnter(to, from, next) {
next(vm => {
vm.usersOpened = from.fullPath.includes('users')
})
},
data () {
return {
usersOpened: null
}
},
computed: {
fields () {
return [
@@ -48,7 +58,7 @@ export default {
},
methods: {
goBack() {
this.$router.go(-1)
this.usersOpened ? this.$router.go(-1) : this.$router.push({path: '/users'})
}
}
}
+27 -34
View File
@@ -1,40 +1,33 @@
<template>
<CRow>
<CCol col="12" xl="8">
<transition name="slide">
<CCard>
<CCardHeader>
Users
</CCardHeader>
<CCardBody>
<CDataTable
hover
striped
:items="items"
:fields="fields"
:items-per-page="5"
clickable-rows
:active-page="activePage"
@row-clicked="rowClicked"
>
<template #status="data">
<td>
<CBadge :color="getBadge(data.item.status)">
{{data.item.status}}
</CBadge>
</td>
</template>
</CDataTable>
<CPagination
align="center"
:double-arrows="false"
:active-page="activePage"
:pages="5"
@update:activePage="pageChange"
/>
</CCardBody>
</CCard>
</transition>
<CCard>
<CCardHeader>
Users
</CCardHeader>
<CCardBody>
<CDataTable
hover
striped
:items="items"
:fields="fields"
:items-per-page="5"
clickable-rows
:active-page="activePage"
@row-clicked="rowClicked"
:pagination="{ doubleArrows: false, align: center}"
@page-change="pageChange"
>
<template #status="data">
<td>
<CBadge :color="getBadge(data.item.status)">
{{data.item.status}}
</CBadge>
</td>
</template>
</CDataTable>
</CCardBody>
</CCard>
</CCol>
</CRow>
</template>