From 0c9f01f1758fafe3cd8dbe58cf7482df7b30d761 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 3 Nov 2017 10:33:00 +0000 Subject: [PATCH] Bug 19420: (Follow-up) Add errors on other pages Fix error array (add '0' value) Update errors on other places using upload.js Eventually these should all be using the same code in a js file upload.tt already dealt with these errors, but has diff code, made it work with new error syntax Signed-off-by: Marcel de Rooy Amended: Removed the added js comment in upload.tt Signed-off-by: Jonathan Druart --- .../prog/en/modules/offline_circ/process_koc.tt | 6 ++++-- .../prog/en/modules/tools/stage-marc-import.tt | 2 +- .../intranet-tmpl/prog/en/modules/tools/upload-images.tt | 6 ++++-- koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt index 26937d9894..d0ec7af06e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt @@ -34,7 +34,7 @@ function StartUpload() { xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload ); } -function cbUpload( status, fileid ) { +function cbUpload( status, fileid, errors ) { if( status=='done' ) { $("form#processfile #uploadedfileid").val( fileid ); $("form#enqueuefile #uploadedfileid").val( fileid ); @@ -42,10 +42,12 @@ function cbUpload( status, fileid ) { $("#processfile").show(); $("#enqueuefile").show(); } else { + var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ]; + var errCode = errors[$('#fileToUpload').prop('files')[0].name].code; $("#fileuploadstatus").hide(); $("#fileuploadfailed").show(); $("#fileuploadfailed").text( _("Upload status: ") + - ( status=='failed'? _("Failed"): + ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]: ( status=='denied'? _("Denied"): status )) ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt index c95c88ea08..acbf12163f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt @@ -72,7 +72,7 @@ function cbUpload( status, fileid, errors ) { } $("#processfile").show(); } else { - var errMsgs = [ _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ]; + var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ]; var errCode = errors[$('#fileToUpload').prop('files')[0].name].code; $('#fileuploadbutton').show(); $("#fileuploadcancel").hide(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt index 82f5912482..28a35de6bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt @@ -18,16 +18,18 @@ function StartUpload() { $("#uploadedfileid").val(''); xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload ); } -function cbUpload( status, fileid ) { +function cbUpload( status, fileid, errors ) { if( status=='done' ) { $("#uploadedfileid").val( fileid ); $('#fileToUpload').prop('disabled',true); $("#processfile").show(); } else { + var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ]; + var errCode = errors[$('#fileToUpload').prop('files')[0].name].code; $("#fileuploadstatus").hide(); $("#fileuploadfailed").show(); $("#fileuploadfailed").text( _("Upload status: ") + - ( status=='failed'? _("Failed"): + ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]: ( status=='denied'? _("Denied"): status )) ); $("#processfile").hide(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt index 5b61b6bcbf..1223213047 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ -265,7 +265,7 @@ function ShowAlerts(err) { var str = ''; for( var file in err ) { str= str + '

' + file + ': ' + - errMESSAGES[ err[file] ] + '

'; + errMESSAGES[ err[file].code ] + '

'; } if( str ) { $('#myalerts').html(str); -- 2.39.5