MDL-67144 mod_forum: If no users exist do not show the grading interface
[moodle.git] / mod / forum / amd / build / local / grades / grader.min.js
CommitLineData
fc741e03 1define ("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/notification","core/str","core_grades/grades/grader/gradingpanel/normalise","core/loadingicon","core/utils","core_grades/grades/grader/gradingpanel/comparison","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"getGradingPanelFunctions",{enumerable:!0,get:function get(){return f.default}});a.view=a.launch=void 0;b=q(b);c=q(c);d=q(d);f=q(f);n=p(n);o=p(o);function p(a){if(a&&a.__esModule){return a}else{var b={};if(null!=a){for(var c in a){if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};if(d.get||d.set){Object.defineProperty(b,c,d)}else{b[c]=a[c]}}}}b.default=a;return b}}function q(a){return a&&a.__esModule?a:{default:a}}function r(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){s(a,b,c[b])})}return a}function s(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 t(a,b){return w(a)||v(a,b)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function v(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 w(a){if(Array.isArray(a))return a}function x(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 y(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){x(h,d,e,f,g,"next",a)}function g(a){x(h,d,e,f,g,"throw",a)}f(void 0)})}}var z={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"}},A=function(a,d){var e=a.querySelector(c.default.regions.pickerRegion);b.default.replaceNodeContents(e,d,"")},B=function(a,b){return[a,b]},C=function(a,d,e){var f=!0;return function(){var g=y(regeneratorRuntime.mark(function g(h){var i,j,l,n,o,p,q,r,s,u,v,w,x;return regeneratorRuntime.wrap(function(g){while(1){switch(g.prev=g.next){case 0:i=f?null:(0,k.addIconToContainerWithPromise)(a);g.next=3;return Promise.all([d(h.id).then(B),e(h.id)]);case 3:j=g.sent;l=t(j,2);n=t(l[0],2);o=n[0];p=n[1];q=l[1];b.default.replaceNodeContents(a.querySelector(c.default.regions.moduleReplace),o,p);g.next=12;return b.default.render(q.templatename,q.grade).then(B);case 12:r=g.sent;s=t(r,2);u=s[0];v=s[1];w=a.querySelector(c.default.regions.gradingPanelContainer);x=w.querySelector(c.default.regions.gradingPanel);b.default.replaceNodeContents(x,u,v);(0,m.fillInitialValues)(x.querySelector("form"));w.scrollTop=0;f=!1;if(i){i.resolve()}case 23:case"end":return g.stop();}}},g)}));return function(){return g.apply(this,arguments)}}()},D=function(a,b,c){a.classList.add("hidden");b.classList.add("hidden");c.classList.remove("hidden")},E=function(a,b,c){a.classList.remove("hidden");b.classList.remove("hidden");c.classList.add("hidden")},F=function(a,b,c){b.classList.remove("collapsed");a.setAttribute("aria-expanded","true");a.classList.add("expand");a.classList.remove("collapse");c.focus()},G=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=""},H=function(a,b){if(""===b){return a}b=b.toLowerCase();return a.filter(function(a){return a.fullname.toLowerCase().includes(b)})},I=function(){var a=y(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(z.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)}}(),J=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),k=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")){G(g,h,i);E(j,k,m);m.innerHTML=""}else{F(g,h,i);D(j,k,m);I(m,e)}return}var l=f.target.closest(c.default.buttons.selectUser);if(l){var n=l.getAttribute("data-userid"),o=e.find(function(a){return a.id==n});b.setUserId(n);b.showUser(o);G(g,h,i);E(j,k,m);m.innerHTML=""}});i.addEventListener("input",(0,l.debounce)(function(){var a=H(e,i.value);I(m,a)},300))},K=function(a,b){return function(){var d=y(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.values.sendStudentNotifications).value,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,i.get_string)("grades:gradesavedfor","mod_forum",e);case 9:d.t1=d.sent;(0,d.t0)(d.t1);case 11:if(f.failed){L(a,e,f.error)}return d.abrupt("return",f);case 15:d.prev=15;d.t2=d["catch"](0);L(a,e,d.t2);return d.abrupt("return",(0,j.failedUpdate)(d.t2));case 19:case"end":return d.stop();}}},d,null,[[0,15]])}));return function(){return d.apply(this,arguments)}}()},L=function(){var a=y(regeneratorRuntime.mark(function a(d,e,f){var h,j,k,l,m,n;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.t0=Promise;a.t1=b.default.renderForPromise(z.grader.gradingPanel.error,{error:f});a.next=4;return(0,i.get_string)("grades:gradesavefailed","mod_forum",r({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:h=a.sent;j=t(h,2);k=j[0];l=k.html;m=k.js;n=j[1];b.default.replaceNodeContents(d.querySelector(c.default.regions.gradingPanelErrors),l,m);(0,g.add)(n);case 16:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),M=function(){var a=y(regeneratorRuntime.mark(function a(f,g,j,k){var l,m,n,o,p,q,r,s,u,v,w,x,y,B,D,E,F,G,H,I,L,M,N=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:l=4<N.length&&N[4]!==void 0?N[4]:{},m=l.initialUserId,n=void 0===m?null:m,o=l.moduleName,p=l.courseName,q=l.courseUrl,r=l.sendStudentNotifications,s=l.focusOnClose,u=void 0===s?null:s;a.next=3;return f();case 3:v=a.sent;if(v.length){a.next=12;break}a.t0=h.addNotification;a.next=8;return(0,i.get_string)("nouserstograde","core_grades");case 8:a.t1=a.sent;a.t2={message:a.t1,type:"error"};(0,a.t0)(a.t2);return a.abrupt("return");case 12:a.next=14;return Promise.all([(0,e.createLayout)({fullscreen:!1,showLoader:!1,focusOnClose:u}),b.default.renderForPromise(z.grader.app,{moduleName:o,courseName:p,courseUrl:q,drawer:{show:!0},defaultsendnotifications:r})]);case 14:w=a.sent;x=t(w,2);y=x[0];B=x[1];D=B.html;E=B.js;F=y.getContainer();G=K(F,k);b.default.replaceNodeContents(F,D,E);H=C(F,g,j);I=v.map(function(a){return a.id});L=F.querySelector(c.default.regions.statusContainer);a.next=28;return(0,d.default)(v,function(a){var c={status:null,index:I.indexOf(a.id)+1,total:v.length};b.default.render(z.grader.status,c).then(function(a){L.innerHTML=a;return a}).catch();H(a)},G,{initialUserId:n});case 28:M=a.sent;J(y,M,G,v);A(F,M.rootNode);case 31:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.launch=M;var N=function(){var a=y(regeneratorRuntime.mark(function a(c,d,e){var f,g,h,i,j,l,m,p,q,r,s,u,v,w,x,y,z,A=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:f=3<A.length&&A[3]!==void 0?A[3]:{},g=f.focusOnClose,h=void 0===g?null:g;a.next=3;return Promise.all([c(d),n.create({title:e,large:!0,type:n.types.CANCEL})]);case 3:i=a.sent;j=t(i,2);l=j[0];m=j[1];p=(0,k.addIconToContainerWithPromise)(m.getRoot());m.getRoot().on(o.hidden,function(){m.destroy();if(h){try{h.focus()}catch(a){}}});m.show();q=document.createElement("div");a.next=13;return b.default.renderForPromise("mod_forum/local/grades/view_grade",l);case 13:r=a.sent;s=r.html;u=r.js;b.default.replaceNodeContents(q,s,u);a.next=19;return O(l);case 19:v=a.sent;w=t(v,2);x=w[0];y=w[1];z=q.querySelector("[data-region=\"grade-template\"]");b.default.replaceNodeContents(z,x,y);m.setBody(q.outerHTML);p.resolve();case 27:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.view=N;var O=function(){var a=y(regeneratorRuntime.mark(function a(c){var d,e,f;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return b.default.renderForPromise(c.templatename,c.grade);case 2:d=a.sent;e=d.html;f=d.js;return a.abrupt("return",[e,f]);case 6:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}()});
bae67469 2//# sourceMappingURL=grader.min.js.map