ee4215d489cd89d1ebfb8e34d007834f2acb7877
[moodle.git] / mod / forum / amd / build / local / grades / grader.min.js
1 define ("mod_forum/local/grades/grader",["exports","core/templates","./local/grader/selectors","./local/grader/user_picker","mod_forum/local/layout/fullscreen","./local/grader/gradingpanel","core/toast","core/str","core_grades/grades/grader/gradingpanel/normalise","core/loadingicon"],function(a,b,c,d,e,f,g,h,i,j){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"getGradingPanelFunctions",{enumerable:!0,get:function get(){return f.default}});a.launch=void 0;b=k(b);c=k(c);d=k(d);f=k(f);function k(a){return a&&a.__esModule?a:{default:a}}function l(a){for(var b=1;b<arguments.length;b++){var c=null!=arguments[b]?arguments[b]:{},d=Object.keys(c);if("function"==typeof Object.getOwnPropertySymbols){d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))}d.forEach(function(b){m(a,b,c[b])})}return a}function m(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function n(a,b){return q(a)||p(a,b)||o()}function o(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function p(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function q(a){if(Array.isArray(a))return a}function r(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function s(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){r(h,d,e,f,g,"next",a)}function g(a){r(h,d,e,f,g,"throw",a)}f(void 0)})}}var t={grader:{app:"mod_forum/local/grades/grader",gradingPanel:{error:"mod_forum/local/grades/local/grader/gradingpanel/error"}}},u=function(a,d){var e=a.querySelector(c.default.regions.pickerRegion);b.default.replaceNodeContents(e,d,"")},v=function(a,b){return[a,b]},w=function(a,d,e){return function(){var f=s(regeneratorRuntime.mark(function f(g){var h,i,k,l,m,o,p,q,r,s,t,u,w;return regeneratorRuntime.wrap(function(f){while(1){switch(f.prev=f.next){case 0:h=(0,j.addIconToContainerWithPromise)(a);f.next=3;return Promise.all([d(g.id).then(v),e(g.id)]);case 3:i=f.sent;k=n(i,2);l=n(k[0],2);m=l[0];o=l[1];p=k[1];b.default.replaceNodeContents(a.querySelector(c.default.regions.moduleReplace),m,o);f.next=12;return b.default.render(p.templatename,p.grade).then(v);case 12:q=f.sent;r=n(q,2);s=r[0];t=r[1];u=a.querySelector(c.default.regions.gradingPanelContainer);w=u.querySelector(c.default.regions.gradingPanel);b.default.replaceNodeContents(w,s,t);u.scrollTop=0;h.resolve();case 21:case"end":return f.stop();}}},f)}));return function(){return f.apply(this,arguments)}}()},x=function(a,b,d){var e=a.getContainer();e.addEventListener("click",function(f){if(f.target.closest(c.default.buttons.toggleFullscreen)){f.stopImmediatePropagation();f.preventDefault();a.toggleFullscreen();return}if(f.target.closest(c.default.buttons.closeGrader)){f.stopImmediatePropagation();f.preventDefault();a.close();return}if(f.target.closest(c.default.buttons.saveGrade)){d(b.currentUser)}})},y=function(a,b){return function(){var d=s(regeneratorRuntime.mark(function d(e){var f;return regeneratorRuntime.wrap(function(d){while(1){switch(d.prev=d.next){case 0:d.prev=0;a.querySelector(c.default.regions.gradingPanelErrors).innerHTML="";d.next=4;return b(e.id,a.querySelector(c.default.regions.gradingPanel));case 4:f=d.sent;if(!f.success){d.next=11;break}d.t0=g.add;d.next=9;return(0,h.get_string)("grades:gradesavedfor","mod_forum",e);case 9:d.t1=d.sent;(0,d.t0)(d.t1);case 11:if(f.failed){z(a,e,f.error)}return d.abrupt("return",f);case 15:d.prev=15;d.t2=d["catch"](0);z(a,e,d.t2);return d.abrupt("return",(0,i.failedUpdate)(d.t2));case 19:case"end":return d.stop();}}},d,null,[[0,15]])}));return function(){return d.apply(this,arguments)}}()},z=function(){var a=s(regeneratorRuntime.mark(function a(d,e,f){var i,j,k,m,o,p;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=Promise;a.t1=b.default.renderForPromise(t.grader.gradingPanel.error,{error:f});a.next=4;return(0,h.get_string)("grades:gradesavefailed","mod_forum",l({error:f.message},e));case 4:a.t2=a.sent;a.t3=[a.t1,a.t2];a.next=8;return a.t0.all.call(a.t0,a.t3);case 8:i=a.sent;j=n(i,2);k=j[0];m=k.html;o=k.js;p=j[1];b.default.replaceNodeContents(d.querySelector(c.default.regions.gradingPanelErrors),m,o);(0,g.add)(p);case 16:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),A=function(){var a=s(regeneratorRuntime.mark(function a(c,f,g,h){var i,j,k,l,m,o,p,q,r,s,v,z,A,B,C,D,E,F=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:i=4<F.length&&F[4]!==void 0?F[4]:{},j=i.initialUserId,k=void 0===j?null:j,l=i.moduleName,m=i.courseName,o=i.courseUrl;a.next=3;return Promise.all([(0,e.createLayout)({fullscreen:!1,showLoader:!1}),b.default.renderForPromise(t.grader.app,{moduleName:l,courseName:m,courseUrl:o,drawer:{show:!0}}),c()]);case 3:p=a.sent;q=n(p,3);r=q[0];s=q[1];v=s.html;z=s.js;A=q[2];B=r.getContainer();C=y(B,h);b.default.replaceNodeContents(B,v,z);D=w(B,f,g);a.next=16;return(0,d.default)(A,D,C,{initialUserId:k});case 16:E=a.sent;x(r,E,C);u(B,E.rootNode);case 19:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.launch=A});
2 //# sourceMappingURL=grader.min.js.map