From 1875faa1235d442c886a177e9a5f66f987944277 Mon Sep 17 00:00:00 2001 From: Favour Olayinka Date: Mon, 10 Jun 2024 12:23:18 +0100 Subject: [PATCH] 942e6 fix scale input decimal value (#444) * fix password reset bug * fix default integer value on scale input --- client/components/forms/ScaleInput.vue | 11 ++++++++++- client/components/open/forms/OpenFormField.vue | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/components/forms/ScaleInput.vue b/client/components/forms/ScaleInput.vue index a259de16..aa73b55f 100644 --- a/client/components/forms/ScaleInput.vue +++ b/client/components/forms/ScaleInput.vue @@ -17,7 +17,7 @@ role="button" @click="setScale(i)" > - {{ parseFloat(i).toFixed(2) }} + {{ formatNumber(i) }} @@ -95,6 +95,15 @@ export default { }, methods: { + formatNumber(num) { + if (Math.floor(num) === num) { + // return as Integer + return num + } else { + // Fformat to 2 decimal places + return parseFloat(num.toFixed(2)) + } + }, btnStyle(isSelected) { if (!isSelected) return {} return { diff --git a/client/components/open/forms/OpenFormField.vue b/client/components/open/forms/OpenFormField.vue index 65439e03..7a1fbf10 100644 --- a/client/components/open/forms/OpenFormField.vue +++ b/client/components/open/forms/OpenFormField.vue @@ -329,8 +329,8 @@ export default { } else if (field.type === 'rating') { inputProperties.numberOfStars = parseInt(field.rating_max_value) ?? 5 } else if (field.type === 'scale') { - inputProperties.minScale = parseInt(field.scale_min_value) ?? 1 - inputProperties.maxScale = parseInt(field.scale_max_value) ?? 5 + inputProperties.minScale = parseFloat(field.scale_min_value) ?? 1 + inputProperties.maxScale = parseFloat(field.scale_max_value) ?? 5 inputProperties.stepScale = parseFloat(field.scale_step_value) ?? 1 } else if (field.type === 'slider') { inputProperties.minSlider = parseInt(field.slider_min_value) ?? 0