Skip to content
Permalink
Browse files

[IMP] web,account: list views: keep row height when editing

  • Loading branch information...
aab-odoo committed Mar 25, 2019
1 parent ca096f9 commit f157ca28fe6044d78aa4da3cc9373237295ec868
@@ -12,7 +12,7 @@ var _t = core._t;
var FieldChar = require('web.basic_fields').FieldChar;
var FieldOne2Many = require('web.relational_fields').FieldOne2Many;
var fieldRegistry = require('web.field_registry');
var FieldText = require('web.basic_fields').FieldText;
var ListFieldText = require('web.basic_fields').ListFieldText;
var ListRenderer = require('web.ListRenderer');

var SectionAndNoteListRenderer = ListRenderer.extend({
@@ -212,7 +212,7 @@ var SectionAndNoteFieldOne2Many = FieldOne2Many.extend({
// and a FieldText for the rest (product and note).
var SectionAndNoteFieldText = function (parent, name, record, options) {
var isSection = record.data.display_type === 'line_section';
var Constructor = isSection ? FieldChar : FieldText;
var Constructor = isSection ? FieldChar : ListFieldText;
return new Constructor(parent, name, record, options);
};
SectionAndNoteFieldText.prototype.colspan123 = 3;
@@ -102,7 +102,7 @@ var dom = {
}

options = options || {};
minHeight = (options && options.min_height) || 50;
minHeight = 'min_height' in options ? options.min_height : 50;

$fixedTextarea = $('<textarea disabled>', {
class: $textarea[0].className,
@@ -1118,6 +1118,7 @@ var FieldText = InputField.extend(TranslatableFieldMixin, {
if (this.mode === 'edit') {
this.tagName = 'textarea';
}
this.autoresizeOptions = {parent: this};
},
/**
* As it it done in the start function, the autoresize is done only once.
@@ -1126,7 +1127,7 @@ var FieldText = InputField.extend(TranslatableFieldMixin, {
*/
start: function () {
if (this.mode === 'edit') {
dom.autoresize(this.$el, {parent: this});
dom.autoresize(this.$el, this.autoresizeOptions);

this.$el = this.$el.add(this._renderTranslateButton());
}
@@ -1163,6 +1164,16 @@ var FieldText = InputField.extend(TranslatableFieldMixin, {
},
});

var ListFieldText = FieldText.extend({
/**
* @override
*/
init: function () {
this._super.apply(this, arguments);
this.autoresizeOptions.min_height = 0;
},
});

/**
* Displays a handle to modify the sequence.
*/
@@ -3027,6 +3038,7 @@ return {
FieldPhone: FieldPhone,
FieldProgressBar: FieldProgressBar,
FieldText: FieldText,
ListFieldText: ListFieldText,
FieldToggleBoolean: FieldToggleBoolean,
HandleWidget: HandleWidget,
InputField: InputField,
@@ -26,6 +26,7 @@ registry
.add('datetime', basic_fields.FieldDateTime)
.add('domain', basic_fields.FieldDomain)
.add('text', basic_fields.FieldText)
.add('list.text', basic_fields.ListFieldText)
.add('html', basic_fields.FieldText)
.add('float', basic_fields.FieldFloat)
.add('char', basic_fields.FieldChar)
@@ -32,7 +32,6 @@
}
tbody > tr > td:not(.o_list_record_selector) {
@include o-text-overflow(table-cell);
white-space: normal;
}

tfoot {
@@ -172,16 +171,14 @@
.o_input {
padding: 0;
@include o-text-overflow();
// FIXME: those rules should be moved to enterprise
border-bottom: 1px solid $o-form-lightsecondary;
&.o_required_modifier {
border-color: black;
}
border: none;
}
.o_field_widget > .o_external_button {
padding: 0;
border: none;
background-color: inherit;
margin-left: 3px;
margin-left: 5px;
font-size: 12px;
}
.o_field_monetary input {
width: 100%; // override width: 100px
@@ -25,6 +25,7 @@ QUnit.module('Views', {
bar: {string: "Bar", type: "boolean"},
date: {string: "Some Date", type: "date"},
int_field: {string: "int_field", type: "integer", sortable: true, group_operator: "sum"},
text: {string: "text field", type: "text"},
qux: {string: "my float", type: "float"},
m2o: {string: "M2O field", type: "many2one", relation: "bar"},
o2m: {string: "O2M field", type: "one2many", relation: "bar"},
@@ -1163,6 +1164,42 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('row height should not change when switching mode', async function (assert) {
assert.expect(3);

// Warning: this test is css dependant
var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="top">' +
'<field name="foo"/>' +
'<field name="int_field" readonly="1"/>' +
'<field name="text"/>' +
'<field name="m2o"/>' +
'<field name="m2m" widget="many2many_tags"/>' +
'</tree>',
});

var startHeight = list.$('.o_data_row:first').height();

// start edition of first row
await testUtils.dom.click(list.$('.o_data_row:first > td:not(.o_list_record_selector)').first());

assert.hasClass(list.$('.o_data_row:first'), 'o_selected_row');
var editionHeight = list.$('.o_data_row:first').height();

// leave edition
await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));

var readonlyHeight = list.$('.o_data_row:first').height();

assert.strictEqual(startHeight, editionHeight);
assert.strictEqual(startHeight, readonlyHeight);

list.destroy();
});

QUnit.test('deleting one record', async function (assert) {
assert.expect(5);

0 comments on commit f157ca2

Please sign in to comment.
You can’t perform that action at this time.