refs #116 Store Jump modal component under Modals

This commit is contained in:
AkiraFukushima 2018-03-30 00:20:35 +09:00
parent bcd1cfd1c4
commit 64a34af860
6 changed files with 45 additions and 27 deletions

View File

@ -7,23 +7,19 @@
</header> </header>
<contents></contents> <contents></contents>
</div> </div>
<new-toot></new-toot> <modals></modals>
<jump-modal></jump-modal>
<image-viewer></image-viewer>
</div> </div>
</template> </template>
<script> <script>
import SideMenu from './TimelineSpace/SideMenu' import SideMenu from './TimelineSpace/SideMenu'
import HeaderMenu from './TimelineSpace/HeaderMenu' import HeaderMenu from './TimelineSpace/HeaderMenu'
import NewToot from './TimelineSpace/Modals/NewToot'
import JumpModal from './TimelineSpace/JumpModal'
import ImageViewer from './TimelineSpace/Modals/ImageViewer'
import Contents from './TimelineSpace/Contents' import Contents from './TimelineSpace/Contents'
import Modals from './TimelineSpace/Modals'
export default { export default {
name: 'timeline-space', name: 'timeline-space',
components: { SideMenu, HeaderMenu, NewToot, JumpModal, ImageViewer, Contents }, components: { SideMenu, HeaderMenu, Modals, Contents },
created () { created () {
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,

View File

@ -0,0 +1,22 @@
<template>
<div>
<new-toot></new-toot>
<jump></jump>
<image-viewer></image-viewer>
</div>
</template>
<script>
import NewToot from './Modals/NewToot'
import Jump from './Modals/Jump'
import ImageViewer from './Modals/ImageViewer'
export default {
name: 'modals',
components: {
NewToot,
Jump,
ImageViewer
}
}
</script>

View File

@ -22,18 +22,18 @@
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'jump-modal', name: 'jump',
computed: { computed: {
...mapState({ ...mapState({
channelList: state => state.TimelineSpace.JumpModal.channelList, channelList: state => state.TimelineSpace.Modals.Jump.channelList,
selectedChannel: state => state.TimelineSpace.JumpModal.selectedChannel selectedChannel: state => state.TimelineSpace.Modals.Jump.selectedChannel
}), }),
channel: { channel: {
get () { get () {
return this.$store.state.TimelineSpace.JumpModal.channel return this.$store.state.TimelineSpace.Modals.Jump.channel
}, },
set (value) { set (value) {
this.$store.commit('TimelineSpace/JumpModal/updateChannel', value) this.$store.commit('TimelineSpace/Modals/Jump/updateChannel', value)
} }
}, },
filterdChannel () { filterdChannel () {
@ -41,16 +41,16 @@ export default {
}, },
jumpModal: { jumpModal: {
get () { get () {
return this.$store.state.TimelineSpace.JumpModal.modalOpen return this.$store.state.TimelineSpace.Modals.Jump.modalOpen
}, },
set (value) { set (value) {
this.$store.commit('TimelineSpace/JumpModal/changeModal', value) this.$store.commit('TimelineSpace/Modals/Jump/changeModal', value)
} }
} }
}, },
watch: { watch: {
channel (newChannel, oldChannel) { channel (newChannel, oldChannel) {
this.$store.commit('TimelineSpace/JumpModal/changeSelected', this.filterChannelForm()[0]) this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', this.filterChannelForm()[0])
} }
}, },
updated () { updated () {
@ -72,7 +72,7 @@ export default {
return e.name === this.selectedChannel.name return e.name === this.selectedChannel.name
}) })
if (i !== undefined && i < (filterd.length - 1)) { if (i !== undefined && i < (filterd.length - 1)) {
this.$store.commit('TimelineSpace/JumpModal/changeSelected', filterd[i + 1]) this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', filterd[i + 1])
} }
}, },
prevChannel () { prevChannel () {
@ -81,17 +81,17 @@ export default {
return e.name === this.selectedChannel.name return e.name === this.selectedChannel.name
}) })
if (i !== undefined && i > 0) { if (i !== undefined && i > 0) {
this.$store.commit('TimelineSpace/JumpModal/changeSelected', filterd[i - 1]) this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', filterd[i - 1])
} }
}, },
changeSelected (channel) { changeSelected (channel) {
this.$store.commit('TimelineSpace/JumpModal/changeSelected', channel) this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', channel)
}, },
jumpCurrentSelected () { jumpCurrentSelected () {
this.$store.dispatch('TimelineSpace/JumpModal/jumpCurrentSelected') this.$store.dispatch('TimelineSpace/Modals/Jump/jumpCurrentSelected')
}, },
jump (channel) { jump (channel) {
this.$store.dispatch('TimelineSpace/JumpModal/jump', channel) this.$store.dispatch('TimelineSpace/Modals/Jump/jump', channel)
} }
} }
} }

View File

@ -1,7 +1,6 @@
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import Mastodon from 'mastodon-api' import Mastodon from 'mastodon-api'
import SideMenu from './TimelineSpace/SideMenu' import SideMenu from './TimelineSpace/SideMenu'
import JumpModal from './TimelineSpace/JumpModal'
import Modals from './TimelineSpace/Modals' import Modals from './TimelineSpace/Modals'
import Contents from './TimelineSpace/Contents' import Contents from './TimelineSpace/Contents'
import router from '../router' import router from '../router'
@ -10,7 +9,6 @@ const TimelineSpace = {
namespaced: true, namespaced: true,
modules: { modules: {
SideMenu, SideMenu,
JumpModal,
Modals, Modals,
Contents Contents
}, },
@ -153,7 +151,7 @@ const TimelineSpace = {
commit('TimelineSpace/Modals/NewToot/changeModal', true, { root: true }) commit('TimelineSpace/Modals/NewToot/changeModal', true, { root: true })
}) })
ipcRenderer.on('CmdOrCtrl+K', () => { ipcRenderer.on('CmdOrCtrl+K', () => {
commit('TimelineSpace/JumpModal/changeModal', true, { root: true }) commit('TimelineSpace/Modals/Jump/changeModal', true, { root: true })
}) })
}, },
async removeShortcutEvents () { async removeShortcutEvents () {

View File

@ -1,11 +1,13 @@
import NewToot from './Modals/NewToot' import NewToot from './Modals/NewToot'
import ImageViewer from './Modals/ImageViewer' import ImageViewer from './Modals/ImageViewer'
import Jump from './Modals/Jump'
const Modals = { const Modals = {
namespaced: true, namespaced: true,
modules: { modules: {
ImageViewer, ImageViewer,
NewToot NewToot,
Jump
} }
} }

View File

@ -1,6 +1,6 @@
import router from '../../router' import router from '../../../router'
const JumpModal = { const Jump = {
namespaced: true, namespaced: true,
state: { state: {
modalOpen: false, modalOpen: false,
@ -55,4 +55,4 @@ const JumpModal = {
} }
} }
export default JumpModal export default Jump