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'

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