Commit 293ac927 by zubair-arbi

show warning on navigate away from import page only for first two stages

TNL-554
parent 3185dc48
...@@ -28,6 +28,7 @@ define([ ...@@ -28,6 +28,7 @@ define([
autoUpload: false, autoUpload: false,
add: function(e, data) { add: function(e, data) {
CourseImport.clearImportDisplay(); CourseImport.clearImportDisplay();
CourseImport.okayToNavigateAway = false;
submitBtn.unbind('click'); submitBtn.unbind('click');
file = data.files[0]; file = data.files[0];
if (file.name.match(/tar\.gz$/)) { if (file.name.match(/tar\.gz$/)) {
...@@ -97,7 +98,9 @@ define([ ...@@ -97,7 +98,9 @@ define([
}, },
start: function(event) { start: function(event) {
window.onbeforeunload = function() { window.onbeforeunload = function() {
return gettext('Your import is in progress; navigating away will abort it.'); if (!CourseImport.okayToNavigateAway) {
return "${_('Your import is in progress; navigating away will abort it.')}";
}
}; };
}, },
sequentialUploads: true, sequentialUploads: true,
......
...@@ -49,6 +49,7 @@ define( ...@@ -49,6 +49,7 @@ define(
*/ */
var getStatus = function (url, timeout, stage) { var getStatus = function (url, timeout, stage) {
var currentStage = stage || 0; var currentStage = stage || 0;
if (currentStage > 1) { CourseImport.okayToNavigateAway = true; }
if (CourseImport.stopGetStatus) { return ;} if (CourseImport.stopGetStatus) { return ;}
if (currentStage === 4) { if (currentStage === 4) {
...@@ -87,6 +88,10 @@ define( ...@@ -87,6 +88,10 @@ define(
* progress. * progress.
*/ */
stopGetStatus: false, stopGetStatus: false,
/**
* Whether its fine to navigate away while import is in progress
*/
okayToNavigateAway: false,
/** /**
* Update DOM to set all stages as not-started (for retrying an upload that * Update DOM to set all stages as not-started (for retrying an upload that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment