diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-04-18 10:43:10 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-04-19 11:42:01 +0200 |
| commit | 7ff8aa73e17b281b3e2bc4c7275d020eab0204e7 (patch) | |
| tree | d45b9ea0299c66bc1bb448634163d8aa686050b5 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | ff86e5b9862deab9a9772774e941140966a9ab7c (diff) | |
[REF] web, *: implement modifiers behaviors
* account, mail, sale
Since the views refactoring, modifiers were not properly handled
anymore (readonly/required not recomputed, use of readonly/required
of "python field" instead of "view field", ...). This commit tries to
implement a system which allows to handle the modifiers (re)computation
the same way for all the basic views.
For this to work, many specialized renderers behaviors have been moved
to the basic renderer so that more mechanisms are shared (especially by
the form renderer and the list editable renderer). The list editable
renderer is hugely impacted by this commit.
Here is a list of key changes:
- The basic renderer now has a `_renderFieldWidget` function which is
used without modification by the form and the list renderers.
- Modifiers have to be registered thanks to the basic renderer
`_registerModifiersData` function (this is done automatically for
fields by the `_renderFieldWidget` function for example).
- All instantiated widgets are accessible, organized by record, and
ordered in a special basic renderer variable.
- The code which resets the widgets of the form view and the code
which updates the row of a list editable view is now shared in the
basic renderer and now also automatically updates the DOM according
to the reevaluated modifiers.
- The last point has an huge impact on list editable renderer: all the
widgets have to be instantiated when editing a row (even readonly and
invisible ones) as they can be switched to editable/visible during
edition (after a modifiers update).
- `replace_element` and `readonly` options of `AbstractField` are
useless: widgets are now always replacing the list editable cells
in edition and the `readonly` widget mechanism is replaced by the
notion of 'focusable' widgets.
(see `AbstractField.getFocusableElement`)
- The 'tab' navigation mechanism is impacted by the previous point,
some code sharing have been done in basic renderer for this too.
- `AbstractField` does not care anymore of the 'required' status, this
is the view responsability to check that a required field has a set
value on save.
- Some list editable bug fixing (e.g. it was possible to edit multiple
rows at the same time, it was not possible to navigate towards the
previous field, crash on o2m add an item click, ...)
- The mockserver now properly simulates server modifiers computation.
- ...
Note: list editable style may be worse than before this commit but a
CSS update is coming in a few days.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 6b23940a9db..93a19de7b81 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -835,15 +835,15 @@ QUnit.module('relational_fields', { "display name of first record in o2m list should be 'relational record 1'"); form.$buttons.find('.o_form_button_edit').click(); form.$('.o_field_one2many tbody td').first().click(); - assert.ok(form.$('.o_field_one2many tbody td').first().hasClass('o_edit_mode'), + assert.ok(form.$('.o_field_one2many tbody td').first().parent().hasClass('o_selected_row'), "first row of o2m should be in edition"); form.$('.o_field_one2many tbody td').first().find('input').val("new value").trigger('input'); - assert.ok(form.$('.o_field_one2many tbody td').first().hasClass('o_edit_mode'), + assert.ok(form.$('.o_field_one2many tbody td').first().parent().hasClass('o_selected_row'), "first row of o2m should still be in edition"); // // leave o2m edition form.$el.click(); - assert.ok(!form.$('.o_field_one2many tbody td').first().hasClass('o_edit_mode'), + assert.ok(!form.$('.o_field_one2many tbody td').first().parent().hasClass('o_selected_row'), "first row of o2m should be readonly again"); // discard changes @@ -1224,18 +1224,18 @@ QUnit.module('relational_fields', { // edit mode, then click on Add an item and enter a value form.$buttons.find('.o_form_button_edit').click(); form.$('.o_form_field_x2many_list_row_add a').click(); - form.$('td.o_edit_mode input').val('kartoffel').trigger('input'); + form.$('.o_selected_row > td input').val('kartoffel').trigger('input'); // click again on Add an item form.$('.o_form_field_x2many_list_row_add a').click(); assert.strictEqual(form.$('td:contains(kartoffel)').length, 1, "should have one td with the new value"); - assert.strictEqual(form.$('td.o_edit_mode input').length, 1, + assert.strictEqual(form.$('.o_selected_row > td input').length, 1, "should have one other new td"); assert.strictEqual(form.$('tr.o_data_row').length, 2, "should have 2 data rows"); // enter another value and save - form.$('td.o_edit_mode input').val('gemuse').trigger('input'); + form.$('.o_selected_row > td input').val('gemuse').trigger('input'); form.$buttons.find('.o_form_button_save').click(); assert.strictEqual(form.$('tr.o_data_row').length, 2, "should have 2 data rows"); assert.strictEqual(form.$('td:contains(kartoffel)').length, 1, @@ -2682,7 +2682,7 @@ QUnit.module('relational_fields', { assert.strictEqual(form.$('.o_data_row').length, 2, "should have 2 data rows"); - assert.ok(form.$('tr.o_data_row:first:contains(My little Foo Value)').length, 1, + assert.strictEqual(form.$('tr.o_data_row:first input').val(), 'My little Foo Value', "first row should be the new value"); assert.ok(form.$('tr.o_data_row:first').hasClass('o_selected_row'), "first row should be selected"); @@ -2728,7 +2728,7 @@ QUnit.module('relational_fields', { assert.strictEqual(form.$('.o_data_row').length, 2, "should have 2 data rows"); - assert.ok(form.$('tr.o_data_row:eq(1):contains(My little Foo Value)').length, 1, + assert.strictEqual(form.$('tr.o_data_row:eq(1) input').val(), 'My little Foo Value', "second row should be the new value"); assert.ok(form.$('tr.o_data_row:eq(1)').hasClass('o_selected_row'), "second row should be selected"); @@ -3190,13 +3190,15 @@ QUnit.module('relational_fields', { res_id: 1, }); - assert.ok(form.$('.o_statusbar_status button[data-value="4"]').hasClass('btn-primary disabled'), + var $selectedStatus = form.$('.o_statusbar_status button[data-value="4"]'); + assert.ok($selectedStatus.hasClass('btn-primary') && $selectedStatus.hasClass('disabled'), "selected status should be btn-primary and disabled"); var $clickable = form.$('.o_statusbar_status button.btn-default:not(.dropdown-toggle):not(:disabled)'); assert.strictEqual($clickable.length, 2, "other status should be btn-default and not disabled"); $clickable.last().click(); // (last is visually the first here (css)) - assert.ok(form.$('.o_statusbar_status button[data-value="1"]').hasClass("btn-primary disabled"), + var $status = form.$('.o_statusbar_status button[data-value="1"]'); + assert.ok($status.hasClass("btn-primary") && $status.hasClass("disabled"), "value should have been updated"); form.destroy(); |
