From 51c65d7bc543a2a4890c190901442f41af576832 Mon Sep 17 00:00:00 2001 From: Jwalit Shah Date: Fri, 27 Mar 2020 12:15:45 +1100 Subject: [PATCH] MDL-66035 message: Restore missing message preferences files --- message/amd/build/message_preferences.min.js | 2 + .../amd/build/message_preferences.min.js.map | 1 + message/amd/src/message_preferences.js | 125 +++++++++++++++++ .../templates/message_preferences.mustache | 119 ++++++++++++++++ .../message_preferences_component.mustache | 84 ++++++++++++ ...references_notification_processor.mustache | 127 ++++++++++++++++++ .../tests/behat/message_preferences.feature | 30 +++++ 7 files changed, 488 insertions(+) create mode 100644 message/amd/build/message_preferences.min.js create mode 100644 message/amd/build/message_preferences.min.js.map create mode 100644 message/amd/src/message_preferences.js create mode 100644 message/templates/message_preferences.mustache create mode 100644 message/templates/message_preferences_component.mustache create mode 100644 message/templates/message_preferences_notification_processor.mustache create mode 100644 message/tests/behat/message_preferences.feature diff --git a/message/amd/build/message_preferences.min.js b/message/amd/build/message_preferences.min.js new file mode 100644 index 00000000000..3378a0d603f --- /dev/null +++ b/message/amd/build/message_preferences.min.js @@ -0,0 +1,2 @@ +define ("core_message/message_preferences",["jquery","core/ajax","core/notification","core_message/message_notification_preference","core/custom_interaction_events"],function(a,b,c,d,e){var f={PREFERENCE:"[data-state]",PREFERENCES_CONTAINER:"[data-region=\"preferences-container\"]",CONTACTABLE_PRIVACY_CONTAINER:"[data-region=\"privacy-setting-container\"]"},g=function(b){this.root=a(b);this.userId=this.root.find(f.PREFERENCES_CONTAINER).attr("data-user-id");this.registerEventListeners()};g.prototype.preferencesDisabled=function(){return this.root.find(f.PREFERENCES_CONTAINER).hasClass("disabled")};g.prototype.saveContactablePrivacySetting=function(){var d=this.root.find(f.CONTACTABLE_PRIVACY_CONTAINER),e=a("input[type='radio']:checked").val();if(d.hasClass("loading")){return a.Deferred().resolve()}d.addClass("loading");var g={methodname:"core_user_update_user_preferences",args:{userid:this.userId,preferences:[{type:d.attr("data-preference-key"),value:e}]}};return b.call([g])[0].fail(c.exception).always(function(){d.removeClass("loading")})};g.prototype.registerEventListeners=function(){e.define(this.root,[e.events.activate]);this.root.on("change",function(b){if("message_blocknoncontacts"==b.target.name){this.saveContactablePrivacySetting()}else{if(!this.preferencesDisabled()){var c=a(b.target).closest(f.PREFERENCES_CONTAINER),e=a(b.target).closest(f.PREFERENCE),g=new d(c,this.userId);e.addClass("loading");g.save().always(function(){e.removeClass("loading")})}}}.bind(this))};return g}); +//# sourceMappingURL=message_preferences.min.js.map diff --git a/message/amd/build/message_preferences.min.js.map b/message/amd/build/message_preferences.min.js.map new file mode 100644 index 00000000000..a83818bfdae --- /dev/null +++ b/message/amd/build/message_preferences.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/message_preferences.js"],"names":["define","$","Ajax","Notification","MessageNotificationPreference","CustomEvents","SELECTORS","PREFERENCE","PREFERENCES_CONTAINER","CONTACTABLE_PRIVACY_CONTAINER","MessagePreferences","element","root","userId","find","attr","registerEventListeners","prototype","preferencesDisabled","hasClass","saveContactablePrivacySetting","container","value","val","Deferred","resolve","addClass","request","methodname","args","userid","preferences","type","call","fail","exception","always","removeClass","events","activate","on","e","target","name","preferencesContainer","closest","preferenceElement","messagePreference","save","bind"],"mappings":"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","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Controls the message preference page.\n *\n * @module core_message/message_preferences\n * @class message_preferences\n * @package message\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/notification',\n 'core_message/message_notification_preference', 'core/custom_interaction_events'],\n function($, Ajax, Notification, MessageNotificationPreference, CustomEvents) {\n\n var SELECTORS = {\n PREFERENCE: '[data-state]',\n PREFERENCES_CONTAINER: '[data-region=\"preferences-container\"]',\n CONTACTABLE_PRIVACY_CONTAINER: '[data-region=\"privacy-setting-container\"]',\n };\n\n /**\n * Constructor for the MessagePreferences.\n *\n * @param {object} element The root element for the message preferences\n */\n var MessagePreferences = function(element) {\n this.root = $(element);\n this.userId = this.root.find(SELECTORS.PREFERENCES_CONTAINER).attr('data-user-id');\n\n this.registerEventListeners();\n };\n\n /**\n * Check if the preferences have been disabled on this page.\n *\n * @method preferencesDisabled\n * @return {bool}\n */\n MessagePreferences.prototype.preferencesDisabled = function() {\n return this.root.find(SELECTORS.PREFERENCES_CONTAINER).hasClass('disabled');\n };\n\n /**\n * Update the contactable privacy user preference in the DOM and\n * send a request to update on the server.\n *\n * @return {Promise}\n * @method saveContactablePrivacySetting\n */\n MessagePreferences.prototype.saveContactablePrivacySetting = function() {\n var container = this.root.find(SELECTORS.CONTACTABLE_PRIVACY_CONTAINER);\n var value = $(\"input[type='radio']:checked\").val();\n\n if (container.hasClass('loading')) {\n return $.Deferred().resolve();\n }\n\n container.addClass('loading');\n\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n userid: this.userId,\n preferences: [\n {\n type: container.attr('data-preference-key'),\n value: value,\n }\n ]\n }\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .always(function() {\n container.removeClass('loading');\n });\n };\n\n /**\n * Create all of the event listeners for the message preferences page.\n *\n * @method registerEventListeners\n */\n MessagePreferences.prototype.registerEventListeners = function() {\n CustomEvents.define(this.root, [\n CustomEvents.events.activate\n ]);\n\n this.root.on('change', function(e) {\n // Add listener for privacy setting radio buttons change.\n if (e.target.name == 'message_blocknoncontacts') {\n this.saveContactablePrivacySetting();\n } else {\n // Add listener for processor preferences.\n if (!this.preferencesDisabled()) {\n var preferencesContainer = $(e.target).closest(SELECTORS.PREFERENCES_CONTAINER);\n var preferenceElement = $(e.target).closest(SELECTORS.PREFERENCE);\n var messagePreference = new MessageNotificationPreference(preferencesContainer, this.userId);\n\n preferenceElement.addClass('loading');\n messagePreference.save().always(function() {\n preferenceElement.removeClass('loading');\n });\n }\n }\n }.bind(this));\n };\n\n return MessagePreferences;\n});\n"],"file":"message_preferences.min.js"} \ No newline at end of file diff --git a/message/amd/src/message_preferences.js b/message/amd/src/message_preferences.js new file mode 100644 index 00000000000..c5944b62ce2 --- /dev/null +++ b/message/amd/src/message_preferences.js @@ -0,0 +1,125 @@ +// 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 . + +/** + * Controls the message preference page. + * + * @module core_message/message_preferences + * @class message_preferences + * @package message + * @copyright 2016 Ryan Wyllie + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define(['jquery', 'core/ajax', 'core/notification', + 'core_message/message_notification_preference', 'core/custom_interaction_events'], + function($, Ajax, Notification, MessageNotificationPreference, CustomEvents) { + + var SELECTORS = { + PREFERENCE: '[data-state]', + PREFERENCES_CONTAINER: '[data-region="preferences-container"]', + CONTACTABLE_PRIVACY_CONTAINER: '[data-region="privacy-setting-container"]', + }; + + /** + * Constructor for the MessagePreferences. + * + * @param {object} element The root element for the message preferences + */ + var MessagePreferences = function(element) { + this.root = $(element); + this.userId = this.root.find(SELECTORS.PREFERENCES_CONTAINER).attr('data-user-id'); + + this.registerEventListeners(); + }; + + /** + * Check if the preferences have been disabled on this page. + * + * @method preferencesDisabled + * @return {bool} + */ + MessagePreferences.prototype.preferencesDisabled = function() { + return this.root.find(SELECTORS.PREFERENCES_CONTAINER).hasClass('disabled'); + }; + + /** + * Update the contactable privacy user preference in the DOM and + * send a request to update on the server. + * + * @return {Promise} + * @method saveContactablePrivacySetting + */ + MessagePreferences.prototype.saveContactablePrivacySetting = function() { + var container = this.root.find(SELECTORS.CONTACTABLE_PRIVACY_CONTAINER); + var value = $("input[type='radio']:checked").val(); + + if (container.hasClass('loading')) { + return $.Deferred().resolve(); + } + + container.addClass('loading'); + + var request = { + methodname: 'core_user_update_user_preferences', + args: { + userid: this.userId, + preferences: [ + { + type: container.attr('data-preference-key'), + value: value, + } + ] + } + }; + + return Ajax.call([request])[0] + .fail(Notification.exception) + .always(function() { + container.removeClass('loading'); + }); + }; + + /** + * Create all of the event listeners for the message preferences page. + * + * @method registerEventListeners + */ + MessagePreferences.prototype.registerEventListeners = function() { + CustomEvents.define(this.root, [ + CustomEvents.events.activate + ]); + + this.root.on('change', function(e) { + // Add listener for privacy setting radio buttons change. + if (e.target.name == 'message_blocknoncontacts') { + this.saveContactablePrivacySetting(); + } else { + // Add listener for processor preferences. + if (!this.preferencesDisabled()) { + var preferencesContainer = $(e.target).closest(SELECTORS.PREFERENCES_CONTAINER); + var preferenceElement = $(e.target).closest(SELECTORS.PREFERENCE); + var messagePreference = new MessageNotificationPreference(preferencesContainer, this.userId); + + preferenceElement.addClass('loading'); + messagePreference.save().always(function() { + preferenceElement.removeClass('loading'); + }); + } + } + }.bind(this)); + }; + + return MessagePreferences; +}); diff --git a/message/templates/message_preferences.mustache b/message/templates/message_preferences.mustache new file mode 100644 index 00000000000..ebe1c40840c --- /dev/null +++ b/message/templates/message_preferences.mustache @@ -0,0 +1,119 @@ +{{! + 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 + + 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: + * userid The logged in user id + * disableall If the user has disabled notifications + * components The list of notification components + * privacychoices The choice options for the contactable privacy setting + + Example context (json): + { + "userid": 1, + "disableall": 0, + "components": [ + { + "notifications": [ + { + "displayname": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "onlinehelphtml": "

some help HTML

", + "offlinehelphtml": "

some help HTML

", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "userconfigured": 1, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "disableall": 0 + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "disableall": 0 + } + } + ] + } + ] + } + ], + "privacychoices": [ + { + "value": 1, + "text": "My contacts only", + "checked": 0 + }, + { + "value": 2, + "text": "Anyone within courses I am a member of", + "checked": 1 + } + ] + } +}} +
+

{{#str}} messagepreferences, message {{/str}}

+
+

{{#str}} contactableprivacy, message {{/str}}

+ {{#privacychoices}} + + +
+ {{/privacychoices}} +

+
+ + + {{#components}} + {{> message/message_preferences_component }} + {{/components}} + +
+
+
+{{#js}} +require(['jquery', 'core_message/message_preferences'], + function($, MessagePreferences) { + + new MessagePreferences($('[data-region="preferences-page-container"]')); +}); +{{/js}} diff --git a/message/templates/message_preferences_component.mustache b/message/templates/message_preferences_component.mustache new file mode 100644 index 00000000000..aeac0261a2b --- /dev/null +++ b/message/templates/message_preferences_component.mustache @@ -0,0 +1,84 @@ +{{! + 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", + "onlinehelphtml": "

some help HTML

", + "offlinehelphtml": "

some help HTML

", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "userconfigured": 1, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "disableall": 0 + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "disableall": 0 + } + } + ] + } + ] + } +}} +{{#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..43c38eff4e4 --- /dev/null +++ b/message/templates/message_preferences_notification_processor.mustache @@ -0,0 +1,127 @@ +{{! + 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": "Notices about minor problems", + "preferencekey": "message_provider_moodle_notices", + "processors": [ + { + "displayname": "Popup notification", + "name": "popup", + "locked": 0, + "userconfigured": 1, + "loggedin": { + "name": "loggedin", + "displayname": "When I'm logged in", + "checked": 0, + "disableall": 0 + }, + "loggedoff": { + "name": "loggedoff", + "displayname": "When I'm offline", + "checked": 0, + "disableall": 0 + } + } + ] + } +}} + + {{displayname}} + + {{#locked}} +
{{lockedmessage}}
+ {{/locked}} + {{^locked}} +
{{#str}} disabled, question {{/str}}
+
+
+
+
+ {{#loggedin}} + {{< core/hover_tooltip }} + {{$anchor}} + + {{/anchor}} + {{$tooltip}}{{displayname}}{{/tooltip}} + {{/ core/hover_tooltip }} + {{/loggedin}} +
+
+ {{#loggedoff}} + {{< core/hover_tooltip }} + {{$anchor}} + + {{/anchor}} + {{$tooltip}}{{displayname}}{{/tooltip}} + {{/ core/hover_tooltip }} + {{/loggedoff}} +
+
+
+
+ {{/locked}} + + diff --git a/message/tests/behat/message_preferences.feature b/message/tests/behat/message_preferences.feature new file mode 100644 index 00000000000..4aeac16e87f --- /dev/null +++ b/message/tests/behat/message_preferences.feature @@ -0,0 +1,30 @@ +@core @core_message +Feature: To be able to see and save user message preferences as admin + As an admin + I need to be able to view and edit message preferences for other users + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@emample.com | + And the following "user preferences" exist: + | user | preference | value | + | student1 | message_provider_moodle_instantmessage_loggedin | none | + | student1 | message_provider_moodle_instantmessage_loggedoff | email | + + @javascript + Scenario: As an admin I can view and edit message preferences for a user + Given I log in as "admin" + And I navigate to "Messaging > Notification settings" in site administration + And I set the field "email" to "1" + And I press "Save changes" + And I navigate to "Users > Accounts > Browse list of users" in site administration + And I click on "Student 1" "link" in the "Student 1" "table_row" + And I click on "Preferences" "link" in the "#region-main-box" "css_element" + And I click on "Message preferences" "link" in the "#region-main-box" "css_element" + And I click on "//label[@data-state='loggedoff']" "xpath_element" + And I log out + And I log in as "student1" + And I follow "Preferences" in the user menu + And I click on "Message preferences" "link" + And the field "Email" matches value "0" \ No newline at end of file