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 { ...@@ -62,11 +62,19 @@ export default {
errors: null, errors: null,
id_for_label: "relation_type", id_for_label: "relation_type",
field: { 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", html_name: "relation_type",
label: "Type de liaison", label: "Type de liaison",
value: "Doublon", value: {
name: "Doublon",
value: "doublon",
},
}, },
feature_to: { feature_to: {
errors: null, errors: null,
...@@ -106,7 +114,7 @@ export default { ...@@ -106,7 +114,7 @@ export default {
selected_relation_type: { selected_relation_type: {
// getter // getter
get() { get() {
return this.form.relation_type.value; return this.form.relation_type.value.name;
}, },
// setter // setter
set(newValue) { set(newValue) {
...@@ -150,8 +158,10 @@ export default { ...@@ -150,8 +158,10 @@ export default {
updateStore() { updateStore() {
this.$store.commit("feature/UPDATE_LINKED_FORM", { this.$store.commit("feature/UPDATE_LINKED_FORM", {
dataKey: this.linkedForm.dataKey, dataKey: this.linkedForm.dataKey,
relation_type: this.form.relation_type.value, relation_type: this.form.relation_type.value.value,
feature_to: this.form.feature_to.value.value, feature_to: {
feature_id: this.form.feature_to.value.value,
},
}); });
}, },
......
...@@ -106,6 +106,8 @@ const feature = { ...@@ -106,6 +106,8 @@ const feature = {
.put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/`, geojson) .put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/`, geojson)
.then((response) => { .then((response) => {
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
dispatch("SEND_ATTACHMENTS", response.data.id)
dispatch("PUT_LINKED_FEATURES", response.data.id)
router.push({ router.push({
name: "details-signalement", name: "details-signalement",
params: { params: {
...@@ -119,12 +121,13 @@ const feature = { ...@@ -119,12 +121,13 @@ const feature = {
.catch((error) => { .catch((error) => {
throw error; throw error;
}); });
} else { } else {
axios 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) {
dispatch("SEND_ATTACHMENTS", response.data.id) dispatch("SEND_ATTACHMENTS", response.data.id)
dispatch("PUT_LINKED_FEATURES", response.data.id)
router.push({ router.push({
name: "details-signalement", name: "details-signalement",
params: { params: {
...@@ -143,6 +146,7 @@ const feature = { ...@@ -143,6 +146,7 @@ const feature = {
SEND_ATTACHMENTS({ state, rootState }, featureId) { SEND_ATTACHMENTS({ state, rootState }, featureId) {
for (let attacht of state.attachmentFormset) { 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(); let formdata = new FormData();
formdata.append("file", attacht.fileToImport, attacht.fileToImport.name); formdata.append("file", attacht.fileToImport, attacht.fileToImport.name);
const data = { const data = {
...@@ -164,6 +168,20 @@ const feature = { ...@@ -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) { /* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI featureAPI
.getlinked_features(featureId) .getlinked_features(featureId)
......
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
}" }"
>{{ link.feature_to.title }}</router-link >{{ link.feature_to.title }}</router-link
> >
({{ link.feature_to.creator }} - ({{ link.feature_to.display_creator }} -
{{ link.feature_to.created_on }}) {{ link.feature_to.created_on }})
</td> </td>
</tr> </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