Skip to content

Commit

Permalink
[timesheets] fix unit on timesheets info
Browse files Browse the repository at this point in the history
Related to GitHub issue cgwire#1686
  • Loading branch information
NicoPennec committed Feb 24, 2025
1 parent e49a927 commit 363db34
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/components/lists/TimeSpentTaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
<td class="name">
{{ task.name }}
</td>
<td class="duration">{{ task.duration / 60 }}</td>
<td class="duration">
{{ getDuration(task) }}
</td>
</router-link>
</tr>
</tbody>
Expand All @@ -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'
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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') {
Expand Down
5 changes: 5 additions & 0 deletions src/components/sides/PeopleTimesheetInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
:tasks="tasks"
:is-loading="isLoading"
:is-error="isLoadingError"
:unit="unit"
/>
</div>
</template>
Expand Down Expand Up @@ -96,6 +97,10 @@ export default {
dayOffCount: {
type: Number,
default: 0
},
unit: {
type: String,
default: 'hour'
}
},
Expand Down

0 comments on commit 363db34

Please sign in to comment.