mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactor(frontend): community routes
This commit is contained in:
parent
b3b84fca36
commit
86742d0158
@ -2,19 +2,19 @@
|
|||||||
<div class="nav-community container">
|
<div class="nav-community container">
|
||||||
<b-row class="nav-row">
|
<b-row class="nav-row">
|
||||||
<b-col cols="12" lg="4" md="4" class="px-0">
|
<b-col cols="12" lg="4" md="4" class="px-0">
|
||||||
<b-btn active-class="btn-active" block variant="link" to="/community#edit">
|
<b-btn active-class="btn-active" block variant="link" @click="handleClick(0)">
|
||||||
<b-icon icon="pencil" class="mr-2" />
|
<b-icon icon="pencil" class="mr-2" />
|
||||||
{{ $t('community.submitContribution') }}
|
{{ $t('community.submitContribution') }}
|
||||||
</b-btn>
|
</b-btn>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="12" lg="4" md="4" class="px-0">
|
<b-col cols="12" lg="4" md="4" class="px-0">
|
||||||
<b-btn active-class="btn-active" block variant="link" to="/community#my">
|
<b-btn active-class="btn-active" block variant="link" @click="handleClick(1)">
|
||||||
<b-icon icon="person" class="mr-2" />
|
<b-icon icon="person" class="mr-2" />
|
||||||
{{ $t('community.myContributions') }}
|
{{ $t('community.myContributions') }}
|
||||||
</b-btn>
|
</b-btn>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="12" lg="4" md="4" class="px-0">
|
<b-col cols="12" lg="4" md="4" class="px-0">
|
||||||
<b-btn active-class="btn-active" block variant="link" to="/community#all">
|
<b-btn active-class="btn-active" block variant="link" @click="handleClick(2)">
|
||||||
<b-icon icon="people" class="mr-2" />
|
<b-icon icon="people" class="mr-2" />
|
||||||
{{ $t('community.community') }}
|
{{ $t('community.community') }}
|
||||||
</b-btn>
|
</b-btn>
|
||||||
@ -23,9 +23,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'NavCommunity',
|
name: 'NavCommunity',
|
||||||
}
|
methods: {
|
||||||
|
handleClick(tab) {
|
||||||
|
console.log('handleClick', tab)
|
||||||
|
if (this.$route.params && this.$route.params.tab && Number(this.$route.params.tab) !== tab) {
|
||||||
|
this.$router.push({ params: { tab } })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'$route.params.tab'(tab) {
|
||||||
|
this.handleClick(tab)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.nav-row {
|
.nav-row {
|
||||||
|
|||||||
@ -65,12 +65,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'ContributionInfo',
|
name: 'ContributionInfo',
|
||||||
computed: {
|
computed: {
|
||||||
hash() {
|
hash() {
|
||||||
return this.$route.hash
|
return this.$route.hash
|
||||||
},
|
},
|
||||||
|
currentTab() {
|
||||||
|
console.log('ROUTE', this.$route)
|
||||||
|
if (this.$route.from && this.$route.from.params && this.$route.from.params.tab)
|
||||||
|
return this.$route.from.params.tab
|
||||||
|
return 0
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -5,12 +5,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'ContentHeader',
|
name: 'ContentHeader',
|
||||||
computed: {
|
computed: {
|
||||||
path() {
|
path() {
|
||||||
return this.$route.path.replace(/^\//, '')
|
console.log('ContentHeader', this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1'))
|
||||||
|
return this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -6,19 +6,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'RightSide',
|
name: 'RightSide',
|
||||||
computed: {
|
computed: {
|
||||||
name() {
|
name() {
|
||||||
switch (this.$route.path.replace(/^\//, '')) {
|
console.log('RightSide', this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1'))
|
||||||
|
switch (this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1')) {
|
||||||
case 'settings':
|
case 'settings':
|
||||||
return 'empty'
|
return 'empty'
|
||||||
case 'community':
|
case 'community':
|
||||||
|
console.log('-----------')
|
||||||
return 'community'
|
return 'community'
|
||||||
default:
|
default:
|
||||||
return 'transactions'
|
return 'transactions'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -58,13 +58,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount.vue'
|
import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount.vue'
|
||||||
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
|
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
|
||||||
import ContributionList from '@/components/Contributions/ContributionList.vue'
|
import ContributionList from '@/components/Contributions/ContributionList.vue'
|
||||||
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
|
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
|
||||||
import { listContributions, listAllContributions, openCreations } from '@/graphql/queries'
|
import { listContributions, listAllContributions, openCreations } from '@/graphql/queries'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Community',
|
name: 'Community',
|
||||||
components: {
|
components: {
|
||||||
ContributionForm,
|
ContributionForm,
|
||||||
@ -73,9 +73,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hashLink: '',
|
tabIndex: 1,
|
||||||
tabLinkHashes: ['#edit', '#my', '#all'],
|
|
||||||
tabIndex: 0,
|
|
||||||
items: [],
|
items: [],
|
||||||
itemsAll: [],
|
itemsAll: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
@ -97,10 +95,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.updateTabIndex(Number(this.$route.params.tab))
|
||||||
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === this.$route.hash)
|
|
||||||
this.hashLink = this.$route.hash
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
OpenCreations: {
|
OpenCreations: {
|
||||||
@ -153,9 +148,6 @@ export default {
|
|||||||
this.items = listContributions.contributionList
|
this.items = listContributions.contributionList
|
||||||
if (this.items.find((item) => item.state === 'IN_PROGRESS')) {
|
if (this.items.find((item) => item.state === 'IN_PROGRESS')) {
|
||||||
this.tabIndex = 1
|
this.tabIndex = 1
|
||||||
if (this.$route.hash !== '#my') {
|
|
||||||
this.$router.push({ path: '/community#my' })
|
|
||||||
}
|
|
||||||
this.toastInfo(this.$t('contribution.alert.answerQuestionToast'))
|
this.toastInfo(this.$t('contribution.alert.answerQuestionToast'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -165,21 +157,8 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route(to, from) {
|
'$route.params.tab'(tab) {
|
||||||
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === to.hash)
|
this.updateTabIndex(tab)
|
||||||
this.hashLink = to.hash
|
|
||||||
this.closeAllOpenCollapse()
|
|
||||||
},
|
|
||||||
tabIndex(num) {
|
|
||||||
if (num !== 0) {
|
|
||||||
this.form = {
|
|
||||||
id: null,
|
|
||||||
date: new Date(),
|
|
||||||
memo: '',
|
|
||||||
hours: 0,
|
|
||||||
amount: '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -211,6 +190,13 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
updateTabIndex(tab) {
|
||||||
|
console.log('updateTabIndex', tab)
|
||||||
|
if (Number(tab) !== this.tabIndex) {
|
||||||
|
this.tabIndex = Number(tab)
|
||||||
|
this.closeAllOpenCollapse()
|
||||||
|
}
|
||||||
|
},
|
||||||
closeAllOpenCollapse() {
|
closeAllOpenCollapse() {
|
||||||
this.$el.querySelectorAll('.collapse.show').forEach((value) => {
|
this.$el.querySelectorAll('.collapse.show').forEach((value) => {
|
||||||
this.$root.$emit('bv::toggle::collapse', value.id)
|
this.$root.$emit('bv::toggle::collapse', value.id)
|
||||||
@ -294,7 +280,6 @@ export default {
|
|||||||
this.form.amount = item.amount
|
this.form.amount = item.amount
|
||||||
this.form.hours = item.amount / 20
|
this.form.hours = item.amount / 20
|
||||||
this.updateAmount = item.amount
|
this.updateAmount = item.amount
|
||||||
this.$router.push({ path: '#edit' })
|
|
||||||
this.tabIndex = 0
|
this.tabIndex = 0
|
||||||
},
|
},
|
||||||
updateTransactions(pagination) {
|
updateTransactions(pagination) {
|
||||||
@ -306,10 +291,8 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.updateTransactions(0)
|
this.updateTransactions(0)
|
||||||
this.tabIndex = 0
|
|
||||||
this.$router.push({ path: '/community#edit' })
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.tab-content {
|
.tab-content {
|
||||||
|
|||||||
@ -58,6 +58,17 @@ const routes = [
|
|||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
pageTitle: 'community',
|
pageTitle: 'community',
|
||||||
},
|
},
|
||||||
|
redirect: (to) => {
|
||||||
|
return { path: '/community/1' }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/community/:tab',
|
||||||
|
component: () => import('@/pages/Community.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
pageTitle: 'community',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/information',
|
path: '/information',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user