From cdf0eef5ca2b028cf4cff6eb0e4543be26b7f34d Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Mon, 16 Sep 2013 15:06:51 -0400 Subject: [PATCH 1/4] Consider redirect code as succcesful --- cms/templates/import.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/templates/import.html b/cms/templates/import.html index 27337bf235..88ccfd4e77 100644 --- a/cms/templates/import.html +++ b/cms/templates/import.html @@ -77,7 +77,7 @@ $('#fileupload').fileupload({ e.preventDefault(); submitBtn.hide(); data.submit().complete(function(result, textStatus, xhr) { - if (result.status != 200) { + if (result.status != 200 && result.status != 302) { alert('${_("Your import has failed.")}\n\n' + JSON.parse(result.responseText)["ErrMsg"]); submitBtn.show(); bar.hide(); From 0f81bdcefd7d10164949e4607063326a7ba38162 Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Mon, 16 Sep 2013 17:25:41 -0400 Subject: [PATCH 2/4] Properly handle error responses --- cms/templates/import.html | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cms/templates/import.html b/cms/templates/import.html index 88ccfd4e77..b3caac54a3 100644 --- a/cms/templates/import.html +++ b/cms/templates/import.html @@ -77,16 +77,11 @@ $('#fileupload').fileupload({ e.preventDefault(); submitBtn.hide(); data.submit().complete(function(result, textStatus, xhr) { - if (result.status != 200 && result.status != 302) { - alert('${_("Your import has failed.")}\n\n' + JSON.parse(result.responseText)["ErrMsg"]); + if (xhr.status != 200) { + alert('${_("Your import has failed.")}\n\n' + result["ErrMsg"]); submitBtn.show(); bar.hide(); - } else { - if (result.responseText["ImportStatus"] == 1) { - bar.hide(); - statusBlock.show(); - } - } + } }); }); } else { From 4fdf7a4849d862953a02594e362c759f88941bc2 Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Tue, 17 Sep 2013 15:55:30 -0400 Subject: [PATCH 3/4] Prompt before leaving page --- cms/templates/import.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cms/templates/import.html b/cms/templates/import.html index b3caac54a3..706c56351a 100644 --- a/cms/templates/import.html +++ b/cms/templates/import.html @@ -78,7 +78,8 @@ $('#fileupload').fileupload({ submitBtn.hide(); data.submit().complete(function(result, textStatus, xhr) { if (xhr.status != 200) { - alert('${_("Your import has failed.")}\n\n' + result["ErrMsg"]); + var errMsg = result.hasOwnProperty("ErrMsg") ? result["ErrMsg"] : "" ; + alert('${_("Your import has failed.")}\n\n' + errMsg); submitBtn.show(); bar.hide(); } @@ -97,13 +98,18 @@ $('#fileupload').fileupload({ }, done: function(e, data){ bar.hide(); + window.onbeforeunload = null; alert('${_("Your import was successful.")}'); window.location = '${successful_import_redirect_url}'; }, + start: function(e) { + window.onbeforeunload = function() { + return "Your import is in progress; navigating " + + "away will abort it."; + } + }, sequentialUploads: true - - }); })(); From c196d1895abc583b811ad79d2e67fc92f3e555c4 Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Mon, 23 Sep 2013 10:13:33 -0400 Subject: [PATCH 4/4] i18n fix --- cms/templates/import.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cms/templates/import.html b/cms/templates/import.html index 706c56351a..2973d6ef4f 100644 --- a/cms/templates/import.html +++ b/cms/templates/import.html @@ -104,8 +104,7 @@ $('#fileupload').fileupload({ }, start: function(e) { window.onbeforeunload = function() { - return "Your import is in progress; navigating " + - "away will abort it."; + return '${_("Your import is in progress; navigating away will abort it.")}'; } }, sequentialUploads: true