fix drag&drop when adding new attachment

This commit is contained in:
Uwe Steinmann 2023-09-05 19:27:15 +02:00
parent 6c36dff064
commit 4e6bc10273
2 changed files with 52 additions and 42 deletions

View File

@ -913,28 +913,33 @@ function onAddClipboard(ev) { /* {{{ */
} }
*/ */
} else if(target_type == 'attachment' && target_id) { } else if(target_type == 'attachment' && target_id) {
for (var i = 0; i < files.length; i++) { for (var i = 0; i < items.length; i++) {
if(files[i].size <= maxFileSize) { var item = items[i]; //.webkitGetAsEntry();
var fd = new FormData(); if (item.isFile) {
fd.append('targettype', target_type); item.file(function(file) {
fd.append('documentid', target_id); if(file.size <= maxFileSize) {
fd.append('formtoken', obj.data('uploadformtoken')); var fd = new FormData();
fd.append('userfile', files[i]); fd.append('targettype', target_type);
fd.append('command', 'addfile'); 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); var status = new SeedDMSUpload.createStatusbar(statusbar);
status.setFileNameSize(files[i].name,files[i].size); status.setFileNameSize(file.name,file.size);
SeedDMSUpload.sendFileToServer(fd,status, function(){ SeedDMSUpload.sendFileToServer(fd,status, function(){
$("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id});
}); });
} else { } else {
noty({ noty({
text: maxFileSizeMsg + '<br /><em>' + files[i].name + ' (' + files[i].size + ' Bytes)</em>', text: maxFileSizeMsg + '<br /><em>' + file.name + ' (' + file.size + ' Bytes)</em>',
type: 'error', type: 'error',
dismissQueue: true, dismissQueue: true,
layout: 'topRight', layout: 'topRight',
theme: 'defaultTheme', theme: 'defaultTheme',
timeout: 5000 timeout: 5000
});
}
}); });
} }
} }

View File

@ -950,28 +950,33 @@ function onAddClipboard(ev) { /* {{{ */
} }
*/ */
} else if(target_type == 'attachment' && target_id) { } else if(target_type == 'attachment' && target_id) {
for (var i = 0; i < files.length; i++) { for (var i = 0; i < items.length; i++) {
if(files[i].size <= maxFileSize) { var item = items[i]; //.webkitGetAsEntry();
var fd = new FormData(); if (item.isFile) {
fd.append('targettype', target_type); item.file(function(file) {
fd.append('documentid', target_id); if(file.size <= maxFileSize) {
fd.append('formtoken', obj.data('uploadformtoken')); var fd = new FormData();
fd.append('userfile', files[i]); fd.append('targettype', target_type);
fd.append('command', 'addfile'); 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); var status = new SeedDMSUpload.createStatusbar(statusbar);
status.setFileNameSize(files[i].name,files[i].size); status.setFileNameSize(file.name,file.size);
SeedDMSUpload.sendFileToServer(fd,status, function(){ SeedDMSUpload.sendFileToServer(fd,status, function(){
$("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id}); $("div.ajax[data-action='documentFiles']").trigger('update', {documentid: target_id});
}); });
} else { } else {
noty({ noty({
text: maxFileSizeMsg + '<br /><em>' + files[i].name + ' (' + files[i].size + ' Bytes)</em>', text: maxFileSizeMsg + '<br /><em>' + file.name + ' (' + file.size + ' Bytes)</em>',
type: 'error', type: 'error',
dismissQueue: true, dismissQueue: true,
layout: 'topRight', layout: 'topRight',
theme: 'defaultTheme', theme: 'defaultTheme',
timeout: 5000 timeout: 5000
});
}
}); });
} }
} }