b6cee8666773efc2d94ceaa6b4f2b787c2f0719d
[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","core/utils"],function(a,b,c,d,e,f,g,h,i,j,k){"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=l(b);c=l(c);d=l(d);f=l(f);function l(a){return a&&a.__esModule?a:{default:a}}function m(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){n(a,b,c[b])})}return a}function n(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 o(a,b){return r(a)||q(a,b)||p()}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function q(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 r(a){if(Array.isArray(a))return a}function s(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 t(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){s(h,d,e,f,g,"next",a)}function g(a){s(h,d,e,f,g,"throw",a)}f(void 0)})}}var u={grader:{app:"mod_forum/local/grades/grader",gradingPanel:{error:"mod_forum/local/grades/local/grader/gradingpanel/error"},searchResults:"mod_forum/local/grades/local/grader/user_picker/user_search",status:"mod_forum/local/grades/local/grader/status"}},v=function(a,d){var e=a.querySelector(c.default.regions.pickerRegion);b.default.replaceNodeContents(e,d,"")},w=function(a,b){return[a,b]},x=function(a,d,e){var f=!0;return function(){var g=t(regeneratorRuntime.mark(function g(h){var i,k,l,m,n,p,q,r,s,t,u,v,x;return regeneratorRuntime.wrap(function(g){while(1){switch(g.prev=g.next){case 0:i=f?null:(0,j.addIconToContainerWithPromise)(a);g.next=3;return Promise.all([d(h.id).then(w),e(h.id)]);case 3:k=g.sent;l=o(k,2);m=o(l[0],2);n=m[0];p=m[1];q=l[1];b.default.replaceNodeContents(a.querySelector(c.default.regions.moduleReplace),n,p);g.next=12;return b.default.render(q.templatename,q.grade).then(w);case 12:r=g.sent;s=o(r,2);t=s[0];u=s[1];v=a.querySelector(c.default.regions.gradingPanelContainer);x=v.querySelector(c.default.regions.gradingPanel);b.default.replaceNodeContents(x,t,u);v.scrollTop=0;f=!1;if(i){i.resolve()}case 22:case"end":return g.stop();}}},g)}));return function(){return g.apply(this,arguments)}}()},y=function(a,b,c){a.classList.add("hidden");b.classList.add("hidden");c.classList.remove("hidden")},z=function(a,b,c){a.classList.remove("hidden");b.classList.remove("hidden");c.classList.add("hidden")},A=function(a,b,c){b.classList.remove("collapsed");a.setAttribute("aria-expanded","true");a.classList.add("expand");a.classList.remove("collapse");c.focus()},B=function(a,b,c){b.classList.add("collapsed");a.setAttribute("aria-expanded","false");a.classList.add("collapse");a.classList.remove("expand");a.focus();c.value=""},C=function(a,b){if(""===b){return a}b=b.toLowerCase();return a.filter(function(a){return a.fullname.toLowerCase().includes(b)})},D=function(){var a=t(regeneratorRuntime.mark(function a(c,d){var e,f,g;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return b.default.renderForPromise(u.grader.searchResults,{users:d});case 2:e=a.sent;f=e.html;g=e.js;b.default.replaceNodeContents(c,f,g);case 6:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),E=function(a,b,d,e){var f=a.getContainer(),g=f.querySelector(c.default.buttons.toggleSearch),h=f.querySelector(c.default.regions.userSearchContainer),i=h.querySelector(c.default.regions.userSearchInput),j=f.querySelector(c.default.regions.bodyContainer),l=f.querySelector(c.default.regions.pickerRegion),m=f.querySelector(c.default.regions.searchResultsContainer);f.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)}if(f.target.closest(c.default.buttons.toggleSearch)){if("true"===g.getAttribute("aria-expanded")){B(g,h,i);z(j,l,m);m.innerHTML=""}else{A(g,h,i);y(j,l,m);D(m,e)}return}var k=f.target.closest(c.default.buttons.selectUser);if(k){var n=k.getAttribute("data-userid"),o=e.find(function(a){return a.id==n});b.setUserId(n);b.showUser(o);B(g,h,i);z(j,l,m);m.innerHTML=""}});i.addEventListener("input",(0,k.debounce)(function(){var a=C(e,i.value);D(m,a)},300))},F=function(a,b){return function(){var d=t(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){G(a,e,f.error)}return d.abrupt("return",f);case 15:d.prev=15;d.t2=d["catch"](0);G(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)}}()},G=function(){var a=t(regeneratorRuntime.mark(function a(d,e,f){var i,j,k,l,n,p;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=Promise;a.t1=b.default.renderForPromise(u.grader.gradingPanel.error,{error:f});a.next=4;return(0,h.get_string)("grades:gradesavefailed","mod_forum",m({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=o(i,2);k=j[0];l=k.html;n=k.js;p=j[1];b.default.replaceNodeContents(d.querySelector(c.default.regions.gradingPanelErrors),l,n);(0,g.add)(p);case 16:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),H=function(){var a=t(regeneratorRuntime.mark(function a(f,g,h,i){var j,k,l,m,n,p,q,r,s,t,w,y,z,A,B,C,D,G,H,I=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:j=4<I.length&&I[4]!==void 0?I[4]:{},k=j.initialUserId,l=void 0===k?null:k,m=j.moduleName,n=j.courseName,p=j.courseUrl;a.next=3;return Promise.all([(0,e.createLayout)({fullscreen:!1,showLoader:!1}),b.default.renderForPromise(u.grader.app,{moduleName:m,courseName:n,courseUrl:p,drawer:{show:!0}}),f()]);case 3:q=a.sent;r=o(q,3);s=r[0];t=r[1];w=t.html;y=t.js;z=r[2];A=s.getContainer();B=F(A,i);b.default.replaceNodeContents(A,w,y);C=x(A,g,h);D=z.map(function(a){return a.id});G=A.querySelector(c.default.regions.statusContainer);a.next=18;return(0,d.default)(z,function(a){var c={status:null,index:D.indexOf(a.id)+1,total:z.length};b.default.render(u.grader.status,c).then(function(a){G.innerHTML=a;return a}).catch();C(a)},B,{initialUserId:l});case 18:H=a.sent;E(s,H,B,z);v(A,H.rootNode);case 21:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.launch=H});
2 //# sourceMappingURL=grader.min.js.map