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

feat: show start date as label in task body #2438

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
4 changes: 3 additions & 1 deletion src/components/TaskBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<span class="calendar__name">{{ task.calendar.displayName }}</span>
</div>
<SortVariant v-if="hasHiddenSubtasks" :size="20" :title="t('tasks', 'Task has hidden subtasks')" />
<CalendarClock v-if="!overdue(task.startMoment) && task.start" :size="20" :title="t('tasks', 'Task has not yet started')" />
<CalendarClock v-if="!overdue(task.startMoment) && task.start" :size="20" :title="startDateString(task)" />
<Pin v-if="task.pinned" :size="20" :title="t('tasks', 'Task is pinned')" />
<TextBoxOutline v-if="task.note!=''"
:size="20"
Expand Down Expand Up @@ -188,6 +188,7 @@ import TaskStatusDisplay from './TaskStatusDisplay.vue'
import TaskDragContainer from './TaskDragContainer.vue'
import Task from '../models/task.js'
import openNewTask from '../mixins/openNewTask.js'
import { startDateString } from '../utils/dateStrings.js'

import { emit } from '@nextcloud/event-bus'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
Expand Down Expand Up @@ -473,6 +474,7 @@ export default {
methods: {
t,
n,
startDateString,

...mapActions([
'toggleCompleted',
Expand Down
143 changes: 143 additions & 0 deletions src/utils/dateStrings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* Nextcloud - Tasks
*
* @author Raimund Schlüßler
*
* @copyright 2024 Raimund Schlüßler <raimund.schluessler@mailbox.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* Returns a formatted string for the due date
*
* @param {Task} task The task
* @return {string} The formatted due date string
*/
export function dueDateString(task) {
if (task.allDay) {
return task.dueMoment.calendar(null, {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
sameDay: t('tasks', '[Due today]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
nextDay: t('tasks', '[Due tomorrow]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string and keep the brackets and the "LL".
nextWeek: t('tasks', '[Due on] LL'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets.
lastDay: t('tasks', '[Was due yesterday]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, but keep the brackets and the "LL".
lastWeek: t('tasks', '[Was due on] LL'),
sameElse(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets and the "LL".
return t('tasks', '[Was due on] LL')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string, but keep the brackets and the "LL".
return t('tasks', '[Due on] LL')
}
},
})
} else {
return task.dueMoment.calendar(null, {
sameDay(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
return t('tasks', '[Was due today at] LT')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
return t('tasks', '[Due today at] LT')
}
},
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
nextDay: t('tasks', '[Due tomorrow at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
nextWeek: t('tasks', '[Due on] LL [at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
lastDay: t('tasks', '[Was due yesterday at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
lastWeek: t('tasks', '[Was due on] LL [at] LT'),
sameElse(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
return t('tasks', '[Was due on] LL [at] LT')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
return t('tasks', '[Due on] LL [at] LT')
}
},
})
}
}

/**
* Returns a formatted string for the start date
*
* @param {Task} task The task
* @return {string} The formatted start date string
*/
export function startDateString(task) {
if (task.allDay) {
return task.startMoment.calendar(null, {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
sameDay: t('tasks', '[Starts today]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
nextDay: t('tasks', '[Starts tomorrow]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL".
nextWeek: t('tasks', '[Starts on] LL'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
lastDay: t('tasks', '[Started yesterday]'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL".
lastWeek: t('tasks', '[Started on] LL'),
sameElse(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL".
return t('tasks', '[Started on] LL')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986'. Please translate the string, and keep the brackets and the "LL".
return t('tasks', '[Starts on] LL')
}
},
})
} else {
return task.startMoment.calendar(null, {
sameDay(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
return t('tasks', '[Started today at] LT')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
return t('tasks', '[Starts today at] LT')
}
},
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
nextDay: t('tasks', '[Starts tomorrow at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
nextWeek: t('tasks', '[Starts on] LL [at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets and the "LT".
lastDay: t('tasks', '[Started yesterday at] LT'),
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
lastWeek: t('tasks', '[Started on] LL [at] LT'),
sameElse(now) {
if (this.isBefore(now)) {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
return t('tasks', '[Started on] LL [at] LT')
} else {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. "LL" will be replaced with a date, e.g. 'September 4 1986' and "LT" will be replaced with a time, e.g. '08:30 PM'. Please translate the string and keep the brackets the "LL" and the "LT".
return t('tasks', '[Starts on] LL [at] LT')
}
},
})
}
}
Loading
Loading