MDL-63293 enrol_manual: observe user paging config in enrol dialog.
[moodle.git] / enrol / manual / amd / build / form-potential-user-selector.min.js.map
1 {"version":3,"sources":["../src/form-potential-user-selector.js"],"names":["define","$","Ajax","Templates","Str","processResults","selector","results","users","isArray","each","index","user","push","value","id","label","_label","transport","query","success","failure","promise","courseid","attr","userfields","split","enrolid","perpage","call","methodname","args","search","searchanywhere","page","then","promises","i","length","ctx","identity","k","hasidentity","join","render","when","apply","arguments","get_string","toomanyuserstoshow","fail"],"mappings":"AAyBAA,OAAM,6CAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,gBAAxB,CAA0C,UAA1C,CAAD,CAAwD,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAA6BC,CAA7B,CAAkC,CAE5F,MAAsE,CAElEC,cAAc,CAAE,wBAASC,CAAT,CAAmBC,CAAnB,CAA4B,CACxC,GAAIC,CAAAA,CAAK,CAAG,EAAZ,CACA,GAAIP,CAAC,CAACQ,OAAF,CAAUF,CAAV,CAAJ,CAAwB,CACpBN,CAAC,CAACS,IAAF,CAAOH,CAAP,CAAgB,SAASI,CAAT,CAAgBC,CAAhB,CAAsB,CAClCJ,CAAK,CAACK,IAAN,CAAW,CACPC,KAAK,CAAEF,CAAI,CAACG,EADL,CAEPC,KAAK,CAAEJ,CAAI,CAACK,MAFL,CAAX,CAIH,CALD,EAMA,MAAOT,CAAAA,CAEV,CATD,IASO,CACH,MAAOD,CAAAA,CACV,CACJ,CAhBiE,CAkBlEW,SAAS,CAAE,mBAASZ,CAAT,CAAmBa,CAAnB,CAA0BC,CAA1B,CAAmCC,CAAnC,CAA4C,IAC/CC,CAAAA,CAD+C,CAE/CC,CAAQ,CAAGtB,CAAC,CAACK,CAAD,CAAD,CAAYkB,IAAZ,CAAiB,UAAjB,CAFoC,CAG/CC,CAAU,CAAGxB,CAAC,CAACK,CAAD,CAAD,CAAYkB,IAAZ,CAAiB,YAAjB,EAA+BE,KAA/B,CAAqC,GAArC,CAHkC,CA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CAClDF,CAAG,CAACG,WAAJ,IACAF,CAAQ,CAAC3B,IAAT,CAAcD,CAAI,CAAC6B,CAAD,CAAlB,CACH,CACJ,CALD,EAMAF,CAAG,CAACC,QAAJ,CAAeA,CAAQ,CAACG,IAAT,CAAc,IAAd,CAAf,CACAP,CAAQ,CAACvB,IAAT,CAAcV,CAAS,CAACyC,MAAV,CAAiB,4CAAjB,CAA+DL,CAA/D,CAAd,CACH,CAXD,EAcA,MAAOtC,CAAAA,CAAC,CAAC4C,IAAF,CAAOC,KAAP,CAAa7C,CAAC,CAAC4C,IAAf,CAAqBT,CAArB,EAA+BD,IAA/B,CAAoC,UAAW,CAClD,GAAIJ,CAAAA,CAAI,CAAGgB,SAAX,CACA9C,CAAC,CAACS,IAAF,CAAOH,CAAP,CAAgB,SAASI,CAAT,CAAgBC,CAAhB,CAAsB,CAClCA,CAAI,CAACK,MAAL,CAAcc,CAAI,CAACM,CAAD,CAAlB,CACAA,CAAC,EACJ,CAHD,EAIAjB,CAAO,CAACb,CAAD,CAEV,CARM,CAUV,CA1BD,IA0BO,CACH,MAAOH,CAAAA,CAAG,CAAC4C,UAAJ,CAAe,oBAAf,CAAqC,MAArC,CAA6C,IAAMpB,CAAnD,EAA4DO,IAA5D,CAAiE,SAASc,CAAT,CAA6B,CACjG7B,CAAO,CAAC6B,CAAD,CAEV,CAHM,CAIV,CAEJ,CArCD,EAqCGC,IArCH,CAqCQ7B,CArCR,CAsCH,CApFiE,CAwFzE,CA1FK,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 * Potential user selector module.\n *\n * @module     enrol_manual/form-potential-user-selector\n * @class      form-potential-user-selector\n * @package    enrol_manual\n * @copyright  2016 Damyon Wiese\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax, Templates, Str) {\n\n    return /** @alias module:enrol_manual/form-potential-user-selector */ {\n\n        processResults: function(selector, results) {\n            var users = [];\n            if ($.isArray(results)) {\n                $.each(results, function(index, user) {\n                    users.push({\n                        value: user.id,\n                        label: user._label\n                    });\n                });\n                return users;\n\n            } else {\n                return results;\n            }\n        },\n\n        transport: function(selector, query, success, failure) {\n            var promise;\n            var courseid = $(selector).attr('courseid');\n            var userfields = $(selector).attr('userfields').split(',');\n            if (typeof courseid === \"undefined\") {\n                courseid = '1';\n            }\n            var enrolid = $(selector).attr('enrolid');\n            if (typeof enrolid === \"undefined\") {\n                enrolid = '';\n            }\n            var perpage = $(selector).attr('perpage');\n            if (typeof perpage === \"undefined\") {\n                perpage = 100;\n            }\n\n            promise = Ajax.call([{\n                methodname: 'core_enrol_get_potential_users',\n                args: {\n                    courseid: courseid,\n                    enrolid: enrolid,\n                    search: query,\n                    searchanywhere: true,\n                    page: 0,\n                    perpage: perpage + 1\n                }\n            }]);\n\n            promise[0].then(function(results) {\n                var promises = [],\n                    i = 0;\n\n                if (results.length <= perpage) {\n                    // Render the label.\n                    $.each(results, function(index, user) {\n                        var ctx = user,\n                            identity = [];\n                        $.each(userfields, function(i, k) {\n                            if (typeof user[k] !== 'undefined' && user[k] !== '') {\n                                ctx.hasidentity = true;\n                                identity.push(user[k]);\n                            }\n                        });\n                        ctx.identity = identity.join(', ');\n                        promises.push(Templates.render('enrol_manual/form-user-selector-suggestion', ctx));\n                    });\n\n                    // Apply the label to the results.\n                    return $.when.apply($.when, promises).then(function() {\n                        var args = arguments;\n                        $.each(results, function(index, user) {\n                            user._label = args[i];\n                            i++;\n                        });\n                        success(results);\n                        return;\n                    });\n\n                } else {\n                    return Str.get_string('toomanyuserstoshow', 'core', '>' + perpage).then(function(toomanyuserstoshow) {\n                        success(toomanyuserstoshow);\n                        return;\n                    });\n                }\n\n            }).fail(failure);\n        }\n\n    };\n\n});\n"],"file":"form-potential-user-selector.min.js"}