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) {
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 + '<br /><em>' + files[i].name + ' (' + files[i].size + ' Bytes)</em>',
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 + '<br /><em>' + file.name + ' (' + file.size + ' Bytes)</em>',
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 5000
});
}
});
}
}

View File

@ -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 + '<br /><em>' + files[i].name + ' (' + files[i].size + ' Bytes)</em>',
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 + '<br /><em>' + file.name + ' (' + file.size + ' Bytes)</em>',
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 5000
});
}
});
}
}