diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-08-08 15:53:02 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-08-08 15:53:02 +0200 |
commit | 2139a5ab26633166d061e9f888fa903607880608 (patch) | |
tree | 3187ff542d48f5c7109302de4f09914251c13953 /server/sonar-web | |
parent | 17a40828946cf3c133b3d8d3ed441c4697bd3229 (diff) | |
download | sonarqube-2139a5ab26633166d061e9f888fa903607880608.tar.gz sonarqube-2139a5ab26633166d061e9f888fa903607880608.zip |
SONAR-5413 Use configuration to handle conversion of work durations
Diffstat (limited to 'server/sonar-web')
-rw-r--r-- | server/sonar-web/src/main/coffee/common/inputs.coffee | 10 | ||||
-rw-r--r-- | server/sonar-web/src/main/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 @@ <script> var pageLang = '<%= I18n.locale.to_s.gsub(/-/, '_') -%>'; + <%# The two lines below mean that before full removal of Rails, we have to find a way to handle config properties %> + window.SS = typeof window.SS === 'object' ? window.SS : {}; + window.SS.hoursInDay = <%= configuration('sonar.technicalDebt.hoursInDay', 8) %>; </script> <script src="<%= ApplicationController.root_context -%>/js/sonar.js"></script> <script> |