[MIG] web_widget_numeric_step: Migration to 18.0

This commit is contained in:
Carlos Roca
2024-12-24 07:57:37 +01:00
parent 0889f10f58
commit 944a4acadc
7 changed files with 55 additions and 33 deletions

View File

@@ -1,6 +1,6 @@
/** @odoo-module */
import {_lt} from "@web/core/l10n/translation";
import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
import {FloatField} from "@web/views/fields/float/float_field";
import {standardFieldProps} from "@web/views/fields/standard_field_props";
@@ -10,7 +10,7 @@ export class NumericStep extends FloatField {
super.setup();
}
_onStepClick(ev) {
const mode = $(ev.target).data("mode");
const mode = ev.target.dataset.mode;
this._doStep(mode);
}
_onKeyDown(ev) {
@@ -22,10 +22,19 @@ export class NumericStep extends FloatField {
}
_onWheel(ev) {
ev.preventDefault();
if (ev.deltaY > 0) {
this._doStep("minus");
} else {
this._doStep("plus");
if (!this._lastWheelTime) {
this._lastWheelTime = 0;
}
const now = Date.now();
const throttleLimit = 100;
if (now - this._lastWheelTime >= throttleLimit) {
this._lastWheelTime = now;
if (ev.deltaY > 0) {
this._doStep("minus");
} else {
this._doStep("plus");
}
}
}
updateField(val) {
@@ -64,7 +73,7 @@ NumericStep.defaultProps = {
export const numericStep = {
component: NumericStep,
supportedTypes: ["float"],
displayName: _lt("Numeric Step"),
displayName: _t("Numeric Step"),
extractProps: ({attrs, options}) => {
return {
name: attrs.name,

View File

@@ -5,7 +5,7 @@ Copyright 2020 Tecnativa - Alexandre Díaz
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<template>
<t t-name="web_widget_numeric_step" owl="1">
<t t-name="web_widget_numeric_step">
<div class="d-flex widget_numeric_step">
<div class="input-group-prepend widget_numeric_step_btn">
<button