diff --git a/frontend/src/components/Deck.vue b/frontend/src/components/Deck.vue
index b3ee2de..e73e5e3 100644
--- a/frontend/src/components/Deck.vue
+++ b/frontend/src/components/Deck.vue
@@ -35,6 +35,7 @@
:id="deck.id"
:value="deck_list"
@close="editing = false"
+ @change="$emit('change')"
/>
diff --git a/frontend/src/components/DeckList.vue b/frontend/src/components/DeckList.vue
index 1ed0c2d..c6462db 100644
--- a/frontend/src/components/DeckList.vue
+++ b/frontend/src/components/DeckList.vue
@@ -1,6 +1,11 @@
-
+
@@ -65,6 +70,12 @@ export default {
return result
}
+ },
+
+ methods: {
+ refresh_decks() {
+ this.$asyncComputed.decks.update()
+ }
}
}
diff --git a/frontend/src/components/forms/DeckEditor.vue b/frontend/src/components/forms/DeckEditor.vue
index bbdde6d..14d542d 100644
--- a/frontend/src/components/forms/DeckEditor.vue
+++ b/frontend/src/components/forms/DeckEditor.vue
@@ -1,22 +1,22 @@
-
- {{ count }} cards detected! (Decks should have exactly 50 cards)
+
+ {{ check.count }} cards detected! (Decks should have exactly 50 cards)
-
- Card with {{ maximum }} copies detected! (Cards should not have more
- than 3 copies)
+
+ Card with {{ check.maximum }} copies detected! (Cards should not have
+ more than 3 copies)
@@ -28,12 +28,16 @@
-
+
check
validate
-
+
save
save
@@ -56,9 +60,12 @@ export default {
},
data: () => ({
- count: 50,
- maximum: 0,
- checked: false
+ check: {
+ count: 50,
+ maximum: 0,
+ checked: false
+ },
+ new_decklist: null
}),
computed: {
@@ -66,7 +73,7 @@ export default {
new_deck() {
try {
- return this.parse_deck(this.$refs.textarea)
+ return this.parse_deck(this.new_decklist)
} catch (e) {
return this.parse_deck(this.value)
}
@@ -171,34 +178,38 @@ export default {
this.$emit('close')
},
- check() {
- let new_deck = this.parse_deck(this.$refs.textarea.lazyValue)
+ update_deck(text) {
+ try {
+ this.new_deck = this.parse_deck(text)
+ } catch (e) {
+ this.new_deck = this.parse_deck(this.value)
+ }
+ },
+ check_deck() {
// count number of cards
- this.count = new_deck.count
+ this.check.count = this.new_deck.count
// find most frequent card
- this.maximum = 0
- new_deck.cards.forEach(card => {
- if (card.count > this.maximum) this.maximum = card.count
+ this.check.maximum = 0
+ this.new_deck.cards.forEach(card => {
+ if (card.count > this.check.maximum) this.check.maximum = card.count
})
// deck has now been checked
- this.checked = true
+ this.check.checked = true
},
- save() {
- let new_deck = this.parse_deck(this.$refs.textarea.lazyValue)
-
+ save_deck() {
axios
.post('/decks/modify', {
session: this.session,
deckID: this.id,
- deckCards: new_deck
+ deckCards: this.new_deck
})
.then(response => {
if (response.data.success) {
- this.$emit('change', new_deck)
+ this.$emit('change')
this.close()
}
})