summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/GroupModule.vue
diff options
context:
space:
mode:
authorUdo Walter2018-08-07 05:25:44 +0200
committerUdo Walter2018-08-07 05:25:44 +0200
commit8f64402237a74ddb380b7e9650fa5897505a665f (patch)
tree692971f50fa7d442bf6fa3be959e72f588626774 /webapp/src/components/GroupModule.vue
parentmerge (diff)
downloadbas-8f64402237a74ddb380b7e9650fa5897505a665f.tar.gz
bas-8f64402237a74ddb380b7e9650fa5897505a665f.tar.xz
bas-8f64402237a74ddb380b7e9650fa5897505a665f.zip
[groups] add ability to show all nested children and not just direkt children + bug fixes
Diffstat (limited to 'webapp/src/components/GroupModule.vue')
-rw-r--r--webapp/src/components/GroupModule.vue42
1 files changed, 20 insertions, 22 deletions
diff --git a/webapp/src/components/GroupModule.vue b/webapp/src/components/GroupModule.vue
index f873e68..bc0c64b 100644
--- a/webapp/src/components/GroupModule.vue
+++ b/webapp/src/components/GroupModule.vue
@@ -14,18 +14,17 @@
<v-card>
<v-tabs :value="activeTab" @input="setActiveTab" :dark="tabsDark" :color="tabsColor" :slider-color="tabsSliderColor">
<template v-for="(item, index) in tabChain">
- <v-icon v-if="item.tabType !== 'home'" :key="'arrow' + index">keyboard_arrow_right</v-icon>
+ <v-icon v-if="item.id > 0 || item.id === 'create'" :key="'arrow' + index">keyboard_arrow_right</v-icon>
<v-tab ripple :key="'tab' + index">
- <v-icon v-if="item.tabType === 'home'">home</v-icon>
+ <v-icon v-if="item.tabType === 'group' && item.id === 0">home</v-icon>
<v-icon v-if="item.tabType === 'client'" style="margin-right: 10px">computer</v-icon>
- <template v-if="item.tabType !== 'home'">{{ item.name || item.id || ' . . . . . . . . . . ' }}</template>
+ <template v-if="item.id > 0 || item.id === 'create'">{{ item.name ? item.name : item.id !== 'create' ? item.id : ' . . . . . . . . . . ' }}</template>
</v-tab>
</template>
</v-tabs>
</v-card>
<v-tabs-items :value="activeTab" @input="setActiveTab" touchless style="padding-bottom: 20px">
<v-tab-item v-for="(item, index) in tabChain" :key="index">
- <group-module-home-view v-if="item.tabType === 'home'" :home="item" />
<group-module-group-view v-if="item.tabType === 'group'" :group="item" :tabIndex="index" />
<group-module-client-view v-if="item.tabType === 'client'" :client="item" :tabIndex="index" />
</v-tab-item>
@@ -37,7 +36,6 @@
</template>
<script>
-import GroupModuleHomeView from '@/components/GroupModuleHomeView'
import GroupModuleGroupView from '@/components/GroupModuleGroupView'
import GroupModuleClientView from '@/components/GroupModuleClientView'
import GroupModuleDialog from '@/components/GroupModuleDialog'
@@ -47,13 +45,11 @@ export default {
name: 'GroupModule',
routes () {
return [
- { name: 'home', path: 'home' },
{ name: 'group', path: ':id' },
{ name: 'client', path: 'client/:id' }
]
},
components: {
- GroupModuleHomeView,
GroupModuleGroupView,
GroupModuleClientView,
GroupModuleDialog
@@ -69,10 +65,10 @@ export default {
watch: {
activeTab (index) {
const item = this.tabChain[index]
- if (item.tabType !== this.$route.name.replace('GroupModule.', '') || String(item.id) !== String(this.$route.params.id)) {
+ if (item.tabType !== this.$route.name.replace('GroupModule.', '') || String(item.id) !== this.$route.params.id) {
this.$router.push({
name: 'GroupModule.' + item.tabType,
- params: { id: (item.id || item.tabType === 'home') ? item.id : 'create', noReload: true }
+ params: { id: item.id !== undefined ? item.id : 'create', noReload: true }
})
}
}
@@ -82,7 +78,7 @@ export default {
loadItem (routeName, id) {
const type = routeName.replace('GroupModule.', '')
if (id === 'create') {
- this.setTab({ index: 1, item: { tabType: type } })
+ this.setTab({ index: 1, item: { id: 'create', tabType: type } })
this.setActiveTab(1)
} else {
const action = type === 'group' ? 'loadGroup' : type === 'client' ? 'loadClient' : null
@@ -92,24 +88,26 @@ export default {
},
created () {
if (this.groupList.length === 0 || this.clientList.length === 0) this.$store.dispatch('groups/loadLists')
- if (this.tabChain.length === 0) this.$store.dispatch('groups/loadHome', true)
- this.loadItem(this.$route.name, this.$route.params.id)
+ if (this.tabChain.length === 0) this.$store.dispatch('groups/loadGroup', { id: 0, tabIndex: 0 })
+ if (this.$route.params.id !== '0') this.loadItem(this.$route.name, this.$route.params.id)
this.$router.replace({
name: 'GroupModule.' + this.tabChain[this.activeTab].tabType,
params: { id: this.tabChain[this.activeTab].id, noReload: true }
})
},
beforeRouteUpdate (to, from, next) {
- const typeFromRoute = to.name.replace('GroupModule.', '')
- var tabIndex
- this.tabChain.some((item, index) => {
- if (item.tabType === typeFromRoute && String(item.id) === String(to.params.id)) {
- tabIndex = index
- return true
- } else { return false }
- })
- if (!to.params.noReload && tabIndex === undefined) this.loadItem(to.name, to.params.id)
- else if (tabIndex !== undefined) this.setActiveTab(tabIndex)
+ if (!to.params.noReload) {
+ var tabIndex
+ for (var i = 0; i < this.tabChain.length; i++) {
+ if (this.tabChain[i].tabType === to.name.replace('GroupModule.', '') && String(this.tabChain[i].id) === to.params.id) {
+ tabIndex = i
+ break
+ }
+ }
+ console.log(tabIndex)
+ if (tabIndex === undefined) this.loadItem(to.name, to.params.id)
+ else this.setActiveTab(tabIndex)
+ }
next()
}
}