diff --git a/lib/amd/build/moodlenet/mutations.min.js b/lib/amd/build/moodlenet/mutations.min.js index bcc097e333a..256cbcd881e 100644 --- a/lib/amd/build/moodlenet/mutations.min.js +++ b/lib/amd/build/moodlenet/mutations.min.js @@ -1,3 +1,3 @@ -define("core/moodlenet/mutations",["exports","core_courseformat/local/courseeditor/mutations","core_courseformat/courseeditor","core_courseformat/local/content/actions","core/pubsub","core/moodlenet/send_resource","core/moodlenet/events"],(function(_exports,_mutations,_courseeditor,_actions,_pubsub,_send_resource,_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_mutations=_interopRequireDefault(_mutations),_actions=_interopRequireDefault(_actions),_events=_interopRequireDefault(_events);class MoodleNetMutations extends _mutations.default{constructor(){var obj,key,value;super(...arguments),value=async function(stateManager,cmIds){this.cmLock(stateManager,cmIds,!0),(0,_send_resource.handleModal)("partial",cmIds),this.cmLock(stateManager,cmIds,!1),(0,_pubsub.subscribe)(_events.default.MOODLENET_SHARE_STARTED,(()=>{this.bulkReset(stateManager)}))},(key="shareToMoodleNet")in(obj=this)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value}}_exports.init=()=>{(0,_courseeditor.getCurrentCourseEditor)().addMutations(new MoodleNetMutations),_actions.default.addActions({cmShareToMoodleNet:"shareToMoodleNet"})}})); +define("core/moodlenet/mutations",["exports","core_courseformat/local/courseeditor/mutations","core_courseformat/courseeditor","core_courseformat/local/content/actions","core/pubsub","core/moodlenet/send_resource","core/moodlenet/events"],(function(_exports,_mutations,_courseeditor,_actions,_pubsub,_send_resource,_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_mutations=_interopRequireDefault(_mutations),_actions=_interopRequireDefault(_actions),_events=_interopRequireDefault(_events);class MoodleNetMutations extends _mutations.default{constructor(){var obj,key,value;super(...arguments),value=async function(stateManager,cmIds){0!=cmIds.length&&(this.cmLock(stateManager,cmIds,!0),(0,_send_resource.handleModal)("partial",cmIds),this.cmLock(stateManager,cmIds,!1),(0,_pubsub.subscribe)(_events.default.MOODLENET_SHARE_STARTED,(()=>{this.bulkReset(stateManager)})))},(key="shareToMoodleNet")in(obj=this)?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value}}_exports.init=()=>{(0,_courseeditor.getCurrentCourseEditor)().addMutations(new MoodleNetMutations),_actions.default.addActions({cmShareToMoodleNet:"shareToMoodleNet"})}})); //# sourceMappingURL=mutations.min.js.map \ No newline at end of file diff --git a/lib/amd/build/moodlenet/mutations.min.js.map b/lib/amd/build/moodlenet/mutations.min.js.map index 76dcde6de55..e6f5b7c9699 100644 --- a/lib/amd/build/moodlenet/mutations.min.js.map +++ b/lib/amd/build/moodlenet/mutations.min.js.map @@ -1 +1 @@ -{"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 .\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 \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 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","cmLock","MoodleNetEvents","MOODLENET_SHARE_STARTED","bulkReset","addMutations","addActions","cmShareToMoodleNet"],"mappings":"ymBAgCMA,2BAA2BC,6EAQVC,eAAeC,aAAcC,YACvCC,OAAOF,aAAcC,OAAO,kCACrB,UAAWA,YAClBC,OAAOF,aAAcC,OAAO,yBACvBE,gBAAgBC,yBAAyB,UAE1CC,UAAUL,4KAQP,MACK,0CACRM,aAAa,IAAIT,qCAEhBU,WAAW,CACrBC,mBAAoB"} \ No newline at end of file +{"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 .\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 \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"} \ No newline at end of file diff --git a/lib/amd/src/moodlenet/mutations.js b/lib/amd/src/moodlenet/mutations.js index ac9fe358786..1ae2244c75f 100644 --- a/lib/amd/src/moodlenet/mutations.js +++ b/lib/amd/src/moodlenet/mutations.js @@ -39,6 +39,9 @@ class MoodleNetMutations extends DefaultMutations { * @param {array} cmIds Course module ids. */ shareToMoodleNet = async function(stateManager, cmIds) { + if (cmIds.length == 0) { + return; + } this.cmLock(stateManager, cmIds, true); handleModal('partial', cmIds); this.cmLock(stateManager, cmIds, false); diff --git a/lib/tests/behat/moodlenet_share_partial_course.feature b/lib/tests/behat/moodlenet_share_partial_course.feature index e89fc9eb1a6..7ee70c4e827 100644 --- a/lib/tests/behat/moodlenet_share_partial_course.feature +++ b/lib/tests/behat/moodlenet_share_partial_course.feature @@ -65,10 +65,13 @@ Feature: MoodleNet outbound share selected activities in a course Given I am on the "C1" "course" page logged in as teacher1 And I turn editing mode on And I click on "Bulk actions" "button" + When I click on "Share to MoodleNet" "button" in the "sticky-footer" "region" + Then "Share to MoodleNet" "dialogue" should not exist And I click on "Select activity Test Assignment 1" "checkbox" And I click on "Select activity Test Assignment 2" "checkbox" - When I click on "Share to MoodleNet" "button" in the "sticky-footer" "region" - Then I should see "Test course 1" in the "Share to MoodleNet" "dialogue" + And I click on "Share to MoodleNet" "button" in the "sticky-footer" "region" + And "Share to MoodleNet" "dialogue" should exist + And I should see "Test course 1" in the "Share to MoodleNet" "dialogue" And I should see "The selected activities are being shared with MoodleNet as a resource." in the "Share to MoodleNet" "dialogue" And I should see "2 activities will be included in the course." in the "Share to MoodleNet" "dialogue" And I click on "Share" "button" in the "Share to MoodleNet" "dialogue"