Update function that saves active tabs in state
This commit is contained in:
parent
6a73b4f20c
commit
84c6319a1f
3 changed files with 11 additions and 12 deletions
|
@ -19,7 +19,7 @@ import Vue from 'vue'
|
||||||
|
|
||||||
const emojiPacks = {
|
const emojiPacks = {
|
||||||
state: {
|
state: {
|
||||||
activeCollapseItems: [],
|
activeTab: '',
|
||||||
currentFilesPage: 1,
|
currentFilesPage: 1,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
filesPageSize: 30,
|
filesPageSize: 30,
|
||||||
|
@ -31,8 +31,8 @@ const emojiPacks = {
|
||||||
remotePacks: {}
|
remotePacks: {}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_ACTIVE_COLLAPSE_ITEMS: (state, items) => {
|
SET_ACTIVE_TAB: (state, tab) => {
|
||||||
state.activeCollapseItems = items
|
state.activeTab = tab
|
||||||
},
|
},
|
||||||
SET_FILES_COUNT: (state, count) => {
|
SET_FILES_COUNT: (state, count) => {
|
||||||
state.localPackFilesCount = count
|
state.localPackFilesCount = count
|
||||||
|
@ -177,8 +177,8 @@ const emojiPacks = {
|
||||||
commit('UPDATE_LOCAL_PACK_PACK', { name: packName, pack: result.data })
|
commit('UPDATE_LOCAL_PACK_PACK', { name: packName, pack: result.data })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SetActiveCollapseItems({ commit }, activeItems) {
|
SetActiveTab({ commit }, activeTab) {
|
||||||
commit('SET_ACTIVE_COLLAPSE_ITEMS', activeItems)
|
commit('SET_ACTIVE_TAB', activeTab)
|
||||||
},
|
},
|
||||||
async SetRemoteEmojiPacks({ commit, getters }, { remoteInstance }) {
|
async SetRemoteEmojiPacks({ commit, getters }, { remoteInstance }) {
|
||||||
const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance)
|
const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance)
|
||||||
|
|
|
@ -114,7 +114,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadRemotePack() {
|
loadRemotePack() {
|
||||||
return this.$store.state.emojiPacks.activeCollapseItems.includes(this.name)
|
return this.$store.state.emojiPacks.activeTab === this.name
|
||||||
},
|
},
|
||||||
remoteInstanceAddress() {
|
remoteInstanceAddress() {
|
||||||
return this.$store.state.emojiPacks.remoteInstance
|
return this.$store.state.emojiPacks.remoteInstance
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="Object.keys(localPacks).length > 0" :label="$t('emoji.packs')">
|
<el-form-item v-if="Object.keys(localPacks).length > 0" :label="$t('emoji.packs')">
|
||||||
<el-collapse v-for="(pack, name) in localPacks" :key="name" v-model="activeLocalPack" accordion @change="setActiveCollapseItems">
|
<el-collapse v-for="(pack, name) in localPacks" :key="name" v-model="activeLocalPack" accordion @change="setActiveTab">
|
||||||
<local-emoji-pack :name="name" :pack="pack" :host="$store.getters.authHost" :is-local="true" />
|
<local-emoji-pack :name="name" :pack="pack" :host="$store.getters.authHost" :is-local="true" />
|
||||||
</el-collapse>
|
</el-collapse>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -65,8 +65,8 @@
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="Object.keys(remotePacks).length > 0" :label="$t('emoji.packs')">
|
<el-form-item v-if="Object.keys(remotePacks).length > 0" :label="$t('emoji.packs')">
|
||||||
<el-collapse v-for="(pack, name) in remotePacks" :key="name" v-model="activeRemotePack" @change="setActiveCollapseItems">
|
<el-collapse v-for="(pack, name) in remotePacks" :key="name" v-model="activeRemotePack" accordion @change="setActiveTab">
|
||||||
<remote-emoji-pack :name="name" :pack="sortPack(pack)" :host="$store.getters.authHost" :is-local="false" />
|
<remote-emoji-pack :name="name" :pack="pack" :host="$store.getters.authHost" :is-local="false" />
|
||||||
</el-collapse>
|
</el-collapse>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -184,9 +184,8 @@ export default {
|
||||||
message: i18n.t('emoji.reloaded')
|
message: i18n.t('emoji.reloaded')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setActiveCollapseItems(activeItems) {
|
setActiveTab(activeTab) {
|
||||||
const items = Array.isArray(activeItems) ? activeItems : [activeItems]
|
this.$store.dispatch('SetActiveTab', activeTab)
|
||||||
this.$store.dispatch('SetActiveCollapseItems', items)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue