From 34cbc6880a7e4ca6d08b65f3a2665987e357da91 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 6 Jul 2020 18:24:07 +0200 Subject: [PATCH] step attribute for number widget --- api/js/etemplate/et2_widget_number.js | 16 ++++++++++++++++ api/js/etemplate/et2_widget_number.ts | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/api/js/etemplate/et2_widget_number.js b/api/js/etemplate/et2_widget_number.js index 26603414d6..e5df640b50 100644 --- a/api/js/etemplate/et2_widget_number.js +++ b/api/js/etemplate/et2_widget_number.js @@ -44,6 +44,7 @@ var et2_number = /** @class */ (function (_super) { var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_number._attributes, _child || {})) || this; _this.min = null; _this.max = null; + _this.step = null; return _this; } et2_number.prototype.transformAttributes = function (_attrs) { @@ -115,6 +116,15 @@ var et2_number = /** @class */ (function (_super) { this.input.attr("max", this.max); } }; + et2_number.prototype.set_step = function (_value) { + this.step = _value; + if (this.step == null) { + this.input.removeAttr("step"); + } + else { + this.input.attr("step", this.step); + } + }; et2_number._attributes = { "value": { "type": "float" @@ -135,6 +145,12 @@ var et2_number = /** @class */ (function (_super) { "default": et2_no_init, "description": "Maximum allowed value" }, + "step": { + "name": "step value", + "type": "integer", + "default": et2_no_init, + "description": "Step attribute specifies the interval between legal numbers" + }, "precision": { // TODO: Implement this in some nice way other than HTML5's step attribute "name": "Precision", diff --git a/api/js/etemplate/et2_widget_number.ts b/api/js/etemplate/et2_widget_number.ts index 330762c97a..2ffd0848ed 100644 --- a/api/js/etemplate/et2_widget_number.ts +++ b/api/js/etemplate/et2_widget_number.ts @@ -43,6 +43,12 @@ class et2_number extends et2_textbox "default": et2_no_init, "description": "Maximum allowed value" }, + "step": { + "name": "step value", + "type": "integer", + "default": et2_no_init, + "description": "Step attribute specifies the interval between legal numbers" + }, "precision": { // TODO: Implement this in some nice way other than HTML5's step attribute "name": "Precision", @@ -55,6 +61,7 @@ class et2_number extends et2_textbox min : number = null; max : number = null; + step : number = null; /** * Constructor * @@ -140,6 +147,7 @@ class et2_number extends et2_textbox this.input.attr("min",this.min); } } + set_max(_value) { this.max = _value; @@ -149,6 +157,16 @@ class et2_number extends et2_textbox this.input.attr("max",this.max); } } + + set_step(_value : number) + { + this.step = _value; + if(this.step == null) { + this.input.removeAttr("step"); + } else { + this.input.attr("step",this.step); + } + } } et2_register_widget(et2_number, ["int", "integer", "float"]);