Proyectos de Subversion Moodle

Rev

Rev 1 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

{"version":3,"file":"event_form.min.js","sources":["../src/event_form.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 * A javascript module to enhance the event form.\n *\n * @module     core_calendar/event_form\n * @copyright  2017 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core_calendar/repository', 'core/notification'], function($, CalendarRepository, Notification) {\n\n    var SELECTORS = {\n        EVENT_GROUP_COURSE_ID: '[name=\"groupcourseid\"]',\n        EVENT_GROUP_ID: '[name=\"groupid\"]',\n        SELECT_OPTION: 'option'\n    };\n\n    /**\n     * Listen for when the user changes the group course when configuring\n     * a group event and filter the options in the group select to only\n     * show the groups available within the course the user has selected.\n     *\n     * @method addCourseGroupSelectListeners\n     * @param {object} formElement The root form element\n     */\n    var addCourseGroupSelectListeners = function(formElement) {\n        var courseGroupSelect = formElement.find(SELECTORS.EVENT_GROUP_COURSE_ID);\n\n        var loadGroupSelectOptions = function(groups) {\n            var groupSelect = formElement.find(SELECTORS.EVENT_GROUP_ID),\n                groupSelectOptions = groupSelect.find(SELECTORS.SELECT_OPTION),\n                courseGroups = $(groups);\n\n            // Let's clear all options first.\n            groupSelectOptions.remove();\n            groupSelect.prop(\"disabled\", false);\n            courseGroups.each(function(id, group) {\n                $(groupSelect).append($(\"<option></option>\").attr(\"value\", group.id).text(group.name));\n            });\n        };\n\n        // If the user choose a course in the selector do a WS request to get groups.\n        courseGroupSelect.on('change', function() {\n            var courseId = formElement.find(SELECTORS.EVENT_GROUP_COURSE_ID).val();\n            if (isNaN(courseId) || courseId <= 0) {\n                loadGroupSelectOptions([]);\n            } else {\n                CalendarRepository.getCourseGroupsData(courseId)\n                    .then(function(groups) {\n                        return loadGroupSelectOptions(groups);\n                    })\n                    .catch(Notification.exception);\n            }\n        });\n    };\n\n    /**\n     * Initialise all of the form enhancements.\n     *\n     * @method init\n     * @param {string} formId The value of the form's id attribute\n     */\n    var init = function(formId) {\n        var formElement = $('#' + formId);\n        addCourseGroupSelectListeners(formElement);\n    };\n\n    return {\n        init: init,\n    };\n});\n"],"names":["define","$","CalendarRepository","Notification","SELECTORS","init","formId","formElement","courseGroupSelect","find","loadGroupSelectOptions","groups","groupSelect","groupSelectOptions","courseGroups","remove","prop","each","id","group","append","attr","text","name","on","courseId","val","isNaN","getCourseGroupsData","then","catch","exception","addCourseGroupSelectListeners"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,SAAU,2BAA4B,sBAAsB,SAASC,EAAGC,mBAAoBC,kBAE5FC,gCACuB,yBADvBA,yBAEgB,mBAFhBA,wBAGe,eAqDZ,CACHC,KANO,SAASC,SArCgB,SAASC,iBACrCC,kBAAoBD,YAAYE,KAAKL,iCAErCM,uBAAyB,SAASC,YAC9BC,YAAcL,YAAYE,KAAKL,0BAC/BS,mBAAqBD,YAAYH,KAAKL,yBACtCU,aAAeb,EAAEU,QAGrBE,mBAAmBE,SACnBH,YAAYI,KAAK,YAAY,GAC7BF,aAAaG,MAAK,SAASC,GAAIC,OAC3BlB,EAAEW,aAAaQ,OAAOnB,EAAE,qBAAqBoB,KAAK,QAASF,MAAMD,IAAII,KAAKH,MAAMI,WAKxFf,kBAAkBgB,GAAG,UAAU,eACvBC,SAAWlB,YAAYE,KAAKL,iCAAiCsB,MAC7DC,MAAMF,WAAaA,UAAY,EAC/Bf,uBAAuB,IAEvBR,mBAAmB0B,oBAAoBH,UAClCI,MAAK,SAASlB,eACJD,uBAAuBC,WAEjCmB,MAAM3B,aAAa4B,cAahCC,CADkB/B,EAAE,IAAMK"}