Sindbad~EG File Manager

Current Path : /var/www/html/aprender.faexito.org/user/amd/build/comboboxsearch/
Upload File :
Current File : /var/www/html/aprender.faexito.org/user/amd/build/comboboxsearch/user.min.js.map

{"version":3,"file":"user.min.js","sources":["../../src/comboboxsearch/user.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 * Allow the user to search for learners.\n *\n * @module    core_user/comboboxsearch/user\n * @copyright 2023 Mathew May <mathew.solutions>\n * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport search_combobox from 'core/comboboxsearch/search_combobox';\nimport {getStrings} from 'core/str';\nimport {renderForPromise, replaceNodeContents} from 'core/templates';\nimport $ from 'jquery';\nimport Notification from 'core/notification';\n\nexport default class UserSearch extends search_combobox {\n\n    courseID;\n    groupID;\n\n    // A map of user profile field names that is human-readable.\n    profilestringmap = null;\n\n    constructor() {\n        super();\n        // Register a small click event onto the document since we need to check if they are clicking off the component.\n        document.addEventListener('click', (e) => {\n            // Since we are handling dropdowns manually, ensure we can close it when clicking off.\n            if (!e.target.closest(this.selectors.component) && this.searchDropdown.classList.contains('show')) {\n                this.toggleDropdown();\n            }\n        });\n\n        // Define our standard lookups.\n        this.selectors = {...this.selectors,\n            courseid: '[data-region=\"courseid\"]',\n            groupid: '[data-region=\"groupid\"]',\n            resetPageButton: '[data-action=\"resetpage\"]',\n        };\n\n        const component = document.querySelector(this.componentSelector());\n        this.courseID = component.querySelector(this.selectors.courseid).dataset.courseid;\n        this.groupID = document.querySelector(this.selectors.groupid)?.dataset?.groupid;\n    }\n\n    static init() {\n        return new UserSearch();\n    }\n\n    /**\n     * The overall div that contains the searching widget.\n     *\n     * @returns {string}\n     */\n    componentSelector() {\n        return '.user-search';\n    }\n\n    /**\n     * The dropdown div that contains the searching widget result space.\n     *\n     * @returns {string}\n     */\n    dropdownSelector() {\n        return '.usersearchdropdown';\n    }\n\n    /**\n     * The triggering div that contains the searching widget.\n     *\n     * @returns {string}\n     */\n    triggerSelector() {\n        return '.usersearchwidget';\n    }\n\n    /**\n     * Build the content then replace the node.\n     */\n    async renderDropdown() {\n        const {html, js} = await renderForPromise('core_user/comboboxsearch/resultset', {\n            users: this.getMatchedResults().slice(0, 5),\n            hasresults: this.getMatchedResults().length > 0,\n            matches: this.getMatchedResults().length,\n            searchterm: this.getSearchTerm(),\n            selectall: this.selectAllResultsLink(),\n        });\n        replaceNodeContents(this.getHTMLElements().searchDropdown, html, js);\n    }\n\n    /**\n     * Get the data we will be searching against in this component.\n     *\n     * @returns {Promise<*>}\n     */\n    fetchDataset() {\n        throw new Error(`fetchDataset() must be implemented in ${this.constructor.name}`);\n    }\n\n    /**\n     * Dictate to the search component how and what we want to match upon.\n     *\n     * @param {Array} filterableData\n     * @returns {Array} The users that match the given criteria.\n     */\n    async filterDataset(filterableData) {\n        const stringMap = await this.getStringMap();\n        return filterableData.filter((user) => Object.keys(user).some((key) => {\n            if (user[key] === \"\" || user[key] === null || !stringMap.get(key)) {\n                return false;\n            }\n            return user[key].toString().toLowerCase().includes(this.getPreppedSearchTerm());\n        }));\n    }\n\n    /**\n     * Given we have a subset of the dataset, set the field that we matched upon to inform the end user.\n     *\n     * @returns {Array} The results with the matched fields inserted.\n     */\n    async filterMatchDataset() {\n        const stringMap = await this.getStringMap();\n        this.setMatchedResults(\n            this.getMatchedResults().map((user) => {\n                for (const [key, value] of Object.entries(user)) {\n                    // Sometimes users have null values in their profile fields.\n                    if (value === null) {\n                        continue;\n                    }\n\n                    const valueString = value.toString().toLowerCase();\n                    const preppedSearchTerm = this.getPreppedSearchTerm();\n                    const searchTerm = this.getSearchTerm();\n\n                    // Ensure we match only on expected keys.\n                    const matchingFieldName = stringMap.get(key);\n                    if (matchingFieldName && valueString.includes(preppedSearchTerm)) {\n                        user.matchingFieldName = matchingFieldName;\n\n                        // Safely prepare our matching results.\n                        const escapedValueString = valueString.replace(/</g, '&lt;');\n                        const escapedMatchingField = escapedValueString.replace(\n                            preppedSearchTerm.replace(/</g, '&lt;'),\n                            `<span class=\"font-weight-bold\">${searchTerm.replace(/</g, '&lt;')}</span>`\n                        );\n\n                        if (user.email) {\n                            user.matchingField = `${escapedMatchingField} (${user.email})`;\n                        } else {\n                            user.matchingField = escapedMatchingField;\n                        }\n                        user.link = this.selectOneLink(user.id);\n                        break;\n                    }\n                }\n                return user;\n            })\n        );\n    }\n\n    /**\n     * The handler for when a user interacts with the component.\n     *\n     * @param {MouseEvent} e The triggering event that we are working with.\n     */\n    clickHandler(e) {\n        super.clickHandler(e).catch(Notification.exception);\n        if (e.target.closest(this.selectors.component)) {\n            // Forcibly prevent BS events so that we can control the open and close.\n            // Really needed because by default input elements cant trigger a dropdown.\n            e.stopImmediatePropagation();\n        }\n        if (e.target === this.getHTMLElements().currentViewAll && e.button === 0) {\n            window.location = this.selectAllResultsLink();\n        }\n        if (e.target.closest(this.selectors.resetPageButton)) {\n            window.location = e.target.closest(this.selectors.resetPageButton).href;\n        }\n    }\n\n    /**\n     * The handler for when a user presses a key within the component.\n     *\n     * @param {KeyboardEvent} e The triggering event that we are working with.\n     */\n    keyHandler(e) {\n        super.keyHandler(e);\n\n        if (e.target === this.getHTMLElements().currentViewAll && (e.key === 'Enter' || e.key === 'Space')) {\n            window.location = this.selectAllResultsLink();\n        }\n\n        // Switch the key presses to handle keyboard nav.\n        switch (e.key) {\n            case 'Enter':\n            case ' ':\n                if (document.activeElement === this.getHTMLElements().searchInput) {\n                    if (e.key === 'Enter' && this.selectAllResultsLink() !== null) {\n                        window.location = this.selectAllResultsLink();\n                    }\n                }\n                if (document.activeElement === this.getHTMLElements().clearSearchButton) {\n                    this.closeSearch(true);\n                    break;\n                }\n                if (e.target.closest(this.selectors.resetPageButton)) {\n                    window.location = e.target.closest(this.selectors.resetPageButton).href;\n                    break;\n                }\n                if (e.target.closest('.dropdown-item')) {\n                    e.preventDefault();\n                    window.location = e.target.closest('.dropdown-item').href;\n                    break;\n                }\n                break;\n            case 'Escape':\n                this.toggleDropdown();\n                this.searchInput.focus({preventScroll: true});\n                break;\n            case 'Tab':\n                // If the current focus is on clear search, then check if viewall exists then around tab to it.\n                if (e.target.closest(this.selectors.clearSearch)) {\n                    if (this.currentViewAll && !e.shiftKey) {\n                        e.preventDefault();\n                        this.currentViewAll.focus({preventScroll: true});\n                    } else {\n                        this.closeSearch();\n                    }\n                }\n                break;\n        }\n    }\n\n    /**\n     * When called, hide or show the users dropdown.\n     *\n     * @param {Boolean} on Flag to toggle hiding or showing values.\n     */\n    toggleDropdown(on = false) {\n        if (on) {\n            this.searchDropdown.classList.add('show');\n            $(this.searchDropdown).show();\n            this.component.setAttribute('aria-expanded', 'true');\n        } else {\n            this.searchDropdown.classList.remove('show');\n            $(this.searchDropdown).hide();\n            this.component.setAttribute('aria-expanded', 'false');\n        }\n    }\n\n    /**\n     * Build up the view all link.\n     */\n    selectAllResultsLink() {\n        throw new Error(`selectAllResultsLink() must be implemented in ${this.constructor.name}`);\n    }\n\n    /**\n     * Build up the view all link that is dedicated to a particular result.\n     *\n     * @param {Number} userID The ID of the user selected.\n     */\n    selectOneLink(userID) {\n        throw new Error(`selectOneLink(${userID}) must be implemented in ${this.constructor.name}`);\n    }\n\n    /**\n     * Given the set of profile fields we can possibly search, fetch their strings,\n     * so we can report to screen readers the field that matched.\n     *\n     * @returns {Promise<void>}\n     */\n    getStringMap() {\n        if (!this.profilestringmap) {\n            const requiredStrings = [\n                'username',\n                'fullname',\n                'firstname',\n                'lastname',\n                'email',\n                'city',\n                'country',\n                'department',\n                'institution',\n                'idnumber',\n                'phone1',\n                'phone2',\n            ];\n            this.profilestringmap = getStrings(requiredStrings.map((key) => ({key})))\n                .then((stringArray) => new Map(\n                    requiredStrings.map((key, index) => ([key, stringArray[index]]))\n                ));\n        }\n        return this.profilestringmap;\n    }\n}\n"],"names":["UserSearch","search_combobox","constructor","document","addEventListener","e","target","closest","this","selectors","component","searchDropdown","classList","contains","toggleDropdown","courseid","groupid","resetPageButton","querySelector","componentSelector","courseID","dataset","groupID","_document$querySelect","_document$querySelect2","dropdownSelector","triggerSelector","html","js","users","getMatchedResults","slice","hasresults","length","matches","searchterm","getSearchTerm","selectall","selectAllResultsLink","getHTMLElements","fetchDataset","Error","name","filterableData","stringMap","getStringMap","filter","user","Object","keys","some","key","get","toString","toLowerCase","includes","getPreppedSearchTerm","setMatchedResults","map","value","entries","valueString","preppedSearchTerm","searchTerm","matchingFieldName","escapedMatchingField","replace","email","matchingField","link","selectOneLink","id","clickHandler","catch","Notification","exception","stopImmediatePropagation","currentViewAll","button","window","location","href","keyHandler","activeElement","searchInput","clearSearchButton","closeSearch","preventDefault","focus","preventScroll","clearSearch","shiftKey","add","show","setAttribute","remove","hide","userID","profilestringmap","requiredStrings","then","stringArray","Map","index"],"mappings":"+rBA4BqBA,mBAAmBC,yBAQpCC,8LAFmB,MAKfC,SAASC,iBAAiB,SAAUC,KAE3BA,EAAEC,OAAOC,QAAQC,KAAKC,UAAUC,YAAcF,KAAKG,eAAeC,UAAUC,SAAS,cACjFC,yBAKRL,UAAY,IAAID,KAAKC,UACtBM,SAAU,2BACVC,QAAS,0BACTC,gBAAiB,mCAGfP,UAAYP,SAASe,cAAcV,KAAKW,0BACzCC,SAAWV,UAAUQ,cAAcV,KAAKC,UAAUM,UAAUM,QAAQN,cACpEO,sCAAUnB,SAASe,cAAcV,KAAKC,UAAUO,0EAAtCO,sBAAgDF,iDAAhDG,uBAAyDR,6BAIjE,IAAIhB,WAQfmB,0BACW,eAQXM,yBACW,sBAQXC,wBACW,iDAODC,KAACA,KAADC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