Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"mutations.min.js","sources":["../../src/moodlenet/mutations.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 * MoodleNet mutations.\n * An instance of this class will be used to add custom mutations to the course editor.\n *\n * @module     core/moodlenet/mutations\n * @copyright  2023 Huong Nguyen <huongnv13@gmail.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      4.3\n */\n\nimport DefaultMutations from 'core_courseformat/local/courseeditor/mutations';\nimport {getCurrentCourseEditor} from 'core_courseformat/courseeditor';\nimport CourseActions from 'core_courseformat/local/content/actions';\nimport {subscribe} from 'core/pubsub';\nimport {handleModal} from 'core/moodlenet/send_resource';\nimport MoodleNetEvents from 'core/moodlenet/events';\n\nclass MoodleNetMutations extends DefaultMutations {\n\n    /**\n     * Share to MoodleNet.\n     *\n     * @param {StateManager} stateManager the current state manager\n     * @param {array} cmIds Course module ids.\n     */\n    shareToMoodleNet = async function(stateManager, cmIds) {\n        if (cmIds.length == 0) {\n            return;\n        }\n        this.cmLock(stateManager, cmIds, true);\n        handleModal('partial', cmIds);\n        this.cmLock(stateManager, cmIds, false);\n        subscribe(MoodleNetEvents.MOODLENET_SHARE_STARTED, () => {\n            // Only clear the selection if the user starts the sharing.\n            this.bulkReset(stateManager);\n        });\n    };\n}\n\n/**\n * Initialize.\n */\nexport const init = () => {\n    const courseEditor = getCurrentCourseEditor();\n    courseEditor.addMutations(new MoodleNetMutations());\n    // Add direct mutation content actions.\n    CourseActions.addActions({\n        cmShareToMoodleNet: 'shareToMoodleNet'\n    });\n};\n"],"names":["MoodleNetMutations","DefaultMutations","async","stateManager","cmIds","length","cmLock","MoodleNetEvents","MOODLENET_SHARE_STARTED","bulkReset","addMutations","addActions","cmShareToMoodleNet"],"mappings":"ymBAgCMA,2BAA2BC,6EAQVC,eAAeC,aAAcC,OACxB,GAAhBA,MAAMC,cAGLC,OAAOH,aAAcC,OAAO,kCACrB,UAAWA,YAClBE,OAAOH,aAAcC,OAAO,yBACvBG,gBAAgBC,yBAAyB,UAE1CC,UAAUN,6KAQP,MACK,0CACRO,aAAa,IAAIV,qCAEhBW,WAAW,CACrBC,mBAAoB"}