knowyt/client/src/components/CollectQuotes.vue

69 lines
1.5 KiB
Vue
Raw Normal View History

2021-10-01 14:40:07 +00:00
<template>
2021-10-15 18:45:41 +00:00
<div>
2022-02-27 14:26:17 +00:00
<CollectQuotesExplain />
<AddNewQuote v-if="quotes.length > 0" @createQuote="createQuote"/>
2022-02-27 14:26:17 +00:00
<NoQuotesYet v-if="quotes.length == 0" />
<QuoteListItem
v-for="quote in quotes"
:key="quote.id"
:quote="quote"
@editQuote="editQuote"
/>
<AddNewQuote @createQuote="createQuote" />
<CollectQuote
v-if="showCollectQuoteDialog"
:quote="collectQuote"
@close="closeCollectQuoteDialog"
@saveQuote="saveQuote"
/>
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() {
var quotes = [...this.$store.state.myQuotes.quotes]
quotes.sort((a, b) => {
return a.id.localeCompare(b.id)
})
return quotes
2021-10-04 06:46:36 +00:00
},
},
methods: {
closeCollectQuoteDialog() {
2021-11-22 06:08:54 +00:00
this.showCollectQuoteDialog = false
},
editQuote(quote) {
2021-10-29 20:13:38 +00:00
this.showCollectQuoteDialog = true
this.collectQuote = {
id: quote.id,
quote: quote.quote,
}
},
async saveQuote(quote) {
this.showCollectQuoteDialog = false
await this.$engine.saveQuote(quote.id, quote.quote)
await this.$engine.getMyQuotes()
},
createQuote() {
2021-10-29 20:13:38 +00:00
this.showCollectQuoteDialog = true
this.collectQuote = {
id: ':new:',
quote: '',
}
},
2021-10-29 20:13:38 +00:00
},
2021-10-04 06:46:36 +00:00
async fetch() {
await this.$engine.getMyQuotes()
},
2021-10-01 14:40:07 +00:00
}
</script>