Skip to content

Commit

Permalink
Merge pull request #509 from saltykheera/changebykheera
Browse files Browse the repository at this point in the history
Fixes #508 Added validation to Task Title and Description
  • Loading branch information
jvJUCA authored Jun 18, 2024
2 parents 40d32ab + aa69417 commit 3c1af1e
Showing 1 changed file with 33 additions and 19 deletions.
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

0 comments on commit 3c1af1e

Please sign in to comment.