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

display attachments in feature_detail

parent 5f7b96c3
No related branches found
No related tags found
No related merge requests found
import axios from 'axios';
import store from '../store'
const baseUrl = store.state.configuration.VUE_APP_DJANGO_API_BASE;
const featureAPI = {
async getFeatureAttachments(featureId) {
const response = await axios.get(
`${baseUrl}features/${featureId}/attachments/`
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
},
/* async subscribeProject({ projectSlug, suscribe }) {
const response = await axios.put(
`${baseUrl}projects/${projectSlug}/subscription/`,
{ is_suscriber: suscribe }
);
if (
response.status === 200 &&
response.data
) {
return response.data;
} else {
return null;
}
}, */
}
export default featureAPI;
...@@ -183,18 +183,15 @@ ...@@ -183,18 +183,15 @@
target="_blank" target="_blank"
:href="pj.attachment_file.url" :href="pj.attachment_file.url"
> >
<img <!-- // ? que faire avec un pdf ? -->
v-if="pj.extension === '.pdf'" <img v-if="pj.extension === '.pdf'" src="@/assets/img/pdf.png" />
src="{% static 'geocontrib/img/pdf.png' %}" <img v-else :src="DJANGO_BASE_URL + pj.attachment_file" />
/>
<!-- // ? que faire ? -->
<img v-else :src="pj.attachment_file.url" />
</a> </a>
<div class="middle aligned content"> <div class="middle aligned content">
<a <a
class="header" class="header"
target="_blank" target="_blank"
:href="pj.attachment_file.url" :href="DJANGO_BASE_URL + pj.attachment_file.url"
>{{ pj.title }}</a >{{ pj.title }}</a
> >
<div class="description"> <div class="description">
...@@ -382,6 +379,7 @@ ...@@ -382,6 +379,7 @@
import frag from "vue-frag"; import frag from "vue-frag";
import { mapState } from "vuex"; import { mapState } from "vuex";
import { mapUtil } from "@/assets/js/map-util.js"; import { mapUtil } from "@/assets/js/map-util.js";
import featureAPI from "@/services/feature-api";
const axios = require("axios"); const axios = require("axios");
export default { export default {
...@@ -407,18 +405,8 @@ export default { ...@@ -407,18 +405,8 @@ export default {
}, },
}, */ }, */
], ],
attachments: [ attachments: [],
// TODO : Récupérer depuis l'api // TODO : Récupérer events depuis l'api
/* {
attachment_file: {
url: "http://localhost:8000/media/user_1/albinoscom.jpg",
},
extension: "jpg",
title: "albinos",
info: "Drôle de bête",
}, */
],
// TODO : Récupérer depuis l'api
events: [], events: [],
comment_form: { comment_form: {
attachment_file: { attachment_file: {
...@@ -444,6 +432,9 @@ export default { ...@@ -444,6 +432,9 @@ export default {
computed: { computed: {
...mapState(["user"]), ...mapState(["user"]),
DJANGO_BASE_URL: function () {
return this.$store.state.configuration.VUE_APP_DJANGO_BASE;
},
feature: function () { feature: function () {
return ( return (
this.$store.state.feature.features.find( this.$store.state.feature.features.find(
...@@ -564,6 +555,9 @@ export default { ...@@ -564,6 +555,9 @@ export default {
"feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG",
this.$route.params.slug_type_signal this.$route.params.slug_type_signal
); );
featureAPI
.getFeatureAttachments(this.$route.params.slug_signal)
.then((data) => (this.attachments = data));
}, },
mounted() { 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