diff --git a/amd/build/userselector.min.js b/amd/build/userselector.min.js index e236ab5..04a5f85 100644 --- a/amd/build/userselector.min.js +++ b/amd/build/userselector.min.js @@ -5,6 +5,6 @@ define("report_customsql/userselector",["exports","core/ajax","core/templates"], * @module report_customsql/userselector * @copyright 2020 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.processResults=function(selector,results){return results.map((function(user){return{value:user.id,label:user._label}}))},_exports.transport=function(selector,query,success,failure){_ajax.default.call([{methodname:"report_customsql_get_users",args:{query:query,capability:document.getElementById("id_capability").value}}])[0].then((function(results){return Promise.all(results.map((function(user){return _templates.default.render("report_customsql/form-user-selector-suggestion",user).then((function(html){return user._label=html,user}))})))})).then(success).catch(failure)},_ajax=_interopRequireDefault(_ajax),_templates=_interopRequireDefault(_templates)})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.processResults=function(selector,results){return results.map((user=>({value:user.id,label:user._label})))},_exports.transport=function(selector,query,success,failure){_ajax.default.call([{methodname:"report_customsql_get_users",args:{query:query,capability:document.getElementById("id_capability").value}}])[0].then((results=>Promise.all(results.map((user=>_templates.default.render("report_customsql/form-user-selector-suggestion",user).then((html=>(user._label=html,user)))))))).then(success).catch(failure)},_ajax=_interopRequireDefault(_ajax),_templates=_interopRequireDefault(_templates)})); //# sourceMappingURL=userselector.min.js.map \ No newline at end of file diff --git a/amd/build/userselector.min.js.map b/amd/build/userselector.min.js.map index 3d894ef..7088de6 100644 --- a/amd/build/userselector.min.js.map +++ b/amd/build/userselector.min.js.map @@ -1 +1 @@ -{"version":3,"file":"userselector.min.js","sources":["../src/userselector.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 .\n\n/**\n * JavaScript module to work with the auto-complete of users.\n *\n * @module report_customsql/userselector\n * @copyright 2020 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\n\n/**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} success To be called with the results, when received.\n * @param {Function} failure To be called with any errors.\n */\nexport function transport(selector, query, success, failure) {\n Ajax.call([{\n methodname: 'report_customsql_get_users',\n args: {\n query: query,\n capability: document.getElementById('id_capability').value\n }\n }])[0]\n\n .then((results) => {\n // For each user in the result, render the display, and set it on the _label field.\n return Promise.all(results.map((user) => {\n return Templates.render('report_customsql/form-user-selector-suggestion', user)\n .then((html) => {\n user._label = html;\n return user;\n });\n }));\n })\n\n .then(success)\n .catch(failure);\n}\n\n/**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\nexport function processResults(selector, results) {\n return results.map((user) => {\n return {\n value: user.id,\n label: user._label\n };\n });\n}\n"],"names":["selector","results","map","user","value","id","label","_label","query","success","failure","call","methodname","args","capability","document","getElementById","then","Promise","all","Templates","render","html","catch"],"mappings":";;;;;;;8FAiE+BA,SAAUC,gBAC9BA,QAAQC,KAAI,SAACC,YACT,CACHC,MAAOD,KAAKE,GACZC,MAAOH,KAAKI,wCAnCEP,SAAUQ,MAAOC,QAASC,uBAC3CC,KAAK,CAAC,CACPC,WAAY,6BACZC,KAAM,CACFL,MAAOA,MACPM,WAAYC,SAASC,eAAe,iBAAiBZ,UAEzD,GAEHa,MAAK,SAAChB,gBAEIiB,QAAQC,IAAIlB,QAAQC,KAAI,SAACC,aACrBiB,mBAAUC,OAAO,iDAAkDlB,MACrEc,MAAK,SAACK,aACHnB,KAAKI,OAASe,KACPnB,eAKtBc,KAAKR,SACLc,MAAMb"} \ No newline at end of file +{"version":3,"file":"userselector.min.js","sources":["../src/userselector.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 .\n\n/**\n * JavaScript module to work with the auto-complete of users.\n *\n * @module report_customsql/userselector\n * @copyright 2020 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Templates from 'core/templates';\n\n/**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} success To be called with the results, when received.\n * @param {Function} failure To be called with any errors.\n */\nexport function transport(selector, query, success, failure) {\n Ajax.call([{\n methodname: 'report_customsql_get_users',\n args: {\n query: query,\n capability: document.getElementById('id_capability').value\n }\n }])[0]\n\n .then((results) => {\n // For each user in the result, render the display, and set it on the _label field.\n return Promise.all(results.map((user) => {\n return Templates.render('report_customsql/form-user-selector-suggestion', user)\n .then((html) => {\n user._label = html;\n return user;\n });\n }));\n })\n\n .then(success)\n .catch(failure);\n}\n\n/**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\nexport function processResults(selector, results) {\n return results.map((user) => {\n return {\n value: user.id,\n label: user._label\n };\n });\n}\n"],"names":["selector","results","map","user","value","id","label","_label","query","success","failure","call","methodname","args","capability","document","getElementById","then","Promise","all","Templates","render","html","catch"],"mappings":";;;;;;;8FAiE+BA,SAAUC,gBAC9BA,QAAQC,KAAKC,OACT,CACHC,MAAOD,KAAKE,GACZC,MAAOH,KAAKI,wCAnCEP,SAAUQ,MAAOC,QAASC,uBAC3CC,KAAK,CAAC,CACPC,WAAY,6BACZC,KAAM,CACFL,MAAOA,MACPM,WAAYC,SAASC,eAAe,iBAAiBZ,UAEzD,GAEHa,MAAMhB,SAEIiB,QAAQC,IAAIlB,QAAQC,KAAKC,MACrBiB,mBAAUC,OAAO,iDAAkDlB,MACrEc,MAAMK,OACHnB,KAAKI,OAASe,KACPnB,aAKtBc,KAAKR,SACLc,MAAMb"} \ No newline at end of file