[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1367-g01222c7

Franck Villaume nerville at libremir.placard.fr.eu.org
Sat Jan 21 12:54:22 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  01222c74b86de7f423ef6dddc70e43b2a3f82538 (commit)
       via  a95bb9230954d9cca48cdbc77b04579a8accaf53 (commit)
      from  639065297ce9fd073887bd5bbc7e0844b1b4dc67 (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=01222c74b86de7f423ef6dddc70e43b2a3f82538

commit 01222c74b86de7f423ef6dddc70e43b2a3f82538
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sat Jan 21 12:54:02 2017 +0100

    remove required. need to review the way query is build/update ...

diff --git a/src/common/tracker/actions/query.php b/src/common/tracker/actions/query.php
index c75a6d5..4444ebf 100644
--- a/src/common/tracker/actions/query.php
+++ b/src/common/tracker/actions/query.php
@@ -307,7 +307,7 @@ echo '<input type="hidden" name="form_key" value="'.form_generate_key().'" />
 	echo '
 		</td>
 		<td class="top">
-		<input type="text" name="query_name" value="'.$aq->getName().'" size="20" maxlength="30"  required="required" /></td>
+		<input type="text" name="query_name" value="'.$aq->getName().'" size="20" maxlength="30" /></td>
 	</tr>
 </table>';
 

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

commit a95bb9230954d9cca48cdbc77b04579a8accaf53
Author: St├ęphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Sat Jan 21 12:25:54 2017 +0100

    Tracker: Efforts in query

diff --git a/src/common/tracker/Artifact.class.php b/src/common/tracker/Artifact.class.php
index e5cfd55..dba5f5b 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -1921,6 +1921,8 @@ class Artifact extends FFObject {
 				case ARTIFACT_EXTRAFIELDTYPE_TEXTAREA:
 				case ARTIFACT_EXTRAFIELDTYPE_RELATION:
 				case ARTIFACT_EXTRAFIELDTYPE_INTEGER:
+				case ARTIFACT_EXTRAFIELDTYPE_DATE:
+				case ARTIFACT_EXTRAFIELDTYPE_DATETIME:
 				case ARTIFACT_EXTRAFIELDTYPE_EFFORT:
 					if (isset($efd[$efid])) {
 						$value = $efd[$efid];
@@ -2139,7 +2141,18 @@ class ArtifactComparator {
 			}
 			$af=$aa[$criterion]['value'];
 			$bf=$ba[$criterion]['value'];
-			$namecmp = strcoll ($af,$bf) ;
+			switch ($aa[$criterion]['type']) {
+				case ARTIFACT_EXTRAFIELDTYPE_EFFORT:
+					$namecmp = intval($af)-intval($bf);
+					break;
+				case ARTIFACT_EXTRAFIELDTYPE_INTEGER:
+				case ARTIFACT_EXTRAFIELDTYPE_DATE:
+				case ARTIFACT_EXTRAFIELDTYPE_DATETIME:
+					$numecmp = $af-$bf;
+					break;
+				default:
+					$namecmp = strcoll ($af,$bf);
+			}
 			if ($namecmp != 0) {
 				return $namecmp ;
 			}
diff --git a/src/common/tracker/ArtifactExtraField.class.php b/src/common/tracker/ArtifactExtraField.class.php
index 86efa44..57510b6 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -50,6 +50,7 @@ define('ARTIFACT_EXTRAFIELDTYPE_DATE',18);
 define('ARTIFACT_EXTRAFIELDTYPE_DATETIMERANGE', 19);
 define('ARTIFACT_EXTRAFIELDTYPE_DATERANGE', 20);
 define('ARTIFACT_EXTRAFIELDTYPE_EFFORT',21);
+define('ARTIFACT_EXTRAFIELDTYPE_EFFORTRANGE',22);
 
 define ("ARTIFACT_EXTRAFIELDTYPEGROUP_SINGLECHOICE", serialize (array (ARTIFACT_EXTRAFIELDTYPE_SELECT, ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_STATUS)));
 define ("ARTIFACT_EXTRAFIELDTYPEGROUP_MULTICHOICE", serialize (array (ARTIFACT_EXTRAFIELDTYPE_CHECKBOX, ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)));
diff --git a/src/common/tracker/ArtifactFactory.class.php b/src/common/tracker/ArtifactFactory.class.php
index 210813b..ca93930 100644
--- a/src/common/tracker/ArtifactFactory.class.php
+++ b/src/common/tracker/ArtifactFactory.class.php
@@ -332,6 +332,21 @@ class ArtifactFactory extends FFError {
 					$params[] = $strartDate->format('U');
 					$wheresql .= ' AND $'.$paramcount++;
 					$params[] = $endDate->format('U');
+				} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+					if (preg_match('/^(\d+U\d+) ?(\d+U\d+)?$/',$vals[$i],$matches)) {
+						$startEffort = intval($matches[1]);
+						$endEffort = intval($matches[2]);
+						if ($startEffort>$endEffort) {
+							$startEffort=$endEffort;
+							$endEffort=intval($matches[1]);
+						}
+						if ($endEffort) {
+							$wheresql .= ' AND cast(substring(aefd'.$i.'.field_data from \'^[0-9]+\') AS BIGINT) BETWEEN $'.$paramcount++;
+							$params[] = $startEffort;
+							$wheresql .= ' AND $'.$paramcount++;
+							$params[] = $endEffort;
+						}
+					}
 				} else {
 					if (is_array($vals[$i])) {
 						$wheresql .= ' AND aefd'.$i.'.field_data = ANY ($'.$paramcount++ .')' ;
@@ -344,7 +359,6 @@ class ArtifactFactory extends FFError {
 				$wheresql .= ' AND aefd'.$i.'.artifact_id=artifact_vw.artifact_id' ;
 			}
 		}
-
 		//if status selected, and more to where clause
 		if ($this->status && ($this->status != 100)) {
 			//for open tasks, add status=100 to make sure we show all
@@ -451,7 +465,6 @@ class ArtifactFactory extends FFError {
 
 		$sortorder = util_ensure_value_in_set ($this->sort,
 						       array ('ASC', 'DESC')) ;
-
 		$sortcol = util_ensure_value_in_set ($this->order_col,
 						     array ('extra',
 							    'artifact_id',
diff --git a/src/common/tracker/actions/browse.php b/src/common/tracker/actions/browse.php
index 844b591..2dc518a 100644
--- a/src/common/tracker/actions/browse.php
+++ b/src/common/tracker/actions/browse.php
@@ -365,11 +365,14 @@ echo ' </div>
 $sort_fields = explode(',', $ath->getBrowseList());
 // Get the list of fields which can be sorted.
 $efarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_TEXT,
-				    ARTIFACT_EXTRAFIELDTYPE_TEXTAREA,
-				    ARTIFACT_EXTRAFIELDTYPE_INTEGER,
-				    ARTIFACT_EXTRAFIELDTYPE_SELECT,
-				    ARTIFACT_EXTRAFIELDTYPE_RADIO,
-				    ARTIFACT_EXTRAFIELDTYPE_STATUS));
+					ARTIFACT_EXTRAFIELDTYPE_TEXTAREA,
+					ARTIFACT_EXTRAFIELDTYPE_INTEGER,
+					ARTIFACT_EXTRAFIELDTYPE_SELECT,
+					ARTIFACT_EXTRAFIELDTYPE_RADIO,
+					ARTIFACT_EXTRAFIELDTYPE_STATUS,
+					ARTIFACT_EXTRAFIELDTYPE_DATE,
+					ARTIFACT_EXTRAFIELDTYPE_DATETIME,
+					ARTIFACT_EXTRAFIELDTYPE_EFFORT));
 echo $HTML->openForm(array('action' => '/tracker/?group_id='.$group_id.'&atid='.$ath->getID(), 'method' => 'post'));
 echo '
 	<input type="hidden" name="query_id" value="-1" />
diff --git a/src/common/tracker/actions/query.php b/src/common/tracker/actions/query.php
index d8071ff..c75a6d5 100644
--- a/src/common/tracker/actions/query.php
+++ b/src/common/tracker/actions/query.php
@@ -361,11 +361,14 @@ if (forge_check_perm ('tracker', $ath->getID(), 'manager')) {
 	// Compute the list of fields which can be sorted.
 	// Currently, only scalar artifacts are taken.
 	$efarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_TEXT,
-					    ARTIFACT_EXTRAFIELDTYPE_TEXTAREA,
-					    ARTIFACT_EXTRAFIELDTYPE_INTEGER,
-					    ARTIFACT_EXTRAFIELDTYPE_SELECT,
-					    ARTIFACT_EXTRAFIELDTYPE_RADIO,
-					    ARTIFACT_EXTRAFIELDTYPE_STATUS));
+						ARTIFACT_EXTRAFIELDTYPE_TEXTAREA,
+						ARTIFACT_EXTRAFIELDTYPE_INTEGER,
+						ARTIFACT_EXTRAFIELDTYPE_SELECT,
+						ARTIFACT_EXTRAFIELDTYPE_RADIO,
+						ARTIFACT_EXTRAFIELDTYPE_STATUS,
+						ARTIFACT_EXTRAFIELDTYPE_DATE,
+						ARTIFACT_EXTRAFIELDTYPE_DATETIME,
+						ARTIFACT_EXTRAFIELDTYPE_EFFORT));
 	$keys=array_keys($efarr);
 	for ($k=0; $k<count($keys); $k++) {
 		$i=$keys[$k];
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 20306f1..b756cd4 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -227,6 +227,8 @@ class ArtifactTypeHtml extends ArtifactType {
 				} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_DATETIME ||
 						$type == ARTIFACT_EXTRAFIELDTYPE_DATE) {
 					$efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_DATERANGE;
+				} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+					$efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_EFFORTRANGE;
 				} else {
 					$efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_TEXT;
 				}
