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

Fix filename

parent a63a2457
Branches
Tags
2 merge requests!2132.3.2-rc1,!203REDMINE_ISSUE-12652
...@@ -369,7 +369,6 @@ export default { ...@@ -369,7 +369,6 @@ export default {
errors: null, errors: null,
title: "", title: "",
file: null, file: null,
type: "",
}, },
comment: { comment: {
id_for_label: "add-comment", id_for_label: "add-comment",
...@@ -478,9 +477,9 @@ export default { ...@@ -478,9 +477,9 @@ export default {
.postCommentAttachment({ .postCommentAttachment({
featureId: this.$route.params.slug_signal, featureId: this.$route.params.slug_signal,
file: this.comment_form.attachment_file.file, file: this.comment_form.attachment_file.file,
fileName: this.comment_form.attachment_file.title, fileName: this.comment_form.attachment_file.fileName,
commentId: response.data.id,
title: this.comment_form.attachment_file.title, title: this.comment_form.attachment_file.title,
commentId: response.data.id,
}) })
.then(() => { .then(() => {
this.confirmComment(); this.confirmComment();
...@@ -496,7 +495,8 @@ export default { ...@@ -496,7 +495,8 @@ export default {
this.$store.commit("DISPLAY_MESSAGE", "Ajout du commentaire confirmé"); this.$store.commit("DISPLAY_MESSAGE", "Ajout du commentaire confirmé");
this.getFeatureEvents(); //* display new comment on the page this.getFeatureEvents(); //* display new comment on the page
this.comment_form.attachment_file.file = null; this.comment_form.attachment_file.file = null;
this.comment_form.attachment_file.title = null; this.comment_form.attachment_file.fileName = "";
this.comment_form.attachment_file.title = "";
this.comment_form.comment.value = null; this.comment_form.comment.value = null;
}, },
...@@ -518,19 +518,19 @@ export default { ...@@ -518,19 +518,19 @@ export default {
// * read image file // * read image file
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
const _this = this; //* 'this' is different in onload function const handleFile = (isValid) => {
function handleFile(isValid) {
if (isValid) { if (isValid) {
const period = files[0].name.lastIndexOf("."); this.comment_form.attachment_file.file = files[0]; //* store the file to post afterwards
const fileName = files[0].name.substring(0, period); let title = files[0].name
const fileExtension = files[0].name.substring(period + 1); this.comment_form.attachment_file.fileName = title; //* name of the file
const shortName = fileName.slice(0, 10) + "[...]." + fileExtension; const fileExtension = title.substring(title.lastIndexOf(".") + 1);
_this.comment_form.attachment_file.file = files[0]; //* store the file to post later if ((title.length - fileExtension.length) > 11) {
_this.comment_form.attachment_file.type = fileExtension; //* for adding to fileName title = title.slice(0, 10) + "[...]." + fileExtension;
_this.comment_form.attachment_file.title = shortName; //* for display }
_this.comment_form.attachment_file.errors = null; this.comment_form.attachment_file.title = title; //* title for display
this.comment_form.attachment_file.errors = null;
} else { } else {
_this.comment_form.attachment_file.errors = this.comment_form.attachment_file.errors =
"Transférez une image valide. Le fichier que vous avez transféré n'est pas une image, ou il est corrompu."; "Transférez une image valide. Le fichier que vous avez transféré n'est pas une image, ou il est corrompu.";
} }
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment