Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require all fields but tags, fix Submit button validation #4080

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 82 additions & 48 deletions src/dispatch/static/dispatch/src/case/ReportSubmissionCard.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<template>
<v-form @submit.prevent v-slot="{ isValid }">
<v-form ref="form" @submit.prevent>
<v-card
class="mx-auto ma-4"
max-width="600"
variant="outlined"
title=" Open a Case
"
title=" Open a Case"
:loading="loading"
>
<template #append>
Expand All @@ -32,50 +31,48 @@
<v-icon size="small">mdi-open-in-new</v-icon>
</a>
</p>
<v-form>
<v-container>
<v-row>
<v-col cols="12">
<v-textarea
v-model="title"
label="Title"
hint="A brief explanatory title. You can change this later."
clearable
auto-grow
rows="2"
required
name="Title"
:rules="[rules.required]"
/>
</v-col>
<v-col cols="12">
<v-textarea
v-model="description"
label="Description"
hint="A summary of what you know so far. It's all right if this is incomplete."
clearable
auto-grow
rows="3"
required
name="Description"
:rules="[rules.required]"
/>
</v-col>
<v-col cols="12">
<project-select v-model="project" />
</v-col>
<v-col cols="12">
<case-type-select :project="project" v-model="case_type" />
</v-col>
<v-col cols="12">
<case-priority-select :project="project" v-model="case_priority" />
</v-col>
<v-col cols="12">
<tag-filter-auto-complete :project="project" v-model="tags" label="Tags" />
</v-col>
</v-row>
</v-container>
</v-form>
<v-container>
<v-row>
<v-col cols="12">
<v-textarea
v-model="title"
label="Title"
hint="A brief explanatory title. You can change this later."
clearable
auto-grow
rows="2"
required
name="Title"
:rules="[rules.required]"
/>
</v-col>
<v-col cols="12">
<v-textarea
v-model="description"
label="Description"
hint="A summary of what you know so far. It's all right if this is incomplete."
clearable
auto-grow
rows="3"
required
name="Description"
:rules="[rules.required]"
/>
</v-col>
<v-col cols="12">
<project-select v-model="project" />
</v-col>
<v-col cols="12">
<case-type-select :project="project" v-model="case_type" />
</v-col>
<v-col cols="12">
<case-priority-select :project="project" v-model="case_priority" />
</v-col>
<v-col cols="12">
<tag-filter-auto-complete :project="project" v-model="tags" label="Tags" />
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer />
Expand All @@ -84,7 +81,7 @@
variant="flat"
block
:loading="loading"
:disabled="!isValid.value"
:disabled="!formIsValid"
@click="report()"
>
Submit
Expand Down Expand Up @@ -128,6 +125,12 @@ export default {
return {
isSubmitted: false,
project_faq: null,
formIsValid: false,
titleValid: false,
descriptionValid: false,
projectValid: false,
caseTypeValid: false,
casePriorityValid: false,
}
},

Expand All @@ -148,6 +151,29 @@ export default {
]),
},

watch: {
title() {
this.titleValid = !!this.title
this.checkFormValidity()
},
description() {
this.descriptionValid = !!this.description
this.checkFormValidity()
},
project() {
this.projectValid = !!this.project
this.checkFormValidity()
},
case_type() {
this.caseTypeValid = !!this.case_type
this.checkFormValidity()
},
case_priority() {
this.casePriorityValid = !!this.case_priority
this.checkFormValidity()
},
},

methods: {
getFAQ() {
if (this.project) {
Expand Down Expand Up @@ -198,6 +224,14 @@ export default {
}
)
},
checkFormValidity() {
this.formIsValid =
this.titleValid &&
this.descriptionValid &&
this.projectValid &&
this.caseTypeValid &&
this.casePriorityValid
},
...mapActions("case_management", ["report", "get", "resetSelected"]),
},

Expand Down
Loading