@@ -420,12 +422,14 @@ class ArtifactTypeHtml extends ArtifactType {
 				$str = $this->renderDateRange($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $attrs);
 			} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
 				$str = $this->renderEffort($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
+			} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORTRANGE) {
+				$str = $this->renderEffortRange($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
 			}
 			$template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}', $post_name, $template);
 			$template = str_replace('{$'.$efarr[$i]['field_name'].'}', $str, $template);
 		}
 		if($template != NULL){
-			if ($mode == 'UPDATE' || $mode == 'NEW') {
+			if ($mode == 'UPDATE' || $mode == 'NEW' || $mode == 'QUERY') {
 				echo $this->javascript();
 			}
 			echo $template;
@@ -859,7 +863,7 @@ class ArtifactTypeHtml extends ArtifactType {
 	 * @param	array		$attrs
 	 * @return	string		HTML code for the box and choices
 	 */
-	function renderMultiReleaseField($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs = array()) {
+	function renderMultiReleaseField($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs=array()) {
 		if ($text_100 == 'none'){
 			$text_100=_('None');
 		}
@@ -1196,11 +1200,57 @@ class ArtifactTypeHtml extends ArtifactType {
 		return $return;
 	}
 
+	function renderEffortRange($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+		$effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+		$effortUnitFactory = New EffortUnitFactory($effortUnitSet);
+		$units = $effortUnitFactory->getUnits();
+		$vals = array();
+		$texts = array();
+		$opts_attrs = array();
+		foreach ($units as $unit) {
+			$vals [] = $unit->getID();
+			$texts [] = $unit->getName();
+			$opts_attrs []['data-factor'] = $unit->getConversionFactorForBaseUnit();
+		}
+		$contentsFrom = '0U'.$vals[0];
+		$contentsTo = '0U'.$vals[0];
+		if (preg_match('/^(\d+U\d+) ?(\d+U\d+)?$/',$contents,$matches)) {
+			$contentsFrom = $matches[1];
+			$contentsTo = $matches[2];
+		}
+		$valueInUnitBaseFrom = $effortUnitFactory->encodedToValueInBaseUnit($contentsFrom);
+		$valueInUnitBaseTo = $effortUnitFactory->encodedToValueInBaseUnit($contentsTo);
+		$valueFrom = $effortUnitFactory->encodedToValue($contentsFrom);
+		$valueTo = $effortUnitFactory->encodedToValue($contentsTo);
+		$unitIdFrom = $effortUnitFactory->encodedToUnitId($contentsFrom);
+		$unitIdTo = $effortUnitFactory->encodedToUnitId($contentsTo);
+		$attrs['data-effortid'] = $extra_field_id;
+		if (isset($attrs['class'])) {
+			$attrs['class'] .= ' effort-range';
+		} else {
+			$attrs['class'] = 'effort-range';
+		}
+		$attrsFrom = $attrs;
+		$attrsTo = $attrs;
+		$hiddenAttrs = array();
+		if (isset($attrs['form'])) {
+			$hiddenAttrs['form'] = $attrs['form'];
+		}
+		$return = html_e('input', array_merge(array('type'=>'hidden', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$valueInUnitBaseFrom.'U'.$unitIdFrom.' '.$valueInUnitBaseTo.'U'.$unitIdTo), $hiddenAttrs));
+		$return .= _('Between')._(':').html_e('br');
+		$return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value_from['.$extra_field_id.']', 'value'=>$valueFrom, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrsFrom));
+		$return .= html_build_select_box_from_arrays($vals, $texts, 'unit_from['.$extra_field_id.']', $unitIdFrom, false, '', false, '', false, $attrsFrom, $opts_attrs);
+		$return .= html_e('br');
+		$return .= _('and')._(':').html_e('br');
+		$return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value_to['.$extra_field_id.']', 'value'=>$valueTo, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrsTo));
+		$return .= html_build_select_box_from_arrays($vals, $texts, 'unit_to['.$extra_field_id.']', $unitIdTo, false, '', false, '', false, $attrsTo, $opts_attrs);
+		return $return;
+	}
+
 	function technicianBox($name = 'assigned_to[]', $checked = 'xzxz', $show_100 = true, $text_100 = 'none', $extra_id = '-1', $extra_name = '', $multiple = false, $attrs = array()) {
 		if ($text_100=='none'){
 			$text_100=_('Nobody');
 		}
-
 		$engine = RBACEngine::getInstance();
 		$techs = $engine->getUsersByAllowedAction('tracker', $this->getID(), 'tech') ;
 
@@ -1224,9 +1274,9 @@ class ArtifactTypeHtml extends ArtifactType {
 				$checked = explode(',', $checked);
 			}
 			$size = min(count($ids)+1, 15);
-			return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, '', false, $attrs);
+			return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, $attrs);
 		} else {
-			return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, '', false, $attrs);
+			return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, $attrs);
 		}
 	}
 
@@ -1247,9 +1297,9 @@ class ArtifactTypeHtml extends ArtifactType {
 				$checked = explode(',', $checked);
 			}
 			$size = min( count($ids)+1, 15);
-			return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, '', false, $attrs);
+			return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, $attrs);
 		} else {
-			return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, '', false, $attrs);
+			return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, $attrs);
 		}
 	}
 
@@ -1312,6 +1362,10 @@ class ArtifactTypeHtml extends ArtifactType {
 		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());
 	});
+	$(".effort-range").on('change', function(){
+		var effortid = $(this).data("effortid");
+		$("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+' '+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_to["+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/Artifact.class.php              | 15 ++++-
 src/common/tracker/ArtifactExtraField.class.php    |  1 +
 src/common/tracker/ArtifactFactory.class.php       | 17 +++++-
 src/common/tracker/actions/browse.php              | 13 +++--
 src/common/tracker/actions/query.php               | 15 +++--
 .../tracker/include/ArtifactTypeHtml.class.php     | 68 +++++++++++++++++++---
 6 files changed, 108 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list