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 <m.de.rooy@rijksmuseum.nl>
Amended: Removed the added js comment in upload.tt

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2017-11-03 10:33:00 +00:00 committed by Jonathan Druart
parent b25cb7ab0f
commit 0c9f01f175
4 changed files with 10 additions and 6 deletions

View file

@ -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 ))
);
}

View file

@ -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();

View file

@ -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();

View file

@ -265,7 +265,7 @@ function ShowAlerts(err) {
var str = '';
for( var file in err ) {
str= str + '<p>' + file + ': ' +
errMESSAGES[ err[file] ] + '</p>';
errMESSAGES[ err[file].code ] + '</p>';
}
if( str ) {
$('#myalerts').html(str);