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/Deck.vue

88 lines
2 KiB
Vue
Raw Normal View History

2019-05-14 15:59:36 +00:00
<template>
<v-expansion-panel-content>
<template v-slot:header>
2019-05-14 22:27:42 +00:00
<span class="subheading">{{ deck.name }}</span>
2019-05-14 15:59:36 +00:00
</template>
2019-05-16 06:10:03 +00:00
<v-alert v-if="!editing" :value="deck.note" type="info">
2019-05-14 22:27:42 +00:00
{{ deck.note }}
</v-alert>
2019-05-17 13:24:52 +00:00
<v-container v-if="!editing" style="position: relative" grid-list-md fluid>
<v-layout row wrap>
2019-05-23 16:11:39 +00:00
<v-flex v-for="part in deck.parts()" :key="part.heading" xs12 sm6 md4>
2019-05-14 22:27:42 +00:00
<v-card>
<v-card-title>{{ part.count }} {{ part.heading }}</v-card-title>
<v-list dense subheader>
2019-05-14 23:13:44 +00:00
<Card
v-for="card in part.cards"
:key="card.serial"
:count="card.count"
:serial="card.serial"
:dbentry="card.dbentry"
></Card>
2019-05-14 22:27:42 +00:00
</v-list>
</v-card>
</v-flex>
2019-05-16 13:54:33 +00:00
2019-05-16 06:10:03 +00:00
<v-btn fab absolute bottom right @click.native="editing = true">
<v-icon>edit</v-icon>
</v-btn>
2019-05-14 22:27:42 +00:00
</v-layout>
</v-container>
2019-05-23 16:11:39 +00:00
2019-05-24 09:25:35 +00:00
<DeckEditor v-if="editing" :deck="deck" @save="save_deck">
<v-btn color="error" @click.native="editing = false">
<v-icon>cancel</v-icon>
cancel
</v-btn>
</DeckEditor>
2019-05-14 15:59:36 +00:00
</v-expansion-panel-content>
</template>
<script>
2019-05-23 16:11:39 +00:00
import * as Cookies from 'js-cookie'
import axios from '@/plugins/axios'
2019-05-14 23:13:44 +00:00
import Card from './Card.vue'
2019-05-16 15:47:58 +00:00
import DeckEditor from './forms/DeckEditor.vue'
2019-05-14 23:13:44 +00:00
2019-05-14 15:59:36 +00:00
export default {
name: 'Deck',
props: {
deck: Object
},
2019-05-14 23:13:44 +00:00
components: {
2019-05-16 15:47:58 +00:00
Card,
DeckEditor
2019-05-14 23:13:44 +00:00
},
2019-05-16 06:10:03 +00:00
data: () => ({
editing: false
}),
2019-05-14 15:59:36 +00:00
computed: {
2019-05-23 16:11:39 +00:00
session: () => Cookies.get('session')
},
2019-05-16 15:47:58 +00:00
2019-05-23 16:11:39 +00:00
methods: {
2019-05-24 09:25:35 +00:00
save_deck(new_deck) {
2019-05-23 16:11:39 +00:00
axios
.post('/decks/modify', {
session: this.session,
deckID: this.deck.id,
2019-05-24 09:25:35 +00:00
deckCards: new_deck.plainObject()
2019-05-23 16:11:39 +00:00
})
.then(response => {
if (response.data.success) {
2019-05-24 09:25:35 +00:00
this.editing = false
2019-05-23 16:11:39 +00:00
this.$emit('change')
}
})
2019-05-14 15:59:36 +00:00
}
}
}
</script>