Compare commits

..

1 Commits

Author SHA1 Message Date
afc5229f5b fix referencii 2025-10-16 02:11:15 +02:00

View File

@ -102,7 +102,7 @@
<div class="form-group"> <div class="form-group">
<label for="description">Nový komentár:</label> <label for="description">Nový komentár:</label>
<textarea <textarea
ref="attachmentNewContent" v-model="attachmentNewContent"
rows="5" rows="5"
class="form-control" class="form-control"
placeholder="Nove zistenia alebo riesenia" placeholder="Nove zistenia alebo riesenia"
@ -175,9 +175,10 @@ const attachments = ref([
created_dt: "--", created_dt: "--",
}, },
]); ]);
const attachmentNewContent = ref(null);
const attachmentNewFiles = ref(null); const attachmentNewFiles = ref(null);
let selectedFiles = []; const selectedFiles = ref([]);
let selectedFilesContent = []; const selectedFilesContent = ref([]);
onMounted(() => { onMounted(() => {
// console.log(report_id); // console.log(report_id);
@ -208,7 +209,7 @@ function onDescriptionChange(event) {
function reportDelete() { function reportDelete() {
if (!confirm("Naozaj chcete report zmazať?")) return; if (!confirm("Naozaj chcete report zmazať?")) return;
loading = true; loading.value = true;
backend.delete(report_id).then(() => { backend.delete(report_id).then(() => {
router.push("/"); router.push("/");
}); });
@ -228,9 +229,9 @@ function reportDone() {
} }
function attachmentAdd() { function attachmentAdd() {
let comment = $refs.attachmentNewContent.value; let comment = attachmentNewContent.value;
if (comment.trim().length > 0) { if (comment.trim().length > 0) {
loading = true; loading.value = true;
backend backend
.attachmentAdd( .attachmentAdd(
report_id, report_id,
@ -238,28 +239,28 @@ function attachmentAdd() {
attachmentNewContent.value attachmentNewContent.value
) )
.then(() => { .then(() => {
$refs.attachmentNewContent.value = ""; attachmentNewContent.value = "";
loadReportData(); loadReportData();
loading = false; loading.value = false;
}); });
} }
if (selectedFiles.length > 0) { if (selectedFiles.value.length > 0) {
let for_upload = selectedFiles.length; let for_upload = selectedFiles.value.length;
loading = true; loading.value = true;
for (let i = 0; i < selectedFiles.length; i++) { for (let i = 0; i < selectedFiles.value.length; i++) {
backend backend
.attachmentAdd(report_id, "file", { .attachmentAdd(report_id, "file", {
'filename': selectedFiles[i].name, 'filename': selectedFiles.value[i].name,
'base64': selectedFilesContent[i] 'base64': selectedFilesContent.value[i]
}) })
.then(() => { .then(() => {
for_upload--; for_upload--;
if (for_upload == 0) { if (for_upload == 0) {
selectedFiles = []; selectedFiles.value = [];
selectedFilesContent = []; selectedFilesContent.value = [];
attachmentNewFiles.value = null; attachmentNewFiles.value = null;
loadReportData(); loadReportData();
loading = false; loading.value = false;
} }
}); });
} }
@ -268,20 +269,20 @@ function attachmentAdd() {
function attachmentDelete(attachment) { function attachmentDelete(attachment) {
if (!confirm("Naozaj chcete zmazať prilohu?")) return; if (!confirm("Naozaj chcete zmazať prilohu?")) return;
loading = true; loading.value = true;
backend.attachmentDelete(attachment.attachment_id).then(() => { backend.attachmentDelete(attachment.attachment_id).then(() => {
loadReportData(); loadReportData();
loading = false; loading.value = false;
}); });
} }
function updateAttachmentContent(event, attachment) { function updateAttachmentContent(event, attachment) {
loading = true; loading.value = true;
backend backend
.attachmentUpdate(attachment.attachment_id, event.target.innerText) .attachmentUpdate(attachment.attachment_id, event.target.innerText)
.then(() => { .then(() => {
loadReportData(); loadReportData();
loading = false; loading.value = false;
}); });
} }
@ -289,10 +290,10 @@ function handleFileUpload(event) {
const files = event.target.files; const files = event.target.files;
if (files) { if (files) {
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
selectedFiles.push(files[i]); selectedFiles.value.push(files[i]);
const reader = new FileReader(); const reader = new FileReader();
reader.onload = () => { reader.onload = () => {
selectedFilesContent[i] = reader.result; selectedFilesContent.value[i] = reader.result;
}; };
reader.readAsDataURL(files[i]); reader.readAsDataURL(files[i]);
} }
@ -300,8 +301,8 @@ function handleFileUpload(event) {
} }
function removeFile(index) { function removeFile(index) {
selectedFiles.splice(index, 1); selectedFiles.value.splice(index, 1);
selectedFilesContent.splice(index, 1); selectedFilesContent.value.splice(index, 1);
} }
function formatFileSize(size) { function formatFileSize(size) {