AutorÃa | Ultima modificación | Ver Log |
define("core_user/participants",["exports","core_table/dynamic","core/str","core/checkbox-toggleall","core/custom_interaction_events","core_table/local/dynamic/selectors","core/modal_events","core/notification","core/pending","jquery","core_user/local/participants/bulkactions","core/inplace_editable"],(function(_exports,DynamicTable,Str,_checkboxToggleall,_custom_interaction_events,_selectors,_modal_events,_notification,_pending,_jquery,_bulkactions,_inplace_editable){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getR
equireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
* Some UI stuff for participants page.
* This is also used by the report/participants/index.php because it has the same functionality.
*
* @module core_user/participants
* @copyright 2017 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,DynamicTable=_interopRequireWildcard(DynamicTable),Str=_interopRequireWildcard(Str),_checkboxToggleall=_interopRequireDefault(_checkboxToggleall),_custom_interaction_events=_interopRequireDefault(_custom_interaction_events),_selectors=_interopRequireDefault(_selectors),_modal_events=_interopRequireDefault(_modal_events),_notification=_interopRequireDefault(_notification),_pending=_interopRequireDefault(_pending),_jquery=_interopRequireDefault(_jquery);const Selectors_bulkActionSelect="#formactionid",Selectors_bulkUserSelectedCheckBoxes="input[data-togglegroup='participants-table'][data-toggle='slave']:checked",Selectors_checkCountButton="#checkall",Selectors_showCountText='[data-region="participant-count"]',Selectors_stateHelpIcon='[data-region="state-help-icon"]',Selectors_tableForm=uniqueId=>'form[data-table-unique-id="'.concat(uniqueId,'"]');_exports.init=_ref=>{let{uniqueid:uniqueid,noteStateNames:noteStateNames={}}=_ref;co
nst root=document.querySelector(Selectors_tableForm(uniqueid)),getTableFromUniqueId=uniqueId=>root.querySelector(_selectors.default.main.fromRegionId(uniqueId)),resetBulkAction=bulkActionSelect=>{bulkActionSelect.value=""};_custom_interaction_events.default.define(Selectors_bulkActionSelect,[_custom_interaction_events.default.events.accessibleChange]),(0,_jquery.default)(Selectors_bulkActionSelect).on(_custom_interaction_events.default.events.accessibleChange,(e=>{const bulkActionSelect=e.target.closest("select"),action=bulkActionSelect.value,checkboxes=getTableFromUniqueId(uniqueid).querySelectorAll(Selectors_bulkUserSelectedCheckBoxes),pendingPromise=new _pending.default("core_user/participants:bulkActionSelect");if(-1!==action.indexOf("#")){e.preventDefault();const ids=[];let bulkAction;if(checkboxes.forEach((checkbox=>{ids.push(checkbox.getAttribute("name").replace("user",""))})),"#messageselect"===action?bulkAction=(0,_bulkactions.showSendMessage)(ids):"#addgroupnote"===action&&(bulkAction=(0,_bulkactio
ns.showAddNote)(root.dataset.courseId,ids,noteStateNames,root.querySelector(Selectors_stateHelpIcon))),bulkAction){const pendingBulkAction=new _pending.default("core_user/participants:bulkActionSelected");bulkAction.then((modal=>(modal.getRoot().on(_modal_events.default.hidden,(()=>{bulkActionSelect.focus()})),pendingBulkAction.resolve(),modal))).catch(_notification.default.exception)}}else""!==action&&checkboxes.length&&bulkActionSelect.form.submit();resetBulkAction(bulkActionSelect),pendingPromise.resolve()})),root.addEventListener("click",(e=>{const checkCountButton=root.querySelector(Selectors_checkCountButton);if(checkCountButton&&checkCountButton.contains(e.target)){e.preventDefault();const tableRoot=getTableFromUniqueId(uniqueid);DynamicTable.setPageSize(tableRoot,checkCountButton.dataset.targetPageSize).then((tableRoot=>(_checkboxToggleall.default.setGroupState(root,"participants-table",!0),tableRoot))).catch(_notification.default.exception)}})),root.addEventListener(DynamicTable.Events.tableContentR
efreshed,(e=>{const checkCountButton=root.querySelector(Selectors_checkCountButton),tableRoot=e.target,defaultPageSize=parseInt(tableRoot.dataset.tableDefaultPerPage,10),currentPageSize=parseInt(tableRoot.dataset.tablePageSize,10),totalRowCount=parseInt(tableRoot.dataset.tableTotalRows,10);_checkboxToggleall.default.updateSlavesFromMasterState(root,"participants-table");const pageCountStrings=[{key:"countparticipantsfound",component:"core_user",param:totalRowCount}];totalRowCount<=defaultPageSize?checkCountButton&&checkCountButton.classList.add("hidden"):totalRowCount<=currentPageSize?(pageCountStrings.push({key:"selectalluserswithcount",component:"core",param:defaultPageSize}),checkCountButton&&checkCountButton.classList.add("hidden")):(pageCountStrings.push({key:"selectalluserswithcount",component:"core",param:totalRowCount}),checkCountButton&&checkCountButton.classList.remove("hidden")),Str.get_strings(pageCountStrings).then((_ref2=>{let[showingParticipantCountString,selectCountString]=_ref2;root.querySel
ector(Selectors_showCountText).innerHTML=showingParticipantCountString,selectCountString&&checkCountButton&&(checkCountButton.value=selectCountString)})).catch(_notification.default.exception)}))}}));
//# sourceMappingURL=participants.min.js.map