Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"frameworks_datasource.min.js","sources":["../src/frameworks_datasource.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 * Frameworks datasource.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @module     tool_lp/frameworks_datasource\n * @copyright  2016 Frédéric Massart - FMCorz.net\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n    return /** @alias module:tool_lpmigrate/frameworks_datasource */ {\n\n        /**\n         * List frameworks.\n         *\n         * @param {Number} contextId The context ID.\n         * @param {Object} options Additional parameters to pass to the external function.\n         * @return {Promise}\n         */\n        list: function(contextId, options) {\n            var args = {\n                    context: {\n                        contextid: contextId\n                    }\n                };\n\n            $.extend(args, typeof options === 'undefined' ? {} : options);\n            return Ajax.call([{\n                methodname: 'core_competency_list_competency_frameworks',\n                args: args\n            }])[0];\n        },\n\n        /**\n         * Process the results for auto complete elements.\n         *\n         * @param {String} selector The selector of the auto complete element.\n         * @param {Array} results An array or results.\n         * @return {Array} New array of results.\n         */\n        processResults: function(selector, results) {\n            var options = [];\n            $.each(results, function(index, data) {\n                options.push({\n                    value: data.id,\n                    label: data.shortname + ' ' + data.idnumber\n                });\n            });\n            return options;\n        },\n\n        /**\n         * Source of data for Ajax element.\n         *\n         * @param {String} selector The selector of the auto complete element.\n         * @param {String} query The query string.\n         * @param {Function} callback A callback function receiving an array of results.\n         */\n        /* eslint-disable promise/no-callback-in-promise */\n        transport: function(selector, query, callback) {\n            var el = $(selector),\n                contextId = el.data('contextid'),\n                onlyVisible = el.data('onlyvisible');\n\n            if (!contextId) {\n                throw new Error('The attribute data-contextid is required on ' + selector);\n            }\n            this.list(contextId, {\n                query: query,\n                onlyvisible: onlyVisible,\n            }).then(callback).catch(Notification.exception);\n        }\n    };\n\n});\n"],"names":["define","$","Ajax","Notification","list","contextId","options","args","context","contextid","extend","call","methodname","processResults","selector","results","each","index","data","push","value","id","label","shortname","idnumber","transport","query","callback","el","onlyVisible","Error","onlyvisible","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,uCAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEF,CAS7DC,KAAM,SAASC,UAAWC,aAClBC,KAAO,CACHC,QAAS,CACLC,UAAWJ,mBAIvBJ,EAAES,OAAOH,UAAyB,IAAZD,QAA0B,GAAKA,SAC9CJ,KAAKS,KAAK,CAAC,CACdC,WAAY,6CACZL,KAAMA,QACN,IAURM,eAAgB,SAASC,SAAUC,aAC3BT,QAAU,UACdL,EAAEe,KAAKD,SAAS,SAASE,MAAOC,MAC5BZ,QAAQa,KAAK,CACTC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,UAAY,IAAML,KAAKM,cAGpClB,SAWXmB,UAAW,SAASX,SAAUY,MAAOC,cAC7BC,GAAK3B,EAAEa,UACPT,UAAYuB,GAAGV,KAAK,aACpBW,YAAcD,GAAGV,KAAK,mBAErBb,gBACK,IAAIyB,MAAM,+CAAiDhB,eAEhEV,KAAKC,UAAW,CACjBqB,MAAOA,MACPK,YAAaF,cACdG,KAAKL,UAAUM,MAAM9B,aAAa+B"}