Skip to content
Snippets Groups Projects
Commit 1020232c authored by Timothee P's avatar Timothee P :sunflower:
Browse files

make choices objects or dropdown & add put linked_feature

parent c74ca189
No related branches found
No related tags found
1 merge request!43Evol/redmine ticket 11442 linked features
......@@ -62,11 +62,19 @@ export default {
errors: null,
id_for_label: "relation_type",
field: {
choices: ["Doublon", "Remplace", "Est remplacé par", "Dépend de"],
choices: [
{ name: "Doublon", value: "doublon" },
{ name: "Remplace", value: "remplace" },
{ name: "Est remplacé par", value: "est_remplace_par" },
{ name: "Dépend de", value: "depend_de" },
],
},
html_name: "relation_type",
label: "Type de liaison",
value: "Doublon",
value: {
name: "Doublon",
value: "doublon",
},
},
feature_to: {
errors: null,
......@@ -106,7 +114,7 @@ export default {
selected_relation_type: {
// getter
get() {
return this.form.relation_type.value;
return this.form.relation_type.value.name;
},
// setter
set(newValue) {
......@@ -150,8 +158,10 @@ export default {
updateStore() {
this.$store.commit("feature/UPDATE_LINKED_FORM", {
dataKey: this.linkedForm.dataKey,
relation_type: this.form.relation_type.value,
feature_to: this.form.feature_to.value.value,
relation_type: this.form.relation_type.value.value,
feature_to: {
feature_id: this.form.feature_to.value.value,
},
});
},
......
......@@ -106,6 +106,8 @@ const feature = {
.put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/`, geojson)
.then((response) => {
if (response.status === 200 && response.data) {
dispatch("SEND_ATTACHMENTS", response.data.id)
dispatch("PUT_LINKED_FEATURES", response.data.id)
router.push({
name: "details-signalement",
params: {
......@@ -119,12 +121,13 @@ const feature = {
.catch((error) => {
throw error;
});
} else {
axios
} else {
axios
.post(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/`, geojson)
.then((response) => {
if (response.status === 201 && response.data) {
dispatch("SEND_ATTACHMENTS", response.data.id)
dispatch("PUT_LINKED_FEATURES", response.data.id)
router.push({
name: "details-signalement",
params: {
......@@ -143,6 +146,7 @@ const feature = {
SEND_ATTACHMENTS({ state, rootState }, featureId) {
for (let attacht of state.attachmentFormset) {
if (!attacht.fileToImport) return; //* if no new file imported abort, until beeing able to do PUT
let formdata = new FormData();
formdata.append("file", attacht.fileToImport, attacht.fileToImport.name);
const data = {
......@@ -164,6 +168,20 @@ const feature = {
}
},
PUT_LINKED_FEATURES({ state, rootState }, featureId) {
axios
.put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${featureId}/feature-links/`, state.linkedFormset)
.then((response) => {
if (response.status === 200 && response.data) {
console.log(response, response.data)
return "La relation a bien été ajouté"
}
})
.catch((error) => {
throw error;
});
},
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
......
......@@ -155,7 +155,7 @@
}"
>{{ link.feature_to.title }}</router-link
>
({{ link.feature_to.creator }} -
({{ link.feature_to.display_creator }} -
{{ link.feature_to.created_on }})
</td>
</tr>
......
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