Skip to content
Snippets Groups Projects
Commit 3ed063db authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'ticket/11729' into 'develop'

fix list fond carto

See merge request !31
parents 45f48f60 4d676c64
No related branches found
No related tags found
No related merge requests found
...@@ -153,43 +153,59 @@ const map = { ...@@ -153,43 +153,59 @@ const map = {
SAVE_BASEMAPS({ state, rootState, dispatch }, newBasemapIds) { SAVE_BASEMAPS({ state, rootState, dispatch }, newBasemapIds) {
for (let basemap of state.basemaps) { return new Promise((resolve, reject) => {
basemap["project"] = rootState.project_slug for (let basemap of state.basemaps) {
// TODO: différencier PUT & POST basemap["project"] = rootState.project_slug
console.log(newBasemapIds.includes(basemap.id), newBasemapIds, basemap.id); // TODO: différencier PUT & POST
if (newBasemapIds.includes(basemap.id)) { if (newBasemapIds.includes(basemap.id)) {
axios axios
.post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/`, basemap) .post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/`, basemap)
.then((response) => (console.log(response.data))) .then((response) => {
.catch((error) => { resolve(response);
throw error; })
}); .catch((error) => {
} else { reject(error);
axios throw error;
.put(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/${basemap.id}/`, basemap) });
.then((response) => (console.log(response.data))) } else {
.catch((error) => { axios
throw error; .put(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/${basemap.id}/`, basemap)
}); .then((response) => {
resolve(response);
})
.catch((error) => {
reject(error);
throw error;
});
}
} }
} //* delete in the backend the basemaps that was rewoved from the front
//* delete in the backend the basemaps that was rewoved from the front for (let basemapId of state.basemapsToDelete) {
for (let basemapId of state.basemapsToDelete) { dispatch("DELETE_BASEMAP", basemapId)
dispatch("DELETE_BASEMAP", basemapId); .then((response) =>{
} resolve(response);
});
}
state.basemapsToDelete = []
});
}, },
DELETE_BASEMAP({ commit }, basemapId) { DELETE_BASEMAP({ commit }, basemapId) {
axios return new Promise((resolve, reject) => {
.delete(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/`, basemapId) let url = `${this.state.configuration.VUE_APP_DJANGO_API_BASE}base-maps/` + basemapId
axios
.delete(url)
.then((response) => { .then((response) => {
if (response && response.status === 200) { if (response && response.status === 200) {
commit("REMOVE_BASEMAP_ID_TO_DELETE", basemapId) commit("REMOVE_BASEMAP_ID_TO_DELETE", basemapId)
} }
resolve(response);
}) })
.catch((error) => { .catch((error) => {
reject(error);
throw error; throw error;
}); });
});
} }
}, },
} }
......
...@@ -70,7 +70,11 @@ export default { ...@@ -70,7 +70,11 @@ export default {
saveChanges() { saveChanges() {
// ToDo : check if values are filled // ToDo : check if values are filled
this.$store.dispatch("map/SAVE_BASEMAPS", this.newBasemapIds); this.$store.dispatch("map/SAVE_BASEMAPS", this.newBasemapIds)
.then((res) => {
console.log('res', res)
});
this.newBasemapIds = [];
}, },
}, },
......
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