From 50253d4063e4727c636f3b82c46f7a707e433a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Fri, 24 Sep 2021 14:38:04 +0200 Subject: [PATCH] get events for currrent feature and adapt template --- src/services/feature-api.js | 14 +++++++++++ src/views/feature/Feature_detail.vue | 35 ++++++++++++---------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/services/feature-api.js b/src/services/feature-api.js index 988a0a3a..49e40e12 100644 --- a/src/services/feature-api.js +++ b/src/services/feature-api.js @@ -4,6 +4,20 @@ import store from '../store' const baseUrl = store.state.configuration.VUE_APP_DJANGO_API_BASE; const featureAPI = { + async getFeatureEvents(featureId) { + const response = await axios.get( + `${baseUrl}features/${featureId}/events/` + ); + if ( + response.status === 200 && + response.data + ) { + return response.data; + } else { + return null; + } + }, + async getFeatureAttachments(featureId) { const response = await axios.get( `${baseUrl}features/${featureId}/attachments/` diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index 8b2c516d..6b4b65a1 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -235,17 +235,15 @@ </div> <div class="extra text"> {{ event.related_comment.comment }} - <div v-frag v-if="event.related_comment.attachments"> - <div - v-frag - v-for="att in event.related_comment.attachments" - :key="att.title" + <div v-frag v-if="event.related_comment.attachment"> + <br /><a + :href=" + DJANGO_BASE_URL + event.related_comment.attachment.url + " + tarrget="_blank" + ><i class="paperclip fitted icon"></i> + {{ event.related_comment.attachment.title }}</a > - <br /><a :href="att.url" tarrget="_blank" - ><i class="paperclip fitted icon"></i> - {{ att.title }}</a - > - </div> </div> </div> </div> @@ -273,15 +271,6 @@ method="POST" enctype="multipart/form-data" > - <!-- <div - v-if="comment_form.non_field_errors" - class="alert alert-danger" - role="alert" - > - <span v-for="error in comment_form.non_field_errors" :key="error"> - {{ error }} - </span> - </div> --> <div class="required field"> <label :for="comment_form.comment.id_for_label" >Ajouter un commentaire</label @@ -539,6 +528,12 @@ export default { }); }, + getFeatureEvents() { + featureAPI + .getFeatureEvents(this.$route.params.slug_signal) + .then((data) => (this.events = data)); + }, + getFeatureAttachments() { featureAPI .getFeatureAttachments(this.$route.params.slug_signal) @@ -562,7 +557,7 @@ export default { "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.$route.params.slug_type_signal ); - + this.getFeatureEvents(); this.getFeatureAttachments(); this.getLinkedFeatures(); }, -- GitLab