Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Provide duration configuration to frontend

Aaron Contreras6e26e66e1229
diff --git a/frontend/src/app/core/config/configuration.service.ts b/frontend/src/app/core/config/configuration.service.ts
index d34618a8703..52d7bd2b272 100644
--- a/frontend/src/app/core/config/configuration.service.ts
+++ b/frontend/src/app/core/config/configuration.service.ts
@@ -95,6 +95,18 @@ export class ConfigurationService {
return this.systemPreference('dateFormat');
}
+ public hoursPerDay():number {
+ return this.systemPreference('hoursPerDay');
+ }
+
+ public hoursPerWeek():number {
+ return this.systemPreference('hoursPerWeek');
+ }
+
+ public daysPerMonth():number {
+ return this.systemPreference('daysPerMonth');
+ }
+
public timeFormatPresent():boolean {
return !!this.systemPreference('timeFormat');
}
diff --git a/frontend/src/app/core/datetime/timezone.service.ts b/frontend/src/app/core/datetime/timezone.service.ts
index 2d5a073479e..fe8042b6e1e 100644
--- a/frontend/src/app/core/datetime/timezone.service.ts
+++ b/frontend/src/app/core/datetime/timezone.service.ts
@@ -131,16 +131,25 @@ export class TimezoneService {
public formattedDuration(durationString:string, unit:'hour'|'days' = 'hour'):string {
switch (unit) {
case 'hour':
- return this.I18n.t('js.units.hour', { count: this.toHours(durationString) });
+ return this.I18n.t('js.units.hour', {
+ count: this.toHours(durationString),
+ });
case 'days':
- return this.I18n.t('js.units.day', { count: this.toDays(durationString) });
+ return this.I18n.t('js.units.day', {
+ count: this.toDays(durationString),
+ });
default:
// Case fallthrough for eslint
return '';
}
}
- public formattedChronicDuration(durationString:string, opts = { format: 'short' }):string {
+ public formattedChronicDuration(durationString:string, opts = {
+ format: 'short',
+ hoursPerDay: this.configurationService.hoursPerDay(),
+ hoursPerWeek: this.configurationService.hoursPerWeek(),
+ daysPerMonth: this.configurationService.daysPerMonth(),
+ }):string {
return outputChronicDuration(this.toHours(durationString) * 3600, opts) || '0h';
}
diff --git a/lib/api/v3/configuration/configuration_representer.rb b/lib/api/v3/configuration/configuration_representer.rb
index e5e51be1c56..f4a9d703745 100644
--- a/lib/api/v3/configuration/configuration_representer.rb
+++ b/lib/api/v3/configuration/configuration_representer.rb
@@ -76,6 +76,15 @@ module API
},
render_nil: true
+ property :hours_per_day,
+ render_nil: true
+
+ property :hours_per_week,
+ render_nil: true
+
+ property :days_per_month,
+ render_nil: true
+
property :host_name,
getter: ->(*) {
Setting.host_name