mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-60918 message: use current user in message preference update
This commit is contained in:
parent
f5b956679e
commit
745783fa13
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user