[FIX] web: numbers in list views should be right-aligned
Before this commit, numbers in list views were right-aligned depending on the widget they were using (float/monetary). Now, the input text alignment is inherited from the parent which should solve the problem.
This commit is contained in:
@@ -246,10 +246,12 @@ var ListRenderer = BasicRenderer.extend({
|
||||
if (node.tag === 'button') {
|
||||
tdClassName += ' o_list_button';
|
||||
} else {
|
||||
if (node.attrs.widget){
|
||||
var typeClass = FIELD_CLASSES[this.state.fields[node.attrs.name].type];
|
||||
if (typeClass) {
|
||||
tdClassName += (' ' + typeClass);
|
||||
}
|
||||
if (node.attrs.widget) {
|
||||
tdClassName += (' o_' + node.attrs.widget + '_cell');
|
||||
} else {
|
||||
tdClassName += (' ' + FIELD_CLASSES[this.state.fields[node.attrs.name].type]);
|
||||
}
|
||||
}
|
||||
var $td = $('<td>', {class: tdClassName});
|
||||
|
||||
@@ -26,7 +26,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
.o_field_widget {
|
||||
display: inline-block;
|
||||
// Default display and alignment of widget and internal <input/>
|
||||
&, input.o_input {
|
||||
display: inline-block;
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
// Block fields
|
||||
&.note-editor, &.oe_form_field_html, &.oe_form_field_html_text, &.oe_form_field_text, &.o_view_manager_content, &.o_field_domain {
|
||||
@@ -64,11 +68,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Input in field
|
||||
input[type="text"] {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
// Text
|
||||
&.o_field_text, &.oe_form_field_text .oe_form_text_content {
|
||||
width: 100%;
|
||||
|
||||
@@ -92,11 +92,11 @@
|
||||
|
||||
// Values styling
|
||||
.o_data_cell {
|
||||
&.o_list_number, &.o_field_integer, &.o_field_float, &.o_field_monetary {
|
||||
&.o_list_number {
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
&.o_list_text, &.o_field_text {
|
||||
&.o_list_text {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
&.o_invisible_modifier {
|
||||
@@ -174,9 +174,6 @@
|
||||
.o_field_boolean {
|
||||
width: auto!important; // Override the width computed in JS (needed for Chrome)
|
||||
}
|
||||
.o_field_number {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2065,6 +2065,48 @@ QUnit.module('Views', {
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('numbers in list are right-aligned', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var currencies = {};
|
||||
_.each(this.data.res_currency.records, function (currency) {
|
||||
currencies[currency.id] = currency;
|
||||
});
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<tree editable="top">' +
|
||||
'<field name="foo"/>' +
|
||||
'<field name="qux"/>' +
|
||||
'<field name="amount" widget="monetary"/>' +
|
||||
'<field name="currency_id" invisible="1"/>' +
|
||||
'</tree>',
|
||||
session: {
|
||||
currencies: currencies,
|
||||
},
|
||||
});
|
||||
|
||||
var nbCellRight = _.filter(list.$('.o_data_row:first > .o_data_cell'), function (el) {
|
||||
var style = window.getComputedStyle(el);
|
||||
return style.textAlign === 'right';
|
||||
}).length;
|
||||
assert.strictEqual(nbCellRight, 2,
|
||||
"there should be two right-aligned cells");
|
||||
|
||||
list.$('.o_data_cell:first').click();
|
||||
|
||||
var nbInputRight = _.filter(list.$('.o_data_row:first > .o_data_cell input'), function (el) {
|
||||
var style = window.getComputedStyle(el);
|
||||
return style.textAlign === 'right';
|
||||
}).length;
|
||||
assert.strictEqual(nbInputRight, 2,
|
||||
"there should be two right-aligned input");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user