Merge branch 'MDL-73895-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE

This commit is contained in:
Jun Pataleta
2022-03-11 11:17:18 +08:00
4 changed files with 32 additions and 22 deletions
@@ -167,8 +167,11 @@ class notification_list implements templatable, renderable {
//
// We only want the first component to render with the help icon.
if (!empty($context['components'])) {
$context['components'][0]['onlinehelphtml'] = $output->help_icon('loggedin', 'message');
$context['components'][0]['offlinehelphtml'] = $output->help_icon('loggedoff', 'message');
$withnotifications = array_search(true, array_column($context['components'], 'hasnotifications'), true);
if ($withnotifications !== false) {
$context['components'][$withnotifications]['onlinehelphtml'] = $output->help_icon('loggedin', 'message');
$context['components'][$withnotifications]['offlinehelphtml'] = $output->help_icon('loggedoff', 'message');
}
}
return $context;
@@ -160,6 +160,8 @@ class notification_list_component implements templatable, renderable {
$context['notifications'][] = $notificationcontext;
}
$context['hasnotifications'] = (count($context['notifications']) > 0);
return $context;
}
}
@@ -43,6 +43,7 @@
"offlinehelphtml": "<p>help button HTML</p>"
}
],
"hasnotifications": 1,
"notifications": [
{
"displayname": "Notices about minor problems",
@@ -28,6 +28,7 @@
Context variables required for this template:
* displayname The component display name
* processors The list of processors for this component
* hasnotifications Whether any notifications exist
* notifications The list of notifications
Example context (json):
@@ -39,6 +40,7 @@
"offlinehelphtml": "<p>help button HTML</p>"
}
],
"hasnotifications": 1,
"notifications": [
{
"displayname": "Notices about minor problems",
@@ -67,25 +69,27 @@
]
}
}}
<tr>
<th><h4>{{displayname}}</h4></th>
{{#processors}}
<td class="align-bottom">
<div class="container-fluid">
<div class="row">
<div class="col-6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="col-6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
{{#hasnotifications}}
<tr>
<th><h4>{{displayname}}</h4></th>
{{#processors}}
<td class="align-bottom">
<div class="container-fluid">
<div class="row">
<div class="col-6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="col-6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
</div>
</div>
</div>
</div>
</td>
{{/processors}}
</tr>
{{#notifications}}
{{> message/notification_preferences_component_notification }}
{{/notifications}}
</td>
{{/processors}}
</tr>
{{#notifications}}
{{> message/notification_preferences_component_notification }}
{{/notifications}}
{{/hasnotifications}}