[vue] Validate bug path length filter
title="Bug path length"
@clear="clear(true)"
>
+ <v-form ref="form">
<v-container
class="py-0"
>
<v-text-field
:id="minId"
:value="minBugPathLength"
+ :rules="rules.bugPathLength"
label="Min..."
@input="setMinBugPathLength"
/>
<v-text-field
:id="maxId"
:value="maxBugPathLength"
+ :rules="rules.bugPathLength"
label="Max..."
@input="setMaxBugPathLength"
/>
</v-col>
</v-row>
</v-container>
+ </v-form>
</filter-toolbar>
</template>
@@ -56,12 +60,19 @@ export default {
minId: "min-bug-path-length",
maxId: "max-bug-path-length",
minBugPathLength: null,
- maxBugPathLength: null
+ maxBugPathLength: null,
+ rules: {
+ bugPathLength: [
+ v => (!v || !!v && !isNaN(parseInt(v))) || "Number is required"
+ ]
+ },
};
},
methods: {
setMinBugPathLength(bugPathLength, updateUrl=true) {
+ if (!this.$refs.form.validate()) return;
+
this.minBugPathLength = bugPathLength;
this.updateReportFilter();
@@ -71,6 +82,8 @@ export default {
},
setMaxBugPathLength(bugPathLength, updateUrl=true) {
+ if (!this.$refs.form.validate()) return;
+
this.maxBugPathLength = bugPathLength;
this.updateReportFilter();
@@ -89,12 +102,12 @@ export default {
initByUrl() {
return new Promise(resolve => {
const minBugPathLength = this.$route.query[this.minId];
- if (minBugPathLength) {
+ if (parseInt(minBugPathLength)) {
this.setMinBugPathLength(minBugPathLength, false);
}
const maxBugPathLength = this.$route.query[this.maxId];
- if (maxBugPathLength) {
+ if (parseInt(maxBugPathLength)) {
this.setMaxBugPathLength(maxBugPathLength, false);
}
