Skip to content
Snippets Groups Projects
Commit 67119cd9 authored by permcu's avatar permcu
Browse files

Handle change in PositiveSmallIntegerField

v-text-field emits 'change' with changed value on focus out.
If someone listenes to 'change' on PositiveSmallIntegerField he
received a string not an integer. This fixes it.
parent fa918f14
No related branches found
No related tags found
1 merge request!1410Handle change in PositiveSmallIntegerField
Pipeline #170876 passed with warnings
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
export default { export default {
name: "PositiveSmallIntegerField", name: "PositiveSmallIntegerField",
extends: "v-text-field", extends: "v-text-field",
methods: {
handleInput(event) {
let num = parseInt(event);
if (!isNaN(num) && num >= 0 && num <= 32767 && num % 1 === 0) {
this.$emit("input", parseInt(event));
}
},
},
data() { data() {
return { return {
rules: [ rules: [
...@@ -46,7 +38,18 @@ export default { ...@@ -46,7 +38,18 @@ export default {
on() { on() {
return { return {
...this.$listeners, ...this.$listeners,
input: this.handleInput, input: this.inputHandler("input"),
change: this.inputHandler("change"),
};
},
},
methods: {
inputHandler(name) {
return (event) => {
const num = parseInt(event);
if (!isNaN(num) && num >= 0 && num <= 32767 && num % 1 === 0) {
this.$emit(name, num);
}
}; };
}, },
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment