Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/message/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/message/amd/build/message_drawer_view_contacts_section_requests.min.js.map

{"version":3,"sources":["../src/message_drawer_view_contacts_section_requests.js"],"names":["define","$","Notification","PubSub","Templates","MessageRepository","MessageDrawerEvents","LazyLoadList","SELECTORS","CONTACT_REQUEST","TEMPLATES","REQUESTS_LIST","render","contentContainer","requests","formattedRequests","map","request","id","profileimageurl","fullname","then","html","append","catch","exception","load","listRoot","userId","getContactRequests","setLoadedAll","handleContactRequestProcessed","root","find","userid","remove","contactRequests","length","showEmptyMessage","hideContent","registerEventListeners","subscribe","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","show","attr"],"mappings":"AAuBAA,OAAM,8DACN,CACI,QADJ,CAEI,mBAFJ,CAGI,aAHJ,CAII,gBAJJ,CAKI,iCALJ,CAMI,oCANJ,CAOI,4CAPJ,CADM,CAUN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQE,IAEMC,CAAAA,CAAS,CAAG,CACZC,eAAe,CAAE,mCADL,CAFlB,CAMMC,CAAS,CAAG,CACZC,aAAa,CAAE,sEADH,CANlB,CAiBMC,CAAM,CAAG,SAASC,CAAT,CAA2BC,CAA3B,CAAqC,CAC9C,GAAIC,CAAAA,CAAiB,CAAGD,CAAQ,CAACE,GAAT,CAAa,SAASC,CAAT,CAAkB,CACnD,MAAO,CAEHC,EAAE,CAAED,CAAO,CAACC,EAFT,CAGHC,eAAe,CAAEF,CAAO,CAACE,eAHtB,CAIHC,QAAQ,CAAEH,CAAO,CAACG,QAJf,CAMV,CAPuB,CAAxB,CAQA,MAAOhB,CAAAA,CAAS,CAACQ,MAAV,CAAiBF,CAAS,CAACC,aAA3B,CAA0C,CAACG,QAAQ,CAAEC,CAAX,CAA1C,EACFM,IADE,CACG,SAASC,CAAT,C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AACa,IAAL,CAAU,oBAAV,IACH,CAGDtC,CAAY,CAACqC,IAAb,CAAkBZ,CAAlB,CAAwBN,CAAxB,CAA8Bd,CAA9B,CACH,CAEM,CAGV,CAnHK,CAAN","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 * @package    message\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 formattedRequests = 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_REQUEST_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"],"file":"message_drawer_view_contacts_section_requests.min.js"}