Skip to content
Snippets Groups Projects

fix list fond carto

Merged Leandro Almada requested to merge ticket/11729 into develop
2 files
+ 46
26
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 41
25
@@ -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;
});
});
 
});
}
}
},
},
}
}
Loading