From 363db3466604b037291e9e3285c6f1c2588cd0c2 Mon Sep 17 00:00:00 2001 From: Nicolas Pennec Date: Mon, 10 Feb 2025 23:25:32 +0100 Subject: [PATCH] [timesheets] fix unit on timesheets info Related to GitHub issue #1686 --- src/components/lists/TimeSpentTaskList.vue | 24 +++++++++++++++++--- src/components/sides/PeopleTimesheetInfo.vue | 5 ++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/components/lists/TimeSpentTaskList.vue b/src/components/lists/TimeSpentTaskList.vue index 5299ef96d7..c15f203f3f 100644 --- a/src/components/lists/TimeSpentTaskList.vue +++ b/src/components/lists/TimeSpentTaskList.vue @@ -35,7 +35,9 @@ {{ task.name }} - {{ task.duration / 60 }} + + {{ getDuration(task) }} + @@ -51,8 +53,9 @@ import { mapGetters } from 'vuex' import { firstBy } from 'thenby' -import { sortByName } from '@/lib/sorting' import { getTaskPath } from '@/lib/path' +import { sortByName } from '@/lib/sorting' +import { hoursToDays } from '@/lib/time' import ProductionName from '@/components/widgets/ProductionName.vue' import TableInfo from '@/components/widgets/TableInfo.vue' @@ -85,11 +88,19 @@ export default { isError: { type: Boolean, default: false + }, + unit: { + type: String, + default: 'hour' } }, computed: { - ...mapGetters(['productionMap', 'taskTypeMap']), + ...mapGetters(['organisation', 'productionMap', 'taskTypeMap']), + + isHours() { + return this.unit === 'hour' + }, projects() { const projects = {} @@ -131,6 +142,13 @@ export default { }, methods: { + getDuration(task) { + const duration = task.duration / 60 + return this.isHours + ? duration + : hoursToDays(this.organisation, duration).toFixed(2) + }, + getTaskPath(task) { const project = this.productionMap.get(task.project_id) if (!project || project.project_status_name === 'Closed') { diff --git a/src/components/sides/PeopleTimesheetInfo.vue b/src/components/sides/PeopleTimesheetInfo.vue index 6ed8d67443..4c0e1ef55d 100644 --- a/src/components/sides/PeopleTimesheetInfo.vue +++ b/src/components/sides/PeopleTimesheetInfo.vue @@ -36,6 +36,7 @@ :tasks="tasks" :is-loading="isLoading" :is-error="isLoadingError" + :unit="unit" /> @@ -96,6 +97,10 @@ export default { dayOffCount: { type: Number, default: 0 + }, + unit: { + type: String, + default: 'hour' } },