Commit 92f36597 authored by Pavel Mashliakovskiy's avatar Pavel Mashliakovskiy 🤹🏻

correct fix for undefined precision in UBaseInput

parent 7d89ed71
Pipeline #21731 skipped with stage
......@@ -13,11 +13,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- in case some files are selected it names are displayed behind `selectedPlaceholder` instead of `placeholder`
- in case `accept` prop is not empty then allowed file types displayed after `placeholder`
- `v-model` support
- `UToolbar`: handler for `showAccessRights` action added for entites with aclRls mixin
- `UToolbar`: handler for `showAccessRights` action added for entities with aclRls mixin
- `lookups` new helper method `getEnum`. It has 2 params `eGroup`, `code`. Example: `this.$lookups.getEnum('AUDIT', 'INSERT')`
### Changed
- `UBaseInput`: change default value for `precision` to `undefined` (instead of 0).
If precision is not defined UBaseInput do not round a value for inputs of type `number` - only transform it
into `Number` before emitting `input` event.
### Deprecated
### Removed
......
......@@ -52,13 +52,11 @@ export default {
},
/**
* rounding precision.
* accepts only integers.
* will be ignored if type !== 'number'
* rounding precision. Applied in case `type !== 'number'` and `precision !== undefined`
*/
precision: {
type: Number,
default: 0
default: undefined
},
/**
......@@ -98,10 +96,12 @@ export default {
if (this.type !== 'number') {
return value
}
const digit = Number(value)
const preciseness = 10 ** this.precision
const rounded = Math.round((digit * preciseness)) / preciseness
this.$emit('input', rounded)
let asNumber = Number(value)
if (this.precision !== undefined) {
const preciseness = 10 ** this.precision
asNumber = Math.round((asNumber * preciseness)) / preciseness
}
this.$emit('input', asNumber)
}
}
}
......
......@@ -71,6 +71,7 @@ export default {
if (this.dataType === 'Currency') {
return 0.01
}
if ((this.dataType === 'Int') || (this.dataType === 'BigInt') || (this.dataType === 'ID')) return 1
return undefined
},
......@@ -81,6 +82,7 @@ export default {
}
if (this.dataType === 'Float') return this.$UB.connection.domain.FLOATING_SCALE_PRECISION
if (this.dataType === 'Currency') return 2
if ((this.dataType === 'Int') || (this.dataType === 'BigInt') || (this.dataType === 'ID')) return 0
return undefined
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment