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

Fixes #508 Added validation to Task Title and Description #509

Merged
merged 3 commits into from
Jun 18, 2024
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
52 changes: 33 additions & 19 deletions src/components/atoms/ModeratedTasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,36 @@
</draggable>

<!-- Modal for adding a new task -->
<v-dialog v-model="addTaskModal" max-width="600">
<v-dialog v-model="addTaskModal" max-width="600" @click:outside="resetForm">
<v-card class="cards">
<v-col />
<v-card-text>
<v-text-field
v-model="newTask.taskName"
outlined
label="Task Name"
color="orange"
/>
<v-textarea
v-model="newTask.taskDescription"
outlined
label="Task Description"
color="orange"
/>
<v-form ref="form" v-modal="valid">
<v-text-field
v-model="newTask.taskName"
outlined
label="Task Name"
color="orange"
:rules="[(v) => !!v || 'Required field']"
required
/>
<v-textarea
ref="taskDescription"
v-model="newTask.taskDescription"
outlined
label="Task Description"
color="orange"
:rules="[(v) => !!v || 'Required field']"
required
/>
</v-form>
</v-card-text>
<v-card-actions>
<v-btn dark color="red" @click="closeAddTaskModal">
<v-icon class="mr-1">
mdi-close </v-icon
>Cancel
<v-icon class="mr-1"> mdi-close </v-icon>Cancel
</v-btn>
<v-btn dark color="orange" @click="addTask">
<v-icon class="mr-1">
mdi-content-save </v-icon
>Save
<v-icon class="mr-1"> mdi-content-save </v-icon>Save
</v-btn>
</v-card-actions>
</v-card>
Expand All @@ -128,6 +131,7 @@ export default {
drag: false,
addTaskModal: false,
taskIndex: null,
valid: false,
newTask: {
taskName: '',
taskDescription: '',
Expand Down Expand Up @@ -165,6 +169,10 @@ export default {
this.taskIndex = null
this.addTaskModal = false
this.newTask = { taskName: '', taskDescription: '', taskStatus: 'closed' }
this.resetForm()
},
resetForm() {
this.$refs.form.resetValidation()
},
addTask() {
if (
Expand All @@ -180,6 +188,12 @@ export default {
taskStatus: 'closed',
})
this.closeAddTaskModal()
this.resetForm()
} else if (
this.newTask.taskDescription.trim() == '' ||
this.newTask.taskName.trim() == ''
) {
this.$refs.form.validate()
}
},

Expand Down
Loading