From cb26ae69ada05d8dd7417f3e1cf11ecaab1abe1e Mon Sep 17 00:00:00 2001 From: jugeeya Date: Fri, 23 Aug 2024 12:06:53 -0700 Subject: [PATCH] Export Winner via Email --- src/App.vue | 11 +- src/components/Menu.vue | 4 + src/components/modals/GameStateModal.vue | 40 +++--- src/components/modals/WinnerModal.vue | 173 +++++++++++++++++++++++ src/main.js | 1 + src/store/index.js | 1 + 6 files changed, 211 insertions(+), 19 deletions(-) create mode 100644 src/components/modals/WinnerModal.vue diff --git a/src/App.vue b/src/App.vue index 866d599..5c2ba15 100644 --- a/src/App.vue +++ b/src/App.vue @@ -35,6 +35,7 @@ + v{{ version }} @@ -56,6 +57,7 @@ import NightOrderModal from "./components/modals/NightOrderModal"; import FabledModal from "@/components/modals/FabledModal"; import VoteHistoryModal from "@/components/modals/VoteHistoryModal"; import GameStateModal from "@/components/modals/GameStateModal"; +import WinnerModal from "@/components/modals/WinnerModal"; export default { components: { @@ -71,7 +73,8 @@ export default { Menu, EditionModal, RolesModal, - Gradients + Gradients, + WinnerModal, }, computed: { ...mapState(["grimoire", "session"]), @@ -85,6 +88,12 @@ export default { methods: { keyup({ key, ctrlKey, metaKey }) { if (ctrlKey || metaKey) return; + // Check if the active element is an input, textarea, or select + const activeElement = document.activeElement; + const isInputField = ["INPUT", "TEXTAREA", "SELECT"].includes( + activeElement.tagName, + ); + if (isInputField) return; switch (key.toLocaleLowerCase()) { case "g": this.$store.commit("toggleGrimoire"); diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 46133ca..7a8ce15 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -204,6 +204,10 @@ Game State JSON +
  • + Export Winner + +
  • Join Discord diff --git a/src/components/modals/GameStateModal.vue b/src/components/modals/GameStateModal.vue index feac038..8a0dc1a 100644 --- a/src/components/modals/GameStateModal.vue +++ b/src/components/modals/GameStateModal.vue @@ -31,25 +31,29 @@ export default { Modal }, computed: { - gamestate: function() { - return JSON.stringify({ - bluffs: this.players.bluffs.map(({ id }) => id), - edition: this.edition.isOfficial - ? { id: this.edition.id } - : this.edition, - roles: this.edition.isOfficial - ? "" - : this.$store.getters.customRolesStripped, - fabled: this.players.fabled.map(fabled => - fabled.isCustom ? fabled : { id: fabled.id } - ), - players: this.players.players.map(player => ({ - ...player, - role: player.role.id || {} - })) - }); + gamestate: function () { + return JSON.stringify( + { + bluffs: this.players.bluffs.map(({ id }) => id), + edition: this.edition.isOfficial + ? { id: this.edition.id } + : this.edition, + roles: this.edition.isOfficial + ? "" + : this.$store.getters.customRolesStripped, + fabled: this.players.fabled.map((fabled) => + fabled.isCustom ? fabled : { id: fabled.id }, + ), + players: this.players.players.map((player) => ({ + ...player, + role: player.role.id || {}, + })), + }, + null, + 2, + ); }, - ...mapState(["modals", "players", "edition", "roles", "session"]) + ...mapState(["modals", "players", "edition", "roles", "session"]), }, data() { return { diff --git a/src/components/modals/WinnerModal.vue b/src/components/modals/WinnerModal.vue new file mode 100644 index 0000000..695664a --- /dev/null +++ b/src/components/modals/WinnerModal.vue @@ -0,0 +1,173 @@ + + + + + diff --git a/src/main.js b/src/main.js index 039a5cb..b48621f 100644 --- a/src/main.js +++ b/src/main.js @@ -22,6 +22,7 @@ const faIcons = [ "ExchangeAlt", "ExclamationTriangle", "FileCode", + "FileExport", "FileUpload", "HandPaper", "HandPointRight", diff --git a/src/store/index.js b/src/store/index.js index feb528d..93e47d4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -112,6 +112,7 @@ export default new Vuex.Store({ edition: false, fabled: false, gameState: false, + winner: false, nightOrder: false, reference: false, reminder: false,