Browse Source

[REF] Replaced on_move_message() methods to thread class to removal duplication code

pull/36/head
x620 8 years ago
parent
commit
b5e6debe77
  1. 43
      mail_move_message/static/src/js/mail_move_message.js

43
mail_move_message/static/src/js/mail_move_message.js

@ -5,6 +5,7 @@ odoo.define('mail_move_message.relocate', function (require) {
var chat_manager = require('mail.chat_manager'); var chat_manager = require('mail.chat_manager');
var base_obj = require('mail_base.base'); var base_obj = require('mail_base.base');
var thread = require('mail.ChatThread'); var thread = require('mail.ChatThread');
var chatter = require('mail.Chatter');
var Model = require('web.Model'); var Model = require('web.Model');
var form_common = require('web.form_common'); var form_common = require('web.form_common');
var widgets = require('web.form_widgets'); var widgets = require('web.form_widgets');
@ -12,23 +13,14 @@ odoo.define('mail_move_message.relocate', function (require) {
var _t = core._t; var _t = core._t;
// Add click reaction in the events of the thread object
thread.include({ thread.include({
init: function(){ init: function(){
this._super.apply(this, arguments); this._super.apply(this, arguments);
// Add click reaction in the events of the thread object
this.events['click .oe_move'] = function(event) { this.events['click .oe_move'] = function(event) {
var message_id = $(event.currentTarget).data('message-id'); var message_id = $(event.currentTarget).data('message-id');
this.trigger("move_message", message_id); this.trigger("move_message", message_id);
} }
}
});
var chatter = require('mail.Chatter');
chatter.include({
start: function() {
var result = this._super.apply(this, arguments);
this.thread.on('move_message', this, this.on_move_message);
return $.when(result).done(function() {});
}, },
on_move_message: function(message_id){ on_move_message: function(message_id){
var action = { var action = {
@ -48,32 +40,23 @@ odoo.define('mail_move_message.relocate', function (require) {
} }
}); });
chatter.include({
start: function() {
var result = this._super.apply(this, arguments);
// For show wizard in the form
this.thread.on('move_message', this, this.thread.on_move_message);
return $.when(result).done(function() {});
}
});
var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({ ChatAction.include({
start: function() { start: function() {
var result = this._super.apply(this, arguments); var result = this._super.apply(this, arguments);
this.thread.on('move_message', this, this.on_move_message);
// For show wizard in the channels
this.thread.on('move_message', this, this.thread.on_move_message);
return $.when(result).done(function() {}); return $.when(result).done(function() {});
},
on_move_message: function(message_id){
var self = this;
var context = {'default_message_id': message_id};
var action = {
name: _t('Relocate Message'),
type: 'ir.actions.act_window',
res_model: 'mail_move_message.wizard',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
context: context
};
self.message_id = message_id;
self.do_action(action, {
'on_close': function(){}
});
} }
}); });

Loading…
Cancel
Save