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' ...@@ -14,6 +14,7 @@ import CrearBarca from './views/CrearBarca.vue'
import Consenso from './views/Consenso.vue' import Consenso from './views/Consenso.vue'
import CrearConsenso from './views/CrearConsenso.vue' import CrearConsenso from './views/CrearConsenso.vue'
import EliminarPropuesta from './views/EliminarPropuesta.vue' import EliminarPropuesta from './views/EliminarPropuesta.vue'
import AbordarBarca from './views/AbordarBarca.vue'
import AbandonarBarca from './views/AbandonarBarca.vue' import AbandonarBarca from './views/AbandonarBarca.vue'
import NotFound from './views/NotFound.vue' import NotFound from './views/NotFound.vue'
...@@ -110,6 +111,15 @@ const router = new Router({ ...@@ -110,6 +111,15 @@ const router = new Router({
router.push(`/barcas/${route.params.id}`), 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', path: '/barcas/:id(\\d+)/abandonar',
name: 'abandonar barca', 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 @@ ...@@ -7,6 +7,15 @@
<LoadingIcono /> <LoadingIcono />
</button> </button>
</div> </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"> <div class="texto">
<Markdown :markdown="consenso.texto" /> <Markdown :markdown="consenso.texto" />
</div> </div>
...@@ -72,13 +81,16 @@ export default { ...@@ -72,13 +81,16 @@ export default {
barcaId() { barcaId() {
return parseInt(this.$route.params.barcaId) return parseInt(this.$route.params.barcaId)
}, },
barca() {
return this.barcas.find(barca => barca.id == this.barcaId)
},
consenso() { consenso() {
return this.consensos.find(consenso => consenso.id == this.id) return this.consensos.find(consenso => consenso.id == this.id)
}, },
date() { date() {
return new Date(this.consenso.created_at) return new Date(this.consenso.created_at)
}, },
...mapState(['consensos']), ...mapState(['barcas', 'consensos']),
...mapState({ ...mapState({
posicionPrevia(state) { posicionPrevia(state) {
if (this.consenso) { if (this.consenso) {
...@@ -93,11 +105,13 @@ export default { ...@@ -93,11 +105,13 @@ export default {
refrescar() { refrescar() {
this.error = null this.error = null
this.loading = true this.loading = true
return this.$store return Promise.all([
.dispatch('conseguirConsenso', { this.$store.dispatch('conseguirBarca', { barcaId: this.barcaId }),
this.$store.dispatch('conseguirConsenso', {
consensoId: this.id, consensoId: this.id,
barcaId: this.barcaId, barcaId: this.barcaId,
}) }),
])
.catch(error => (this.error = error)) .catch(error => (this.error = error))
.finally(() => (this.loading = false)) .finally(() => (this.loading = false))
}, },
...@@ -121,4 +135,6 @@ export default { ...@@ -121,4 +135,6 @@ export default {
display: inline display: inline
margin: 0 margin: 0
margin-right: .2em margin-right: .2em
.link-barca
color: var(--foreground)
</style> </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