[imp] made url readonly-able
bzr revid: nicolas.vanhoren@openerp.com-20120316114424-veofbtwtzmz7kakj
This commit is contained in:
parent
7cee52681f
commit
55b40f3e17
|
@ -1514,10 +1514,22 @@ openerp.web.form.FieldEmail = openerp.web.form.FieldChar.extend({
|
|||
|
||||
openerp.web.form.FieldUrl = openerp.web.form.FieldChar.extend({
|
||||
template: 'FieldUrl',
|
||||
start: function() {
|
||||
this._super.apply(this, arguments);
|
||||
bind_events: function() {
|
||||
this._super();
|
||||
this.$element.find('button').click(this.on_button_clicked);
|
||||
},
|
||||
render_value: function() {
|
||||
if (!this.get("effective_readonly")) {
|
||||
this._super();
|
||||
} else {
|
||||
var tmp = this.value;
|
||||
var s = /(\w+):(.+)/.exec(tmp);
|
||||
if (!s) {
|
||||
tmp = "http://" + this.value;
|
||||
}
|
||||
this.$element.find('a').attr('href', tmp).text(tmp);
|
||||
}
|
||||
},
|
||||
on_button_clicked: function() {
|
||||
if (!this.value) {
|
||||
this.do_warn("Resource error", "This resource is empty");
|
||||
|
|
|
@ -68,24 +68,6 @@ openerp.web.page = function (openerp) {
|
|||
/** @namespace */
|
||||
openerp.web.page = {};
|
||||
|
||||
openerp.web.page.FieldURIReadonly = openerp.web.form.FieldChar.extend({
|
||||
form_template: 'FieldURI.readonly',
|
||||
scheme: null,
|
||||
format_value: function (value) {
|
||||
return value;
|
||||
},
|
||||
set_value: function (value) {
|
||||
}
|
||||
});
|
||||
openerp.web.page.FieldUrlReadonly = openerp.web.page.FieldURIReadonly.extend({
|
||||
set_value: function (value) {
|
||||
var s = /(\w+):(.+)/.exec(value);
|
||||
if (!s) {
|
||||
value = "http://" + value;
|
||||
}
|
||||
this.$element.find('a').attr('href', value).text(value);
|
||||
}
|
||||
});
|
||||
openerp.web.page.FieldBooleanReadonly = openerp.web.form.FieldBoolean.extend({
|
||||
update_dom: function() {
|
||||
this._super.apply(this, arguments);
|
||||
|
@ -168,8 +150,6 @@ openerp.web.page = function (openerp) {
|
|||
}
|
||||
});
|
||||
openerp.web.page.readonly = openerp.web.form.widgets.extend({
|
||||
'frame': 'openerp.web.page.WidgetFrameReadonly',
|
||||
'url': 'openerp.web.page.FieldUrlReadonly',
|
||||
'selection' : 'openerp.web.page.FieldSelectionReadonly',
|
||||
'reference': 'openerp.web.page.FieldReferenceReadonly',
|
||||
'boolean': 'openerp.web.page.FieldBooleanReadonly',
|
||||
|
|
|
@ -987,18 +987,25 @@
|
|||
</t>
|
||||
</t>
|
||||
<t t-name="FieldUrl">
|
||||
<table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<t t-call="FieldChar"/>
|
||||
</td>
|
||||
<td width="16">
|
||||
<button class="oe_button oe_field_button" type="button" title="Open this resource">
|
||||
<img t-att-src='_s + "/web/static/src/img/icons/gtk-ok.png"'/>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<t t-if="!widget.get('effective_readonly')">
|
||||
<table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<t t-call="FieldChar"/>
|
||||
</td>
|
||||
<td width="16">
|
||||
<button class="oe_button oe_field_button" type="button" title="Open this resource">
|
||||
<img t-att-src='_s + "/web/static/src/img/icons/gtk-ok.png"'/>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
<t t-if="widget.get('effective_readonly')">
|
||||
<div>
|
||||
<a href="#" class="oe_form_uri"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
<t t-name="FieldText">
|
||||
<div t-attf-class="oe_form_field_#{type}">
|
||||
|
|
Loading…
Reference in New Issue