step attribute for number widget

This commit is contained in:
Ralf Becker 2020-07-06 18:24:07 +02:00
parent b0965ea44d
commit 34cbc6880a
2 changed files with 34 additions and 0 deletions

View File

@ -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",

View File

@ -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"]);