Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"group-user-selector.min.js","sources":["../src/group-user-selector.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Search user selector module.\n *\n * @module block_dash/group-user-selector\n * @copyright 2017 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n\n    return /** @alias module:block_dash/group-user-selector */ {\n\n        processResults: function(selector, results) {\n            var users = [];\n            $.each(results, function(index, user) {\n                users.push({\n                    value: user.id,\n                    label: user._label\n                });\n            });\n            return users;\n        },\n\n        transport: function(selector, query, success, failure) {\n            var promise;\n\n            // Search within specific course if known and if the 'search within' dropdown is set\n            // to search within course or activity.\n            var args = {query: query};\n\n            var groupid = $(selector).data('groupid');\n            if (typeof groupid !== \"undefined\" && $('#id_searchwithin').val() !== '') {\n                args.groupid = groupid;\n            } else {\n                args.groupid = 0;\n            }\n\n            // Call AJAX request.\n            promise = Ajax.call([{methodname: 'block_dash_groups_get_non_members', args: args}]);\n\n            // When AJAX request returns, handle the results.\n            promise[0].then(function(results) {\n                var promises = [];\n\n                // Render label with user name and picture.\n                $.each(results, function(index, user) {\n                    promises.push(Templates.render('mod_assign/list_participant_user_summary', user));\n                });\n\n                // Apply the label to the results.\n                return $.when.apply($.when, promises).then(function() {\n                    var args = arguments;\n                    var i = 0;\n                    $.each(results, function(index, user) {\n                        user._label = args[i++];\n                    });\n                    success(results);\n                    return;\n                });\n\n            }).fail(failure);\n        }\n\n    };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","args","groupid","data","val","call","methodname","then","promises","render","when","apply","arguments","i","fail"],"mappings":";;;;;;;AAuBAA,wCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBAEL,CAEvDC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAKtCC,KAAO,CAACH,MAAOA,OAEfI,QAAUpB,EAAEI,UAAUiB,KAAK,gBACR,IAAZD,SAA2D,KAAhCpB,EAAE,oBAAoBsB,MACxDH,KAAKC,QAAUA,QAEfD,KAAKC,QAAU,EAITnB,KAAKsB,KAAK,CAAC,CAACC,WAAY,oCAAqCL,KAAMA,QAGrE,GAAGM,MAAK,SAASpB,aACjBqB,SAAW,UAGf1B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BiB,SAAShB,KAAKR,UAAUyB,OAAO,2CAA4ClB,UAIxET,EAAE4B,KAAKC,MAAM7B,EAAE4B,KAAMF,UAAUD,MAAK,eACnCN,KAAOW,UACPC,EAAI,EACR/B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BA,KAAKK,OAASK,KAAKY,QAEvBd,QAAQZ,eAIb2B,KAAKd"}