[FIX] web: debug mode tooltip
Display properly the content of context object instead of [object Object].
This commit is contained in:
@@ -812,7 +812,7 @@ var FormRenderer = BasicRenderer.extend({
|
||||
_.each(this.allFieldWidgets[this.state.id], function (widget) {
|
||||
var idForLabel = self.idsForLabels[widget.name];
|
||||
var $label = idForLabel ? self.$('label[for=' + idForLabel + ']') : $();
|
||||
if (core.debug || widget.attrs.help || widget.field.help) {
|
||||
if (config.debug || widget.attrs.help || widget.field.help) {
|
||||
self._addFieldTooltip(widget, $label);
|
||||
}
|
||||
if (widget.attrs.widget === 'upgrade_boolean') {
|
||||
|
||||
@@ -59,11 +59,11 @@
|
||||
</li>
|
||||
<li t-if="widget.attrs.context || widget.field.context" data-item="context">
|
||||
<span class="oe_tooltip_technical_title">Context:</span>
|
||||
<t t-esc="widget.attrs.context || widget.field.context"/>
|
||||
<t t-esc="widget.attrs.context || JSON.stringify(widget.field.context)"/>
|
||||
</li>
|
||||
<li t-if="widget.attrs.domain || widget.field.domain" data-item="domain">
|
||||
<span class="oe_tooltip_technical_title">Domain:</span>
|
||||
<t t-esc="widget.attrs.domain || widget.field.domain"/>
|
||||
<t t-esc="widget.attrs.domain || JSON.stringify(widget.field.domain)"/>
|
||||
</li>
|
||||
<li t-if="widget.attrs.modifiers and widget.attrs.modifiers != '{}'" data-item="modifiers">
|
||||
<span class="oe_tooltip_technical_title">Modifiers:</span>
|
||||
|
||||
@@ -5920,5 +5920,36 @@ QUnit.module('Views', {
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('proper context stringification in debug mode tooltip', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var initialDebugMode = config.debug;
|
||||
config.debug = true;
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="product_id" context="{\'lang\': \'en_US\'}"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
});
|
||||
|
||||
var $field = form.$('[name="product_id"]');
|
||||
$field.tooltip('show', true);
|
||||
$field.trigger($.Event('mouseenter'));
|
||||
assert.strictEqual($('.oe_tooltip_technical>li[data-item="context"]').length,
|
||||
1, 'context should be present for this field');
|
||||
assert.strictEqual($('.oe_tooltip_technical>li[data-item="context"]')[0].lastChild.wholeText.trim(),
|
||||
"{'lang': 'en_US'}", "context should be properly stringified");
|
||||
|
||||
config.debug = initialDebugMode;
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user