Skip to content

Commit

Permalink
feat: show start date as label in task body
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Jan 4, 2024
1 parent 381262d commit 3057254
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 105 deletions.
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
131 changes: 131 additions & 0 deletions src/utils/dateStrings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* 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/>.
*
*/

export function dueDateString(task) {
if (!!task.allDay) {

Check failure on line 24 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 1 tab but found 4 spaces

Check failure on line 24 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Redundant double negation
return task.dueMoment.calendar(null, {

Check failure on line 25 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 8 spaces
// 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.

Check failure on line 26 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
sameDay: t('tasks', '[Due today]'),

Check failure on line 27 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
// 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.

Check failure on line 28 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
nextDay: t('tasks', '[Due tomorrow]'),

Check failure on line 29 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
// 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".

Check failure on line 30 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
nextWeek: t('tasks', '[Due on] LL'),

Check failure on line 31 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
// 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.

Check failure on line 32 in src/utils/dateStrings.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
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')
}
},
})
}
}

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

0 comments on commit 3057254

Please sign in to comment.