knowyt/client/src/components/CollectQuotes.vue
2021-10-29 22:13:38 +02:00

52 lines
1.1 KiB
Vue

<template>
<div>
<!-- <CollectQuotesExplain /> -->
<QuoteListItem v-for="quote in quotes" :key="quote.id" :quote="quote" />
<CollectQuote v-if="showCollectQuoteDialog" :quote="collectQuote" />
<p>{{ showCollectQuoteDialog }}</p>
</div>
</template>
<script>
export default {
data() {
return {
showCollectQuoteDialog: false,
collectQuote: {},
}
},
computed: {
quotes() {
return this.$store.state.myQuotes.quotes
},
},
created() {
this.$nuxt.$on('edit-quote', (quote) => {
this.showCollectQuoteDialog = true
this.collectQuote = {
id: quote.id,
quote: quote.quote,
}
})
this.$nuxt.$on('create-quote', (quote) => {
this.showCollectQuoteDialog = true
this.collectQuote = {
id: ':new:',
quote: '',
}
})
this.$nuxt.$on('save-quote', async (quote) => {
this.$engine.saveQuote(quote.id, quote.quote)
await this.$engine.getMyQuotes()
this.showCollectQuoteDialog = false
})
},
async fetch() {
await this.$engine.getMyQuotes()
},
}
</script>