[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({
|
openerp.web.form.FieldUrl = openerp.web.form.FieldChar.extend({
|
||||||
template: 'FieldUrl',
|
template: 'FieldUrl',
|
||||||
start: function() {
|
bind_events: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super();
|
||||||
this.$element.find('button').click(this.on_button_clicked);
|
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() {
|
on_button_clicked: function() {
|
||||||
if (!this.value) {
|
if (!this.value) {
|
||||||
this.do_warn("Resource error", "This resource is empty");
|
this.do_warn("Resource error", "This resource is empty");
|
||||||
|
|
|
@ -68,24 +68,6 @@ openerp.web.page = function (openerp) {
|
||||||
/** @namespace */
|
/** @namespace */
|
||||||
openerp.web.page = {};
|
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({
|
openerp.web.page.FieldBooleanReadonly = openerp.web.form.FieldBoolean.extend({
|
||||||
update_dom: function() {
|
update_dom: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
@ -168,8 +150,6 @@ openerp.web.page = function (openerp) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openerp.web.page.readonly = openerp.web.form.widgets.extend({
|
openerp.web.page.readonly = openerp.web.form.widgets.extend({
|
||||||
'frame': 'openerp.web.page.WidgetFrameReadonly',
|
|
||||||
'url': 'openerp.web.page.FieldUrlReadonly',
|
|
||||||
'selection' : 'openerp.web.page.FieldSelectionReadonly',
|
'selection' : 'openerp.web.page.FieldSelectionReadonly',
|
||||||
'reference': 'openerp.web.page.FieldReferenceReadonly',
|
'reference': 'openerp.web.page.FieldReferenceReadonly',
|
||||||
'boolean': 'openerp.web.page.FieldBooleanReadonly',
|
'boolean': 'openerp.web.page.FieldBooleanReadonly',
|
||||||
|
|
|
@ -987,18 +987,25 @@
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="FieldUrl">
|
<t t-name="FieldUrl">
|
||||||
<table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%">
|
<t t-if="!widget.get('effective_readonly')">
|
||||||
<tr>
|
<table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||||
<td width="100%">
|
<tr>
|
||||||
<t t-call="FieldChar"/>
|
<td width="100%">
|
||||||
</td>
|
<t t-call="FieldChar"/>
|
||||||
<td width="16">
|
</td>
|
||||||
<button class="oe_button oe_field_button" type="button" title="Open this resource">
|
<td width="16">
|
||||||
<img t-att-src='_s + "/web/static/src/img/icons/gtk-ok.png"'/>
|
<button class="oe_button oe_field_button" type="button" title="Open this resource">
|
||||||
</button>
|
<img t-att-src='_s + "/web/static/src/img/icons/gtk-ok.png"'/>
|
||||||
</td>
|
</button>
|
||||||
</tr>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
|
</table>
|
||||||
|
</t>
|
||||||
|
<t t-if="widget.get('effective_readonly')">
|
||||||
|
<div>
|
||||||
|
<a href="#" class="oe_form_uri"/>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="FieldText">
|
<t t-name="FieldText">
|
||||||
<div t-attf-class="oe_form_field_#{type}">
|
<div t-attf-class="oe_form_field_#{type}">
|
||||||
|
|
Loading…
Reference in New Issue