change to named tab param

This commit is contained in:
Moriz Wahl 2023-02-17 11:15:19 +01:00
parent 86742d0158
commit df468b9b1d
8 changed files with 370 additions and 366 deletions

View File

@ -23,21 +23,23 @@
</div> </div>
</template> </template>
<script> <script>
export const COMMUNITY_TABS = ['contribute', 'contributions', 'community']
export default { export default {
name: 'NavCommunity', name: 'NavCommunity',
methods: { methods: {
handleClick(tab) { handleClick(tab) {
console.log('handleClick', tab) if (this.$route.params.tab !== COMMUNITY_TABS[tab]) {
if (this.$route.params && this.$route.params.tab && Number(this.$route.params.tab) !== tab) { this.$router.push({ params: { tab: COMMUNITY_TABS[tab] } })
this.$router.push({ params: { tab } })
} }
}, },
}, },
/*
watch: { watch: {
'$route.params.tab'(tab) { '$route.params.tab'() {
this.handleClick(tab)
}, },
}, },
*/
} }
</script> </script>
<style scoped> <style scoped>

View File

@ -1,82 +1,10 @@
<template> <template>
<div class="contribution-info d-none d-lg-block"> <div class="contribution-info d-none d-lg-block">
<div v-if="hash === '#my'"> <slot :name="$route.params.tab" />
<h4 class="alert-heading">{{ $t('community.myContributions') }}</h4>
<p>
{{ $t('contribution.alert.myContributionNoteList') }}
</p>
<ul>
<li>
<b-icon icon="bell-fill" variant="primary"></b-icon>
{{ $t('contribution.alert.pending') }}
</li>
<li>
<b-icon icon="question-square" variant="warning"></b-icon>
{{ $t('contribution.alert.in_progress') }}
</li>
<li>
<b-icon icon="check" variant="success"></b-icon>
{{ $t('contribution.alert.confirm') }}
</li>
<li>
<b-icon icon="x-circle" variant="warning"></b-icon>
{{ $t('contribution.alert.denied') }}
</li>
<li>
<b-icon icon="trash" variant="danger"></b-icon>
{{ $t('contribution.alert.deleted') }}
</li>
</ul>
</div>
<div v-if="hash === '#all'" show fade variant="secondary" class="text-dark">
<h4 class="alert-heading">{{ $t('navigation.community') }}</h4>
<p>
{{ $t('contribution.alert.communityNoteList') }}
</p>
<ul>
<li>
<b-icon icon="bell-fill" variant="primary"></b-icon>
{{ $t('contribution.alert.pending') }}
</li>
<li>
<b-icon icon="question-square" variant="warning"></b-icon>
{{ $t('contribution.alert.in_progress') }}
</li>
<li>
<b-icon icon="check" variant="success"></b-icon>
{{ $t('contribution.alert.confirm') }}
</li>
<li>
<b-icon icon="x-circle" variant="warning"></b-icon>
{{ $t('contribution.alert.denied') }}
</li>
</ul>
</div>
<div v-if="hash === '#edit'" show fade variant="secondary" class="text-dark">
<div>
<h3>{{ $t('contribution.formText.yourContribution') }}</h3>
{{ $t('contribution.formText.bringYourTalentsTo') }}
<div class="my-3">
<b>{{ $t('contribution.formText.describeYourCommunity') }}</b>
</div>
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'ContributionInfo', name: 'ContributionInfo',
computed: {
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>

View File

@ -121,11 +121,7 @@
</b-col> </b-col>
<!-- Right Side Mobil --> <!-- Right Side Mobil -->
<b-col class="d-block d-lg-none"> <b-col class="d-block d-lg-none">
<right-side <right-side>
:transactions="transactions"
:transactionCount="transactionCount"
:transactionLinkCount="transactionLinkCount"
>
<template #transactions> <template #transactions>
<last-transactions <last-transactions
:transactions="transactions" :transactions="transactions"
@ -135,7 +131,7 @@
/> />
</template> </template>
<template #community> <template #community>
<contribution-info /> <community-template />
</template> </template>
<template #empty /> <template #empty />
</right-side> </right-side>
@ -162,11 +158,7 @@
</b-col> </b-col>
<!-- RightSide Desktop --> <!-- RightSide Desktop -->
<b-col cols="3" class="d-none d-lg-block"> <b-col cols="3" class="d-none d-lg-block">
<right-side <right-side>
:transactions="transactions"
:transactionCount="transactionCount"
:transactionLinkCount="transactionLinkCount"
>
<template #transactions> <template #transactions>
<last-transactions <last-transactions
:transactions="transactions" :transactions="transactions"
@ -175,10 +167,10 @@
@set-tunneled-email="setTunneledEmail" @set-tunneled-email="setTunneledEmail"
/> />
</template> </template>
<template #community>
<contribution-info />
</template>
<template #empty /> <template #empty />
<template #community>
<community-template />
</template>
</right-side> </right-side>
</b-col> </b-col>
</b-row> </b-row>
@ -194,6 +186,7 @@
</template> </template>
<script> <script>
import ContentHeader from '@/layouts/templates/ContentHeader.vue' import ContentHeader from '@/layouts/templates/ContentHeader.vue'
import CommunityTemplate from '@/layouts/templates/CommunityTemplate.vue'
import Breadcrumb from '@/components/Breadcrumb/breadcrumb.vue' import Breadcrumb from '@/components/Breadcrumb/breadcrumb.vue'
import RightSide from '@/layouts/templates/RightSide.vue' import RightSide from '@/layouts/templates/RightSide.vue'
import SkeletonOverview from '@/components/skeleton/Overview.vue' import SkeletonOverview from '@/components/skeleton/Overview.vue'
@ -211,7 +204,6 @@ import GdtAmount from '@/components/Template/ContentHeader/GdtAmount.vue'
import CommunityMember from '@/components/Template/ContentHeader/CommunityMember.vue' import CommunityMember from '@/components/Template/ContentHeader/CommunityMember.vue'
import NavCommunity from '@/components/Template/ContentHeader/NavCommunity.vue' import NavCommunity from '@/components/Template/ContentHeader/NavCommunity.vue'
import LastTransactions from '@/components/Template/RightSide/LastTransactions.vue' import LastTransactions from '@/components/Template/RightSide/LastTransactions.vue'
import ContributionInfo from '@/components/Template/RightSide/ContributionInfo.vue'
export default { export default {
name: 'DashboardLayout', name: 'DashboardLayout',
@ -231,7 +223,7 @@ export default {
CommunityMember, CommunityMember,
NavCommunity, NavCommunity,
LastTransactions, LastTransactions,
ContributionInfo, CommunityTemplate,
}, },
data() { data() {
return { return {

View File

@ -0,0 +1,82 @@
<template>
<contribution-info>
<template #contribute>
<div show fade variant="secondary" class="text-dark">
<div>
<h3>{{ $t('contribution.formText.yourContribution') }}</h3>
{{ $t('contribution.formText.bringYourTalentsTo') }}
<div class="my-3">
<b>{{ $t('contribution.formText.describeYourCommunity') }}</b>
</div>
</div>
</div>
</template>
<template #contributions>
<div show fade variant="secondary" class="text-dark">
<h4 class="alert-heading">{{ $t('community.myContributions') }}</h4>
<p>
{{ $t('contribution.alert.myContributionNoteList') }}
</p>
<ul>
<li>
<b-icon icon="bell-fill" variant="primary"></b-icon>
{{ $t('contribution.alert.pending') }}
</li>
<li>
<b-icon icon="question-square" variant="warning"></b-icon>
{{ $t('contribution.alert.in_progress') }}
</li>
<li>
<b-icon icon="check" variant="success"></b-icon>
{{ $t('contribution.alert.confirm') }}
</li>
<li>
<b-icon icon="x-circle" variant="warning"></b-icon>
{{ $t('contribution.alert.denied') }}
</li>
<li>
<b-icon icon="trash" variant="danger"></b-icon>
{{ $t('contribution.alert.deleted') }}
</li>
</ul>
</div>
</template>
<template #community>
<div show fade variant="secondary" class="text-dark">
<h4 class="alert-heading">{{ $t('navigation.community') }}</h4>
<p>
{{ $t('contribution.alert.communityNoteList') }}
</p>
<ul>
<li>
<b-icon icon="bell-fill" variant="primary"></b-icon>
{{ $t('contribution.alert.pending') }}
</li>
<li>
<b-icon icon="question-square" variant="warning"></b-icon>
{{ $t('contribution.alert.in_progress') }}
</li>
<li>
<b-icon icon="check" variant="success"></b-icon>
{{ $t('contribution.alert.confirm') }}
</li>
<li>
<b-icon icon="x-circle" variant="warning"></b-icon>
{{ $t('contribution.alert.denied') }}
</li>
</ul>
</div>
</template>
</contribution-info>
</template>
<script>
import ContributionInfo from '@/components/Template/RightSide/ContributionInfo.vue'
export default {
name: 'CommunityTemplate',
components: {
ContributionInfo,
},
}
</script>

View File

@ -9,7 +9,6 @@
name: 'ContentHeader', name: 'ContentHeader',
computed: { computed: {
path() { path() {
console.log('ContentHeader', this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1'))
return this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1') return this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1')
}, },
}, },

View File

@ -10,12 +10,10 @@
name: 'RightSide', name: 'RightSide',
computed: { computed: {
name() { name() {
console.log('RightSide', this.$route.path.replace(/^\/(.+?)(\/.+)?$/, '$1'))
switch (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'

View File

@ -63,6 +63,7 @@
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'
import { COMMUNITY_TABS } from '@/components/Template/ContentHeader/NavCommunity'
export default { export default {
name: 'Community', name: 'Community',
@ -73,7 +74,7 @@
}, },
data() { data() {
return { return {
tabIndex: 1, tabIndex: 0,
items: [], items: [],
itemsAll: [], itemsAll: [],
currentPage: 1, currentPage: 1,
@ -95,7 +96,7 @@
} }
}, },
mounted() { mounted() {
this.updateTabIndex(Number(this.$route.params.tab)) this.updateTabIndex()
}, },
apollo: { apollo: {
OpenCreations: { OpenCreations: {
@ -147,7 +148,7 @@
this.contributionCount = listContributions.contributionCount this.contributionCount = listContributions.contributionCount
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.$router.push({ params: { tab: 'contributions' } })
this.toastInfo(this.$t('contribution.alert.answerQuestionToast')) this.toastInfo(this.$t('contribution.alert.answerQuestionToast'))
} }
}, },
@ -158,7 +159,7 @@
}, },
watch: { watch: {
'$route.params.tab'(tab) { '$route.params.tab'(tab) {
this.updateTabIndex(tab) this.updateTabIndex()
}, },
}, },
computed: { computed: {
@ -190,12 +191,14 @@
}, },
}, },
methods: { methods: {
updateTabIndex(tab) { updateTabIndex() {
console.log('updateTabIndex', tab) const index = COMMUNITY_TABS.indexOf(this.$route.params.tab)
if (Number(tab) !== this.tabIndex) { if (index > -1) {
this.tabIndex = Number(tab) this.tabIndex = index
this.closeAllOpenCollapse() } else {
this.tabIndex = 0
} }
this.closeAllOpenCollapse()
}, },
closeAllOpenCollapse() { closeAllOpenCollapse() {
this.$el.querySelectorAll('.collapse.show').forEach((value) => { this.$el.querySelectorAll('.collapse.show').forEach((value) => {
@ -280,7 +283,7 @@
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.tabIndex = 0 this.$router.push({ params: { tab: 'contribute' } })
}, },
updateTransactions(pagination) { updateTransactions(pagination) {
this.$emit('update-transactions', pagination) this.$emit('update-transactions', pagination)

View File

@ -59,7 +59,7 @@ const routes = [
pageTitle: 'community', pageTitle: 'community',
}, },
redirect: (to) => { redirect: (to) => {
return { path: '/community/1' } return { path: '/community/contribute' }
}, },
}, },
{ {