From f2eee78a91b36bf629f2041457bcbbda0b1248df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Wed, 22 Sep 2021 11:38:24 +0200 Subject: [PATCH] adapt link on attachment thumbnail --- .../feature/FeatureAttachmentForm.vue | 8 +++----- src/views/feature/Feature_detail.vue | 18 +++++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/feature/FeatureAttachmentForm.vue b/src/components/feature/FeatureAttachmentForm.vue index 898bb52d..f49247a6 100644 --- a/src/components/feature/FeatureAttachmentForm.vue +++ b/src/components/feature/FeatureAttachmentForm.vue @@ -118,7 +118,7 @@ export default { if (el && this.form[el]) { this.form[el].value = el === "attachment_file" - ? attachmentForm[el].split("/").pop() //* keep only the file name + ? attachmentForm[el].split("/").pop() //* keep only the file name, not the path : attachmentForm[el]; } } @@ -140,12 +140,10 @@ export default { }, onFileChange(e) { const files = e.target.files || e.dataTransfer.files; - console.log(e, files); if (!files.length) return; - this.fileToImport = files[0]; - this.form.attachment_file.value = files[0].name; + this.fileToImport = files[0]; //* store file to import + this.form.attachment_file.value = files[0].name; //* add name to the form for display, in order to match format return from API this.updateStore(); - //this.$store.commit("feature_type/SET_FILE_TO_IMPORT", this.fileToImport); }, }, diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index 246bebf5..37883fdb 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -181,17 +181,21 @@ <a class="ui tiny image" target="_blank" - :href="pj.attachment_file.url" + :href="DJANGO_BASE_URL + pj.attachment_file" > - <!-- // ? que faire avec un pdf ? --> - <img v-if="pj.extension === '.pdf'" src="@/assets/img/pdf.png" /> - <img v-else :src="DJANGO_BASE_URL + pj.attachment_file" /> + <img + :src=" + pj.extension === '.pdf' + ? require('@/assets/img/pdf.png') + : DJANGO_BASE_URL + pj.attachment_file + " + /> </a> <div class="middle aligned content"> <a class="header" target="_blank" - :href="DJANGO_BASE_URL + pj.attachment_file.url" + :href="DJANGO_BASE_URL + pj.attachment_file" >{{ pj.title }}</a > <div class="description"> @@ -271,10 +275,6 @@ method="POST" enctype="multipart/form-data" > - <!-- action="{% url 'geocontrib:add_comment' slug=feature.project.slug feature_type_slug=feature.feature_type.slug feature_id=feature.feature_id%}" --> - <!-- {% for hidden in comment_form.hidden_fields %} - {{ hidden }} - {% endfor %} --> <div v-if="comment_form.non_field_errors" class="alert alert-danger" -- GitLab