[IMP] mail: redirect on mail activity
Allow to redirect on a form view when the user click on a html tag a with data-oe-model and data-oe-id specified. In order to avoid code duplication the do_action already existing in mail_thread is moved in the action_manager and mail_thread and mail_activity use a trigger_up in order to call it.
This commit is contained in:
committed by
Simon Lejeune
parent
18d5b11cb4
commit
17f5f74af9
@@ -111,6 +111,7 @@ var AbstractActivityField = AbstractField.extend({
|
||||
var Activity = AbstractActivityField.extend({
|
||||
className: 'o_mail_activity',
|
||||
events: {
|
||||
'click a': '_onClickRedirect',
|
||||
'click .o_activity_edit': '_onEditActivity',
|
||||
'click .o_activity_unlink': '_onUnlinkActivity',
|
||||
'click .o_activity_done': '_onMarkActivityDone',
|
||||
@@ -164,6 +165,17 @@ var Activity = AbstractActivityField.extend({
|
||||
},
|
||||
|
||||
// handlers
|
||||
_onClickRedirect: function (ev) {
|
||||
var id = $(ev.target).data('oe-id');
|
||||
if (id) {
|
||||
ev.preventDefault();
|
||||
var model = $(ev.target).data('oe-model');
|
||||
this.trigger_up('redirect', {
|
||||
res_id: id,
|
||||
res_model: model,
|
||||
});
|
||||
}
|
||||
},
|
||||
_onEditActivity: function (event, options) {
|
||||
event.preventDefault();
|
||||
var self = this;
|
||||
|
||||
@@ -168,13 +168,9 @@ var ThreadField = AbstractField.extend({
|
||||
});
|
||||
},
|
||||
_onRedirect: function (res_model, res_id) {
|
||||
this.do_action({
|
||||
type:'ir.actions.act_window',
|
||||
view_type: 'form',
|
||||
view_mode: 'form',
|
||||
res_model: res_model,
|
||||
views: [[false, 'form']],
|
||||
this.trigger_up('redirect', {
|
||||
res_id: res_id,
|
||||
res_model: res_model,
|
||||
});
|
||||
},
|
||||
_onUpdateMessage: function (message) {
|
||||
|
||||
@@ -27,6 +27,7 @@ var ActionManager = Widget.extend({
|
||||
breadcrumb_clicked: '_onBreadcrumbClicked',
|
||||
history_back: '_onHistoryBack',
|
||||
push_state: '_onPushState',
|
||||
redirect: '_onRedirect',
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -885,6 +886,24 @@ var ActionManager = Widget.extend({
|
||||
this._pushState(ev.data.controllerID, ev.data.state);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Intercepts and triggers a redirection on a link
|
||||
*
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {integer} ev.data.res_id
|
||||
* @param {string} ev.data.res_model
|
||||
*/
|
||||
_onRedirect: function (ev) {
|
||||
this.do_action({
|
||||
type:'ir.actions.act_window',
|
||||
view_type: 'form',
|
||||
view_mode: 'form',
|
||||
res_model: ev.data.res_model,
|
||||
views: [[false, 'form']],
|
||||
res_id: ev.data.res_id,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return ActionManager;
|
||||
|
||||
Reference in New Issue
Block a user