Skip to content

Commit

Permalink
fix: Fix validation check for input number - MEED-7842 - Meeds-io/MIP…
Browse files Browse the repository at this point in the history
…s#154 (#4213)

Before this change, there was no validity check of the entry number if
it had the same value as the default value 20.
  • Loading branch information
AzmiTouil committed Dec 9, 2024
1 parent 1270b83 commit dcec363
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions webapp/src/main/webapp/vue-apps/common/components/NumberInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,7 @@ export default {
},
watch: {
num() {
if (!this.initialized) {
return;
} else if (this.min && Number(this.num) < Number(this.min)) {
this.$emit('input', Number(this.min) + this.diff);
this.valid = false;
} else if (this.max && Number(this.num) > Number(this.max)) {
this.$emit('input', Number(this.max) + this.diff);
this.valid = false;
} else {
this.$emit('input', Number(this.num) + this.diff);
this.valid = true;
}
this.handleInputValidation();
},
valid: {
immediate: true,
Expand All @@ -130,6 +119,7 @@ export default {
},
mounted() {
this.initialized = true;
this.handleInputValidation();
},
methods: {
adjust() {
Expand All @@ -151,6 +141,20 @@ export default {
this.num = Number(this.num) + this.step;
}
},
handleInputValidation() {
if (!this.initialized) {
return;
} else if (this.min && Number(this.num) < Number(this.min)) {
this.$emit('input', Number(this.min) + this.diff);
this.valid = false;
} else if (this.max && Number(this.num) > Number(this.max)) {
this.$emit('input', Number(this.max) + this.diff);
this.valid = false;
} else {
this.$emit('input', Number(this.num) + this.diff);
this.valid = true;
}
}
},
};
</script>

0 comments on commit dcec363

Please sign in to comment.