mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
insert a 'View all courses' link when loading category navigation entries from AJAX
This commit is contained in:
parent
56babbcb76
commit
c683165a4a
2 changed files with 24 additions and 8 deletions
22
blocks/navigation/yui/navigation/navigation.js
vendored
22
blocks/navigation/yui/navigation/navigation.js
vendored
|
@ -310,11 +310,18 @@ BRANCH.prototype = {
|
|||
try {
|
||||
var object = Y.JSON.parse(outcome.responseText);
|
||||
if (object.children && object.children.length > 0) {
|
||||
var count = 0;
|
||||
for (var i in object.children) {
|
||||
if (object.children[i].type == 20) {
|
||||
count++;
|
||||
}
|
||||
if (typeof(object.children[i])=='object') {
|
||||
this.addChild(object.children[i]);
|
||||
}
|
||||
}
|
||||
if (this.get('type') == 10 && count >= M.block_navigation.courselimit) {
|
||||
this.addViewAllCoursesChild(this);
|
||||
}
|
||||
this.get('tree').toggleExpansion({target:this.node});
|
||||
return true;
|
||||
}
|
||||
|
@ -345,16 +352,23 @@ BRANCH.prototype = {
|
|||
}
|
||||
}
|
||||
if (branch.get('type') == 10 && count >= M.block_navigation.courselimit) {
|
||||
this.addViewAllCoursesChild(branch);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a link to view all courses in a category
|
||||
*/
|
||||
addViewAllCoursesChild: function(branch) {
|
||||
branch.addChild({
|
||||
name : M.str.moodle.viewallcourses,
|
||||
title : M.str.moodle.viewallcourses,
|
||||
link : M.cfg.wwwroot+'/course/category.php?id='+branch.get('key'),
|
||||
haschildren : false,
|
||||
icon : {'pix':"i/navigationitem",'component':'moodle'}
|
||||
}, branch);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
Y.extend(BRANCH, Y.Base, BRANCH.prototype, {
|
||||
|
|
|
@ -1098,6 +1098,8 @@ class global_navigation extends navigation_node {
|
|||
$this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
$this->page->requires->string_for_js('viewallcourses', 'moodle');
|
||||
|
||||
// Load for the current user
|
||||
$this->load_for_user();
|
||||
if ($this->page->context->contextlevel >= CONTEXT_COURSE && $this->page->context->instanceid != SITEID && $canviewcourseprofile) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue