[FIX] web: ModelFieldSelectorPopover: edition of path in input
Before this commit, it was not possible to edit the path via the model field selector popover input (visible in debug mode). We fix that. closes odoo/odoo#102462 X-original-commit: 084af201f1f4f4cb3476ab34d3dcd649a71a4254 Signed-off-by: Luca Vitali <luvi@odoo.com> Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
This commit is contained in:
@@ -85,12 +85,13 @@ export class ModelFieldSelectorPopover extends Component {
|
||||
}
|
||||
async onFieldNameChange(ev) {
|
||||
this.fullFieldName = ev.target.value.replace(/\s+/g, "");
|
||||
const { resModel } = this.props.chain[0];
|
||||
try {
|
||||
this.chain = await this.props.loadChain(this.fullFieldName);
|
||||
this.chain = await this.props.loadChain(resModel, this.fullFieldName);
|
||||
this.update();
|
||||
} catch (_error) {
|
||||
// WOWL TODO: rethrow error when not the expected type
|
||||
this.chain = [{ resModel: this.props.chain[0], field: null }];
|
||||
this.chain = [{ resModel, field: null }];
|
||||
await this.props.update([]);
|
||||
this.render();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { registry } from "@web/core/registry";
|
||||
import { uiService } from "@web/core/ui/ui_service";
|
||||
import { viewService } from "@web/views/view_service";
|
||||
import { makeTestEnv } from "../helpers/mock_env";
|
||||
import { click, getFixture, triggerEvent, mount } from "../helpers/utils";
|
||||
import { click, getFixture, triggerEvent, mount, editInput } from "../helpers/utils";
|
||||
import { makeFakeLocalizationService } from "../helpers/mock_services";
|
||||
|
||||
const { Component, xml } = owl;
|
||||
@@ -518,4 +518,53 @@ QUnit.module("Components", (hooks) => {
|
||||
await click(target, ".o_field_selector_item:last-child");
|
||||
assert.containsNone(target, ".o_popover");
|
||||
});
|
||||
|
||||
QUnit.test("Edit path in popover debug input", async (assert) => {
|
||||
serverData.models.partner.fields.partner_id = {
|
||||
string: "Partner",
|
||||
type: "many2one",
|
||||
relation: "partner",
|
||||
searchable: true,
|
||||
};
|
||||
|
||||
class Parent extends Component {
|
||||
setup() {
|
||||
this.fieldName = "foo";
|
||||
}
|
||||
onUpdate(value) {
|
||||
this.fieldName = value;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
Parent.components = { ModelFieldSelector };
|
||||
Parent.template = xml`
|
||||
<ModelFieldSelector
|
||||
readonly="false"
|
||||
resModel="'partner'"
|
||||
fieldName="fieldName"
|
||||
isDebugMode="true"
|
||||
update="(value) => this.onUpdate(value)"
|
||||
/>
|
||||
`;
|
||||
|
||||
await mountComponent(Parent);
|
||||
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".o_field_selector_value span")].map((el) => el.innerText),
|
||||
["Foo"]
|
||||
);
|
||||
|
||||
await click(target, ".o_field_selector");
|
||||
|
||||
await editInput(
|
||||
target,
|
||||
".o_field_selector_popover .o_field_selector_debug",
|
||||
"partner_id.bar"
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".o_field_selector_value span")].map((el) => el.innerText),
|
||||
["Partner", "Bar"]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user