Rev 1 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
{"version":3,"file":"user.min.js","sources":["../src/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 within the user report.\n *\n * @module gradereport_user/user\n * @copyright 2023 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimp
ort UserSearch from 'core_user/comboboxsearch/user';\nimport {renderForPromise, replaceNodeContents} from 'core/templates';\nimport * as Repository from 'core_grades/searchwidget/repository';\n\nexport default class User extends UserSearch {\n\n /**\n * Construct the class.\n *\n * @param {string} baseUrl The base URL for the page.\n */\n constructor(baseUrl) {\n super();\n this.baseUrl = baseUrl;\n }\n\n static init(baseUrl) {\n return new User(baseUrl);\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 instance: this.instance,\n matches: this.getDatasetSize(),\n searchterm: this.getSearchTerm(),\n selectall: this.selectAllResultsLink(),\n });\n
replaceNodeContents(this.getHTMLElements().searchDropdown, html, js);\n // Remove aria-activedescendant when the available options change.\n this.searchInput.removeAttribute('aria-activedescendant');\n }\n\n /**\n * Build up the view all link.\n *\n * @returns {string|*}\n */\n selectAllResultsLink() {\n const url = new URL(this.baseUrl);\n url.searchParams.set('userid', 0);\n url.searchParams.set('searchvalue', this.getSearchTerm());\n return url.toString();\n }\n\n /**\n * Build up the link that is dedicated to a particular result.\n *\n * @param {Number} userID The ID of the user selected.\n * @returns {string|*}\n */\n selectOneLink(userID) {\n const url = new URL(this.baseUrl);\n url.searchParams.set('userid', userID);\n url.searchParams.set('searchvalue', this.getSearchTerm());\n return url.toString();\n }\n\n /**\n * Get the data we will be searching against in
this component.\n *\n * @returns {Promise<*>}\n */\n fetchDataset() {\n // Small typing checks as sometimes groups don't exist therefore the element returns a empty string.\n const gts = typeof (this.groupID) === \"string\" && this.groupID === '' ? 0 : this.groupID;\n return Repository.userFetch(this.courseID, gts).then((r) => r.users);\n }\n}\n"],"names":["User","UserSearch","constructor","baseUrl","html","js","users","this","getMatchedResults","slice","hasresults","length","instance","matches","getDatasetSize","searchterm","getSearchTerm","selectall","selectAllResultsLink","getHTMLElements","searchDropdown","searchInput","removeAttribute","url","URL","searchParams","set","toString","selectOneLink","userID","fetchDataset","gts","groupID","Repository","userFetch","courseID","then","r"],"mappings":";;;;;;;skCA0BqBA,aAAaC,cAO9BC,YAAYC,sBAEHA,QAAUA,oBAGPA,gBACD,IAAIH,KAAKG,sCAOVC,KAACA,KAADC,GAAOA,UAAY,+BAAiB,qCAAsC,CAC5EC,MAAOC,KAAKC,oBAAoBC,MAAM,EAAG,GACzCC,WAAYH,KAAKC,o
BAAoBG,OAAS,EAC9CC,SAAUL,KAAKK,SACfC,QAASN,KAAKO,iBACdC,WAAYR,KAAKS,gBACjBC,UAAWV,KAAKW,4DAEAX,KAAKY,kBAAkBC,eAAgBhB,KAAMC,SAE5DgB,YAAYC,gBAAgB,yBAQrCJ,6BACUK,IAAM,IAAIC,IAAIjB,KAAKJ,gBACzBoB,IAAIE,aAAaC,IAAI,SAAU,GAC/BH,IAAIE,aAAaC,IAAI,cAAenB,KAAKS,iBAClCO,IAAII,WASfC,cAAcC,cACJN,IAAM,IAAIC,IAAIjB,KAAKJ,gBACzBoB,IAAIE,aAAaC,IAAI,SAAUG,QAC/BN,IAAIE,aAAaC,IAAI,cAAenB,KAAKS,iBAClCO,IAAII,WAQfG,qBAEUC,IAAgC,iBAAlBxB,KAAKyB,SAA0C,KAAjBzB,KAAKyB,QAAiB,EAAIzB,KAAKyB,eAC1EC,WAAWC,UAAU3B,KAAK4B,SAAUJ,KAAKK,MAAMC,GAAMA,EAAE/B"}