[IMP] web: use showSearchInput in model field selector
The option `showSearchInput`, which is used on the model field selector to display a search input that filters the displayed fields, is not set by default. This includes the model field selector instantiated in the `domain` field widget. closes odoo/odoo#29986
This commit is contained in:
@@ -71,8 +71,8 @@ var ModelFieldSelector = Widget.extend({
|
||||
* the fields itself)
|
||||
* @param {boolean|function} [options.followRelations=true]
|
||||
* true if can follow relation when building the chain
|
||||
* @param {boolean} [options.showSearchInput=false]
|
||||
* true to show a search input to filter displayed fields
|
||||
* @param {boolean} [options.showSearchInput=true]
|
||||
* false to hide a search input to filter displayed fields
|
||||
* @param {boolean} [options.debugMode=false]
|
||||
* true if the widget is in debug mode, false otherwise
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ var ModelFieldSelector = Widget.extend({
|
||||
filter: function () {return true;},
|
||||
followRelations: true,
|
||||
debugMode: false,
|
||||
showSearchInput: false,
|
||||
showSearchInput: true,
|
||||
}, options || {});
|
||||
this.options.filters = _.extend({
|
||||
searchable: true,
|
||||
|
||||
@@ -5164,7 +5164,7 @@ QUnit.module('basic_fields', {
|
||||
});
|
||||
|
||||
QUnit.test('basic domain field usage is ok', function (assert) {
|
||||
assert.expect(6);
|
||||
assert.expect(7);
|
||||
|
||||
this.data.partner.records[0].foo = "[]";
|
||||
|
||||
@@ -5205,6 +5205,9 @@ QUnit.module('basic_fields', {
|
||||
assert.ok($fieldSelectorPopover.is(":visible"),
|
||||
"field selector popover should be visible");
|
||||
|
||||
assert.containsOnce($fieldSelectorPopover, '.o_field_selector_search input',
|
||||
"field selector popover should contain a search input");
|
||||
|
||||
// The popover should contain the list of partner_type fields and so
|
||||
// there should be the "Color index" field
|
||||
var $lis = $fieldSelectorPopover.find("li");
|
||||
|
||||
@@ -130,7 +130,7 @@ QUnit.module('DomainSelector', {
|
||||
// field instead of "id" should rerender the widget and adapt the
|
||||
// widget suggestions
|
||||
domainSelector.$(".o_domain_debug_input").val('["&","&",["bar","=",True],"|",["foo","=","hello"],["id","=",1],["id","=",1]]').change();
|
||||
assert.strictEqual(domainSelector.$(".o_field_selector").eq(1).find("input").val(), "foo",
|
||||
assert.strictEqual(domainSelector.$(".o_field_selector").eq(1).find("input.o_field_selector_debug").val(), "foo",
|
||||
"the second field selector should now contain the 'foo' value");
|
||||
assert.ok(domainSelector.$(".o_domain_leaf_operator_select").eq(1).html().indexOf("contains") >= 0,
|
||||
"the second operator selector should now contain the 'contains' operator");
|
||||
|
||||
@@ -192,7 +192,7 @@ QUnit.module('ModelFieldSelector', {
|
||||
fieldSelector.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("use the `showSearchInput` option", function (assert) {
|
||||
QUnit.test("default `showSearchInput` option", function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
var $target = $("#qunit-fixture");
|
||||
@@ -200,7 +200,6 @@ QUnit.module('ModelFieldSelector', {
|
||||
// Create the field selector and its mock environment
|
||||
var fieldSelector = new ModelFieldSelector(null, "partner", [], {
|
||||
readonly: false,
|
||||
showSearchInput: true,
|
||||
});
|
||||
testUtils.mock.addMockEnvironment(fieldSelector, {data: this.data});
|
||||
fieldSelector.appendTo($target);
|
||||
@@ -222,6 +221,27 @@ QUnit.module('ModelFieldSelector', {
|
||||
|
||||
fieldSelector.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("false `showSearchInput` option", function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var $target = $("#qunit-fixture");
|
||||
|
||||
// Create the field selector and its mock environment
|
||||
var fieldSelector = new ModelFieldSelector(null, "partner", [], {
|
||||
readonly: false,
|
||||
showSearchInput: false,
|
||||
});
|
||||
testUtils.mock.addMockEnvironment(fieldSelector, { data: this.data });
|
||||
fieldSelector.appendTo($target);
|
||||
|
||||
fieldSelector.$el.trigger('focusin');
|
||||
var $fieldSelectorPopover = fieldSelector.$(".o_field_selector_popover:visible");
|
||||
var $searchInput = $fieldSelectorPopover.find(".o_field_selector_search input");
|
||||
assert.strictEqual($searchInput.length, 0, "there should be no search input");
|
||||
|
||||
fieldSelector.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user