moodle/lib/amd/build/form-cohort-selector.min.js

11 lines
1.0 KiB
JavaScript
Raw Normal View History

/**
* Course selector adaptor for auto-complete form element.
*
* @module core/form-cohort-selector
* @copyright 2016 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.1
*/
define("core/form-cohort-selector",["core/ajax","jquery"],(function(ajax,$){return{processResults:function(selector,data){var results=[],i=0,excludelist=String($(selector).data("exclude")).split(",");for(i=0;i<data.cohorts.length;i++)-1===excludelist.indexOf(String(data.cohorts[i].id))&&results.push({value:data.cohorts[i].id,label:data.cohorts[i].name});return results},transport:function(selector,query,success,failure){var promises;void 0===query&&(query="");var calls=[{methodname:"core_cohort_search_cohorts",args:{query:query,includes:"parents",limitfrom:0,limitnum:100,context:{contextid:$(selector).data("contextid")}}}];promises=ajax.call(calls),$.when.apply($.when,promises).done((function(data){success(data)})).fail(failure)}}}));
//# sourceMappingURL=form-cohort-selector.min.js.map