[REF] mail: create separate files for includes
The rev. odoo/odoo@ab900bb fixes an issue in mail which needed an include on BasicModel and FormController. As this rev. has been done in a stable branch, the includes have been done in an existing file. This rev. correctly separates the includes in different files.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
odoo.define('mail.basic_model', function (require) {
|
||||
"use strict";
|
||||
|
||||
var BasicModel = require('web.BasicModel');
|
||||
|
||||
/**
|
||||
* Include the BasicModel to update the datapoint on the model when a
|
||||
* message is posted.
|
||||
*/
|
||||
BasicModel.include({
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update the message ids on a datapoint.
|
||||
*
|
||||
* Note that we directly update the res_ids on the datapoint as the message
|
||||
* has already been posted ; this change can't be handled 'normally' with
|
||||
* x2m commands because the change won't be saved as a normal field.
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {integer[]} msgIDs
|
||||
*/
|
||||
updateMessageIDs: function (id, msgIDs) {
|
||||
var element = this.localData[id];
|
||||
element.res_ids = msgIDs;
|
||||
element.count = msgIDs.length;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
odoo.define('mail.form_controller', function (require) {
|
||||
"use strict";
|
||||
|
||||
var FormController = require('web.FormController');
|
||||
|
||||
/**
|
||||
* Include the FormController to update the datapoint on the model when a
|
||||
* message is posted.
|
||||
*/
|
||||
FormController.include({
|
||||
custom_events: _.extend({}, FormController.prototype.custom_events, {
|
||||
new_message: '_onNewMessage',
|
||||
}),
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} event
|
||||
* @param {string} event.data.id datapointID
|
||||
* @param {integer[]} event.data.msgIDs list of message ids
|
||||
*/
|
||||
_onNewMessage: function (event) {
|
||||
this.model.updateMessageIDs(event.data.id, event.data.msgIDs);
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,9 +1,7 @@
|
||||
odoo.define('mail.form_renderer', function (require) {
|
||||
"use strict";
|
||||
|
||||
var BasicModel = require('web.BasicModel');
|
||||
var Chatter = require('mail.Chatter');
|
||||
var FormController = require('web.FormController');
|
||||
var FormRenderer = require('web.FormRenderer');
|
||||
|
||||
/**
|
||||
@@ -92,51 +90,4 @@ FormRenderer.include({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Include the FormController and BasicModel to update the datapoint on the
|
||||
* model when a message is posted.
|
||||
*/
|
||||
FormController.include({
|
||||
custom_events: _.extend({}, FormController.prototype.custom_events, {
|
||||
new_message: '_onNewMessage',
|
||||
}),
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} event
|
||||
* @param {string} event.data.id datapointID
|
||||
* @param {integer[]} event.data.msgIDs list of message ids
|
||||
*/
|
||||
_onNewMessage: function (event) {
|
||||
this.model.updateMessageIDs(event.data.id, event.data.msgIDs);
|
||||
},
|
||||
});
|
||||
|
||||
BasicModel.include({
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update the message ids on a datapoint.
|
||||
*
|
||||
* Note that we directly update the res_ids on the datapoint as the message
|
||||
* has already been posted ; this change can't be handled 'normally' with
|
||||
* x2m commands because the change won't be saved as a normal field.
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {integer[]} msgIDs
|
||||
*/
|
||||
updateMessageIDs: function (id, msgIDs) {
|
||||
var element = this.localData[id];
|
||||
element.res_ids = msgIDs;
|
||||
element.count = msgIDs.length;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
<script type="text/javascript" src="/mail/static/src/js/chatter.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/chatter_composer.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/followers.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/form_controller.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/form_renderer.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/basic_model.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/basic_view.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/thread.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/thread_field.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user