Commit 1f024609 authored by rene's avatar rene
Browse files

mostrar barca en consenso si no está abordada y invitar a abordar

parent b812c792
Pipeline #37702 passed with stages
in 1 minute and 40 seconds
......@@ -14,6 +14,7 @@ import CrearBarca from './views/CrearBarca.vue'
import Consenso from './views/Consenso.vue'
import CrearConsenso from './views/CrearConsenso.vue'
import EliminarPropuesta from './views/EliminarPropuesta.vue'
import AbordarBarca from './views/AbordarBarca.vue'
import AbandonarBarca from './views/AbandonarBarca.vue'
import NotFound from './views/NotFound.vue'
......@@ -110,6 +111,15 @@ const router = new Router({
router.push(`/barcas/${route.params.id}`),
},
},
{
path: '/barcas/:id(\\d+)/abordar',
name: 'abordar barca',
component: AbordarBarca,
meta: {
requiresAuth: true,
backCallback: () => history.back(),
},
},
{
path: '/barcas/:id(\\d+)/abandonar',
name: 'abandonar barca',
......
<template>
<div class="container">
<h3>Estás abordando esta barca:</h3>
<barca v-if="barca" :barca="barca" />
<p v-else>cargando...</p>
<custom-button @click="abordarBarca" :loading="loading">
Abordar barca
</custom-button>
</div>
</template>
<script>
import { mapState } from 'vuex'
import Barca from '@/components/Barca'
import CustomButton from '@/components/Button.vue'
export default {
name: 'AbordarBarca',
components: { Barca, CustomButton },
data() {
return { loading: false, error: null }
},
computed: {
...mapState(['barcas']),
barcaId() {
return this.$route.params.id
},
barca() {
return this.barcas.find(barca => barca.id == this.barcaId)
},
},
methods: {
abordarBarca() {
this.loading = true
this.$store
.dispatch('abordarBarca', { barcaId: this.barcaId })
.then(() => {
this.$router.push(`/barcas/${this.barcaId}`)
})
.catch(error => (this.error = error))
.finally(() => (this.loading = false))
},
refrescar() {
return this.$store.dispatch('conseguirBarca', {
barcaId: this.barcaId,
})
},
},
mounted() {
this.refrescar()
},
}
</script>
<style lang="sass">
// ocultar los botones de el componente de barca
.barca .buttons
display: none
</style>
......@@ -7,6 +7,15 @@
<LoadingIcono />
</button>
</div>
<p v-if="barca && !barca.abordada">
de la barca
<router-link class="link-barca" :to="`/barcas/${barcaId}`">
{{ barca.nombre }}</router-link
>.
<router-link :to="`/barcas/${barcaId}/abordar`">
abordar esta barca
</router-link>
</p>
<div class="texto">
<Markdown :markdown="consenso.texto" />
</div>
......@@ -72,13 +81,16 @@ export default {
barcaId() {
return parseInt(this.$route.params.barcaId)
},
barca() {
return this.barcas.find(barca => barca.id == this.barcaId)
},
consenso() {
return this.consensos.find(consenso => consenso.id == this.id)
},
date() {
return new Date(this.consenso.created_at)
},
...mapState(['consensos']),
...mapState(['barcas', 'consensos']),
...mapState({
posicionPrevia(state) {
if (this.consenso) {
......@@ -93,11 +105,13 @@ export default {
refrescar() {
this.error = null
this.loading = true
return this.$store
.dispatch('conseguirConsenso', {
return Promise.all([
this.$store.dispatch('conseguirBarca', { barcaId: this.barcaId }),
this.$store.dispatch('conseguirConsenso', {
consensoId: this.id,
barcaId: this.barcaId,
})
}),
])
.catch(error => (this.error = error))
.finally(() => (this.loading = false))
},
......@@ -121,4 +135,6 @@ export default {
display: inline
margin: 0
margin-right: .2em
.link-barca
color: var(--foreground)
</style>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment