MDL-67917 user: Add skeleton for new participants filter
[moodle.git] / user / amd / build / participantsfilter.min.js
1 function _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/notification","./local/participantsfilter/selectors","core/templates"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=i(c);d=j(d);e=j(e);f=j(f);g=j(g);var m="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function h(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;h=function(){return a};return a}function i(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=h();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 j(a){return a&&a.__esModule?a:{default:a}}function k(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 l(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){k(h,d,e,f,g,"next",a)}function g(a){k(h,d,e,f,g,"throw",a)}f(void 0)})}}var n=function(a){var h=document.querySelector("#".concat(a)),i={courseid:new b.default("courseid",h)},j=function(){return h.querySelector(f.default.filterset.regions.filterlist)},k=function(){return g.default.renderForPromise("core_user/local/participantsfilter/filterrow",{}).then(function(a){var b=a.html,c=a.js,d=g.default.appendNodeContents(j(),b,c);return d}).then(function(a){var b=h.querySelector(f.default.data.typeList);a.forEach(function(a){var c=a.querySelector(f.default.filter.fields.type);if(c){c.innerHTML=b.innerHTML}});return a}).then(function(a){v();return a}).catch(e.default.exception)},n=function(a){var b=h.querySelector(f.default.filterset.regions.datasource);return b.querySelector(f.default.data.fields.byName(a))},o=function(){var a=l(regeneratorRuntime.mark(function a(b,c){var e,g,j;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:b.dataset.filterType=c;e=n(c);g=d.default;if(!e.dataset.filterTypeClass){a.next=7;break}a.next=6;return"function"==typeof m.define&&m.define.amd?new Promise(function(a,b){m.require([e.dataset.filterTypeClass],a,b)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&m.require&&"component"===m.require.loader?Promise.resolve(require((e.dataset.filterTypeClass))):Promise.resolve(m[e.dataset.filterTypeClass]);case 6:g=a.sent;case 7:i[c]=new g(c,h);j=b.querySelector(f.default.filter.fields.type);j.disabled="disabled";v();case 11:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),p=function(a){return i[a]},q=function(a){var b=j().querySelectorAll(f.default.filter.region).length;if(1===b){s(a)}else{r(a)}},r=function(a){t(a.dataset.filterType);a.remove();w();v()},s=function(a){t(a.dataset.filterType);return g.default.renderForPromise("core_user/local/participantsfilter/filterrow",{}).then(function(b){var c=b.html,d=b.js,e=g.default.replaceNode(a,c,d);return e}).then(function(a){var b=h.querySelector(f.default.data.typeList);a.forEach(function(a){var c=a.querySelector(f.default.filter.fields.type);if(c){c.innerHTML=b.innerHTML}});return a}).then(function(a){v();return a}).then(function(a){w();return a}).catch(e.default.exception)},t=function(a){if(a){var b=p(a);if(b){b.tearDown();delete i[a]}}},u=function(){var a=l(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:b=j().querySelectorAll(f.default.filter.region);b.forEach(function(a){q(a)});w();case 3:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),v=function(){var a=j().querySelectorAll(f.default.filter.region);a.forEach(function(a){var b=a.querySelectorAll(f.default.filter.fields.type+" option");b.forEach(function(b){if(b.value===a.dataset.filterType){b.classList.remove("hidden");b.disabled=!1}else if(i[b.value]){b.classList.add("hidden");b.disabled=!0}else{b.classList.remove("hidden");b.disabled=!1}})})},w=function(){return c.setFilters(c.getTableFromId(h.dataset.tableRegion),{filters:Object.values(i).map(function(a){return a.filterValue}),jointype:1})};h.querySelector(f.default.filterset.region).addEventListener("click",function(a){if(a.target.closest(f.default.filterset.actions.addRow)){a.preventDefault();k()}if(a.target.closest(f.default.filterset.actions.applyFilters)){a.preventDefault();w()}if(a.target.closest(f.default.filterset.actions.resetFilters)){a.preventDefault();u()}});h.querySelector(f.default.filterset.regions.filterlist).addEventListener("click",function(a){if(a.target.closest(f.default.filter.actions.remove)){a.preventDefault();q(a.target.closest(f.default.filter.region))}});h.querySelector(f.default.filterset.regions.filterlist).addEventListener("change",function(a){var b=a.target.closest(f.default.filter.fields.type);if(b&&b.value){var c=a.target.closest(f.default.filter.region);o(c,b.value)}})};a.init=n});
2 //# sourceMappingURL=participantsfilter.min.js.map