mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 14:15:11 +02:00
MDL-64438 block_starredcourses: Optionally show course category
AMOS BEGIN CPY [displaycategories,block_myoverview],[displaycategories,block_starredcourses] AMOS END
This commit is contained in:
parent
d0b237b306
commit
60983cc2a6
2
blocks/starredcourses/amd/build/main.min.js
vendored
2
blocks/starredcourses/amd/build/main.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("block_starredcourses/main",["jquery","core/notification","block_starredcourses/repository","core/pubsub","core/templates","core_course/events"],function(a,b,c,d,e,f){var g={STARRED_COURSES_REGION_VIEW:"[data-region=\"starred-courses-view\"]",STARRED_COURSES_REGION:"[data-region=\"starred-courses-view-content\"]"},h=function(a,b){if(0<b.length){return e.render("core_course/view-cards",{courses:b})}else{var c=a.find(g.STARRED_COURSES_REGION_VIEW).attr("data-nocoursesimg");return e.render("block_starredcourses/no-courses",{nocoursesimg:c})}},i=function(a){var d=a.find(g.STARRED_COURSES_REGION);return c.getStarredCourses({limit:0,offset:0}).then(function(b){return h(a,b)}).then(function(a,b){return e.replaceNodeContents(d,a,b)}).catch(b.exception)},j=function(a){d.subscribe(f.favourited,function(){i(a)});d.subscribe(f.unfavorited,function(){i(a)})};return{init:function init(b){b=a(b);j(b);i(b)}}});
|
||||
define ("block_starredcourses/main",["jquery","core/notification","block_starredcourses/repository","core/pubsub","core/templates","core_course/events"],function(a,b,c,d,e,f){var g={BLOCK_CONTAINER:"[data-region=\"starred-courses\"]",STARRED_COURSES_REGION_VIEW:"[data-region=\"starred-courses-view\"]",STARRED_COURSES_REGION:"[data-region=\"starred-courses-view-content\"]"},h=function(a,b){if(0<b.length){return e.render("core_course/view-cards",{courses:b})}else{var c=a.find(g.STARRED_COURSES_REGION_VIEW).attr("data-nocoursesimg");return e.render("block_starredcourses/no-courses",{nocoursesimg:c})}},i=function(d){var f=d.find(g.STARRED_COURSES_REGION);return c.getStarredCourses({limit:0,offset:0}).then(function(b){var c=a(g.BLOCK_CONTAINER).data("displaycoursecategory");b=b.map(function(a){a.showcoursecategory=c;return a});return h(d,b)}).then(function(a,b){return e.replaceNodeContents(f,a,b)}).catch(b.exception)},j=function(a){d.subscribe(f.favourited,function(){i(a)});d.subscribe(f.unfavorited,function(){i(a)})};return{init:function init(b){b=a(b);j(b);i(b)}}});
|
||||
//# sourceMappingURL=main.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -39,6 +39,7 @@ function(
|
||||
) {
|
||||
|
||||
var SELECTORS = {
|
||||
BLOCK_CONTAINER: '[data-region="starred-courses"]',
|
||||
STARRED_COURSES_REGION_VIEW: '[data-region="starred-courses-view"]',
|
||||
STARRED_COURSES_REGION: '[data-region="starred-courses-view-content"]'
|
||||
};
|
||||
@ -80,6 +81,12 @@ function(
|
||||
|
||||
return Repository.getStarredCourses(args)
|
||||
.then(function(courses) {
|
||||
// Whether the course category should be displayed in the course item.
|
||||
var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory');
|
||||
courses = courses.map(function(course) {
|
||||
course.showcoursecategory = showcoursecategory;
|
||||
return course;
|
||||
});
|
||||
return renderCourses(root, courses);
|
||||
}).then(function(html, js) {
|
||||
return Templates.replaceNodeContents(content, html, js);
|
||||
|
@ -72,4 +72,13 @@ class block_starredcourses extends block_base {
|
||||
public function applicable_formats() {
|
||||
return array('my' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the block to have a configuration page
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -50,10 +50,12 @@ class main implements renderable, templatable {
|
||||
global $USER;
|
||||
|
||||
$nocoursesurl = $output->image_url('courses', 'block_starredcourses')->out();
|
||||
$config = get_config('block_starredcourses');
|
||||
|
||||
return [
|
||||
'userid' => $USER->id,
|
||||
'nocoursesimg' => $nocoursesurl
|
||||
'nocoursesimg' => $nocoursesurl,
|
||||
'displaycategories' => !empty($config->displaycategories)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['displaycategories'] = 'Display categories';
|
||||
$string['displaycategories_help'] = 'Display the course category on the starred courses block items.';
|
||||
$string['pluginname'] = 'Starred courses';
|
||||
$string['privacy:metadata'] = 'The starred courses block does not store any personal data.';
|
||||
$string['starredcourses:myaddinstance'] = 'Add a new starred courses block to Dashboard';
|
||||
|
34
blocks/starredcourses/settings.php
Normal file
34
blocks/starredcourses/settings.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Settings for the starredcourses block
|
||||
*
|
||||
* @package block_starredcourses
|
||||
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
// Display Course Categories on the starred courses block items.
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'block_starredcourses/displaycategories',
|
||||
get_string('displaycategories', 'block_starredcourses'),
|
||||
get_string('displaycategories_help', 'block_starredcourses'),
|
||||
1));
|
||||
}
|
@ -23,7 +23,8 @@
|
||||
{}
|
||||
}}
|
||||
|
||||
<div id="block-starredcourses-{{uniqid}}" class="block-starredcourses block-cards" data-region="starred-courses">
|
||||
<div id="block-starredcourses-{{uniqid}}" class="block-starredcourses block-cards" data-region="starred-courses"
|
||||
data-displaycoursecategory="{{displaycategories}}">
|
||||
<div class="container-fluid p-0">
|
||||
{{> block_starredcourses/view }}
|
||||
</div>
|
||||
|
@ -1,5 +1,10 @@
|
||||
This file describes API changes in the starredcourses block code.
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
* New admin setting block_starredcourses/displaycategories which enables the starred courses block
|
||||
to display the course category.
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
* The 'block/starredcourses:addinstance' capability has been removed. It has never been used in code.
|
@ -23,6 +23,6 @@
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2019052000;
|
||||
$plugin->version = 2019052001;
|
||||
$plugin->requires = 2019051100;
|
||||
$plugin->component = 'block_starredcourses';
|
Loading…
x
Reference in New Issue
Block a user