From 2139a5ab26633166d061e9f888fa903607880608 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Fri, 8 Aug 2014 15:53:02 +0200 Subject: [PATCH] SONAR-5413 Use configuration to handle conversion of work durations --- server/sonar-web/src/main/coffee/common/inputs.coffee | 10 ++++++---- .../webapp/WEB-INF/app/views/layouts/_head.html.erb | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/coffee/common/inputs.coffee b/server/sonar-web/src/main/coffee/common/inputs.coffee index 452636f9cff..92c5c2e7ac2 100644 --- a/server/sonar-web/src/main/coffee/common/inputs.coffee +++ b/server/sonar-web/src/main/coffee/common/inputs.coffee @@ -1,5 +1,8 @@ $ = jQuery +window.SS = if typeof window.SS == 'object' then window.SS else {} +window.SS.hoursInDay = window.SS.hoursInDay || 8 + transformPattern = (pattern) -> return pattern.replace /\{0\}/g, '(\\d+)' @@ -22,15 +25,15 @@ convertWorkDuration = (value) -> if !value value else - (days * 8 + hours) * 60 + minutes + (days * window.SS.hoursInDay + hours) * 60 + minutes restoreWorkDuration = (value) -> return '0' if (value == '0' || value == 0) return value unless /^\d+$/.test value - days = Math.floor(value / (8 * 60)) - hours = Math.floor((value - days * 8 * 60) / 60) + days = Math.floor(value / (window.SS.hoursInDay * 60)) + hours = Math.floor((value - days * window.SS.hoursInDay * 60) / 60) minutes = value % 60 result = [] result.push t('work_duration.x_days').replace('{0}', days) if days > 0 @@ -85,4 +88,3 @@ $.fn.val = (value) -> convertValue originalVal.call(@), @ $.fn.originalVal = originalVal - diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb index 193a0a0096a..d32c00b4ef8 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb @@ -24,6 +24,9 @@