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

154 lines
3.7 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-27 11:43:18 +00:00
<v-layout align-center row>
<v-flex text-xs-center xs2>
<Crystal
v-for="element in deck.elements()"
:key="element.name"
:element="element.name"
/>
</v-flex>
<v-flex class="subheading">
{{ deck.name }}
</v-flex>
</v-layout>
2019-05-14 15:59:36 +00:00
</template>
2019-05-27 11:51:24 +00:00
<template v-if="!editing">
<v-alert :value="deck.note" type="info">
{{ deck.note }}
</v-alert>
2019-05-14 22:27:42 +00:00
2019-05-27 11:51:24 +00:00
<v-container style="position: relative" grid-list-md fluid>
<v-layout row wrap>
<v-flex v-for="part in deck.parts()" :key="part.heading" xs12 sm6 md4>
<v-card>
<v-card-title>{{ part.count }} {{ part.heading }}</v-card-title>
<v-list dense subheader>
<Card
v-for="card in part.cards"
:key="card.serial"
:count="card.count"
:serial="card.serial"
:dbentry="card.dbentry"
></Card>
</v-list>
</v-card>
</v-flex>
2019-05-24 11:41:48 +00:00
2019-05-27 11:51:24 +00:00
<v-btn fab absolute bottom right @click.native="editing = true">
<v-icon>edit</v-icon>
2019-05-24 11:41:48 +00:00
</v-btn>
2019-05-27 11:51:24 +00:00
<v-dialog v-model="deleting" persistent>
<template v-slot:activator="{ on }">
<v-btn fab absolute bottom left v-on="on">
<v-icon>delete</v-icon>
</v-btn>
</template>
2019-05-24 11:41:48 +00:00
2019-05-27 11:51:24 +00:00
<v-card>
<v-card-title class="headline">
Really delete this deck?
</v-card-title>
2019-05-24 11:41:48 +00:00
2019-05-27 11:51:24 +00:00
<v-card-text>
Are you sure you want to delete this deck? This cannot be
undone.
</v-card-text>
2019-05-24 11:41:48 +00:00
2019-05-27 11:51:24 +00:00
<v-card-actions>
<v-spacer></v-spacer>
2019-05-24 11:41:48 +00:00
2019-05-27 11:51:24 +00:00
<v-btn color="error" @click.native="deleting = false">
Cancel
</v-btn>
<v-btn
color="success"
@click.native="
deleting = false
delete_deck()
"
>
Confirm
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</v-container>
</template>
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-27 11:43:18 +00:00
import Crystal from './Crystal.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,
2019-05-27 11:43:18 +00:00
Crystal,
2019-05-16 15:47:58 +00:00
DeckEditor
2019-05-14 23:13:44 +00:00
},
2019-05-16 06:10:03 +00:00
data: () => ({
2019-05-24 11:41:48 +00:00
editing: false,
deleting: false
2019-05-16 06:10:03 +00:00
}),
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-24 11:41:48 +00:00
},
delete_deck() {
axios
.post('/decks/delete', {
session: this.session,
deckID: this.deck.id
})
.then(response => {
if (response.data.success) {
this.$emit('change')
}
})
2019-05-14 15:59:36 +00:00
}
}
}
</script>