Skip to content

update range int size #1479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pgml-dashboard/src/components/inputs/range/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ impl From<&str> for InterpolationType {
#[template(path = "inputs/range/template.html")]
pub struct Range {
color: String,
min: i32,
max: i32,
min: i64,
max: i64,
interpolation_type: InterpolationType,
target: Target,
initial_value: i32,
initial_value: i64,
}

impl Range {
Expand All @@ -56,12 +56,12 @@ impl Range {
self
}

pub fn min(mut self, min: i32) -> Self {
pub fn min(mut self, min: i64) -> Self {
self.min = min;
self
}

pub fn max(mut self, max: i32) -> Self {
pub fn max(mut self, max: i64) -> Self {
self.max = max;
self
}
Expand All @@ -76,7 +76,7 @@ impl Range {
self
}

pub fn initial_value(mut self, initial_value: i32) -> Self {
pub fn initial_value(mut self, initial_value: i64) -> Self {
self.initial_value = initial_value;
self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class extends Controller {
initialize() {}

connect() {
// console.log("range connected", this.initialValue)
this.rangeTarget.value =
this.interpolationTypeValue === "exponential"
? this.exponentialInterpolationSolveX(this.initialValue)
Expand Down Expand Up @@ -52,7 +51,7 @@ export default class extends Controller {

exponentialInterpolation(value) {
if (value < 1) {
return 0;
return this.minValue;
}

let minValue = this.minValue > 1 ? this.minValue : 1;
Expand All @@ -72,7 +71,6 @@ export default class extends Controller {
let numerator = Math.log(value / minValue);
let denominator = Math.log(this.maxValue / minValue);
let out = (numerator / denominator) * 100;
// console.log(numerator, denominator, out, Number(out.toPrecision(3)))
return parseInt(Number(out.toPrecision(3)));
}

Expand All @@ -82,7 +80,6 @@ export default class extends Controller {
}

linearInterpolationSolveX(value) {
// console.log("linear solve x ", value, this.minValue, this.maxValue)
let out = ((value - this.minValue) / (this.maxValue - this.minValue)) * 100;
return parseInt(Number(out.toPrecision(3)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use sailfish::TemplateOnce;
pub struct RangeGroupPricingCalc {
interpolation_type: InterpolationType,
include_slider: bool,
min: i32,
max: i32,
min: i64,
max: i64,
target: StimulusTarget,
label: String,
name: String,
initial_value: i32,
initial_value: i64,
}

impl RangeGroupPricingCalc {
Expand All @@ -40,12 +40,12 @@ impl RangeGroupPricingCalc {
self
}

pub fn min(mut self, min: i32) -> Self {
pub fn min(mut self, min: i64) -> Self {
self.min = min;
self
}

pub fn max(mut self, max: i32) -> Self {
pub fn max(mut self, max: i64) -> Self {
self.max = max;
self
}
Expand All @@ -65,7 +65,7 @@ impl RangeGroupPricingCalc {
self
}

pub fn initial_value(mut self, initial_value: i32) -> Self {
pub fn initial_value(mut self, initial_value: i64) -> Self {
self.initial_value = initial_value;
self
}
Expand Down