MDL-58835 report_insights: Force window reload when no more predictions

This commit is contained in:
David Monllao 2017-09-14 12:55:03 +02:00
parent a2bcf808d9
commit 3f6933d896
2 changed files with 6 additions and 2 deletions

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{init:function(d){a("a[data-prediction-methodname][data-prediction-id="+d+"]").on("click",function(e){e.preventDefault();var f=a(e.currentTarget),g=f.attr("data-prediction-methodname"),h=f.closest("tr");if(h.length>0){var i=b.call([{methodname:g,args:{predictionid:d}}])[0];i.done(function(){h[0].remove(),a(".insights-list tr").length<2&&window.history.back()}).fail(c.exception)}})}}});
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{init:function(d){a("a[data-prediction-methodname][data-prediction-id="+d+"]").on("click",function(e){e.preventDefault();var f=a(e.currentTarget),g=f.attr("data-prediction-methodname"),h=f.closest("tr");if(h.length>0){var i=b.call([{methodname:g,args:{predictionid:d}}])[0];i.done(function(){h[0].remove(),a(".insights-list tr").length<2&&(document.referrer?window.location.assign(document.referrer):window.location.reload(!0))}).fail(c.exception)}})}}});

View File

@ -57,7 +57,11 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
// Move back if no remaining predictions.
if ($('.insights-list tr').length < 2) {
window.history.back();
if (document.referrer) {
window.location.assign(document.referrer);
} else {
window.location.reload(true);
}
}
}).fail(Notification.exception);
}