diff --git a/amd/build/kanbancomponent.min.js b/amd/build/kanbancomponent.min.js index 5737e1aa..9bff70de 100644 --- a/amd/build/kanbancomponent.min.js +++ b/amd/build/kanbancomponent.min.js @@ -1,3 +1,3 @@ -define("mod_kanban/kanbancomponent",["exports","core/reactive"],(function(_exports,_reactive){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;class _default extends _reactive.BaseComponent{toggleClass(trueFalseOrUndefined,className){void 0!==trueFalseOrUndefined&&(1==trueFalseOrUndefined?this.getElement().classList.add(className):this.getElement().classList.remove(className))}}return _exports.default=_default,_exports.default})); +define("mod_kanban/kanbancomponent",["exports","core/reactive"],(function(_exports,_reactive){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;class _default extends _reactive.BaseComponent{toggleClass(trueFalseOrUndefined,className){void 0!==trueFalseOrUndefined&&(1==trueFalseOrUndefined?this.getElement().classList.add(className):this.getElement().classList.remove(className))}addEventListener(element,event,listener){element&&super.addEventListener(element,event,listener)}}return _exports.default=_default,_exports.default})); //# sourceMappingURL=kanbancomponent.min.js.map \ No newline at end of file diff --git a/amd/build/kanbancomponent.min.js.map b/amd/build/kanbancomponent.min.js.map index c712d320..92037c0d 100644 --- a/amd/build/kanbancomponent.min.js.map +++ b/amd/build/kanbancomponent.min.js.map @@ -1 +1 @@ -{"version":3,"file":"kanbancomponent.min.js","sources":["../src/kanbancomponent.js"],"sourcesContent":["import {BaseComponent} from 'core/reactive';\n\n/**\n * Component representing a card in a kanban board.\n */\nexport default class extends BaseComponent {\n /**\n * Does nothing if trueFalseOrUndefined is undefined.\n * If it is true, class is added to elements classList else it is removed.\n *\n * @param {*} trueFalseOrUndefined\n * @param {*} className\n */\n toggleClass(trueFalseOrUndefined, className) {\n if (trueFalseOrUndefined !== undefined) {\n if (trueFalseOrUndefined == true) {\n this.getElement().classList.add(className);\n } else {\n this.getElement().classList.remove(className);\n }\n }\n }\n}"],"names":["BaseComponent","toggleClass","trueFalseOrUndefined","className","undefined","getElement","classList","add","remove"],"mappings":"qMAK6BA,wBAQzBC,YAAYC,qBAAsBC,gBACDC,IAAzBF,uBAC4B,GAAxBA,0BACKG,aAAaC,UAAUC,IAAIJ,gBAE3BE,aAAaC,UAAUE,OAAOL"} \ No newline at end of file +{"version":3,"file":"kanbancomponent.min.js","sources":["../src/kanbancomponent.js"],"sourcesContent":["import {BaseComponent} from 'core/reactive';\n\n/**\n * Component representing a card in a kanban board.\n */\nexport default class extends BaseComponent {\n /**\n * Does nothing if trueFalseOrUndefined is undefined.\n * If it is true, class is added to elements classList else it is removed.\n *\n * @param {*} trueFalseOrUndefined\n * @param {*} className\n */\n toggleClass(trueFalseOrUndefined, className) {\n if (trueFalseOrUndefined !== undefined) {\n if (trueFalseOrUndefined == true) {\n this.getElement().classList.add(className);\n } else {\n this.getElement().classList.remove(className);\n }\n }\n }\n\n /**\n * Helper function to add an event listener to an element if it exists.\n * @param {*} element\n * @param {*} event\n * @param {*} listener\n */\n addEventListener(element, event, listener) {\n if (element) {\n super.addEventListener(element, event, listener);\n }\n }\n}"],"names":["BaseComponent","toggleClass","trueFalseOrUndefined","className","undefined","getElement","classList","add","remove","addEventListener","element","event","listener"],"mappings":"qMAK6BA,wBAQzBC,YAAYC,qBAAsBC,gBACDC,IAAzBF,uBAC4B,GAAxBA,0BACKG,aAAaC,UAAUC,IAAIJ,gBAE3BE,aAAaC,UAAUE,OAAOL,YAW/CM,iBAAiBC,QAASC,MAAOC,UACzBF,eACMD,iBAAiBC,QAASC,MAAOC"} \ No newline at end of file diff --git a/amd/src/kanbancomponent.js b/amd/src/kanbancomponent.js index 4f96fbce..1a664324 100644 --- a/amd/src/kanbancomponent.js +++ b/amd/src/kanbancomponent.js @@ -20,4 +20,16 @@ export default class extends BaseComponent { } } } + + /** + * Helper function to add an event listener to an element if it exists. + * @param {*} element + * @param {*} event + * @param {*} listener + */ + addEventListener(element, event, listener) { + if (element) { + super.addEventListener(element, event, listener); + } + } } \ No newline at end of file diff --git a/classes/external/get_kanban_content.php b/classes/external/get_kanban_content.php index 3e23b3e3..5c6b0ea2 100644 --- a/classes/external/get_kanban_content.php +++ b/classes/external/get_kanban_content.php @@ -372,9 +372,10 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool $kanbanboard->heading = get_string('courseboard', 'mod_kanban'); $groupselector = null; + $groupmode = groups_get_activity_groupmode($cminfo, $course); if (!$asupdate) { - if (!empty($cminfo->groupmode)) { + if (!empty($groupmode)) { $groupselector = groups_print_activity_menu( $cminfo, new \moodle_url('/mod/kanban/view.php', ['id' => $cminfo->id]), @@ -432,11 +433,11 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool return intval($v->id); }, $members); $ismember = in_array($USER->id, $members); - if ($cminfo->groupmode == SEPARATEGROUPS && !$ismember) { + if ($groupmode == SEPARATEGROUPS && !$ismember) { require_capability('mod/kanban:viewallboards', $context); $restrictcaps = true; } - if ($cminfo->groupmode == VISIBLEGROUPS && !$ismember) { + if ($groupmode == VISIBLEGROUPS && !$ismember) { $restrictcaps = true; } } @@ -457,7 +458,7 @@ public static function execute(int $cmid, int $boardid, int $timestamp = 0, bool $common->lang = str_replace('_', '-', $common->lang); $common->liveupdate = get_config('mod_kanban', 'liveupdatetime'); $common->userboards = $kanban->userboards; - $common->groupmode = $cminfo->groupmode; + $common->groupmode = $groupmode; $common->groupselector = $groupselector; $common->history = $kanban->history; diff --git a/classes/helper.php b/classes/helper.php index 1e2decdc..b7a3e4d0 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -152,10 +152,11 @@ public static function check_permissions_for_user_or_group( return intval($v->id); }, $members); $ismember = in_array($USER->id, $members); - if ($cminfo->groupmode == SEPARATEGROUPS && !$ismember) { + $groupmode = groups_get_activity_groupmode($cminfo, $cminfo->course); + if ($groupmode == SEPARATEGROUPS && !$ismember) { require_capability(constants::MOD_KANBAN_CAPABILITY[$type], $context); } - if ($cminfo->groupmode == VISIBLEGROUPS && !$ismember && $type == constants::MOD_KANBAN_EDIT) { + if ($groupmode == VISIBLEGROUPS && !$ismember && $type == constants::MOD_KANBAN_EDIT) { require_capability(constants::MOD_KANBAN_CAPABILITY[$type], $context); } } diff --git a/view.php b/view.php index 298b13b5..5db880dd 100644 --- a/view.php +++ b/view.php @@ -33,9 +33,8 @@ $id = required_param('id', PARAM_INT); $boardid = optional_param('boardid', 0, PARAM_INT); $userid = optional_param('user', 0, PARAM_INT); -$group = optional_param('group', -1, PARAM_INT); - [$course, $cm] = get_course_and_cm_from_cmid($id, 'kanban'); +[$course, $cm] = get_course_and_cm_from_cmid($id, 'kanban'); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); @@ -55,7 +54,9 @@ $groupselector = ''; $groupid = 0; -if (!empty($cm->groupmode) && $group != 0) { +$groupmode = groups_get_activity_groupmode($cm, $course); + +if (!empty($groupmode)) { $groupid = groups_get_activity_group($cm, true); }