[FIX] web: fix the color_picker widget alignment issue

Currently, when we go to the planning > config > resource
(editable list view without any record) and create a ersaource
the color picker widget is resized vertically instead of horizontally.

In this commit we have fixed the issue, when there is no record in
the planning_resources list view, the color_picker widget gets 72px width by
default, so we have added a condition that if there is a color_picker widget
in a field, we will calculate the width based on the total fields in the view.

task-2720976

X-original-commit: d047080c18ea4c9314df5f2aefdfb6b7deeef45a
Part-of: odoo/odoo#90897
This commit is contained in:
Adesh Jolhe (adjo)
2022-05-09 17:05:55 +02:00
committed by Barad Mahendra
parent 38bb37c386
commit 1bd3bce8df
2 changed files with 25 additions and 1 deletions
@@ -4075,7 +4075,7 @@ var FieldColorPicker = FieldInteger.extend({
_t('Green'),
_t('Purple'),
],
widthInList: '1',
/**
* Prepares the rendering, since we are based on an input but not using it
* setting tagName after parent init force the widget to not render an input
@@ -12808,6 +12808,30 @@ QUnit.module('Views', {
list.destroy();
});
QUnit.test('FieldColorPicker: dont overflow color picker in list', async function (assert) {
const list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: `
<tree editable="top" string="Partners">
<field name="date"/>
<field name="int_field" widget="color_picker"/>
</tree>`,
domain: [['id', '<', 0]],
});
await testUtils.dom.click(list.el.querySelector('.o_list_button_add'))
const date_column_width = list.el.querySelector('.o_list_table thead th[data-name="date"]').style.width.replace('px', '');
const int_field_column_width = list.el.querySelector('.o_list_table thead th[data-name="int_field"]').style.width.replace('px', '');
// Default values for date and int fields are: date: '92px', integer: '74px'
// With the screen growing, the proportion is kept and thus int_field would remain smaller than date if
// the color_picker wouldn't have widthInList set to '1'. With that property set, int_field size will be bigger
// than date's one.
assert.ok(parseFloat(date_column_width) < parseFloat(int_field_column_width), "colorpicker should display properly (Horizontly)");
list.destroy();
});
});
});