forked from Techsystech/web
Use separate on_click function
parent
4f4b8d03e2
commit
e481038c03
|
@ -13,8 +13,8 @@ instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({
|
||||||
template: 'FieldEmailIntern',
|
template: 'FieldEmailIntern',
|
||||||
initialize_content: function() {
|
initialize_content: function() {
|
||||||
this._super();
|
this._super();
|
||||||
var $button = this.$el.find('button');
|
var $button = this.$el.find('a');
|
||||||
$button.click(this.on_button_clicked);
|
$button.click(this.on_clicked);
|
||||||
this.setupFocus($button);
|
this.setupFocus($button);
|
||||||
},
|
},
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
|
@ -23,28 +23,26 @@ instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({
|
||||||
this._super();
|
this._super();
|
||||||
} else {
|
} else {
|
||||||
this.$el.find('a')
|
this.$el.find('a')
|
||||||
//.attr('href', 'nix:' + this.get('value'))
|
|
||||||
.removeAttr('href')
|
.removeAttr('href')
|
||||||
.text(this.get('value') || '')
|
.removeAttr('target')
|
||||||
.unbind('click')
|
.text(this.get('value') || '');
|
||||||
.click(function () {
|
|
||||||
self.do_action('mail.action_email_compose_message_wizard',{
|
|
||||||
additional_context:{
|
|
||||||
default_partner_ids: self.field_manager.get_selected_ids()
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_button_clicked: function() {
|
on_clicked: function() {
|
||||||
if (!this.get('value') || !this.is_syntax_valid()) {
|
var self = this;
|
||||||
this.do_warn(_t("E-mail Error"), _t("Can't send email to invalid e-mail address"));
|
if (!self.get('value') || !self.is_syntax_valid()) {
|
||||||
|
self.do_warn(_t("E-mail Error"), _t("Can't send email to invalid e-mail address"));
|
||||||
} else {
|
} else {
|
||||||
// action to open: mail.action_email_compose_message_wizard
|
self.do_action(
|
||||||
//location.href = 'mailto:' + this.get('value');
|
'mail.action_email_compose_message_wizard',{
|
||||||
self.do_action('mail.action_email_compose_message_wizard')
|
additional_context:{
|
||||||
}
|
// getting partner this way is wrong, need to search in
|
||||||
|
// res.partner by email
|
||||||
|
default_partner_ids: self.field_manager.get_selected_ids()
|
||||||
|
}}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.form.widgets.add('email', 'instance.web.form.FieldEmailIntern')
|
instance.web.form.widgets.add('email', 'instance.web.form.FieldEmailIntern')
|
||||||
|
|
Loading…
Reference in New Issue