From df9986c87f5769534a9065382b85ae8a971ddc24 Mon Sep 17 00:00:00 2001 From: Ryan Wyllie Date: Thu, 29 Sep 2016 03:03:35 +0000 Subject: [PATCH] MDL-56292 message: split up preferences templates --- message/renderer.php | 2 +- .../templates/message_preferences.mustache | 83 +------ .../message_preferences_component.mustache | 81 +++++++ ...references_notification_processor.mustache | 112 +++++++++ .../notification_preferences.mustache | 113 ++++++++++ ...otification_preferences_component.mustache | 93 ++++++++ ...references_component_notification.mustache | 118 ++++++++++ ...otification_preferences_processor.mustache | 61 +++++ .../preferences_notifications_list.mustache | 213 ------------------ 9 files changed, 581 insertions(+), 295 deletions(-) create mode 100644 message/templates/message_preferences_component.mustache create mode 100644 message/templates/message_preferences_notification_processor.mustache create mode 100644 message/templates/notification_preferences.mustache create mode 100644 message/templates/notification_preferences_component.mustache create mode 100644 message/templates/notification_preferences_component_notification.mustache create mode 100644 message/templates/notification_preferences_processor.mustache delete mode 100644 message/templates/preferences_notifications_list.mustache diff --git a/message/renderer.php b/message/renderer.php index f1e37e9916b..a6154675902 100644 --- a/message/renderer.php +++ b/message/renderer.php @@ -228,7 +228,7 @@ class core_message_renderer extends plugin_renderer_base { $preferences = \core_message\api::get_all_message_preferences($processors, $providers, $user); $notificationlistoutput = new \core_message\output\preferences\notification_list($processors, $providers, $preferences, $user); - return $this->render_from_template('message/preferences_notifications_list', + return $this->render_from_template('message/notification_preferences', $notificationlistoutput->export_for_template($this)); } diff --git a/message/templates/message_preferences.mustache b/message/templates/message_preferences.mustache index a108289c0cc..58df036cddb 100644 --- a/message/templates/message_preferences.mustache +++ b/message/templates/message_preferences.mustache @@ -23,7 +23,7 @@ * None Data attibutes required for JS: - * None + * All data attributes are required Context variables required for this template: * userid The logged in user id @@ -93,86 +93,7 @@ {{#components}} - {{#notifications}} - - - - - {{#processors}} - - - - - {{/processors}} - {{/notifications}} + {{> message/message_preferences_component }} {{/components}}
{{displayname}} -
-
-
- {{#str}} loggedin, message {{/str}} - {{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}} -
-
- {{#str}} loggedoff, message {{/str}} - {{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}} -
-
-
-
{{displayname}} - {{#locked}} -
{{lockedmessage}}
- {{/locked}} - {{^locked}} -
{{#str}} disabled, question {{/str}}
-
-
-
-
- {{#loggedin}} - - {{/loggedin}} -
-
- {{#loggedoff}} - - {{/loggedoff}} -
-
-
-
- {{/locked}} -
diff --git a/message/templates/message_preferences_component.mustache b/message/templates/message_preferences_component.mustache new file mode 100644 index 00000000000..d441810b99c --- /dev/null +++ b/message/templates/message_preferences_component.mustache @@ -0,0 +1,81 @@ +{{! + 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 . +}} +{{! + @template core_message/message_preferences_component + + The message preferences page + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * notifications The list of notifications + + Example context (json): + { + "notifications": [ + { + "displayname": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "iconurl": "some url" + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "iconurl": "some url" + }, + } + ] + } + ] + } +}} +{{#notifications}} + + {{displayname}} + +
+
+
+ {{#str}} loggedin, message {{/str}} + {{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}} +
+
+ {{#str}} loggedoff, message {{/str}} + {{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}} +
+
+
+ + + {{#processors}} + {{> message/message_preferences_notification_processor }} + {{/processors}} +{{/notifications}} diff --git a/message/templates/message_preferences_notification_processor.mustache b/message/templates/message_preferences_notification_processor.mustache new file mode 100644 index 00000000000..9c8be05b86b --- /dev/null +++ b/message/templates/message_preferences_notification_processor.mustache @@ -0,0 +1,112 @@ +{{! + 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 . +}} +{{! + @template core_message/message_preferences_notification_processor + + The message preferences page + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * displayname The display name of the processor + * name The name of the processor + * locked Whether the processor is locked + * loggedin The logged in settings + * loggedoff The logged off settings + + Example context (json): + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "iconurl": "some url" + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "iconurl": "some url" + }, + } +}} + + {{displayname}} + + {{#locked}} +
{{lockedmessage}}
+ {{/locked}} + {{^locked}} +
{{#str}} disabled, question {{/str}}
+
+
+
+
+ {{#loggedin}} + + {{/loggedin}} +
+
+ {{#loggedoff}} + + {{/loggedoff}} +
+
+
+
+ {{/locked}} + + diff --git a/message/templates/notification_preferences.mustache b/message/templates/notification_preferences.mustache new file mode 100644 index 00000000000..410e41c269f --- /dev/null +++ b/message/templates/notification_preferences.mustache @@ -0,0 +1,113 @@ +{{! + 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 . +}} +{{! + @template core_message/notification_preferences + + The list of notifications for the notification preferences page + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * userid The logged in user id + * disableall If the user has disabled notifications + * components The list of notification components + + Example context (json): + { + "userid": 1, + "disableall": 0, + "components": [ + { + "displayname": "System", + "processors": [ + { + displayname: "Popup notification", + name: "popup", + userid: 1, + contextid: 18, + hassettings: true + } + ], + "notifications": [ + { + "displayname": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "iconurl": "some url" + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "iconurl": "some url" + }, + } + ] + } + ] + } + ] + } +}} +
+

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

+
+ + + {{> core/loading }} +
+
+ + + + + {{#processors}} + {{> message/notification_preferences_processor }} + {{/processors}} + + + + {{#components}} + {{> message/notification_preferences_component }} + {{/components}} + +
{{displayname}}
+
+
+{{#js}} +require(['jquery', 'theme_bootstrapbase/bootstrap', 'core_message/preferences_notifications_list_controller'], + function($, bootstrap, controller) { + + $('[data-toggle="tooltip"]').tooltip(); + new controller($('.preferences-container')); +}); +{{/js}} diff --git a/message/templates/notification_preferences_component.mustache b/message/templates/notification_preferences_component.mustache new file mode 100644 index 00000000000..b6553f5b0a9 --- /dev/null +++ b/message/templates/notification_preferences_component.mustache @@ -0,0 +1,93 @@ +{{! + 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 . +}} +{{! + @template core_message/notification_preferences_component + + The notification preferences page + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * displayname The component display name + * processors The list of processors for this component + * notifications The list of notifications + + Example context (json): + { + "displayname": "System", + "processors": [ + { + displayname: "Popup notification", + name: "popup", + userid: 1, + contextid: 18, + hassettings: true + } + ], + "notifications": [ + { + "displayname": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "iconurl": "some url" + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "iconurl": "some url" + }, + } + ] + } + ] + } +}} + +

{{displayname}}

+ {{#processors}} + +
+
+
+ {{#str}} loggedin, message {{/str}} + {{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}} +
+
+ {{#str}} loggedoff, message {{/str}} + {{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}} +
+
+
+ + {{/processors}} + +{{#notifications}} + {{> message/notification_preferences_component_notification }} +{{/notifications}} diff --git a/message/templates/notification_preferences_component_notification.mustache b/message/templates/notification_preferences_component_notification.mustache new file mode 100644 index 00000000000..71bd664da78 --- /dev/null +++ b/message/templates/notification_preferences_component_notification.mustache @@ -0,0 +1,118 @@ +{{! + 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 . +}} +{{! + @template core_message/notification_preferences_component_notification + + The notification preferences page + + Classes required for JS: + * disabled + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * displayname The notification display name + * preferencekey The unique key to identify this preference + * processors The list of processors for this notification + + Example context (json): + { + "displayname": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "iconurl": "some url" + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "iconurl": "some url" + }, + } + ] + } +}} + + {{displayname}} + {{#processors}} + + {{#locked}} +
{{lockedmessage}}
+ {{/locked}} + {{^locked}} +
{{#str}} disabled, question {{/str}}
+
+
+
+
+ {{#loggedin}} + + {{/loggedin}} +
+
+ {{#loggedoff}} + + {{/loggedoff}} +
+
+
+
+ {{/locked}} + + {{/processors}} + diff --git a/message/templates/notification_preferences_processor.mustache b/message/templates/notification_preferences_processor.mustache new file mode 100644 index 00000000000..b732481e7f5 --- /dev/null +++ b/message/templates/notification_preferences_processor.mustache @@ -0,0 +1,61 @@ +{{! + 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 . +}} +{{! + @template core_message/notification_preferences_processor + + The list of notifications for the message preferences page + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * displayname The display name for the processor + * name The name of the processor + * hassettings If the processor has settings to configure + * userid The current user id + * contextid The current context id + + Example context (json): + { + "displayname": "Popup notification", + "name": "popup", + "hassettings": 1, + "userid": 3, + "contextid": 3, + } +}} + + {{#hassettings}} + + + + {{#pix}} i/risk_xss, core {{/pix}} + + {{displayname}} {{#pix}} i/settings {{/pix}} + + {{/hassettings}} + {{^hassettings}} + {{displayname}} + {{/hassettings}} + diff --git a/message/templates/preferences_notifications_list.mustache b/message/templates/preferences_notifications_list.mustache deleted file mode 100644 index af0d3757149..00000000000 --- a/message/templates/preferences_notifications_list.mustache +++ /dev/null @@ -1,213 +0,0 @@ -{{! - 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 . -}} -{{! - @template core_message/preferences_notifications_list - - The list of notifications for the message preferences page - - Classes required for JS: - * None - - Data attibutes required for JS: - * None - - Context variables required for this template: - * userid The logged in user id - * disableall If the user has disabled notifications - * components The list of notification components - - Example context (json): - { - "userid": 1, - "disableall": 0, - "components": [ - { - "displayname": "System", - "processors": [ - { - displayname: "Popup notification", - name: "popup", - userid: 1, - contextid: 18, - hassettings: true - } - ], - "notifications": [ - { - "displayname": "Notices about minor problems", - "preferencekey": "message_provider_moodle_notices", - "processors": [ - { - "displayname": "Popup notification", - "name": "popup", - "locked": 0, - "loggedin": { - "name": "loggedin", - "displayname": "When I'm logged in", - "checked": 0, - "iconurl": "some url" - }, - "loggedoff": { - "name": "loggedoff", - "displayname": "When I'm offline", - "checked": 0, - "iconurl": "some url" - }, - } - ] - } - ] - } - ] - } -}} -
-

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

-
- - - {{> core/loading }} -
-
- - - - - {{#processors}} - - {{/processors}} - - - - {{#components}} - - - {{#processors}} - - {{/processors}} - - {{#notifications}} - - - {{#processors}} - - {{/processors}} - - {{/notifications}} - {{/components}} - -
{{displayname}} - {{#hassettings}} - - - - {{#pix}} i/risk_xss, core {{/pix}} - - {{displayname}} {{#pix}} i/settings {{/pix}} - - {{/hassettings}} - {{^hassettings}} - {{displayname}} - {{/hassettings}} -

{{displayname}}

-
-
-
- {{#str}} loggedin, message {{/str}} - {{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}} -
-
- {{#str}} loggedoff, message {{/str}} - {{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}} -
-
-
-
- {{displayname}} - - {{#locked}} -
{{lockedmessage}}
- {{/locked}} - {{^locked}} -
{{#str}} disabled, question {{/str}}
-
-
-
-
- {{#loggedin}} - - {{/loggedin}} -
-
- {{#loggedoff}} - - {{/loggedoff}} -
-
-
-
- {{/locked}} -
-
-
-{{#js}} -require(['jquery', 'theme_bootstrapbase/bootstrap', 'core_message/preferences_notifications_list_controller'], - function($, bootstrap, controller) { - - $('[data-toggle="tooltip"]').tooltip(); - new controller($('.preferences-container')); -}); -{{/js}}