From d9bd46b2877054303009a1c041d4c0966060c195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 27 May 2019 11:11:45 +0200 Subject: [PATCH] Prettier deck editor --- frontend/src/classes/Deck.js | 3 +++ frontend/src/components/forms/DeckEditor.vue | 26 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/classes/Deck.js b/frontend/src/classes/Deck.js index f7aaedc..4d84216 100644 --- a/frontend/src/classes/Deck.js +++ b/frontend/src/classes/Deck.js @@ -161,6 +161,9 @@ export default class { } deckList() { + // empty deck is empty + if (this.count() == 0) return '' + let lines = [] // begin with deck name and note diff --git a/frontend/src/components/forms/DeckEditor.vue b/frontend/src/components/forms/DeckEditor.vue index 611b6c2..db4c149 100644 --- a/frontend/src/components/forms/DeckEditor.vue +++ b/frontend/src/components/forms/DeckEditor.vue @@ -11,9 +11,15 @@ import Deck from '@/classes/Deck' +import CardsDB from '@/plugins/ffdecks' export default { name: 'DeckEditor', @@ -53,6 +60,21 @@ export default { new_deck: null }), + computed: { + format_sample() { + let serials = [] + for (let tmp_key in CardsDB) { + if (CardsDB.hasOwnProperty(tmp_key)) { + serials.push(tmp_key) + } + } + + let quantity = Math.floor(Math.random() * 3) + 1 + let serial = serials[Math.floor(Math.random() * serials.length)] + return `${quantity}x ${serial}` + } + }, + created() { this.clear() },