[ADD] Added widget field type "email"
bzr revid: fme@openerp.com-20110512162550-ksv72qrac2l9ttvi
This commit is contained in:
parent
d9fa808fcf
commit
4508febaea
|
@ -654,7 +654,24 @@ openerp.base.form.FieldChar = openerp.base.form.Field.extend({
|
|||
openerp.base.form.FieldEmail = openerp.base.form.FieldChar.extend({
|
||||
init: function(view, node) {
|
||||
this._super(view, node);
|
||||
this.template = "FieldEmail";
|
||||
this.validation_regex = /@/;
|
||||
},
|
||||
start: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.$element.find('button').click(this.on_button_clicked);
|
||||
},
|
||||
on_button_clicked: function() {
|
||||
if (!this.value || this.invalid) {
|
||||
this.notification.warn("E-mail error", "Can't send email to invalid e-mail address");
|
||||
} else {
|
||||
location.href = 'mailto:' + this.value;
|
||||
}
|
||||
},
|
||||
set_value: function(value) {
|
||||
this._super.apply(this, arguments);
|
||||
var show_value = (value != null && value !== false) ? value : '';
|
||||
this.$element.find('a').attr('href', 'mailto:' + show_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -304,6 +304,20 @@
|
|||
t-att-class="'field_' + widget.type" style="width: 100%"
|
||||
/>
|
||||
</t>
|
||||
<t t-name="FieldEmail">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<t t-call="FieldChar"/>
|
||||
</td>
|
||||
<td width="16">
|
||||
<button class="button" title="Send an e-mail with your default e-mail client">
|
||||
<img src="/base/static/src/img/icons/terp-mail-message-new.png"/>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
<t t-name="FieldText">
|
||||
<textarea rows="6" style="width: 100%;"
|
||||
t-att-name="widget.name"
|
||||
|
|
Loading…
Reference in New Issue