feat(task wizard): allow setting a due date via popup or quick add magic
This commit is contained in:
parent
169f95af33
commit
e492ce40d2
2 changed files with 26 additions and 8 deletions
|
@ -1,8 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="datepicker">
|
<div class="datepicker">
|
||||||
<BaseButton @click.stop="toggleDatePopup" class="show" :disabled="disabled || undefined">
|
<slot :date="date" :openPopup="toggleDatePopup">
|
||||||
{{ date === null ? chooseDateLabel : formatDateShort(date) }}
|
<BaseButton @click.stop="toggleDatePopup" class="show" :disabled="disabled || undefined">
|
||||||
</BaseButton>
|
{{ date === null ? chooseDateLabel : formatDateShort(date) }}
|
||||||
|
</BaseButton>
|
||||||
|
</slot>
|
||||||
|
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<div v-if="show" class="datepicker-popup" ref="datepickerPopup">
|
<div v-if="show" class="datepicker-popup" ref="datepickerPopup">
|
||||||
|
|
|
@ -30,11 +30,21 @@
|
||||||
:preview-is-default="false"
|
:preview-is-default="false"
|
||||||
class="m-4"
|
class="m-4"
|
||||||
/>
|
/>
|
||||||
|
<div class="px-4">
|
||||||
|
<Datepicker
|
||||||
|
v-model="newTask.dueDate"
|
||||||
|
v-slot="{ date, openPopup }"
|
||||||
|
>
|
||||||
|
<XButton variant="secondary" @click.stop="openPopup()">
|
||||||
|
{{ date ? formatDateShort(date) : t('task.attributes.dueDate') }}
|
||||||
|
</XButton>
|
||||||
|
</Datepicker>
|
||||||
|
</div>
|
||||||
</CreateEdit>
|
</CreateEdit>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, ref} from 'vue'
|
import {computed, ref, watch} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {formatISO} from 'date-fns'
|
import {formatISO} from 'date-fns'
|
||||||
|
|
||||||
|
@ -42,6 +52,8 @@ import CreateEdit from '@/components/misc/create-edit.vue'
|
||||||
import Editor from '@/components/input/AsyncEditor'
|
import Editor from '@/components/input/AsyncEditor'
|
||||||
import BaseButton from '@/components/base/BaseButton.vue'
|
import BaseButton from '@/components/base/BaseButton.vue'
|
||||||
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
|
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
|
||||||
|
import XButton from '@/components/input/button.vue'
|
||||||
|
import Datepicker from '@/components/input/datepicker.vue'
|
||||||
|
|
||||||
import type {ITask} from '@/modelTypes/ITask'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
import TaskModel from '@/models/task'
|
import TaskModel from '@/models/task'
|
||||||
|
@ -51,6 +63,7 @@ import {useListStore} from '@/stores/lists'
|
||||||
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
||||||
import {parseTaskText} from '@/modules/parseTaskText'
|
import {parseTaskText} from '@/modules/parseTaskText'
|
||||||
import {findAssignees} from '@/helpers/findAssignees'
|
import {findAssignees} from '@/helpers/findAssignees'
|
||||||
|
import {formatDateShort} from '@/helpers/time/formatDate'
|
||||||
|
|
||||||
const listStore = useListStore()
|
const listStore = useListStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -67,11 +80,15 @@ const heading = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
|
const taskService = ref(new TaskService())
|
||||||
const descriptionFormVisible = ref(false)
|
const descriptionFormVisible = ref(false)
|
||||||
const newTask = ref<ITask>(new TaskModel({}))
|
const newTask = ref<ITask>(new TaskModel({}))
|
||||||
const taskService = ref(new TaskService())
|
|
||||||
|
|
||||||
const parsedTask = computed(() => parseTaskText(newTask.value.title, getQuickAddMagicMode()))
|
const parsedTask = computed(() => parseTaskText(newTask.value.title, getQuickAddMagicMode()))
|
||||||
|
watch(
|
||||||
|
() => parsedTask.value.date,
|
||||||
|
date => newTask.value.dueDate = date
|
||||||
|
)
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
if (newTask.value.title === '') {
|
if (newTask.value.title === '') {
|
||||||
|
@ -83,12 +100,11 @@ async function create() {
|
||||||
newTask.value.listId = props.listId
|
newTask.value.listId = props.listId
|
||||||
newTask.value.title = parsedTask.value.text
|
newTask.value.title = parsedTask.value.text
|
||||||
const assignees = await findAssignees(parsedTask.value.assignees)
|
const assignees = await findAssignees(parsedTask.value.assignees)
|
||||||
const dueDate = parsedTask.value.date !== null ? formatISO(parsedTask.value.date) : null
|
|
||||||
|
|
||||||
const finalTask = new TaskModel({
|
const finalTask = new TaskModel({
|
||||||
...newTask.value,
|
...newTask.value,
|
||||||
title: parsedTask.value.text,
|
title: parsedTask.value.text,
|
||||||
dueDate,
|
dueDate: newTask.value.dueDate !== null ? formatISO(newTask.value.dueDate) : null,
|
||||||
priority: parsedTask.value.priority,
|
priority: parsedTask.value.priority,
|
||||||
assignees: parsedTask.value.assignees,
|
assignees: parsedTask.value.assignees,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue