From b6cd1c1151b171afdabd2ff24603d64aa81ade1a Mon Sep 17 00:00:00 2001 From: Ryan Wyllie Date: Fri, 29 Jul 2016 02:58:46 +0000 Subject: [PATCH] MDL-54698 message: combine message preferences into single table --- .../output/preferences/notification_list.php | 20 +++++-- .../notification_list_component.php | 12 ----- .../preferences_notifications_list.mustache | 52 ++++++++++--------- theme/bootstrapbase/less/moodle/message.less | 4 +- theme/bootstrapbase/style/moodle.css | 4 +- 5 files changed, 48 insertions(+), 44 deletions(-) diff --git a/message/classes/output/preferences/notification_list.php b/message/classes/output/preferences/notification_list.php index 2dfe7ba43b4..6ed09f88e1b 100644 --- a/message/classes/output/preferences/notification_list.php +++ b/message/classes/output/preferences/notification_list.php @@ -27,6 +27,7 @@ namespace core_message\output\preferences; use renderable; use templatable; +use context_user; /** * Class to create context for the list of notifications on the message @@ -78,6 +79,7 @@ class notification_list implements templatable, renderable { $providers = $this->providers; $preferences = $this->preferences; $user = $this->user; + $usercontext = context_user::instance($user->id); foreach($providers as $provider) { if($provider->component != 'moodle') { @@ -91,7 +93,20 @@ class notification_list implements templatable, renderable { array_unshift($components, 'moodle'); // pop it in front! phew! asort($providers); - $context = []; + $context = [ + 'userid' => $user->id, + 'disableall' => $user->emailstop, + 'processors' => [], + ]; + + foreach ($processors as $processor) { + $context['processors'][] = [ + 'displayname' => get_string('pluginname', 'message_'.$processor->name), + 'name' => $processor->name, + 'hassettings' => !empty($processor->object->config_form($preferences)), + 'contextid' => $usercontext->id, + ]; + } foreach ($components as $component) { $notificationcomponent = new \core_message\output\preferences\notification_list_component( @@ -99,9 +114,6 @@ class notification_list implements templatable, renderable { $context['components'][] = $notificationcomponent->export_for_template($output); } - $context['userid'] = $user->id; - $context['disableall'] = $user->emailstop; - return $context; } } diff --git a/message/classes/output/preferences/notification_list_component.php b/message/classes/output/preferences/notification_list_component.php index f6d22651928..224eba875e3 100644 --- a/message/classes/output/preferences/notification_list_component.php +++ b/message/classes/output/preferences/notification_list_component.php @@ -29,7 +29,6 @@ require_once($CFG->dirroot . '/message/lib.php'); use renderable; use templatable; -use context_user; /** * Class to create context for a notification component on the message @@ -108,7 +107,6 @@ class notification_list_component implements templatable, renderable { $preferences = $this->preferences; $component = $this->component; $defaultpreferences = get_message_output_default_preferences(); - $usercontext = context_user::instance($this->user->id); if ($component != 'moodle') { $componentname = get_string('pluginname', $component); @@ -118,19 +116,9 @@ class notification_list_component implements templatable, renderable { $context = [ 'displayname' => $componentname, - 'processors' => [], 'notifications' => [], ]; - foreach ($processors as $processor) { - $context['processors'][] = [ - 'displayname' => get_string('pluginname', 'message_'.$processor->name), - 'name' => $processor->name, - 'hassettings' => !empty($processor->object->config_form($preferences)), - 'contextid' => $usercontext->id, - ]; - } - foreach ($providers as $provider) { $preferencebase = $this->get_preference_base($provider); // If provider component is not same or provider disabled then don't show. diff --git a/message/templates/preferences_notifications_list.mustache b/message/templates/preferences_notifications_list.mustache index 4e446b2c6c0..64dc980a667 100644 --- a/message/templates/preferences_notifications_list.mustache +++ b/message/templates/preferences_notifications_list.mustache @@ -77,30 +77,34 @@ }}

{{#str}} notificationpreferences, message {{/str}}

- {{#components}} - - +
+ + + + {{#processors}} + + {{/processors}} + + + + {{#components}} - {{#processors}} - - {{/processors}} + {{#processors}}{{/processors}} - - {{#notifications}} {{/notifications}} - -
{{displayname}} + {{#hassettings}} + + {{displayname}} {{#pix}} i/settings {{/pix}} + + {{/hassettings}} + {{^hassettings}} + {{displayname}} + {{/hassettings}} +
{{displayname}} - {{#hassettings}} - - {{displayname}} {{#pix}} i/settings {{/pix}} - - {{/hassettings}} - {{^hassettings}} - {{displayname}} - {{/hassettings}} -
@@ -156,9 +160,9 @@ {{/processors}}
- {{/components}} + {{/components}} + +
{{#js}} require(['jquery', 'theme_bootstrapbase/bootstrap', 'core_message/preferences_notifications_list_controller'], diff --git a/theme/bootstrapbase/less/moodle/message.less b/theme/bootstrapbase/less/moodle/message.less index 5f93d2b4119..f9ee9712f72 100644 --- a/theme/bootstrapbase/less/moodle/message.less +++ b/theme/bootstrapbase/less/moodle/message.less @@ -312,7 +312,7 @@ vertical-align: middle; input[type="checkbox"]:checked + .preference-state-image-container { - border: 1px solid #5cb85c; + border: 2px solid #5cb85c; } .preference-state-image-container { width: 30px; @@ -320,7 +320,7 @@ line-height: 30px; text-align: center; border-radius: 4px; - border: 1px solid #d9534f; + border: 2px solid #d9534f; .loading-icon { display: none; diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index 3e7f0b824aa..df1f0662530 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -6024,7 +6024,7 @@ a.ygtvspacer:hover { vertical-align: middle; } .preferences-container .preference-table .preference-row .preference-state input[type="checkbox"]:checked + .preference-state-image-container { - border: 1px solid #5cb85c; + border: 2px solid #5cb85c; } .preferences-container .preference-table .preference-row .preference-state .preference-state-image-container { width: 30px; @@ -6032,7 +6032,7 @@ a.ygtvspacer:hover { line-height: 30px; text-align: center; border-radius: 4px; - border: 1px solid #d9534f; + border: 2px solid #d9534f; } .preferences-container .preference-table .preference-row .preference-state .preference-state-image-container .loading-icon { display: none;