[REF] web: ensure factor override is taken into account in FloatToggleField

Prior to this commit, the factor override, if any, was not taken into account
when toggle was performed.

task-2990758

Part-of: odoo/odoo#100626
This commit is contained in:
Laurent Stukkens (LTU)
2022-09-21 02:26:04 +02:00
parent 37d8810235
commit 87fd81d7f9
@@ -10,14 +10,15 @@ export class FloatToggleField extends Component {
// TODO perf issue (because of update round trip)
// we probably want to have a state and a useEffect or onWillUpateProps
onChange() {
let currentIndex = this.props.range.indexOf(this.props.value * this.props.factor);
let currentIndex = this.props.range.indexOf(this.props.value * this.factor);
currentIndex++;
if (currentIndex > this.props.range.length - 1) {
currentIndex = 0;
}
this.props.update(this.props.range[currentIndex] / this.props.factor);
this.props.update(this.props.range[currentIndex] / this.factor);
}
// This property has been created in order to allow overrides in other modules.
get factor() {
return this.props.factor;
}