From: Sven Schöling Date: Fri, 14 May 2021 16:37:34 +0000 (+0200) Subject: ImageUpload: modal undismissable + cancel X-Git-Tag: kivitendo-mebil_0.1-0~9^2~70 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b2b8017f6c6d4780cdfc1a7fcf4661b3dadf4e18;p=kivitendo-erp.git ImageUpload: modal undismissable + cancel --- diff --git a/js/kivi.ImageUpload.js b/js/kivi.ImageUpload.js index 5d22a0a3f..e655b54fb 100644 --- a/js/kivi.ImageUpload.js +++ b/js/kivi.ImageUpload.js @@ -5,6 +5,7 @@ namespace("kivi.ImageUpload", function(ns) { const M = kivi.Materialize; let num_images = 0; + ns.upload_in_progress = undefined; ns.add_files = function(target) { let files = []; @@ -67,6 +68,7 @@ namespace("kivi.ImageUpload", function(ns) { }; ns.upload_selected_files = function(id, type, maxsize) { + $("#upload_modal").modal({ dismissible: false }); $("#upload_modal").modal("open"); kivi.FileDB.retrieve_all((myfiles) => { @@ -91,33 +93,38 @@ namespace("kivi.ImageUpload", function(ns) { let xhr = new XMLHttpRequest; xhr.open('POST', 'controller.pl', true); - xhr.onload = ns.attSuccess; - xhr.upload.onprogress = ns.attProgress; - xhr.upload.onerror = ns.attFailed; - xhr.upload.onabort = ns.attCanceled; + xhr.onload = ns.upload_complete; + xhr.upload.onprogress = ns.progress; + xhr.upload.onerror = ns.failed; + xhr.upload.onabort = ns.abort; xhr.send(data); + + ns.upload_in_progress = xhr; }); }); }; - ns.attProgress = function(event) { + ns.progress = function(event) { if (event.lengthComputable) { var percent_complete = (event.loaded / event.total) * 100; + console.log(percent_complete); $("#upload_progress div").removeClass("indeterminate").addClass("determinate").attr("style", "width: " + percent_complete + "%"); } }; - ns.attFailed = function() { + ns.failed = function() { $('#upload_modal').modal('close'); M.flash(kivi.t8("An error occurred while transferring the file.")); }; - ns.attCanceled = function() { + ns.abort = function() { $('#upload_modal').modal('close'); M.flash(kivi.t8("The transfer has been canceled by the user.")); + + ns.upload_in_progress = undefined; }; - ns.attSuccess = function() { + ns.upload_complete = function() { $('#upload_modal').modal('close'); M.flash(kivi.t8("Files have been uploaded successfully.")); kivi.FileDB.delete_all(ns.reload_images); diff --git a/templates/mobile_webpages/image_upload/local_list.html b/templates/mobile_webpages/image_upload/local_list.html index bc3af8029..9aad15df4 100644 --- a/templates/mobile_webpages/image_upload/local_list.html +++ b/templates/mobile_webpages/image_upload/local_list.html @@ -54,11 +54,13 @@