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

[WIP] Feature: add deadlines to tasks #70

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions src/components/TaskCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<v-card :color="$theme.nestedCard.color">
<v-system-bar
:class="{'red': isLate, 'light-green': !isLate}"
text-color=white
v-if=task.deadline
small
>
<v-icon small v-if=isLate>{{ $icons.mdiClockAlert }}</v-icon>
<span class="font-weight-bold">{{ task.deadline }}</span>
</v-system-bar>

<v-card-text :class="[$theme.nestedCard.textSize, 'pt-3 pb-1 px-3']">
<v-checkbox
class="task-checkbox my-0 py-0"
Expand Down Expand Up @@ -85,6 +95,11 @@
:items="$store.getters['taskListChoices']"
label="List"
></v-select>
<v-text-field
v-model="newTask.deadline"
label="Deadline"
type="date"
></v-text-field>
<v-btn transition="" small text color="red" @click.prevent="deleteTask">
<v-icon left transition="">{{ $icons.mdiDelete }}</v-icon>
Delete
Expand Down Expand Up @@ -124,6 +139,14 @@ export default {
},
components: {SubtaskList},
computed: {
isLate () {
if (this.task.deadline &&
this.task.deadline < new Date().toISOString() &&
!this.isDone) {
return true
}
return false
},
category () {
if (!this.task.category) {
return
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
mdiChevronRight,
mdiChevronUp,
mdiClock,
mdiClockAlert,
mdiClockOutline,
mdiClose,
mdiCog,
Expand Down Expand Up @@ -59,6 +60,7 @@ Vue.prototype.$icons = {
mdiChevronRight,
mdiChevronUp,
mdiClock,
mdiClockAlert,
mdiClockOutline,
mdiClose,
mdiCog,
Expand Down
8 changes: 8 additions & 0 deletions src/views/Tasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
@keydown.enter="submitTask(idx)"
label="Category"
></v-select>
<v-text-field
label="Deadline"
v-model="newTaskDeadline"
type="date"
></v-text-field>
</v-form>
</v-card-text>
<v-card-actions class="py-4 px-0">
Expand Down Expand Up @@ -198,6 +203,7 @@ export default {
tasks: [],
newTaskText: '',
newTaskCategory: null,
newTaskDeadLine: null,
trackEvent,
clearDoneDialog: false,
}
Expand Down Expand Up @@ -234,13 +240,15 @@ export default {
text: this.newTaskText,
list: idx,
category: this.newTaskCategory,
deadline: this.newTaskDeadline,
subtasks: [],
}
let result = await this.$store.state.db.put(task)
task._rev = result.rev
this.tasks.push(task)
this.newTaskText = null
this.newTaskCategory = null
this.newTaskDeadline = null
trackEvent(this.$store, "task.created")
await this.$store.dispatch('forceSync', {updateLastSync: false})
},
Expand Down