deck list request in decklist component (duh)

This commit is contained in:
Jörn-Michael Miehe 2019-05-20 17:06:40 +02:00
parent da69fb8e9d
commit 3bbb949400
2 changed files with 28 additions and 23 deletions

View file

@ -1,10 +1,12 @@
<template>
<v-expansion-panel v-if="value">
<Deck v-for="deck in decks" :deck="deck" :key="deck.id" />
<v-expansion-panel v-if="linked_decks">
<Deck v-for="deck in linked_decks" :deck="deck" :key="deck.id" />
</v-expansion-panel>
</template>
<script>
import * as Cookies from 'js-cookie'
import axios from '@/plugins/axios'
import CardsDB from '@/plugins/ffdecks'
import Deck from './Deck.vue'
@ -12,20 +14,35 @@ import Deck from './Deck.vue'
export default {
name: 'DeckList',
props: {
value: Array
},
components: {
Deck
},
asyncComputed: {
decks: {
get() {
return axios
.post('/decks/list', {
session: this.session
})
.then(response => {
if (response.data.success) {
return response.data.decks
}
})
},
default: []
}
},
computed: {
decks() {
session: () => Cookies.get('session'),
linked_decks() {
let result = []
for (let i = 0; i < this.value.length; i++) {
let elem = this.value[i]
for (let i = 0; i < this.decks.length; i++) {
let elem = this.decks[i]
let cards = []
for (let j = 0; j < elem.content.cards.length; j++) {

View file

@ -5,7 +5,7 @@
<template v-if="user">
<p>user logged in: {{ user.login }}</p>
<DeckList v-model="decks" />
<DeckList />
<v-btn @click.native="logout">Logout</v-btn>
</template>
@ -36,7 +36,7 @@ export default {
logout() {
axios
.post('/user/logout', {
session: Cookies.get('session')
session: this.session
})
.then(response => {
if (response.data.success) {
@ -64,18 +64,6 @@ export default {
return null
}
})
},
decks() {
return axios
.post('/decks/list', {
session: this.session
})
.then(response => {
if (response.data.success) {
return response.data.decks
}
})
}
}
}