summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorKhoi Nguyen <bng@odoo.com>2017-07-23 16:09:18 +0200
committerKhoi Nguyen <bng@odoo.com>2017-07-24 13:14:23 +0200
commit952c17b8a76c39f6bdf780edcd07ca5def3c8520 (patch)
tree68abba882908c2b8f026f9b5742de06e336d06c7 /addons/web/static/src
parentcae497b6794ec8b9dd44c986660106ae28b332ba (diff)
[FIX] web: add tooltips for buttons
Button tooltips have been missing since the switch to the new views. As their omission was unintentional, this revision restores the functionality.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/form/form_renderer.js15
-rw-r--r--addons/web/static/src/xml/base_common.xml49
2 files changed, 46 insertions, 18 deletions
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js
index 25b72e4fb5a..75d3fcebf1d 100644
--- a/addons/web/static/src/js/views/form/form_renderer.js
+++ b/addons/web/static/src/js/views/form/form_renderer.js
@@ -336,12 +336,27 @@ var FormRenderer = BasicRenderer.extend({
* @returns {jQueryElement}
*/
_renderHeaderButton: function (node) {
+ var self = this;
var $button = $('<button>')
.text(node.attrs.string)
.addClass('btn btn-sm btn-default');
this._addOnClickAction($button, node);
this._handleAttributes($button, node);
this._registerModifiers(node, this.state, $button);
+
+ // Display tooltip
+ if (config.debug || node.attrs.help) {
+ $button.tooltip({
+ delay: { show: 1000, hide: 0 },
+ title: function () {
+ return qweb.render('WidgetButton.tooltip', {
+ debug: config.debug,
+ state: self.state,
+ node: node,
+ });
+ },
+ });
+ }
return $button;
},
/**
diff --git a/addons/web/static/src/xml/base_common.xml b/addons/web/static/src/xml/base_common.xml
index 618c3a1f7e2..3e0d6291dfd 100644
--- a/addons/web/static/src/xml/base_common.xml
+++ b/addons/web/static/src/xml/base_common.xml
@@ -93,36 +93,49 @@
</li>
</ul>
</t>
-<t t-name="WidgetButton.tooltip" t-extend="WidgetLabel.tooltip">
- <t t-jquery="div.oe_tooltip_string" t-operation="replace">
- <div class="oe_tooltip_string" t-if="debug || widget.string">
- <t t-if="debug">
- Button
- <t t-if="widget.string">: </t>
- <t t-if="!widget.string"> (no string)</t>
- </t>
- <t t-esc="widget.string"/>
- </div>
- </t>
- <t t-jquery="ul.oe_tooltip_technical" t-operation="append">
- <li t-if="widget.node.attrs.special" data-item="special">
+<t t-name="WidgetButton.tooltip">
+ <div class="oe_tooltip_string" t-if="debug || node.attrs.string">
+ <t t-if="debug">
+ Button
+ <t t-if="node.attrs.string">: </t>
+ <t t-if="!node.attrs.string"> (no string)</t>
+ </t>
+ <t t-esc="node.attrs.string"/>
+ </div>
+ <p t-if="node.attrs.help" class="oe_tooltip_help">
+ <t t-esc="node.attrs.help"/>
+ </p>
+ <ul t-if="debug" class="oe_tooltip_technical">
+ <li data-item="object">
+ <span class="oe_tooltip_technical_title">Object:</span>
+ <t t-esc="state.model"/>
+ </li>
+ <li t-if="node.attrs.context" data-item="context">
+ <span class="oe_tooltip_technical_title">Context:</span>
+ <t t-esc="node.attrs.context || widget.field.context"/>
+ </li>
+ <li t-if="node.attrs.modifiers and node.attrs.modifiers != '{}'" data-item="modifiers">
+ <span class="oe_tooltip_technical_title">Modifiers:</span>
+ <t t-esc="node.attrs.modifiers"/>
+ </li>
+ <li t-if="node.attrs.special" data-item="special">
<span class="oe_tooltip_technical_title">Special:</span>
- <t t-esc="widget.node.attrs.special"/>
+ <t t-esc="node.attrs.special"/>
</li>
- <t t-set="button_type" t-value="widget.node.attrs.type"/>
+ <t t-set="button_type" t-value="node.attrs.type"/>
<li t-if="button_type" data-item="button_type">
<span class="oe_tooltip_technical_title">Button Type:</span>
<t t-esc="button_type"/>
</li>
<li t-if="button_type === 'object'" data-item="button_method">
<span class="oe_tooltip_technical_title">Method:</span>
- <t t-esc="widget.node.attrs.name"/>
+ <t t-esc="node.attrs.name"/>
</li>
<li t-if="button_type === 'action'" data-item="button_action">
<span class="oe_tooltip_technical_title">Action ID:</span>
- <t t-esc="widget.node.attrs.name"/>
+ <t t-esc="node.attrs.name"/>
</li>
- </t>
+ </ul>
</t>
<t t-name="SwitchCompanyMenu">