knowyt/client/src/components/CollectQuotes.vue

51 lines
1.1 KiB
Vue
Raw Normal View History

2021-10-01 14:40:07 +00:00
<template>
2021-10-15 18:45:41 +00:00
<div>
2021-10-15 21:07:41 +00:00
<!-- <CollectQuotesExplain /> -->
2021-10-29 20:13:38 +00:00
<QuoteListItem v-for="quote in quotes" :key="quote.id" :quote="quote" />
<CollectQuote v-if="showCollectQuoteDialog" :quote="collectQuote" />
2021-10-01 14:40:07 +00:00
</div>
</template>
<script>
2021-10-04 06:46:36 +00:00
export default {
2021-10-29 20:13:38 +00:00
data() {
return {
showCollectQuoteDialog: false,
collectQuote: {},
}
},
2021-10-04 06:46:36 +00:00
computed: {
quotes() {
return this.$store.state.myQuotes.quotes
},
},
2021-10-29 20:13:38 +00:00
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
})
},
2021-10-04 06:46:36 +00:00
async fetch() {
await this.$engine.getMyQuotes()
},
2021-10-01 14:40:07 +00:00
}
</script>