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

Fix filename

parent a63a2457
No related branches found
No related tags found
2 merge requests!2132.3.2-rc1,!203REDMINE_ISSUE-12652
......@@ -369,7 +369,6 @@ export default {
errors: null,
title: "",
file: null,
type: "",
},
comment: {
id_for_label: "add-comment",
......@@ -478,9 +477,9 @@ export default {
.postCommentAttachment({
featureId: this.$route.params.slug_signal,
file: this.comment_form.attachment_file.file,
fileName: this.comment_form.attachment_file.title,
commentId: response.data.id,
fileName: this.comment_form.attachment_file.fileName,
title: this.comment_form.attachment_file.title,
commentId: response.data.id,
})
.then(() => {
this.confirmComment();
......@@ -496,7 +495,8 @@ export default {
this.$store.commit("DISPLAY_MESSAGE", "Ajout du commentaire confirmé");
this.getFeatureEvents(); //* display new comment on the page
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;
},
......@@ -518,19 +518,19 @@ export default {
// * read image file
const files = e.target.files || e.dataTransfer.files;
const _this = this; //* 'this' is different in onload function
function handleFile(isValid) {
const handleFile = (isValid) => {
if (isValid) {
const period = files[0].name.lastIndexOf(".");
const fileName = files[0].name.substring(0, period);
const fileExtension = files[0].name.substring(period + 1);
const shortName = fileName.slice(0, 10) + "[...]." + fileExtension;
_this.comment_form.attachment_file.file = files[0]; //* store the file to post later
_this.comment_form.attachment_file.type = fileExtension; //* for adding to fileName
_this.comment_form.attachment_file.title = shortName; //* for display
_this.comment_form.attachment_file.errors = null;
this.comment_form.attachment_file.file = files[0]; //* store the file to post afterwards
let title = files[0].name
this.comment_form.attachment_file.fileName = title; //* name of the file
const fileExtension = title.substring(title.lastIndexOf(".") + 1);
if ((title.length - fileExtension.length) > 11) {
title = title.slice(0, 10) + "[...]." + fileExtension;
}
this.comment_form.attachment_file.title = title; //* title for display
this.comment_form.attachment_file.errors = null;
} 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.";
}
}
......
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