aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/number_setting.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/settings_modal/helpers/number_setting.js')
-rw-r--r--src/components/settings_modal/helpers/number_setting.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/settings_modal/helpers/number_setting.js b/src/components/settings_modal/helpers/number_setting.js
new file mode 100644
index 00000000..676a0d22
--- /dev/null
+++ b/src/components/settings_modal/helpers/number_setting.js
@@ -0,0 +1,24 @@
+import Setting from './setting.js'
+
+export default {
+ ...Setting,
+ props: {
+ ...Setting.props,
+ truncate: {
+ type: Number,
+ required: false,
+ default: 1
+ }
+ },
+ methods: {
+ ...Setting.methods,
+ getValue (e) {
+ if (!this.truncate === 1) {
+ return parseInt(e.target.value)
+ } else if (this.truncate > 1) {
+ return Math.trunc(e.target.value / this.truncate) * this.truncate
+ }
+ return parseFloat(e.target.value)
+ }
+ }
+}