From 1321cf6a96638a906dcf7711d7c32c2d8aec417f Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 13 Oct 2020 13:42:18 +0200 Subject: [PATCH] Moved log tab to right drawer --- .../ui/creature/character/CharacterSheet.vue | 36 +++++++++++-------- .../character/CharacterSheetRightDrawer.vue | 32 +++++++++++++++++ .../character/CharacterSheetToolbar.vue | 5 ++- .../character/characterSheetTabs/LogTab.vue | 4 +-- app/imports/ui/layouts/AppLayout.vue | 4 ++- app/imports/ui/router.js | 3 ++ app/imports/ui/vuexStore.js | 7 ++++ 7 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 app/imports/ui/creature/character/CharacterSheetRightDrawer.vue diff --git a/app/imports/ui/creature/character/CharacterSheet.vue b/app/imports/ui/creature/character/CharacterSheet.vue index cb6c3734..a412f46e 100644 --- a/app/imports/ui/creature/character/CharacterSheet.vue +++ b/app/imports/ui/creature/character/CharacterSheet.vue @@ -37,9 +37,6 @@ - - - @@ -62,16 +59,17 @@ - {{ snackbar.text }} + {{ snackbar.text.split(/\n+/).pop() }} - Close + close @@ -112,7 +110,7 @@ }, }, data(){return { - snackbars: new Set(), + snackbars: [], }}, reactiveProvide: { name: 'context', @@ -136,16 +134,23 @@ mounted(){ this.$store.commit('setPageTitle', this.creature && this.creature.name || 'Character Sheet'); let that = this; - let observer = CreatureLogs.find({ + this.logObserver = CreatureLogs.find({ creatureId: this.creatureId, }).observe({ added(doc){ - console.log({added: doc}); - that.snackbars.add(doc); - setTimeout(function(){that.snackbars.delete(doc)}, 8000); + if (!that.$subReady.singleCharacter) return; + if (that.activeTab === 0) return; + if (that.snackbars.some(o => o._id === doc._id)) return; + doc.open = true; + that.snackbars.push(doc); + setTimeout(function(){ + that.snackbars = that.snackbars.filter(bar => bar._id === doc._id); + }, 8000); }, }); - console.log(observer); + }, + beforeDestroy(){ + this.logObserver.stop(); }, meteor: { $subscribe: { @@ -164,6 +169,9 @@ return false; } }, + snackbars(){ + + } }, } diff --git a/app/imports/ui/creature/character/CharacterSheetRightDrawer.vue b/app/imports/ui/creature/character/CharacterSheetRightDrawer.vue new file mode 100644 index 00000000..3eb06fa3 --- /dev/null +++ b/app/imports/ui/creature/character/CharacterSheetRightDrawer.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/app/imports/ui/creature/character/CharacterSheetToolbar.vue b/app/imports/ui/creature/character/CharacterSheetToolbar.vue index 98ba6b9a..87ba1e22 100644 --- a/app/imports/ui/creature/character/CharacterSheetToolbar.vue +++ b/app/imports/ui/creature/character/CharacterSheetToolbar.vue @@ -71,6 +71,7 @@ + @@ -91,9 +92,6 @@ max="100px" @change="e => $emit('input', e)" > - - Log - Stats @@ -156,6 +154,7 @@ export default { methods: { ...mapMutations([ 'toggleDrawer', + 'toggleRightDrawer', ]), recompute(charId){ recomputeCreature.call({charId}); diff --git a/app/imports/ui/creature/character/characterSheetTabs/LogTab.vue b/app/imports/ui/creature/character/characterSheetTabs/LogTab.vue index f248c761..2ba705ad 100644 --- a/app/imports/ui/creature/character/characterSheetTabs/LogTab.vue +++ b/app/imports/ui/creature/character/characterSheetTabs/LogTab.vue @@ -1,6 +1,6 @@ diff --git a/app/imports/ui/router.js b/app/imports/ui/router.js index 89c7d0e3..2eac1cf3 100644 --- a/app/imports/ui/router.js +++ b/app/imports/ui/router.js @@ -10,6 +10,7 @@ import SingleLibraryPage from '/imports/ui/pages/SingleLibraryPage.vue' import SingleLibraryToolbarItems from '/imports/ui/library/SingleLibraryToolbarItems.vue' import CharacterSheetPage from '/imports/ui/pages/CharacterSheetPage.vue'; import CharacterSheetToolbar from '/imports/ui/creature/character/CharacterSheetToolbar.vue'; +import CharacterSheetRightDrawer from '/imports/ui/creature/character/CharacterSheetRightDrawer.vue'; import SignIn from '/imports/ui/pages/SignIn.vue' ; import Register from '/imports/ui/pages/Register.vue'; import IconAdmin from '/imports/ui/icons/IconAdmin.vue'; @@ -142,6 +143,7 @@ RouterFactory.configure(factory => { components: { default: CharacterSheetPage, toolbar: CharacterSheetToolbar, + rightDrawer: CharacterSheetRightDrawer, }, meta: { title: 'Character Sheet', @@ -151,6 +153,7 @@ RouterFactory.configure(factory => { components: { default: CharacterSheetPage, toolbar: CharacterSheetToolbar, + rightDrawer: CharacterSheetRightDrawer, }, meta: { title: 'Character Sheet', diff --git a/app/imports/ui/vuexStore.js b/app/imports/ui/vuexStore.js index 8941c236..a9050040 100644 --- a/app/imports/ui/vuexStore.js +++ b/app/imports/ui/vuexStore.js @@ -10,15 +10,22 @@ const store = new Vuex.Store({ }, state: { drawer: undefined, + rightDrawer: undefined, pageTitle: undefined, }, mutations: { toggleDrawer (state) { state.drawer = !state.drawer; }, + toggleRightDrawer (state) { + state.rightDrawer = !state.rightDrawer; + }, setDrawer (state, value) { state.drawer = value; }, + setRightDrawer (state, value) { + state.rightDrawer = value; + }, setPageTitle (state, value) { state.pageTitle = value; document.title = value;