This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/frontend/src/components/DeckList.vue

82 lines
1.5 KiB
Vue
Raw Normal View History

2019-05-14 15:59:36 +00:00
<template>
<v-expansion-panel v-if="linked_decks">
2019-05-23 11:58:59 +00:00
<Deck
v-for="deck in linked_decks"
:deck="deck"
:key="deck.id"
@change="refresh_decks"
/>
2019-05-14 15:59:36 +00:00
</v-expansion-panel>
</template>
<script>
import * as Cookies from 'js-cookie'
import axios from '@/plugins/axios'
2019-05-14 15:59:36 +00:00
import CardsDB from '@/plugins/ffdecks'
2019-05-14 23:13:44 +00:00
import Deck from './Deck.vue'
2019-05-14 15:59:36 +00:00
export default {
name: 'DeckList',
components: {
Deck
},
asyncComputed: {
decks: {
get() {
return axios
.post('/decks/list', {
session: this.session
})
.then(response => {
if (response.data.success) {
return response.data.decks
}
})
},
default: []
}
},
2019-05-14 15:59:36 +00:00
computed: {
session: () => Cookies.get('session'),
linked_decks() {
2019-05-14 15:59:36 +00:00
let result = []
for (let i = 0; i < this.decks.length; i++) {
let elem = this.decks[i]
2019-05-14 15:59:36 +00:00
let cards = []
for (let j = 0; j < elem.content.cards.length; j++) {
let card = elem.content.cards[j]
cards.push({
count: card.count,
2019-05-14 22:27:42 +00:00
serial: card.serial,
dbentry: CardsDB[card.serial]
2019-05-14 15:59:36 +00:00
})
}
result.push({
id: elem.id,
name: elem.content.name,
note: elem.content.note,
cards: cards
})
}
return result
}
2019-05-23 11:58:59 +00:00
},
methods: {
refresh_decks() {
this.$asyncComputed.decks.update()
}
2019-05-14 15:59:36 +00:00
}
}
</script>