MDL-73895 message: hide empty component notification categories.

If a component has no available notification types (because they're
disabled), then it (the component) should be hidden entirely from
the user notification preferences page.
This commit is contained in:
Paul Holden 2022-02-15 22:56:39 +00:00
parent d24a4ab56f
commit 44ce37902d
3 changed files with 14 additions and 7 deletions

View File

@ -161,6 +161,8 @@ class notification_list_component implements templatable, renderable {
$context['notifications'][] = $notificationcontext;
}
$context['hasnotifications'] = (count($context['notifications']) > 0);
return $context;
}
}

View File

@ -47,6 +47,7 @@
{
"displayname": "System",
"colspan": 2,
"hasnotifications": 1,
"notifications": [
{
"displayname": "Notices about minor problems",

View File

@ -27,13 +27,15 @@
Context variables required for this template:
* displayname The component display name
* processors The list of processors for this component
* colspan The number of columns the row should span
* hasnotifications Whether any notifications exist
* notifications The list of notifications
Example context (json):
{
"displayname": "System",
"colspan": 2,
"hasnotifications": 1,
"notifications": [
{
"displayname": "Notices about minor problems",
@ -52,9 +54,11 @@
]
}
}}
<tr>
<th colspan="{{{colspan}}}">{{{displayname}}}</th>
</tr>
{{#notifications}}
{{> message/notification_preferences_component_notification }}
{{/notifications}}
{{#hasnotifications}}
<tr>
<th colspan="{{{colspan}}}">{{{displayname}}}</th>
</tr>
{{#notifications}}
{{> message/notification_preferences_component_notification }}
{{/notifications}}
{{/hasnotifications}}