[FIX] rendering of readonly URI fields

don't call FieldChar's set_value as this nukes the URI widget's content (link in this case). Either that, or empty the content and add the link back via DOM manipulations

lp bug: https://launchpad.net/bugs/930761 fixed

bzr revid: xmo@openerp.com-20120213082047-931ea10a8lrb18wf
This commit is contained in:
Xavier Morel 2012-02-13 09:20:47 +01:00
parent d970294f61
commit c0c89da4b8
1 changed files with 8 additions and 3 deletions

View File

@ -92,17 +92,22 @@ openerp.web.page = function (openerp) {
openerp.web.page.FieldURIReadonly = openerp.web.page.FieldCharReadonly.extend({
template: 'FieldURI.readonly',
scheme: null,
format_value: function (value) {
return value;
},
set_value: function (value) {
var displayed = this._super.apply(this, arguments);
this.$element.find('a')
.attr('href', this.scheme + ':' + displayed)
.text(displayed);
.attr('href', this.scheme + ':' + value)
.text(this.format_value(value));
}
});
openerp.web.page.FieldEmailReadonly = openerp.web.page.FieldURIReadonly.extend({
scheme: 'mailto'
});
openerp.web.page.FieldUrlReadonly = openerp.web.page.FieldURIReadonly.extend({
format_value: function (value) {
return value.slice(2);
},
set_value: function (value) {
var s = /(\w+):(.+)/.exec(value);
if (!s || !(s[1] === 'http' || s[1] === 'https')) { return; }