Skip to content

Commit

Permalink
Merge branch 'release_24.0' into release_24.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Jul 31, 2024
2 parents 7765dea + 42829a5 commit fe6d2e3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions client/src/components/Form/Elements/FormNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export default {
type: [Number, String],
required: false,
default: undefined,
validator: (prop) => typeof prop == "number" || prop === null,
},
max: {
type: [Number, String],
required: false,
default: undefined,
validator: (prop) => typeof prop == "number" || prop === null,
},
workflowBuildingMode: {
type: Boolean,
Expand Down Expand Up @@ -74,7 +76,7 @@ export default {
return this.workflowBuildingMode ? "text" : "number";
},
isRangeValid() {
return !isNaN(this.min) && !isNaN(this.max) && this.max > this.min;
return typeof this.min == "number" && typeof this.max == "number" && this.max > this.min;
},
isInteger() {
return this.type.toLowerCase() === "integer";
Expand Down Expand Up @@ -124,10 +126,15 @@ export default {
}
},
isOutOfRange(value) {
return this.isRangeValid && (value > this.max || value < this.min);
/* If value=null, then value is within range. */
return (
(typeof this.max == "number" && value > this.max) || (typeof this.min == "number" && value < this.min)
);
},
showOutOfRangeWarning(value) {
const warningMessage = `${value} is out of ${this.min} - ${this.max} range!`;
const rangeDetail =
typeof this.max == "number" && value > this.max ? `${value} > ${this.max}` : `${value} < ${this.min}`;
const warningMessage = `${value} is out of range! (${rangeDetail})`;
this.showAlert(warningMessage);
},
resetAlert() {
Expand Down

0 comments on commit fe6d2e3

Please sign in to comment.