From 20b474a383a7210ecf5b0c8daff2bb6b2f7565d7 Mon Sep 17 00:00:00 2001 From: Sonia Zorba <sonia.zorba@inaf.it> Date: Mon, 15 Mar 2021 18:41:46 +0100 Subject: [PATCH] Improved show main page functionality --- gms-ui/src/components/GroupsBreadcrumb.vue | 12 +----------- gms-ui/src/components/TopMenu.vue | 6 +++++- gms-ui/src/store.js | 12 ++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gms-ui/src/components/GroupsBreadcrumb.vue b/gms-ui/src/components/GroupsBreadcrumb.vue index faefa3a..f8da78e 100644 --- a/gms-ui/src/components/GroupsBreadcrumb.vue +++ b/gms-ui/src/components/GroupsBreadcrumb.vue @@ -20,7 +20,6 @@ <script> import { mapState } from 'vuex'; -import client from 'api-client'; function buildItems(values) { let groups = []; @@ -50,16 +49,7 @@ export default { }), methods: { changeBreadcrumb: function(groupId) { - this.input.selectedGroupId = groupId; - this.input.searchFilter = null; - if (this.input.tabIndex === 0) { - client.fetchGroupsTab(this.input) - .then(model => { - this.$store.commit('updateGroups', model); - }); - } else { - this.$store.dispatch('changeTab', 0); - } + this.$store.dispatch('changeBreadcrumb', groupId); }, openEditGroupModal: function(group) { group.leaf = this.model.leaf; diff --git a/gms-ui/src/components/TopMenu.vue b/gms-ui/src/components/TopMenu.vue index 71ad85a..c689fdb 100644 --- a/gms-ui/src/components/TopMenu.vue +++ b/gms-ui/src/components/TopMenu.vue @@ -36,7 +36,11 @@ export default { }), methods: { showMainPage() { - this.$router.push('/', () => {}); + if (this.$router.currentRoute.path === '/') { + this.$store.dispatch('changeBreadcrumb', 'ROOT'); + } else { + this.$router.push('/', () => {}); + } }, genericSearch() { this.$router.push({ path: '/search', query: { q: this.input.genericSearch.filter } }, () => {}); diff --git a/gms-ui/src/store.js b/gms-ui/src/store.js index 9d8ffa8..2f5ce00 100644 --- a/gms-ui/src/store.js +++ b/gms-ui/src/store.js @@ -148,6 +148,18 @@ export default new Vuex.Store({ break; } }, + changeBreadcrumb({ state, commit, dispatch }, groupId) { + state.input.selectedGroupId = groupId; + state.input.searchFilter = null; + if (state.input.tabIndex === 0) { + client.fetchGroupsTab(state.input) + .then(model => { + commit('updateGroups', model); + }); + } else { + dispatch('changeTab', 0); + } + }, updateCurrentGroup({ dispatch, state }, data) { state.model.breadcrumbs[state.model.breadcrumbs.length - 1].groupName = data.newGroupName; state.model.leaf = data.leaf; -- GitLab