aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/number_setting.js
blob: 676a0d227f5cbbc545b225c5fd2681105d107d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
    }
  }
}