Skip to content
Snippets Groups Projects
Merged Timothee P requested to merge redmine-issues/11915 into develop
1 file
+ 11
3
Compare changes
  • Side-by-side
  • Inline
@@ -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;
});
});
}
}
Loading