V8: Don't use floats in the slider config as it only supports integers (#4821)

This commit is contained in:
Kenn Jacobsen
2019-04-23 17:27:34 +02:00
committed by Sebastiaan Janssen
parent 67e046e477
commit fab025bf66
2 changed files with 11 additions and 8 deletions

View File

@@ -9,18 +9,18 @@
public bool EnableRange { get; set; }
[ConfigurationField("initVal1", "Initial value", "number")]
public int InitialValue { get; set; }
public decimal InitialValue { get; set; }
[ConfigurationField("initVal2", "Initial value 2", "number", Description = "Used when range is enabled")]
public int InitialValue2 { get; set; }
public decimal InitialValue2 { get; set; }
[ConfigurationField("minVal", "Minimum value", "number")]
public int MinimumValue { get; set; }
public decimal MinimumValue { get; set; }
[ConfigurationField("maxVal", "Maximum value", "number")]
public int MaximumValue { get; set; }
public decimal MaximumValue { get; set; }
[ConfigurationField("step", "Step increments", "number")]
public int StepIncrements { get; set; }
public decimal StepIncrements { get; set; }
}
}

View File

@@ -38,7 +38,10 @@
const tooltips = $scope.model.config.enableRange ? [true, true] : [true];
const min = $scope.model.config.minVal ? [$scope.model.config.minVal] : [$scope.model.config.minVal];
const max = $scope.model.config.maxVal ? [$scope.model.config.maxVal] : [$scope.model.config.maxVal];
// don't render values with decimal places if the step increment in a whole number
var stepDecimalPlaces = $scope.model.config.step % 1 == 0
? 0
: _.last($scope.model.config.step.toString().replace(",", ".").split(".")).length;
// setup default
$scope.sliderOptions = {
"start": start,
@@ -46,10 +49,10 @@
"tooltips": tooltips,
"format": {
to: function (value) {
return Math.round(value);
return value.toFixed(stepDecimalPlaces);
},
from: function (value) {
return Math.round(value);
return value;
}
},
"range": {