From 95c31ad01cc762d1dcd9c4dfccdf2d21c5264d35 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 14 Nov 2011 21:59:16 +0100 Subject: [PATCH] [ADD] FormView: Added debug information as tooltips bzr revid: fme@openerp.com-20111114205916-549at8roai7yrpjm --- addons/web/static/src/css/base.css | 16 ++++ addons/web/static/src/js/view_form.js | 35 ++++++++ addons/web/static/src/xml/base.xml | 111 ++++++++++++++++++++++++-- 3 files changed, 157 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 4fa2475e437..c061353d113 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -908,6 +908,22 @@ label.error { .openerp label.oe_label_help { cursor: help; } +.openerp #tiptip_content { + font-size: 12px; +} +.openerp .oe_tooltip_string { + color: #FD5; + font-weight: bold; + font-size: 13px; +} +.openerp .oe_tooltip_technical { + padding: 0 0 4px 0; + margin: 5px 0 0 15px; + list-style: circle; +} +.openerp .oe_tooltip_technical_title { + font-weight: bold; +} .openerp .oe_forms label.oe_label, .openerp .oe_forms label.oe_label_help { margin: 3px 0 0 10px; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a58c1d86d86..84041ef8b60 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -776,6 +776,25 @@ openerp.web.form.Widget = openerp.web.Widget.extend(/** @lends openerp.web.form. var template = this.template; return QWeb.render(template, { "widget": this }); }, + do_attach_tooltip: function(widget, trigger, options) { + widget = widget || this; + trigger = trigger || this.$element; + options = _.extend({ + delay: 1000, + maxWidth: openerp.connection.debug ? '300px' : '200px', + content: function() { + var template = widget.template + '.tooltip'; + if (!QWeb.has_template(template)) { + template = 'WidgetLabel.tooltip'; + } + return QWeb.render(template, { + debug: openerp.connection.debug, + widget: widget + }); + } + }, options || {}); + trigger.tipTip(options); + }, _build_view_fields_values: function() { var a_dataset = this.view.dataset; var fields_values = this.view.get_fields_values(); @@ -948,6 +967,11 @@ openerp.web.form.WidgetNotebook = openerp.web.form.Widget.extend({ }); this.$element.tabs(); this.view.on_button_new.add_first(this.do_select_first_visible_tab); + if (openerp.connection.debug) { + this.do_attach_tooltip(this, this.$element.find('ul:first'), { + defaultPosition: 'top' + }); + } }, do_select_first_visible_tab: function() { for (var i = 0; i < this.pages.length; i++) { @@ -1011,6 +1035,9 @@ openerp.web.form.WidgetButton = openerp.web.form.Widget.extend({ start: function() { this._super.apply(this, arguments); this.$element.find("button").click(this.on_click); + if (this.help || openerp.connection.debug) { + this.do_attach_tooltip(); + } }, on_click: function() { var self = this; @@ -1110,6 +1137,9 @@ openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({ start: function() { this._super(); var self = this; + if (this['for'] && (this['for'].help || openerp.connection.debug)) { + this.do_attach_tooltip(self['for']); + } this.$element.find("label").dblclick(function() { var widget = self['for'] || self; openerp.log(widget.element_class , widget); @@ -1155,6 +1185,11 @@ openerp.web.form.Field = openerp.web.form.Widget.extend(/** @lends openerp.web.f this.view.translatable_fields.push(this); this.$element.find('.oe_field_translate').click(this.on_translate); } + if (this.nolabel && openerp.connection.debug) { + this.do_attach_tooltip(this, this.$element, { + defaultPosition: 'top' + }); + } }, set_value: function(value) { this.value = value; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2dfbf8b2532..bbbbbea0c4b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -753,6 +753,19 @@ + + +
+ Notebook Page "" +
+
    +
  • + Modifiers: + +
  • +
+
+
@@ -765,13 +778,72 @@ + +
+ (nolabel) +
+

+ +

+
    +
  • + Field: + +
  • +
  • + Object: + +
  • +
  • + Type: + +
  • +
  • + Widget: + +
  • +
  • + Size: + +
  • +
  • + Context: + +
  • +
  • + Domain: + +
  • +
  • + Modifiers: + +
  • +
  • + On change: + +
  • +
  • + Relation: + +
  • +
  • + Selection: +
      +
    • + [] + - + +
    • +
    +
  • +
+

@@ -1007,13 +1079,42 @@ - + + +
+ + Button + : + (no string) + + +
+
+ +
  • + Special: + +
  • + +
  • + Button Type: + +
  • +
  • + Method: + +
  • +
  • + Action ID: + +
  • +
    +