From 9beefdba365bee90297c0b7bf325b1c2ab04a0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e?= <tpoussard@neogeo.fr> Date: Fri, 8 Jul 2022 19:04:15 +0200 Subject: [PATCH] disable redirect to feature details when editing in feature details, fix anchor at scroll under header & remove dead code --- src/App.vue | 1 + src/store/index.js | 4 ++-- src/store/modules/feature.store.js | 14 ++++++++++++-- src/store/modules/projects.store.js | 14 -------------- src/views/Project/ProjectEdit.vue | 6 +----- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5c941e33..b45820b6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,6 +3,7 @@ <AppHeader /> <div id="app-content"> + <span id="scroll-top-anchor" /> <div :class="{ active: loader.isLoading }" class="ui inverted dimmer" diff --git a/src/store/index.js b/src/store/index.js index 6def4d63..f5ed15a2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -76,8 +76,8 @@ export default new Vuex.Store({ }, DISPLAY_MESSAGE(state, message) { state.messages = [message, ...state.messages]; - if (document.getElementById('app-content')) { - document.getElementById('app-content').scrollIntoView({ block: 'start', inline: 'nearest' }); + if (document.getElementById('scroll-top-anchor')) { + document.getElementById('scroll-top-anchor').scrollIntoView({ block: 'start', inline: 'nearest' }); } setTimeout(() => { state.messages = []; diff --git a/src/store/modules/feature.store.js b/src/store/modules/feature.store.js index 743d9e8c..450290f9 100644 --- a/src/store/modules/feature.store.js +++ b/src/store/modules/feature.store.js @@ -176,8 +176,19 @@ const feature = { }); }, - SEND_FEATURE({ state, rootState, dispatch }, routeName) { + SEND_FEATURE({ state, rootState, commit, dispatch }, routeName) { function redirect(featureId) { + commit( + 'DISPLAY_MESSAGE', + { + comment: routeName === 'ajouter-signalement' ? + 'Le signalement a été crée' : + 'Le signalement a été mis à jour', + level: 'positive' + }, + { root: true }, + ); + if (routeName.includes('details-signalement')) return; dispatch( 'GET_PROJECT_FEATURE', { @@ -194,7 +205,6 @@ const feature = { message: routeName === 'ajouter-signalement' ? 'Le signalement a été crée' : 'Le signalement a été mis à jour' }, }); - dispatch('projects/GET_ALL_PROJECTS', null, { root:true }); //* & refresh project list }); } diff --git a/src/store/modules/projects.store.js b/src/store/modules/projects.store.js index 14266f6d..cfb9b6c3 100644 --- a/src/store/modules/projects.store.js +++ b/src/store/modules/projects.store.js @@ -66,20 +66,6 @@ const projectsStore = { }, actions: { - async GET_ALL_PROJECTS({ rootState, commit }) { - console.trace('GET_ALL_PROJECTS'); - try { - const response = await axios - .get(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}projects/`); - if (response.status === 200 && response.data) { - commit('SET_PROJECTS', response.data); - } - } catch (error) { - console.error(error); - throw error; - } - }, - async GET_PROJECTS({ state, rootState, commit }, payload) { let { page, myaccount, projectSlug } = payload || {}; if (!page) { diff --git a/src/views/Project/ProjectEdit.vue b/src/views/Project/ProjectEdit.vue index 72611502..9a6de251 100644 --- a/src/views/Project/ProjectEdit.vue +++ b/src/views/Project/ProjectEdit.vue @@ -229,7 +229,7 @@ import axios from '@/axios-client.js'; import Dropdown from '@/components/Dropdown.vue'; -import { mapState, mapActions } from 'vuex'; +import { mapState } from 'vuex'; export default { name: 'ProjectEdit', @@ -352,9 +352,6 @@ export default { }, methods: { - ...mapActions('projects', [ - 'GET_ALL_PROJECTS' - ]), definePageType() { if (this.$router.history.current.name === 'project_create') { this.action = 'create'; @@ -445,7 +442,6 @@ export default { Promise.all([ this.$store.dispatch('GET_USER_LEVEL_PROJECTS'), //* refresh projects user levels this.$store.dispatch('GET_USER_LEVEL_PERMISSIONS'), //* refresh projects permissions - this.GET_ALL_PROJECTS(), //* & refresh project list ]).then(() => // * go back to project list this.$router.push({ -- GitLab