on-demand release 4.0dev+
[moodle.git] / report / insights / amd / build / actions.min.js
1 define ("report_insights/actions",["jquery","core/str","core/ajax","core/notification","core/url","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){return{initBulk:function initBulk(h){var i=function(a,b,f){return c.call([{methodname:"report_insights_action_executed",args:{predictionids:a,actionname:f}}])[0].then(function(){var a=!1;b.forEach(function(b){if(!1===a){a=b.closest("table")}b.remove()});if(0===a.find("tbody > tr").length){var c={contextid:a.closest("div.insight-container").data("context-id"),modelid:a.closest("div.insight-container").data("model-id")};window.location.assign(e.relativeUrl("report/insights/insights.php",c,!1))}}).catch(d.exception)};a(h+" [data-bulk-actionname]").on("click",function(c){c.preventDefault();var e=a(c.currentTarget),h=e.data("bulk-actionname"),j=e.text().trim(),k=[],l=[];a(".insights-list input[data-togglegroup^=\"insight-bulk-action-\"][data-toggle=\"slave\"]:checked").each(function(){var b=a(this).closest("tr[data-prediction-id]");l.push(b);k.push(b.data("prediction-id"))});if(0===k.length){return this}var m=[];b.get_strings([{key:"confirmbulkaction",component:"report_insights",param:{action:j,nitems:k.length}},{key:"confirm",component:"moodle"}]).then(function(a){m=a;return f.create({type:f.types.SAVE_CANCEL,title:j,body:m[0]})}).then(function(a){a.setSaveButtonText(m[1]);a.show();a.getRoot().on(g.save,function(){return i(k,l,h)});return a}).catch(d.exception);return this})}}});
2 //# sourceMappingURL=actions.min.js.map