feat: Edit relative reminders #3248

Merged
konrad merged 27 commits from ce72/frontend:main into main 2023-06-10 17:04:10 +00:00
3 changed files with 11 additions and 9 deletions
Showing only changes of commit 5fb45afb12 - Show all commits

View File

@ -14,7 +14,7 @@
v-model="periodInput.duration.days"
type="number"
min="0"
/> {{ $t('task.reminder.daysShort') }}
/> {{ $t('task.reminder.days') }}
ce72 marked this conversation as resolved Outdated

Please add a translation string for the d. (It does not look like much, but still)

Please add a translation string for the `d`. (It does not look like much, but still)

Same for the placeholders.

Same for the placeholders.
Outdated
Review

ok

ok

To be honest I was confused by the d when I first saw the interface.
Why don't we write it out?

To be honest I was confused by the `d` when I first saw the interface. Why don't we write it out?
Outdated
Review

ok

ok
<input
:disabled="disabled"
class="input"
@ -166,7 +166,7 @@ function formatDuration(reminderPeriod: number): string {
return '00:00'
}
const duration = secondsToPeriod(Math.abs(reminderPeriod))
return (duration.days > 0 ? duration.days + ' d ' : '') +
return (duration.days > 0 ? `${duration.days} ${t('task.reminder.days')} `: '') +
('' + duration.hours).padStart(2, '0') + ':' +
('' + duration.minutes).padStart(2, '0')
}

View File

@ -3,12 +3,13 @@ import {SECONDS_A_DAY, SECONDS_A_HOUR, SECONDS_A_MINUTE} from '@/constants/date'
/**
* Convert time period given as seconds to days, hour, minutes, seconds
*/
export function secondsToPeriod(seconds: number): {days: number, hours: number, minutes: number, seconds: number} {
const d = Math.floor(seconds / SECONDS_A_DAY)
const h = Math.floor(seconds % SECONDS_A_DAY / 3600)
const m = Math.floor(seconds % SECONDS_A_HOUR / 60)
const s = Math.floor(seconds % 60)
return {days: d, hours: h, minutes: m, seconds: s}
export function secondsToPeriod(seconds: number): {days: number, hours: number, minutes: number, seconds: number} {
dpschen marked this conversation as resolved Outdated

Can you add a type hint for the return value?

Can you add a type hint for the return value?
Outdated
Review

ok

ok

Couldn't we instead define the return via as const?
Also we don' really need the declaration of the variables but could inline those definitions in the returned object directly

Couldn't we instead define the return via `as const`? Also we don' really need the declaration of the variables but could inline those definitions in the returned object directly
Outdated
Review

OK concerning the inlining. Can you please make a suggestion on how to replace the function using as const? My typescript might be not sufficient here.

OK concerning the inlining. Can you please make a suggestion on how to replace the function using `as const`? My typescript might be not sufficient here.
return {
days: Math.floor(seconds / SECONDS_A_DAY),
hours: Math.floor(seconds % SECONDS_A_DAY / 3600),
minutes: Math.floor(seconds % SECONDS_A_HOUR / 60),
seconds: Math.floor(seconds % 60),
}
}
/**

View File

@ -723,7 +723,8 @@
"reminder": {
"hoursShort": "HH",
"minutesShort": "MM",
"daysShort": "d"
"daysShort": "d",
"days": "days"
},
"repeat": {
"everyDay": "Every Day",