MDL-59365 enrol: Switch the user selector
[moodle.git] / enrol / manual / amd / build / form-potential-user-selector.min.js
blob1ae8096143ebbab00095431594099b8dbfe100c0
1 define(["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d},transport:function(d,e,f,g){var h,i=a(d).attr("courseid");"undefined"==typeof i&&(i="1");var j=a(d).attr("enrolid");"undefined"==typeof j&&(j=""),h=b.call([{methodname:"core_enrol_get_potential_users",args:{courseid:i,enrolid:j,search:e,searchanywhere:!0,page:0,perpage:30}}]),h[0].then(function(b){var d=[],e=0;return a.each(b,function(b,e){var f=e,g=[];a.each(["idnumber","email","phone1","phone2","department","institution"],function(a,b){"undefined"!=typeof e[b]&&""!==e[b]&&(f.hasidentity=!0,g.push(e[b]))}),f.identity=g.join(", "),d.push(c.render("enrol_manual/form-user-selector-suggestion",f))}),a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[e],e++}),f(b)})},g)}}});