Skip to content

Commit

Permalink
Enable duration and estimated stats to be displayed in hours
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeGrosmaire committed Sep 23, 2024
1 parent f43cac4 commit 9d71fdb
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
17 changes: 15 additions & 2 deletions src/components/lists/AssetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,17 @@
v-show="displayedAssetsTimeSpent > 0 || displayedAssetsEstimation > 0"
>
({{ formatDuration(displayedAssetsTimeSpent) }}
{{ $tc('main.days_spent', displayedAssetsTimeSpent) }},
{{
isDurationInHours()
? $tc('main.hours_spent', displayedAssetsTimeSpent)
: $tc('main.days_spent', displayedAssetsTimeSpent)
}},
{{ formatDuration(displayedAssetsEstimation) }}
{{ $tc('main.man_days', displayedAssetsEstimation) }})
{{
isDurationInHours()
? $tc('main.hours_estimated', displayedAssetsEstimation)
: $tc('main.man_days', displayedAssetsEstimation)
}})
</span>
</p>
</div>
Expand Down Expand Up @@ -592,6 +600,7 @@ export default {
'displayedAssetsTimeSpent',
'displayedAssetsEstimation',
'nbSelectedTasks',
'organisation',
'isAssetDescription',
'isBigThumbnails',
'isCurrentUserClient',
Expand Down Expand Up @@ -693,6 +702,10 @@ export default {
isAssetsOnly() {
return this.currentProduction.production_type === 'assets'
},
formatDurationInHours() {
return this.organisation.format_duration_in_hours
}
},
Expand Down
13 changes: 11 additions & 2 deletions src/components/lists/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,16 @@
{{ tasks.length }} {{ $tc('tasks.number', tasks.length) }} ({{
formatDuration(timeEstimated)
}}
{{ $tc('main.days_estimated', isTimeEstimatedPlural) }},
{{
isDurationInHours()
? $tc('main.hours_estimated', isTimeEstimatedPlural)
: $tc('main.days_estimated', isTimeEstimatedPlural)
}},
{{ formatDuration(timeSpent) }}
{{ $tc('main.days_spent', isTimeSpentPlural)
{{
isDurationInHours()
? $tc('main.hours_spent', isTimeSpentPlural)
: $tc('main.days_spent', isTimeSpentPlural)
}}<span v-if="!isAssets"
>, {{ nbFrames }} {{ $tc('main.nb_frames', nbFrames) }}</span
>)
Expand Down Expand Up @@ -565,6 +572,7 @@ export default {
)
return
data = getDatesFromStartDate(
this.organisation,
startDate,
dueDate,
minutesToDays(this.organisation, task.estimation)
Expand Down Expand Up @@ -599,6 +607,7 @@ export default {
)
return
data = getDatesFromEndDate(
this.organisation,
startDate,
dueDate,
minutesToDays(this.organisation, task.estimation)
Expand Down
4 changes: 4 additions & 0 deletions src/components/mixins/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const formatListMixin = {
return duration
},

isDurationInHours() {
return this.organisation.format_duration_in_hours
},

formatPriority(priority) {
let label = priority + ''
if (priority === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<td class="field-label">
{{ $t('tasks.fields.estimation') }}
</td>
<td>{{ task.estimation }}</td>
<td>{{ formatDuration(task.estimation) }}</td>
</tr>
<tr class="datatable-row">
<td class="field-label">
Expand Down
15 changes: 13 additions & 2 deletions src/components/pages/production/ProductionStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@
</span>
<span class="tag">
{{ formatDuration(stats.total_duration) }}
{{ $tc('main.days_spent', formatDuration(stats.total_duration)) }}
{{
isDurationInHours()
? $tc('main.hours_spent', formatDuration(stats.total_duration))
: $tc('main.days_spent', formatDuration(stats.total_duration))
}}
/
{{ formatDuration(stats.total_estimation) }}
{{ $tc('main.days_estimated', formatDuration(stats.total_estimation)) }}
{{
isDurationInHours()
? $tc(
'main.hours_estimated',
formatDuration(stats.total_estimation)
)
: $tc('main.days_estimated', formatDuration(stats.total_estimation))
}}
</span>
</div>
<div class="color-wrapper">
Expand Down
6 changes: 4 additions & 2 deletions src/lib/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ export const getEndDateFromString = (startDate, endDateString) => {
}

export const getDatesFromStartDate = (
organisation,
startDate,
dueDate,
estimation,
daysOff = []
) => {
if (estimation > 0) {
if (estimation > 0 && !organisation.format_duration_in_hours) {
dueDate = addBusinessDays(startDate, Math.ceil(estimation) - 1, daysOff)
}

Expand All @@ -166,12 +167,13 @@ export const getDatesFromStartDate = (
}

export const getDatesFromEndDate = (
organisation,
startDate,
dueDate,
estimation,
daysOff = []
) => {
if (estimation > 0) {
if (estimation > 0 && !organisation.format_duration_in_hours) {
startDate = removeBusinessDays(dueDate, Math.ceil(estimation) - 1, daysOff)
}

Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ export default {
days: 'days',
days_spent: 'day spent | days spent',
days_estimated: 'day estimated | days estimated',
hours_spent: 'hour spent | hours spent',
hours_estimated: 'hour estimated | hours estimated',
delete: 'Delete',
delete_all: 'Delete all',
delete_text: 'Are you sure you want to remove {name} from your database?',
Expand Down

0 comments on commit 9d71fdb

Please sign in to comment.