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

Merge branch 'redmine-issues/11915' into 'develop'

REDMINE_ISSUE-11915

See merge request !106
parents eb50668f d8a2553f
No related branches found
No related tags found
No related merge requests found
......@@ -103,9 +103,12 @@ const feature = {
});
},
SEND_FEATURE({ state, rootState, dispatch }, routeName) {
SEND_FEATURE({ state, rootState, commit, dispatch }, routeName) {
commit("DISPLAY_LOADER", "Le signalement est en cours de création", { root: true })
const message = routeName === "editer-signalement" ? "Le signalement a été mis à jour" : "Le signalement a été crée";
function redirect(featureId) {
commit("DISCARD_LOADER", null, { root: true })
router.push({
name: "details-signalement",
params: {
......@@ -115,12 +118,14 @@ const feature = {
},
});
}
async function handleOtherForms(featureId) {
await dispatch("SEND_ATTACHMENTS", featureId)
await dispatch("PUT_LINKED_FEATURES", featureId)
redirect(featureId);
}
//* prepare feature data to send
let extraFormObject = {}; //* prepare an object to be flatten in properties of geojson
for (const field of state.extra_form) {
extraFormObject[field.name] = field.value;
......@@ -138,8 +143,9 @@ const feature = {
...extraFormObject
}
}
if (routeName === "editer-signalement") {
axios
return axios
.put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/?` +
`feature_type__slug=${rootState.feature_type.current_feature_type_slug}` +
`&project__slug=${rootState.project_slug}`
......@@ -154,10 +160,11 @@ const feature = {
}
})
.catch((error) => {
commit("DISCARD_LOADER", null, { root: true })
throw error;
});
} else {
axios
return axios
.post(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/`, geojson)
.then((response) => {
if (response.status === 201 && response.data) {
......@@ -169,6 +176,7 @@ const feature = {
}
})
.catch((error) => {
commit("DISCARD_LOADER", null, { root: true })
throw error;
});
}
......
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