AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"message_drawer_view_contacts_section_requests.min.js","sources":["../src/message_drawer_view_contacts_section_requests.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Controls the requests section of the contacts page.\n *\n * @module core_message/message_drawer_view_contacts_section_requests\n * @copyright 2018
Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/notification',\n 'core/pubsub',\n 'core/templates',\n 'core_message/message_repository',\n 'core_message/message_drawer_events',\n 'core_message/message_drawer_lazy_load_list'\n],\nfunction(\n $,\n Notification,\n PubSub,\n Templates,\n MessageRepository,\n MessageDrawerEvents,\n LazyLoadList\n) {\n\n var SELECTORS = {\n CONTACT_REQUEST: '[data-region=\"contact-request\"]'\n };\n\n var TEMPLATES = {\n REQUESTS_LIST: 'core_message/message_drawer_view_contacts_body_section_requests_list'\n };\n\n /**\n * Render the requests in the content container.\n *\n * @param {Object} contentContainer List container element.\n * @param {Array} requests List of requests.\n * @return {Object} jQuery promise\n */\n var render = function(contentContainer, requests) {\n var formattedReq
uests = requests.map(function(request) {\n return {\n // This is actually the user id.\n id: request.id,\n profileimageurl: request.profileimageurl,\n fullname: request.fullname\n };\n });\n return Templates.render(TEMPLATES.REQUESTS_LIST, {requests: formattedRequests})\n .then(function(html) {\n contentContainer.append(html);\n return html;\n })\n .catch(Notification.exception);\n };\n\n /**\n * Load the user contacts and call the renderer.\n *\n * @param {Object} listRoot The lazy loaded list root element\n * @param {Integer} userId The logged in user id.\n * @return {Object} jQuery promise\n */\n var load = function(listRoot, userId) {\n return MessageRepository.getContactRequests(userId)\n .then(function(requests) {\n LazyLoadList.setLoadedAll(listRoot, true);\n return
requests;\n })\n .catch(Notification.exception);\n };\n\n /**\n * Handle when a contact request is accepted or declined by removing the contact\n * list from the page.\n *\n * @param {Object} root The section root element\n * @return {Function} The event handler function\n */\n var handleContactRequestProcessed = function(root) {\n return function(request) {\n root.find('[data-request-id=\"' + request.userid + '\"]').remove();\n var contactRequests = root.find(SELECTORS.CONTACT_REQUEST);\n\n if (!contactRequests.length) {\n LazyLoadList.showEmptyMessage(root);\n LazyLoadList.hideContent(root);\n }\n };\n };\n\n /**\n * Listen for any events that might affect the requests section.\n *\n * @param {Object} root The section root element\n */\n var registerEventListeners = function(root) {\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQU
EST_ACCEPTED, handleContactRequestProcessed(root));\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED, handleContactRequestProcessed(root));\n };\n\n /**\n * Setup the requests section.\n *\n * @param {Object} root Requests section container.\n */\n var show = function(root) {\n if (!root.attr('data-contacts-init')) {\n registerEventListeners(root);\n root.attr('data-contacts-init', true);\n }\n\n // The root element is already the lazy loaded list root.\n LazyLoadList.show(root, load, render);\n };\n\n return {\n show: show,\n };\n});\n"],"names":["define","$","Notification","PubSub","Templates","MessageRepository","MessageDrawerEvents","LazyLoadList","SELECTORS","TEMPLATES","render","contentContainer","requests","formattedRequests","map","request","id","profileimageurl","fullname","then","html","append","catch","exception","load","listRoot","userId","getContactRequests","setLoadedAll","handleCont
actRequestProcessed","root","find","userid","remove","length","showEmptyMessage","hideContent","show","attr","subscribe","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","registerEventListeners"],"mappings":";;;;;;;AAsBAA,oEACA,CACI,SACA,oBACA,cACA,iBACA,kCACA,qCACA,+CAEJ,SACIC,EACAC,aACAC,OACAC,UACAC,kBACAC,oBACAC,kBAGIC,0BACiB,kCAGjBC,wBACe,uEAUfC,OAAS,SAASC,iBAAkBC,cAChCC,kBAAoBD,SAASE,KAAI,SAASC,eACnC,CAEHC,GAAID,QAAQC,GACZC,gBAAiBF,QAAQE,gBACzBC,SAAUH,QAAQG,oBAGnBd,UAAUM,OAAOD,wBAAyB,CAACG,SAAUC,oBACvDM,MAAK,SAASC,aACXT,iBAAiBU,OAAOD,MACjBA,QAEVE,MAAMpB,aAAaqB,YAUxBC,KAAO,SAASC,SAAUC,eACnBrB,kBAAkBsB,mBAAmBD,QACvCP,MAAK,SAASP,iBACXL,aAAaqB,aAAaH,UAAU,GAC7Bb,YAEVU,MAAMpB,aAAaqB,YAUxBM,8BAAgC,SAASC,aAClC,SAASf,SACZe,KAAKC,KAAK,qBAAuBhB,QAAQiB,OAAS,MAAMC,SAClCH,KAAKC,KAAKvB,2BAEX0B,SACjB3B,aAAa4B,iBAAiBL,MAC9BvB,aAAa6B,YAAYN,eA8B9B,CACHO,KAXO,SAASP,MACXA,KAAKQ,KAAK,yBAXU,SAASR,MAClC3B,OAAOoC,UAAUjC,oBAAoBkC,yBAA0BX,8BAA8BC,OAC7F3B,OAAOoC,UAAUjC,oBAAoBmC,yBAA0BZ,8BAA8BC,OAUzFY,CAAuBZ,MACvBA,KAAKQ,KAAK,
sBAAsB,IAIpC/B,aAAa8B,KAAKP,KAAMN,KAAMd"}