fix(task): bubble date changes from the picker up
Resolves https://github.com/go-vikunja/frontend/issues/142
This commit is contained in:
parent
167953b26b
commit
5619fda0f2
@ -541,6 +541,86 @@ describe('Task', () => {
|
|||||||
.should('contain', 'Success')
|
.should('contain', 'Success')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Can set a due date to a specific date for a task', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
done: false,
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Set Due Date')
|
||||||
|
.click()
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input .datepicker .show')
|
||||||
|
.click()
|
||||||
|
cy.get('.datepicker-popup .flatpickr-innerContainer .flatpickr-days .flatpickr-day.today')
|
||||||
|
.click()
|
||||||
|
cy.get('[data-cy="closeDatepicker"]')
|
||||||
|
.contains('Confirm')
|
||||||
|
.click()
|
||||||
|
|
||||||
|
const date = (new Date()).toLocaleString('default', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: 'short',
|
||||||
|
year: 'numeric',
|
||||||
|
}) + ', 12:00'
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input .datepicker-popup')
|
||||||
|
.should('not.exist')
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input')
|
||||||
|
.should('contain.text', date)
|
||||||
|
cy.get('.global-notification')
|
||||||
|
.should('contain', 'Success')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Can change a due date to a specific date for a task', () => {
|
||||||
|
const dueDate = new Date()
|
||||||
|
dueDate.setHours(12)
|
||||||
|
dueDate.setMinutes(0)
|
||||||
|
dueDate.setSeconds(0)
|
||||||
|
dueDate.setDate(1)
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
done: false,
|
||||||
|
due_date: dueDate.toISOString(),
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .action-buttons .button')
|
||||||
|
.contains('Set Due Date')
|
||||||
|
.click()
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input .datepicker .show')
|
||||||
|
.click()
|
||||||
|
cy.get('.datepicker-popup .flatpickr-innerContainer .flatpickr-days .flatpickr-day.today')
|
||||||
|
.click()
|
||||||
|
cy.get('[data-cy="closeDatepicker"]')
|
||||||
|
.contains('Confirm')
|
||||||
|
.click()
|
||||||
|
|
||||||
|
const date = (new Date()).toLocaleString('default', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: 'short',
|
||||||
|
year: 'numeric',
|
||||||
|
}) + ', 12:00'
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input .datepicker-popup')
|
||||||
|
.should('not.exist')
|
||||||
|
cy.get('.task-view .columns.details .column')
|
||||||
|
.contains('Due Date')
|
||||||
|
.get('.date-input')
|
||||||
|
.should('contain.text', date)
|
||||||
|
cy.get('.global-notification')
|
||||||
|
.should('contain', 'Success')
|
||||||
|
})
|
||||||
|
|
||||||
it('Can set a reminder', () => {
|
it('Can set a reminder', () => {
|
||||||
TaskReminderFactory.truncate()
|
TaskReminderFactory.truncate()
|
||||||
const tasks = TaskFactory.create(1, {
|
const tasks = TaskFactory.create(1, {
|
||||||
@ -645,7 +725,7 @@ describe('Task', () => {
|
|||||||
.click()
|
.click()
|
||||||
cy.get('.reminder-options-popup .card-content .reminder-period input')
|
cy.get('.reminder-options-popup .card-content .reminder-period input')
|
||||||
.first()
|
.first()
|
||||||
.type('10')
|
.type('{selectall}10')
|
||||||
cy.get('.reminder-options-popup .card-content .reminder-period select')
|
cy.get('.reminder-options-popup .card-content .reminder-period select')
|
||||||
.first()
|
.first()
|
||||||
.select('days')
|
.select('days')
|
||||||
@ -771,7 +851,7 @@ describe('Task', () => {
|
|||||||
.should('exist')
|
.should('exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only('Can check items off a checklist', () => {
|
it('Can check items off a checklist', () => {
|
||||||
const tasks = TaskFactory.create(1, {
|
const tasks = TaskFactory.create(1, {
|
||||||
id: 1,
|
id: 1,
|
||||||
description: `
|
description: `
|
||||||
@ -858,7 +938,7 @@ describe('Task', () => {
|
|||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: `${Cypress.env('API_URL')}/tasks/${tasks[0].id}/attachments`,
|
url: `${Cypress.env('API_URL')}/tasks/${tasks[0].id}/attachments`,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${window.localStorage.getItem('token')}`,
|
'Authorization': `Bearer ${window.localStorage.getItem('token')}`,
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
body: formData,
|
body: formData,
|
||||||
|
@ -128,9 +128,11 @@ const flatPickrDate = computed({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldDate = formatDate(date.value, 'yyy-LL-dd H:mm')
|
if (date.value !== null) {
|
||||||
if (oldDate !== newValue) {
|
const oldDate = formatDate(date.value, 'yyy-LL-dd H:mm')
|
||||||
return
|
if (oldDate === newValue) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
date.value = createDateFromString(newValue)
|
date.value = createDateFromString(newValue)
|
||||||
updateData()
|
updateData()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<slot name="trigger" :isOpen="open" :toggle="toggle"></slot>
|
<slot name="trigger" :isOpen="open" :toggle="toggle" :close="close"></slot>
|
||||||
<div
|
<div
|
||||||
class="popup"
|
class="popup"
|
||||||
:class="{
|
:class="{
|
||||||
@ -8,7 +8,7 @@
|
|||||||
}"
|
}"
|
||||||
ref="popup"
|
ref="popup"
|
||||||
>
|
>
|
||||||
<slot name="content" :isOpen="open" :toggle="toggle"/>
|
<slot name="content" :isOpen="open" :toggle="toggle" :close="close"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{{ reminderText }}
|
{{ reminderText }}
|
||||||
</SimpleButton>
|
</SimpleButton>
|
||||||
</template>
|
</template>
|
||||||
<template #content="{isOpen, toggle}">
|
<template #content="{isOpen, close}">
|
||||||
<Card class="reminder-options-popup" :class="{'is-open': isOpen}" :padding="false">
|
<Card class="reminder-options-popup" :class="{'is-open': isOpen}" :padding="false">
|
||||||
<div class="options" v-if="activeForm === null">
|
<div class="options" v-if="activeForm === null">
|
||||||
<SimpleButton
|
<SimpleButton
|
||||||
@ -17,7 +17,7 @@
|
|||||||
:key="k"
|
:key="k"
|
||||||
class="option-button"
|
class="option-button"
|
||||||
:class="{'currently-active': p.relativePeriod === modelValue?.relativePeriod && modelValue?.relativeTo === p.relativeTo}"
|
:class="{'currently-active': p.relativePeriod === modelValue?.relativePeriod && modelValue?.relativeTo === p.relativeTo}"
|
||||||
@click="setReminderFromPreset(p, toggle)"
|
@click="setReminderFromPreset(p, close)"
|
||||||
>
|
>
|
||||||
{{ formatReminder(p) }}
|
{{ formatReminder(p) }}
|
||||||
</SimpleButton>
|
</SimpleButton>
|
||||||
@ -40,20 +40,20 @@
|
|||||||
<ReminderPeriod
|
<ReminderPeriod
|
||||||
v-if="activeForm === 'relative'"
|
v-if="activeForm === 'relative'"
|
||||||
v-model="reminder"
|
v-model="reminder"
|
||||||
@update:modelValue="updateDataAndMaybeClose(toggle)"
|
@update:modelValue="updateDataAndMaybeClose(close)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DatepickerInline
|
<DatepickerInline
|
||||||
v-if="activeForm === 'absolute'"
|
v-if="activeForm === 'absolute'"
|
||||||
v-model="reminderDate"
|
v-model="reminderDate"
|
||||||
@update:modelValue="setReminderDate(toggle)"
|
@update:modelValue="setReminderDate(close)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<x-button
|
<x-button
|
||||||
v-if="showFormSwitch !== null"
|
v-if="showFormSwitch !== null"
|
||||||
class="reminder__close-button"
|
class="reminder__close-button"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
@click="toggle"
|
@click="updateDataAndMaybeClose(close)"
|
||||||
>
|
>
|
||||||
{{ $t('misc.confirm') }}
|
{{ $t('misc.confirm') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
@ -148,25 +148,26 @@ function updateData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setReminderDate(toggle) {
|
function setReminderDate(close) {
|
||||||
reminder.value.reminder = reminderDate.value === null
|
reminder.value.reminder = reminderDate.value === null
|
||||||
? null
|
? null
|
||||||
: new Date(reminderDate.value)
|
: new Date(reminderDate.value)
|
||||||
reminder.value.relativeTo = null
|
reminder.value.relativeTo = null
|
||||||
reminder.value.relativePeriod = 0
|
reminder.value.relativePeriod = 0
|
||||||
updateDataAndMaybeClose(toggle)
|
updateDataAndMaybeClose(close)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setReminderFromPreset(preset, toggle) {
|
|
||||||
|
function setReminderFromPreset(preset, close) {
|
||||||
reminder.value = preset
|
reminder.value = preset
|
||||||
updateData()
|
updateData()
|
||||||
toggle()
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDataAndMaybeClose(toggle) {
|
function updateDataAndMaybeClose(close) {
|
||||||
updateData()
|
updateData()
|
||||||
if (clearAfterUpdate) {
|
if (clearAfterUpdate) {
|
||||||
toggle()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ import TaskReminderModel from '@/models/taskReminder'
|
|||||||
|
|
||||||
import type {ITaskReminder} from '@/modelTypes/ITaskReminder'
|
import type {ITaskReminder} from '@/modelTypes/ITaskReminder'
|
||||||
import {REMINDER_PERIOD_RELATIVE_TO_TYPES, type IReminderPeriodRelativeTo} from '@/types/IReminderPeriodRelativeTo'
|
import {REMINDER_PERIOD_RELATIVE_TO_TYPES, type IReminderPeriodRelativeTo} from '@/types/IReminderPeriodRelativeTo'
|
||||||
|
import {useDebounceFn} from '@vueuse/core'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
modelValue,
|
modelValue,
|
||||||
@ -105,7 +106,7 @@ function updateData() {
|
|||||||
reminder.value.relativeTo = period.value.relativeTo
|
reminder.value.relativeTo = period.value.relativeTo
|
||||||
reminder.value.reminder = null
|
reminder.value.reminder = null
|
||||||
|
|
||||||
emit('update:modelValue', reminder.value)
|
useDebounceFn(() => emit('update:modelValue', reminder.value), 1000)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user