mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 06:31:22 +01:00
Merge branch 'MDL-60918-master' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
4a87646654
2
message/amd/build/message_preferences.min.js
vendored
2
message/amd/build/message_preferences.min.js
vendored
@ -1 +1 @@
|
||||
define(["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"]',BLOCK_NON_CONTACTS:'[data-region="block-non-contacts-container"] [data-block-non-contacts]',BLOCK_NON_CONTACTS_CONTAINER:'[data-region="block-non-contacts-container"]'},g=function(b){this.root=a(b),this.registerEventListeners()};return g.prototype.preferencesDisabled=function(){return this.root.find(f.PREFERENCES_CONTAINER).hasClass("disabled")},g.prototype.saveBlockNonContactsStatus=function(){var d=this.root.find(f.BLOCK_NON_CONTACTS),e=this.root.find(f.BLOCK_NON_CONTACTS_CONTAINER),g=d.prop("checked");if(e.hasClass("loading"))return a.Deferred().resolve();e.addClass("loading");var h={methodname:"core_user_update_user_preferences",args:{preferences:[{type:d.attr("data-preference-key"),value:g?1:0}]}};return b.call([h])[0].fail(c.exception).always(function(){e.removeClass("loading")})},g.prototype.registerEventListeners=function(){e.define(this.root,[e.events.activate]),this.root.on(e.events.activate,f.BLOCK_NON_CONTACTS,function(){this.saveBlockNonContactsStatus()}.bind(this)),this.root.on("change",function(b){if(!this.preferencesDisabled()){var c=a(b.target).closest(f.PREFERENCES_CONTAINER),e=a(b.target).closest(f.PREFERENCE),g=new d(c);e.addClass("loading"),g.save().always(function(){e.removeClass("loading")})}}.bind(this))},g});
|
||||
define(["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"]',BLOCK_NON_CONTACTS:'[data-region="block-non-contacts-container"] [data-block-non-contacts]',BLOCK_NON_CONTACTS_CONTAINER:'[data-region="block-non-contacts-container"]'},g=function(b){this.root=a(b),this.userId=this.root.find(f.PREFERENCES_CONTAINER).attr("data-user-id"),this.registerEventListeners()};return g.prototype.preferencesDisabled=function(){return this.root.find(f.PREFERENCES_CONTAINER).hasClass("disabled")},g.prototype.saveBlockNonContactsStatus=function(){var d=this.root.find(f.BLOCK_NON_CONTACTS),e=this.root.find(f.BLOCK_NON_CONTACTS_CONTAINER),g=d.prop("checked");if(e.hasClass("loading"))return a.Deferred().resolve();e.addClass("loading");var h={methodname:"core_user_update_user_preferences",args:{userid:this.userId,preferences:[{type:d.attr("data-preference-key"),value:g?1:0}]}};return b.call([h])[0].fail(c.exception).always(function(){e.removeClass("loading")})},g.prototype.registerEventListeners=function(){e.define(this.root,[e.events.activate]),this.root.on(e.events.activate,f.BLOCK_NON_CONTACTS,function(){this.saveBlockNonContactsStatus()}.bind(this)),this.root.on("change",function(b){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))},g});
|
@ -40,6 +40,7 @@ define(['jquery', 'core/ajax', 'core/notification',
|
||||
*/
|
||||
var MessagePreferences = function(element) {
|
||||
this.root = $(element);
|
||||
this.userId = this.root.find(SELECTORS.PREFERENCES_CONTAINER).attr('data-user-id');
|
||||
|
||||
this.registerEventListeners();
|
||||
};
|
||||
@ -75,6 +76,7 @@ define(['jquery', 'core/ajax', 'core/notification',
|
||||
var request = {
|
||||
methodname: 'core_user_update_user_preferences',
|
||||
args: {
|
||||
userid: this.userId,
|
||||
preferences: [
|
||||
{
|
||||
type: checkbox.attr('data-preference-key'),
|
||||
@ -109,7 +111,7 @@ define(['jquery', 'core/ajax', 'core/notification',
|
||||
if (!this.preferencesDisabled()) {
|
||||
var preferencesContainer = $(e.target).closest(SELECTORS.PREFERENCES_CONTAINER);
|
||||
var preferenceElement = $(e.target).closest(SELECTORS.PREFERENCE);
|
||||
var messagePreference = new MessageNotificationPreference(preferencesContainer);
|
||||
var messagePreference = new MessageNotificationPreference(preferencesContainer, this.userId);
|
||||
|
||||
preferenceElement.addClass('loading');
|
||||
messagePreference.save().always(function() {
|
||||
|
33
message/tests/behat/update_messaging_preferences.feature
Normal file
33
message/tests/behat/update_messaging_preferences.feature
Normal file
@ -0,0 +1,33 @@
|
||||
@core @message @javascript
|
||||
Feature: Messaging preferences
|
||||
In order to be notified of messages
|
||||
As a user
|
||||
I need to be able to alter my message preferences
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Manage message outputs" node in "Site administration > Plugins > Message outputs"
|
||||
And I click on "//table[contains(@class, 'admintable')]/tbody/tr/td[contains(text(), 'Email')]/following-sibling::td[1]/a" "xpath_element"
|
||||
|
||||
Scenario: Alter my message preferences
|
||||
Given I follow "Preferences" in the user menu
|
||||
And I click on "Message preferences" "link" in the "region-main" "region"
|
||||
And I should see "On" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I should not see "Off" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I click on "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I reload the page
|
||||
Then I should see "Off" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
|
||||
Scenario: Alter another users preferences
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| user1 | User | 1 | user1@example.com |
|
||||
And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
|
||||
And I click on "User 1" "link"
|
||||
And I click on "Preferences" "link" in the ".profile_tree" "css_element"
|
||||
And I click on "Message preferences" "link" in the "region-main" "region"
|
||||
And I should see "On" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I should not see "Off" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I click on "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
||||
And I reload the page
|
||||
Then I should see "Off" in the "[data-preference-key=message_provider_moodle_instantmessage] [data-state=loggedoff] .preference-state-status-container" "css_element"
|
Loading…
x
Reference in New Issue
Block a user