mirror of
https://github.com/moodle/moodle.git
synced 2025-02-11 19:16:23 +01:00
MDL-80746 gradereport_grader: fix action bar rendering
This code was unnecessarily pre-rendering some context properties used by the action_menu, which also meant the mustache template expected HTML in the context, which should be avoided. Instead of pre-rendering, just export_for_template() and adjust the mustache template to render the sub template for the respective templatables.
This commit is contained in:
parent
b62aff2c3a
commit
cf524d0172
@ -17,7 +17,9 @@
|
||||
namespace gradereport_grader\output;
|
||||
|
||||
use core\output\comboboxsearch;
|
||||
use core_course\output\actionbar\group_selector;
|
||||
use core_course\output\actionbar\initials_selector;
|
||||
use core_course\output\actionbar\user_selector;
|
||||
use core_grades\output\general_action_bar;
|
||||
use moodle_url;
|
||||
|
||||
@ -70,7 +72,7 @@ class action_bar extends \core_grades\output\action_bar {
|
||||
* @throws \moodle_exception
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output): array {
|
||||
global $PAGE, $OUTPUT, $SESSION, $USER;
|
||||
global $SESSION, $USER;
|
||||
// If in the course context, we should display the general navigation selector in gradebook.
|
||||
$courseid = $this->context->instanceid;
|
||||
// Get the data used to output the general navigation selector.
|
||||
@ -94,7 +96,6 @@ class action_bar extends \core_grades\output\action_bar {
|
||||
$additionalparams['gpr_search'] = $this->usersearch;
|
||||
}
|
||||
|
||||
$actionbarrenderer = $PAGE->get_renderer('core_course', 'actionbar');
|
||||
$initialselector = new initials_selector(
|
||||
course: $course,
|
||||
targeturl: '/grade/report/grader/index.php',
|
||||
@ -102,22 +103,22 @@ class action_bar extends \core_grades\output\action_bar {
|
||||
lastinitial: $lastnameinitial,
|
||||
additionalparams: $additionalparams,
|
||||
);
|
||||
$data['initialselector'] = $actionbarrenderer->render($initialselector);
|
||||
$data['initialselector'] = $initialselector->export_for_template($output);
|
||||
|
||||
if ($course->groupmode) {
|
||||
$data['groupselector'] = $actionbarrenderer->render(
|
||||
new \core_course\output\actionbar\group_selector($this->context));
|
||||
$gs = new group_selector($this->context);
|
||||
$data['groupselector'] = $gs->export_for_template($output);
|
||||
}
|
||||
|
||||
$resetlink = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
|
||||
$userselectorrenderer = new \core_course\output\actionbar\user_selector(
|
||||
$userselector = new user_selector(
|
||||
course: $course,
|
||||
resetlink: $resetlink,
|
||||
userid: $this->userid,
|
||||
groupid: 0,
|
||||
usersearch: $this->usersearch
|
||||
);
|
||||
$data['searchdropdown'] = $userselectorrenderer->export_for_template($output);
|
||||
$data['searchdropdown'] = $userselector->export_for_template($output);
|
||||
// The collapsed column dialog is aligned to the edge of the screen, we need to place it such that it also aligns.
|
||||
$collapsemenudirection = right_to_left() ? 'dropdown-menu-left' : 'dropdown-menu-right';
|
||||
|
||||
|
@ -60,7 +60,9 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"groupselector": "<div class='group-selector'></div>",
|
||||
"searchdropdown": {"search dropdown": "context here"},
|
||||
"groupselector": {"group selector": "context here"},
|
||||
"initialselector": {"initial selector": "context here"},
|
||||
"collapsedcolumns": "<div class='collapse-columns'></div>",
|
||||
"pagereset": "http://moodle.local/grade/report/grader/index.php?id=2&userid=2&reset=1"
|
||||
}
|
||||
@ -81,13 +83,13 @@
|
||||
{{/searchdropdown}}
|
||||
{{#groupselector}}
|
||||
<div class="navitem">
|
||||
{{{.}}}
|
||||
{{>core/comboboxsearch}}
|
||||
</div>
|
||||
<div class="navitem-divider"></div>
|
||||
{{/groupselector}}
|
||||
{{#initialselector}}
|
||||
<div class="navitem d-flex flex-column align-self-center">
|
||||
{{{.}}}
|
||||
{{>core/comboboxsearch}}
|
||||
</div>
|
||||
<div class="navitem-divider"></div>
|
||||
{{/initialselector}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user