[ADD] FormView: Added debug information as tooltips

bzr revid: fme@openerp.com-20111114205916-549at8roai7yrpjm
This commit is contained in:
Fabien Meghazi 2011-11-14 21:59:16 +01:00
parent 2bd2ef2cf3
commit 95c31ad01c
3 changed files with 157 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -753,6 +753,19 @@
<t t-raw="page.render()"/>
</t>
</t>
<t t-name="WidgetNotebook.tooltip">
<t t-foreach="widget.pages" t-as="page">
<div class="oe_tooltip_string">
Notebook Page "<t t-esc="page.string"/>"
</div>
<ul class="oe_tooltip_technical">
<li data-item="modifiers">
<span class="oe_tooltip_technical_title">Modifiers:</span>
<t t-esc="page.node.attrs.modifiers"/>
</li>
</ul>
</t>
</t>
<t t-name="WidgetNotebookPage">
<div>
<t t-call="WidgetFrame"/>
@ -765,13 +778,72 @@
</t>
<t t-name="WidgetLabel">
<label t-att-for="widget.element_id"
t-attf-class="oe_label#{widget.help ? '_help' : ''} oe_align_#{widget.align}"
t-att-title="widget.help">
t-attf-class="oe_label#{widget.help ? '_help' : ''} oe_align_#{widget.align}">
<t t-esc="widget.string"/>
<span t-if="widget.help">?</span>
<t t-if="widget.string and widget.node.tag != 'label'">:</t>
</label>
</t>
<t t-name="WidgetLabel.tooltip">
<div class="oe_tooltip_string" t-if="widget.string">
<t t-esc="widget.string"/> <t t-if="debug and widget.nolabel">(nolabel)</t>
</div>
<p t-if="widget.help" class="oe_tooltip_help">
<t t-esc="widget.help"/>
</p>
<ul t-if="debug" class="oe_tooltip_technical">
<li data-item="field" t-if="widget.name">
<span class="oe_tooltip_technical_title">Field:</span>
<t t-esc="widget.name"/>
</li>
<li data-item="object" t-if="widget.view and widget.view.fields_view">
<span class="oe_tooltip_technical_title">Object:</span>
<t t-esc="widget.view.fields_view.model"/>
</li>
<li data-item="type" t-if="widget.field">
<span class="oe_tooltip_technical_title">Type:</span>
<t t-esc="widget.field.type"/>
</li>
<li t-if="widget.node.attrs.widget" data-item="widget">
<span class="oe_tooltip_technical_title">Widget:</span>
<t t-esc="widget.node.attrs.widget"/>
</li>
<li t-if="widget.node.attrs.size || (widget.field and widget.field.size)" data-item="size">
<span class="oe_tooltip_technical_title">Size:</span>
<t t-esc="widget.node.attrs.size || widget.field.size"/>
</li>
<li t-if="widget.node.attrs.context" data-item="context">
<span class="oe_tooltip_technical_title">Context:</span>
<t t-esc="widget.node.attrs.context_string"/>
</li>
<li t-if="widget.node.attrs.domain" data-item="domain">
<span class="oe_tooltip_technical_title">Domain:</span>
<t t-esc="widget.node.attrs.domain_string"/>
</li>
<li t-if="widget.node.attrs.modifiers and widget.node.attrs.modifiers != '{}'" data-item="modifiers">
<span class="oe_tooltip_technical_title">Modifiers:</span>
<t t-esc="widget.node.attrs.modifiers"/>
</li>
<li t-if="widget.node.attrs.on_change" data-item="on_change">
<span class="oe_tooltip_technical_title">On change:</span>
<t t-esc="widget.node.attrs.on_change"/>
</li>
<li t-if="widget.field and widget.field.relation" data-item="relation">
<span class="oe_tooltip_technical_title">Relation:</span>
<t t-esc="widget.field.relation"/>
</li>
<li t-if="widget.field and widget.field.selection" data-item="selection">
<span class="oe_tooltip_technical_title">Selection:</span>
<ul>
<li t-foreach="widget.field.selection" t-as="option">
[<t t-esc="option[0]"/>]
<t t-if="option[1]"> - </t>
<t t-esc="option[1]"/>
</li>
</ul>
</li>
</ul>
</t>
<t t-name="WidgetParagraph">
<p t-attf-class="oe_form_paragraph oe_align_#{widget.align}"><t t-esc="widget.string"/></p>
</t>
@ -1007,13 +1079,42 @@
</table>
</t>
<t t-name="WidgetButton">
<button type="button"
t-att-title="widget.help"
style="width: 100%" class="button">
<button type="button" style="width: 100%" class="button">
<img t-if="widget.node.attrs.icon" t-att-src="'/web/static/src/img/icons/' + widget.node.attrs.icon + '.png'" width="16" height="16"/>
<span t-if="widget.string"><t t-esc="widget.string"/></span>
</button>
</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">
<span class="oe_tooltip_technical_title">Special:</span>
<t t-esc="widget.node.attrs.special"/>
</li>
<t t-set="button_type" t-value="widget.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"/>
</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"/>
</li>
</t>
</t>
<t t-name="SearchView">
<form class="oe_forms">