[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1357-ged21ff0

Franck Villaume nerville at libremir.placard.fr.eu.org
Wed Jan 18 23:29:32 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  ed21ff0f6f119ab4d095e566fff6ee2dc537e112 (commit)
      from  9d136b13879dbae53890ae590aa7558e9044daa7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=ed21ff0f6f119ab4d095e566fff6ee2dc537e112

commit ed21ff0f6f119ab4d095e566fff6ee2dc537e112
Author: St├ęphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Wed Jan 18 23:19:31 2017 +0100

    Tracker: Extra field type Effort Fix 3

diff --git a/src/common/tracker/EffortUnitFactory.class.php b/src/common/tracker/EffortUnitFactory.class.php
index b14e7f7..7a71a1f 100644
--- a/src/common/tracker/EffortUnitFactory.class.php
+++ b/src/common/tracker/EffortUnitFactory.class.php
@@ -153,6 +153,14 @@ class EffortUnitFactory extends FFError {
 		return $value;
 	}
 
+	function encodedToValueInBaseUnit($encoded){
+		$value = 0;
+		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
+			$value = intval(intval($matches[1]));
+		}
+		return $value;
+	}
+
 	function encodedToUnitId($encoded) {
 		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
 			$unitId = intval($matches[2]);
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 789e3b6..f5da206 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -1177,6 +1177,7 @@ class ArtifactTypeHtml extends ArtifactType {
 			$texts [] = $unit->getName();
 			$opts_attrs []['data-factor'] = $unit->getConversionFactorForBaseUnit();
 		}
+		$valueInUnitBase = $effortUnitFactory->encodedToValueInBaseUnit($contents);
 		$value = $effortUnitFactory->encodedToValue($contents);
 		$unitId = $effortUnitFactory->encodedToUnitId($contents);
 		if (isset($attrs['class'])) {
@@ -1189,7 +1190,7 @@ class ArtifactTypeHtml extends ArtifactType {
 		if (isset($attrs['form'])) {
 			$hiddenAttrs['form'] = $attrs['form'];
 		}
-		$return = html_e('input', array_merge(array('type'=>'hidden', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$value.'U'.$unitId), $hiddenAttrs));
+		$return = html_e('input', array_merge(array('type'=>'hidden', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$valueInUnitBase.'U'.$unitId), $hiddenAttrs));
 		$return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value['.$extra_field_id.']', 'value'=>$value, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrs));
 		$return .= html_build_select_box_from_arrays($vals, $texts, 'unit['.$extra_field_id.']', $unitId, false, '', false, '', false, $attrs, $opts_attrs);
 		return $return;
@@ -1307,15 +1308,10 @@ class ArtifactTypeHtml extends ArtifactType {
 		}
 		return false;
 	};
-	$("input.effort").on('change', function(){
+	$(".effort").on('change', function(){
 		var effortid = $(this).data("effortid");
 		$("input[name='extra_fields["+effortid+"]']").val($("input[name='value["+effortid+"]']").val()*$("select[name='unit["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
 	});
-	$("select.effort").on('change', function(){
-		var effortid = $(this).data("effortid");
-		$("input[name='value["+effortid+"]']").val(parseInt(parseInt($("input[name='extra_fields["+effortid+"]']").val())/$("select[name='unit["+effortid+"]'] option:selected").data('factor')));
-		$("input[name='extra_fields["+effortid+"]']").val($("input[name='value["+effortid+"]']").val()*$("select[name='unit["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
-	});
 	$("input[type='radio'].readonly, input[type='checkbox'].readonly").on('click', function(){
 		return false;
 	}).on('keydown', function(event){

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/EffortUnitFactory.class.php        |  8 ++++++++
 src/common/tracker/include/ArtifactTypeHtml.class.php | 10 +++-------
 2 files changed, 11 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list