knowyt/client/src/components/CollectQuotes.vue
2021-11-07 23:31:04 +01:00

51 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" />
</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>