summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2013-04-04 12:34:22 +0200
committerThibault Delavallée <tde@openerp.com>2013-04-04 12:34:22 +0200
commit431f447fa4232a037f1cfa0579fcd8f005583180 (patch)
tree34fdbf3f3979399c3f9f246846eb2276ee706c5b /addons/web/static/src
parentcaff74a6504d48e2a3fde8fb61d23efcd3c68a2f (diff)
parentb207801acc5daa3c1244f9a0321fa1caaf8ca07e (diff)
[MERGE] Sync with trunk.
bzr revid: tde@openerp.com-20130328112348-5gcg79ipve3rt4ut bzr revid: tde@openerp.com-20130402081347-hgz8vg6af9l18vcx bzr revid: tde@openerp.com-20130404090149-csbp0wnodbe126q7 bzr revid: tde@openerp.com-20130404103422-p533mmjn7btlhvcb
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/css/base.css22
-rw-r--r--addons/web/static/src/css/base.sass19
-rw-r--r--addons/web/static/src/img/icons/input_radio-off.pngbin0 -> 512 bytes
-rw-r--r--addons/web/static/src/img/icons/input_radio-on.pngbin0 -> 559 bytes
-rw-r--r--addons/web/static/src/js/view_form.js40
-rw-r--r--addons/web/static/src/xml/base.xml29
6 files changed, 101 insertions, 9 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css
index 1bad7a02f90..50028703f51 100644
--- a/addons/web/static/src/css/base.css
+++ b/addons/web/static/src/css/base.css
@@ -2312,6 +2312,28 @@
display: inline-block;
min-width: 70px;
}
+.openerp .oe_form_field_radio.oe_horizontal {
+ white-space: nowrap;
+}
+.openerp .oe_form_field_radio.oe_horizontal .oe_radio_header {
+ display: inline-block;
+ text-align: center;
+}
+.openerp .oe_form_field_radio.oe_vertical .oe_radio_header {
+ cursor: pointer;
+}
+.openerp .oe_form_field_radio .oe_radio_input {
+ cursor: pointer;
+ display: inline-block;
+ width: 20px;
+ background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center;
+}
+.openerp .oe_form_field_radio .oe_radio_input_on {
+ background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center;
+}
+.openerp .oe_form_field_radio .oe_radio_label {
+ cursor: default;
+}
.openerp .oe_form_field_progressbar.ui-progressbar {
height: 22px;
font-size: 10px;
diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass
index a9fa725b07c..c0d5aa0ad91 100644
--- a/addons/web/static/src/css/base.sass
+++ b/addons/web/static/src/css/base.sass
@@ -480,7 +480,24 @@ $sheet-padding: 16px
.oe_tag_dark
background: $tag-bg-dark
color: #eee
-
+ .oe_form_field_radio
+ &.oe_horizontal
+ white-space: nowrap
+ .oe_radio_header
+ display: inline-block
+ text-align: center
+ &.oe_vertical
+ .oe_radio_header
+ cursor: pointer
+ .oe_radio_input
+ cursor: pointer
+ display: inline-block
+ width: 20px
+ background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center
+ .oe_radio_input_on
+ background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center
+ .oe_radio_label
+ cursor: default
.oe_tags
&.oe_inline
min-width: 250px
diff --git a/addons/web/static/src/img/icons/input_radio-off.png b/addons/web/static/src/img/icons/input_radio-off.png
new file mode 100644
index 00000000000..790f7ed13b2
--- /dev/null
+++ b/addons/web/static/src/img/icons/input_radio-off.png
Binary files differ
diff --git a/addons/web/static/src/img/icons/input_radio-on.png b/addons/web/static/src/img/icons/input_radio-on.png
new file mode 100644
index 00000000000..d55c291e795
--- /dev/null
+++ b/addons/web/static/src/img/icons/input_radio-on.png
Binary files differ
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index b057616b6ab..9d79a32d60d 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -2804,6 +2804,40 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
}
});
+instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
+ template: 'FieldRadio',
+ init: function(field_manager, node) {
+ /* Radio button widget: Attributes options:
+ * - "horizontal" to display in column
+ * - "no_radiolabel" don't display text values
+ * - "display_readonly" to display radio button (not clickable) in read only mode
+ */
+ var self = this;
+ this._super(field_manager, node);
+ this.horizontal = +this.options.horizontal;
+ this.no_radiolabel = +this.options.no_radiolabel;
+ this.display_readonly = +this.options.display_readonly;
+ },
+ initialize_content: function () {
+ var self = this;
+ this.$el.on('click', '.oe_radio_input,.oe_radio_header', function (event) {
+ var id = $(event.target).data("id");
+ id = isNaN(+id) ? id : +id;
+ if (id && !self.get("effective_readonly")) {
+ if (!self.field.required && id == self.get_value()) {
+ self.set_value(false);
+ } else {
+ self.set_value(id);
+ }
+ }
+ });
+ },
+ render_value: function () {
+ this.$(".oe_radio_input_on").removeClass("oe_radio_input_on");
+ this.$(".oe_radio_input[data-id='" + this.get_value() + "'], .oe_radio_header[data-id='" + this.get_value() + "'] .oe_radio_input").addClass("oe_radio_input_on");
+ }
+});
+
// jquery autocomplete tweak to allow html and classnames
(function() {
var proto = $.ui.autocomplete.prototype,
@@ -5295,11 +5329,6 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
var self = this;
var content = QWeb.render("FieldStatus.content", {widget: self});
self.$el.html(content);
- var colors = JSON.parse((self.node.attrs || {}).statusbar_colors || "{}");
- var color = colors[self.get('value')];
- if (color) {
- self.$("oe_active").css("color", color);
- }
},
calc_domain: function() {
var d = instance.web.pyeval.eval('domain', this.build_domain());
@@ -5423,6 +5452,7 @@ instance.web.form.widgets = new instance.web.Registry({
'date' : 'instance.web.form.FieldDate',
'datetime' : 'instance.web.form.FieldDatetime',
'selection' : 'instance.web.form.FieldSelection',
+ 'radio' : 'instance.web.form.FieldRadio',
'many2one' : 'instance.web.form.FieldMany2One',
'many2onebutton' : 'instance.web.form.Many2OneButton',
'many2many' : 'instance.web.form.FieldMany2Many',
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index bcd5763a37e..405ee81e0cd 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -40,11 +40,11 @@
<td>
<p>
<t t-js="d">
- var message = d.error.data.message || d.error.data.fault_code;
- d.error.html_error = context.engine.tools.html_escape(message)
+ var message = d.message ? d.message : d.error.data.message;
+ d.html_error = context.engine.tools.html_escape(message)
.replace(/\n/g, '<br/>');
</t>
- <t t-raw="error.html_error"/>
+ <t t-raw="html_error"/>
</p>
</td>
</tr>
@@ -1111,6 +1111,29 @@
</select>
</span>
</t>
+<t t-name="FieldRadio">
+ <span t-attf-class="oe_form_field oe_form_field_radio #{widget.horizontal ? 'oe_horizontal' : 'oe_vertical'}" t-att-style="widget.node.attrs.style">
+ <t t-if="widget.horizontal">
+ <t t-set="width" t-value="Math.floor(100 / widget.field.selection.length)"/>
+ <t t-if="!widget.no_radiolabel">
+ <t t-foreach="widget.field.selection" t-as="selection">
+ <div class="oe_radio_header" t-att-style="'width: ' + width + '%;'"><t t-esc="selection[1]"/></div>
+ </t>
+ <br/>
+ </t>
+ <t t-foreach="widget.field.selection" t-as="selection">
+ <div class="oe_radio_input" t-att-style="'width: ' + width + '%;'" t-att-data-id="selection[0]">&amp;nbsp;</div>
+ </t>
+ </t>
+ <t t-if="!widget.horizontal">
+ <t t-foreach="widget.field.selection" t-as="selection">
+ <div class="oe_radio_header" t-att-style="'width: ' + width + '%;'" t-att-data-id="selection[0]">
+ <div class="oe_radio_input">&amp;nbsp;</div><t t-if="!widget.no_radiolabel" t-esc="selection[1]"/>
+ </div>
+ </t>
+ </t>
+ </span>
+</t>
<t t-name="FieldMany2One">
<span class="oe_form_field oe_form_field_many2one oe_form_field_with_button" t-att-style="widget.node.attrs.style">
<t t-if="widget.get('effective_readonly')">