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

get linked_features to display in feature_detaid

parent 38608143
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,20 @@ const featureAPI = {
return null;
}
},
async getFeatureLinks(featureId) {
const response = await axios.get(
`${baseUrl}features/${featureId}/feature-links/`
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
},
}
export default featureAPI;
......@@ -15,7 +15,8 @@ const feature = {
linkedFormset: [],
features: [],
form: null,
extra_form: []
extra_form: [],
linked_features: [],
},
mutations: {
SET_FEATURES(state, features) {
......@@ -56,6 +57,9 @@ const feature = {
REMOVE_LINKED_FORM(state, payload) {
state.linkedFormset = state.linkedFormset.filter(form => form.dataKey !== payload);
},
SET_LINKED_FEATURES(state, payload) {
state.linked_features = payload;
},
},
getters: {
},
......@@ -111,8 +115,8 @@ const feature = {
.catch((error) => {
throw error;
});
} else {
axios
} else {
axios
.post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}features/`, geojson)
.then((response) => {
if (response.status === 201 && response.data) {
......@@ -153,7 +157,13 @@ const feature = {
throw error;
});
}
}
},
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
//DELETE_FEATURE({ state }, feature_slug) {
//console.log("Deleting feature:", feature_slug, state)
......
......@@ -138,8 +138,6 @@
</tbody>
</table>
<!-- <small>{% for link in linked_features %} {% endfor %}</small> // ? EMPTY ?!??? -->
<h3>Liaison entre signalements</h3>
<table class="ui very basic table">
<tbody>
......@@ -153,8 +151,8 @@
:to="{
name: 'details-signalement',
params: {
slug_type_signal: link.feature_to.feature_type.slug,
slug_signal: link.feature_to.title,
slug_type_signal: link.feature_to.feature_type_slug,
slug_signal: link.feature_to.feature_id,
},
}"
>{{ link.feature_to.title }}</router-link
......@@ -391,21 +389,7 @@ export default {
data() {
return {
isCanceling: false,
mock_linked_features: [
/* {
relation_type: "Doublon",
feature_to: {
title: "Éolienne offshore",
creator: "Mr Dupont",
created_on: new Date().toDateString(),
feature_type: {
title: "Éolienne",
},
},
}, */
],
attachments: [],
// TODO : Récupérer events depuis l'api
events: [],
comment_form: {
attachment_file: {
......@@ -432,6 +416,7 @@ export default {
computed: {
...mapState(["user"]),
...mapState("feature", ["linked_features"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
......@@ -443,12 +428,6 @@ export default {
) || []
);
},
linked_features: function () {
// todo: vérifier avec données réels si ça fonctionne correctement
//return this.mock_linked_features.filter((el) => el.feature_to);
return [];
},
},
methods: {
......@@ -559,6 +538,20 @@ export default {
throw error;
});
},
getFeatureAttachments() {
featureAPI
.getFeatureAttachments(this.$route.params.slug_signal)
.then((data) => (this.attachments = data));
},
getLinkedFeatures() {
featureAPI
.getFeatureLinks(this.$route.params.slug_signal)
.then((data) =>
this.$store.commit("feature/SET_LINKED_FEATURES", data)
);
},
},
created() {
......@@ -569,9 +562,9 @@ export default {
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
this.$route.params.slug_type_signal
);
featureAPI
.getFeatureAttachments(this.$route.params.slug_signal)
.then((data) => (this.attachments = data));
this.getFeatureAttachments();
this.getLinkedFeatures();
},
mounted() {
......
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