MDL-63293 enrol_manual: observe user paging config in enrol dialog.
[moodle.git] / enrol / manual / amd / src / form-potential-user-selector.js
index 7fac602..ab38b1e 100644 (file)
@@ -25,9 +25,6 @@
 
 define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax, Templates, Str) {
 
-    /** @var {Number} Maximum number of users to show. */
-    var MAXUSERS = 100;
-
     return /** @alias module:enrol_manual/form-potential-user-selector */ {
 
         processResults: function(selector, results) {
@@ -57,6 +54,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
             if (typeof enrolid === "undefined") {
                 enrolid = '';
             }
+            var perpage = $(selector).attr('perpage');
+            if (typeof perpage === "undefined") {
+                perpage = 100;
+            }
 
             promise = Ajax.call([{
                 methodname: 'core_enrol_get_potential_users',
@@ -66,7 +67,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                     search: query,
                     searchanywhere: true,
                     page: 0,
-                    perpage: MAXUSERS + 1
+                    perpage: perpage + 1
                 }
             }]);
 
@@ -74,7 +75,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                 var promises = [],
                     i = 0;
 
-                if (results.length <= MAXUSERS) {
+                if (results.length <= perpage) {
                     // Render the label.
                     $.each(results, function(index, user) {
                         var ctx = user,
@@ -101,7 +102,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                     });
 
                 } else {
-                    return Str.get_string('toomanyuserstoshow', 'core', '>' + MAXUSERS).then(function(toomanyuserstoshow) {
+                    return Str.get_string('toomanyuserstoshow', 'core', '>' + perpage).then(function(toomanyuserstoshow) {
                         success(toomanyuserstoshow);
                         return;
                     });