From 4e6bc1027314b8598c651c22a2505a8f6d88c26b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 5 Sep 2023 19:27:15 +0200 Subject: [PATCH] fix drag&drop when adding new attachment --- views/bootstrap/styles/application.js | 47 ++++++++++++++------------ views/bootstrap4/styles/application.js | 47 ++++++++++++++------------ 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/views/bootstrap/styles/application.js b/views/bootstrap/styles/application.js index 4ffab8463..349ecdf50 100644 --- a/views/bootstrap/styles/application.js +++ b/views/bootstrap/styles/application.js @@ -913,28 +913,33 @@ function onAddClipboard(ev) { /* {{{ */ } */ } else if(target_type == 'attachment' && target_id) { - for (var i = 0; i < files.length; i++) { - if(files[i].size <= maxFileSize) { - var fd = new FormData(); - fd.append('targettype', target_type); - fd.append('documentid', target_id); - fd.append('formtoken', obj.data('uploadformtoken')); - fd.append('userfile', files[i]); - fd.append('command', 'addfile'); + for (var i = 0; i < items.length; i++) { + var item = items[i]; //.webkitGetAsEntry(); + if (item.isFile) { + item.file(function(file) { + if(file.size <= maxFileSize) { + var fd = new FormData(); + fd.append('targettype', target_type); + fd.append('documentid', target_id); + fd.append('formtoken', obj.data('uploadformtoken')); + fd.append('userfile', file); + fd.append('command', 'addfile'); - var status = new SeedDMSUpload.createStatusbar(statusbar); - status.setFileNameSize(files[i].name,files[i].size); - SeedDMSUpload.sendFileToServer(fd,status, function(){ - $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); - }); - } else { - noty({ - text: maxFileSizeMsg + '
' + files[i].name + ' (' + files[i].size + ' Bytes)', - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 5000 + var status = new SeedDMSUpload.createStatusbar(statusbar); + status.setFileNameSize(file.name,file.size); + SeedDMSUpload.sendFileToServer(fd,status, function(){ + $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); + }); + } else { + noty({ + text: maxFileSizeMsg + '
' + file.name + ' (' + file.size + ' Bytes)', + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 5000 + }); + } }); } } diff --git a/views/bootstrap4/styles/application.js b/views/bootstrap4/styles/application.js index a675b01a5..8b4d2c6fd 100644 --- a/views/bootstrap4/styles/application.js +++ b/views/bootstrap4/styles/application.js @@ -950,28 +950,33 @@ function onAddClipboard(ev) { /* {{{ */ } */ } else if(target_type == 'attachment' && target_id) { - for (var i = 0; i < files.length; i++) { - if(files[i].size <= maxFileSize) { - var fd = new FormData(); - fd.append('targettype', target_type); - fd.append('documentid', target_id); - fd.append('formtoken', obj.data('uploadformtoken')); - fd.append('userfile', files[i]); - fd.append('command', 'addfile'); + for (var i = 0; i < items.length; i++) { + var item = items[i]; //.webkitGetAsEntry(); + if (item.isFile) { + item.file(function(file) { + if(file.size <= maxFileSize) { + var fd = new FormData(); + fd.append('targettype', target_type); + fd.append('documentid', target_id); + fd.append('formtoken', obj.data('uploadformtoken')); + fd.append('userfile', file); + fd.append('command', 'addfile'); - var status = new SeedDMSUpload.createStatusbar(statusbar); - status.setFileNameSize(files[i].name,files[i].size); - SeedDMSUpload.sendFileToServer(fd,status, function(){ - $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); - }); - } else { - noty({ - text: maxFileSizeMsg + '
' + files[i].name + ' (' + files[i].size + ' Bytes)', - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 5000 + var status = new SeedDMSUpload.createStatusbar(statusbar); + status.setFileNameSize(file.name,file.size); + SeedDMSUpload.sendFileToServer(fd,status, function(){ + $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); + }); + } else { + noty({ + text: maxFileSizeMsg + '
' + file.name + ' (' + file.size + ' Bytes)', + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 5000 + }); + } }); } }