Skip to content
Snippets Groups Projects
Commit 2466bff4 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

remove project getter and project_slug var, fix feature_edit & basemaps

parent eec001ad
No related branches found
No related tags found
No related merge requests found
......@@ -183,7 +183,7 @@ const feature = {
dispatch(
'GET_PROJECT_FEATURE',
{
project_slug: rootState.project.project_slug,
project_slug: rootState.projects.project.slug,
feature_id: featureId
}
)
......@@ -220,7 +220,7 @@ const feature = {
title: state.form.title,
description: state.form.description.value,
status: state.form.status.value,
project: rootState.project_slug,
project: rootState.projects.project.slug,
feature_type: rootState.feature_type.current_feature_type_slug,
...extraFormObject
}
......@@ -232,7 +232,7 @@ const feature = {
if (routeName === 'editer-signalement') {
url += `${state.form.feature_id}/?
feature_type__slug=${rootState.feature_type.current_feature_type_slug}
&project__slug=${rootState.project_slug}`;
&project__slug=${rootState.projects.project.slug}`;
}
return axios({
......@@ -259,7 +259,7 @@ const feature = {
arraysOffline = JSON.parse(localStorageArray);
}
let updateMsg = {
project: rootState.project_slug,
project: rootState.projects.project.slug,
type: routeName === 'editer-signalement' ? 'put' : 'post',
featureId: state.form.feature_id,
geojson: geojson
......@@ -375,7 +375,7 @@ const feature = {
DELETE_FEATURE({ rootState }, feature_id) {
const url = `${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}/?` +
`feature_type__slug=${rootState.feature_type.current_feature_type_slug}` +
`&project__slug=${rootState.project_slug}`;
`&project__slug=${rootState.projects.project.slug}`;
return axios
.delete(url)
.then((response) => response)
......
......@@ -157,7 +157,7 @@ const map = {
async SAVE_BASEMAPS({ state, rootState, dispatch }, newBasemapIds) {
const DJANGO_API_BASE = this.state.configuration.VUE_APP_DJANGO_API_BASE;
function postOrPut(basemap) {
basemap['project'] = rootState.project_slug;
basemap['project'] = rootState.projects.project.slug;
if (newBasemapIds.includes(basemap.id)) {
return axios
.post(`${DJANGO_API_BASE}base-maps/`, basemap)
......
......@@ -23,7 +23,6 @@ const projects = {
},
getters: {
project: state => state.projects.find((project) => project.slug === state.project_slug), // todo : delete it
project_types: state => state.projects.filter(projet => projet.is_project_type),
project_user: state => state.projects.filter(projet => projet.creator === state.user.id),
},
......@@ -51,10 +50,6 @@ const projects = {
state.project = project;
},
SET_PROJECT_SLUG(state, slug) { // todo : delete it
state.project_slug = slug;
},
SET_PROJECTS_FILTER(state, payload) {
state.filters[payload.filter] = payload.value;
},
......@@ -110,14 +105,12 @@ const projects = {
commit('SET_PROJECT', project);
},
async GET_PROJECT_INFO({ state, commit, dispatch }, slug) {
commit('SET_PROJECT_SLUG', slug);
async GET_PROJECT_INFO({ rootState, dispatch }, slug) {
let promises = [
dispatch('GET_PROJECT_LAST_MESSAGES', slug).then(response => response),
dispatch('feature_type/GET_PROJECT_FEATURE_TYPES', slug, { root: true }).then(response => response),
// dispatch("feature/GET_PROJECT_FEATURES", slug).then(response => response),
];
if (state.user) promises.push(dispatch('map/GET_BASEMAPS', slug).then(response => response));
if (rootState.user) promises.push(dispatch('map/GET_BASEMAPS', slug, { root: true }).then(response => response));
const promiseResult = await Promise.all(promises);
return promiseResult;
......
......@@ -649,7 +649,7 @@ export default {
this.$router.push({
name: 'project_detail',
params: {
slug: this.$store.state.project_slug,
slug: this.$route.params.slug,
message,
},
});
......
......@@ -370,9 +370,10 @@ export default {
},
computed: {
...mapGetters(['project', 'permissions']),
...mapGetters(['permissions']),
...mapGetters('feature_type', ['feature_type']),
...mapState(['user', 'USER_LEVEL_PROJECTS']),
...mapState('projects', ['project']),
...mapState('map', ['basemaps']),
...mapState('feature', [
'attachmentFormset',
......@@ -486,7 +487,8 @@ export default {
mounted() {
let promises = [
this.$store.dispatch('GET_PROJECT_INFO', this.$route.params.slug),
this.$store.dispatch('projects/GET_PROJECT_INFO', this.$route.params.slug),
this.$store.dispatch('projects/GET_PROJECT', this.$route.params.slug),
];
if (this.$route.params.slug_signal) {
promises.push(
......
......@@ -533,7 +533,7 @@ export default {
.then(() => {
if (!this.modalAllDeleteOpen) {
this.GET_PROJECT_FEATURES({
project_slug: this.project.slug,
project_slug: this.$route.params.slug,
})
.then(() => {
this.fetchPagedFeatures();
......
......@@ -272,7 +272,7 @@ export default {
this.$router.push({
name: 'project_detail',
params: {
slug: this.$store.state.project_slug,
slug: this.$route.params.slug,
},
});
}, 1500);
......
......@@ -128,7 +128,7 @@
<script>
import axios from '@/axios-client.js';
import frag from 'vue-frag';
import { mapGetters } from 'vuex';
import { mapState } from 'vuex';
import Dropdown from '@/components/Dropdown.vue';
export default {
......@@ -170,7 +170,7 @@ export default {
},
computed: {
...mapGetters(['project']),
...mapState('projects', ['project']),
userOptions: function () {
return this.projectUsers
......@@ -226,6 +226,7 @@ export default {
created() {
if (!this.project) {
this.$store.dispatch('GET_PROJECT', this.$route.params.slug);
this.$store.dispatch('GET_PROJECT_INFO', this.$route.params.slug);
}
this.populateMembers();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment