Skip to content
Snippets Groups Projects
Commit 4d676c64 authored by leandro's avatar leandro
Browse files

fix list fond carto

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