MDL-68612 user: Participants filter row accessibility improvements
[moodle.git] / user / amd / build / participantsfilter.min.js
CommitLineData
3d60881d 1function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_user/participantsfilter",["exports","./local/participantsfilter/filtertypes/courseid","core_table/dynamic","./local/participantsfilter/filter","core/str","core/notification","./local/participantsfilter/selectors","core/templates"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=k(b);c=j(c);d=k(d);f=k(f);g=k(g);h=k(h);var t="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function i(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;i=function(){return a};return a}function j(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=i();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function k(a){return a&&a.__esModule?a:{default:a}}function l(a){return p(a)||o(a)||n(a)||m()}function m(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(a,b){if(!a)return;if("string"==typeof a)return q(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return q(a,b)}function o(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}function p(a){if(Array.isArray(a))return q(a)}function q(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}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 u=function(a){var i=document.querySelector("#".concat(a)),j={courseid:new b.default("courseid",i)},k=function(){return i.querySelector(g.default.filterset.regions.filterlist)},m=function(){var a=1+k().querySelectorAll(g.default.filter.region).length;return h.default.renderForPromise("core_user/local/participantsfilter/filterrow",{rownumber:a}).then(function(a){var b=a.html,c=a.js,d=h.default.appendNodeContents(k(),b,c);return d}).then(function(a){var b=i.querySelector(g.default.data.typeList);a.forEach(function(a){var c=a.querySelector(g.default.filter.fields.type);if(c){c.innerHTML=b.innerHTML}});return a}).then(function(a){x();return a}).catch(f.default.exception)},n=function(a){var b=i.querySelector(g.default.filterset.regions.datasource);return b.querySelector(g.default.data.fields.byName(a))},o=function(){var a=s(regeneratorRuntime.mark(function a(b,c){var e,f,h;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:b.dataset.filterType=c;e=n(c);f=d.default;if(!e.dataset.filterTypeClass){a.next=7;break}a.next=6;return"function"==typeof t.define&&t.define.amd?new Promise(function(a,b){t.require([e.dataset.filterTypeClass],a,b)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&t.require&&"component"===t.require.loader?Promise.resolve(require((e.dataset.filterTypeClass))):Promise.resolve(t[e.dataset.filterTypeClass]);case 6:f=a.sent;case 7:j[c]=new f(c,i);h=b.querySelector(g.default.filter.fields.type);h.disabled="disabled";x();case 11:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),p=function(a){return j[a]},q=function(a){var b=k().querySelectorAll(g.default.filter.region).length;if(1===b){u(a)}else{r(a)}},r=function(){var a=s(regeneratorRuntime.mark(function a(b){var c;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:v(b.dataset.filterType);b.remove();y();x();a.next=6;return z();case 6:c=a.sent;k().querySelectorAll(g.default.filter.region).forEach(function(a,b){a.querySelector("legend").innerText=c[b]});case 8:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),u=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:1;v(a.dataset.filterType);return h.default.renderForPromise("core_user/local/participantsfilter/filterrow",{rownumber:b}).then(function(b){var c=b.html,d=b.js,e=h.default.replaceNode(a,c,d);return e}).then(function(a){var b=i.querySelector(g.default.data.typeList);a.forEach(function(a){var c=a.querySelector(g.default.filter.fields.type);if(c){c.innerHTML=b.innerHTML}});return a}).then(function(a){x();return a}).then(function(a){y();return a}).catch(f.default.exception)},v=function(a){if(a){var b=p(a);if(b){b.tearDown();delete j[a]}}},w=function(){var a=s(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:b=k().querySelectorAll(g.default.filter.region);b.forEach(function(a){q(a)});y();case 3:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),x=function(){var a=k().querySelectorAll(g.default.filter.region);a.forEach(function(a){var b=a.querySelectorAll(g.default.filter.fields.type+" option");b.forEach(function(b){if(b.value===a.dataset.filterType){b.classList.remove("hidden");b.disabled=!1}else if(j[b.value]){b.classList.add("hidden");b.disabled=!0}else{b.classList.remove("hidden");b.disabled=!1}})});var b=i.querySelector(g.default.filterset.actions.addRow),c=i.querySelectorAll(g.default.data.fields.all);if(c.length<=a.length){b.setAttribute("disabled","disabled")}else{b.removeAttribute("disabled")}if(1===a.length){i.querySelector(g.default.filterset.regions.filtermatch).classList.add("hidden");i.querySelector(g.default.filterset.fields.join).value=1}else{i.querySelector(g.default.filterset.regions.filtermatch).classList.remove("hidden")}},y=function(){return c.setFilters(c.getTableFromId(i.dataset.tableRegion),{filters:Object.values(j).map(function(a){return a.filterValue}),jointype:i.querySelector(g.default.filterset.fields.join).value})},z=function(){var a=s(regeneratorRuntime.mark(function a(){var b,c,d;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:b=document.querySelector(g.default.data.typeListSelect).length-1;c=[];l(Array(b)).forEach(function(a,b){c.push({key:"filterrowlegend",component:"core_user",param:b+1})});a.next=5;return(0,e.get_strings)(c).then(function(a){return a}).catch(f.default.exception);case 5:d=a.sent;return a.abrupt("return",d);case 7:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();i.querySelector(g.default.filterset.region).addEventListener("click",function(a){if(a.target.closest(g.default.filterset.actions.addRow)){a.preventDefault();m()}if(a.target.closest(g.default.filterset.actions.applyFilters)){a.preventDefault();y()}if(a.target.closest(g.default.filterset.actions.resetFilters)){a.preventDefault();w()}});i.querySelector(g.default.filterset.regions.filterlist).addEventListener("click",function(a){if(a.target.closest(g.default.filter.actions.remove)){a.preventDefault();q(a.target.closest(g.default.filter.region))}});i.querySelector(g.default.filterset.regions.filterlist).addEventListener("change",function(a){var b=a.target.closest(g.default.filter.fields.type);if(b&&b.value){var c=a.target.closest(g.default.filter.region);o(c,b.value)}});i.querySelector(g.default.filterset.fields.join).addEventListener("change",function(a){i.dataset.filterverb=a.target.value})};a.init=u});
77ba77f1 2//# sourceMappingURL=participantsfilter.min.js.map