[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1889-g4af4ca8

Franck Villaume nerville at libremir.placard.fr.eu.org
Thu Jun 1 12:14:27 CEST 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  4af4ca821fed9cecd668bd0f29df61000d98e271 (commit)
      from  90ba9fd17cd76b2ab8dd3d18221245f1fdfa40df (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=4af4ca821fed9cecd668bd0f29df61000d98e271

commit 4af4ca821fed9cecd668bd0f29df61000d98e271
Author: St├ęphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Thu Jun 1 12:11:53 2017 +0200

    Tracker: Artifacts dependencies, part 5

diff --git a/src/common/tracker/Artifact.class.php b/src/common/tracker/Artifact.class.php
index 08a178c..e43c954 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -1564,7 +1564,7 @@ class Artifact extends FFObject {
 				$new = '';
 				foreach (explode(' ',$value) as $id) {
 					if (preg_match('/^(\d+)$/', $id)) {
-						if ($id == $this->getID) {
+						if ($id == $this->getID()) {
 							$this->setError('Illegal id '.$id.', self reference for field: '.$ef[$efid]['field_name'].'.'); // @todo: lang
 							return false;
 						}
@@ -2306,6 +2306,40 @@ class Artifact extends FFObject {
 		return $return;
 	}
 
+	function setParent($parent_id){
+		$return = false;
+		$update = false;
+		if ($this->getParent()) {
+			if ($this->getParent() == $parent_id) {
+				return true;
+			} else {
+				$this->setError(_('Error')._(':').' '.sprintf(_('Artifact $s has already a parent', $child_id)));
+				return false;
+			}
+		}
+		$extra_fields = $this->getExtraFieldData();
+		$priority = $this->getPriority();
+		$status_id = $this->getStatusID();
+		$status_id = $this->getArtifactType()->remapStatus($status_id, $extra_fields);
+		$assigned_to = $this->getAssignedTo();
+		$summary = $this->getSummary();
+		$canned_response = 100;
+		$details = "";
+		$artifact_type_id = $this->getArtifactType()->getID();
+		$description = $this->getDetails();
+		$ef_parent_arr= $this->getArtifactType()->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+		$ef_parent = array_shift($ef_parent_arr);
+		$ef_parent_id = $ef_parent['extra_field_id'];
+		$extra_fields[$ef_parent_id] = $parent_id;
+		$ret['ef_parent_id'] = $ef_parent_id;
+		$return = $this->update($priority,$status_id,
+							$assigned_to,$summary,$canned_response,$details,$artifact_type_id,
+							$extra_fields, $description);
+		unset($this->parent);
+		$this->fetchData($this->getID());
+		return $return;
+	}
+
 	function getPermalink() {
 		return '/tracker/a_follow.php/'.$this->getID();
 	}
diff --git a/src/common/tracker/actions/ajax.php b/src/common/tracker/actions/ajax.php
index b829a4b..7ab58c5 100644
--- a/src/common/tracker/actions/ajax.php
+++ b/src/common/tracker/actions/ajax.php
@@ -23,6 +23,7 @@
  */
 
 require_once $gfcommon.'tracker/ArtifactExpression.class.php';
+require_once $gfcommon.'tracker/Artifact.class.php';
 
 global $group;
 global $atid;
@@ -45,6 +46,16 @@ switch ($function) {
 		$description = getStringFromRequest('description');
 		echo get_formulas_results($group, $atid, $extra_fields, $status, $assigned_to, $priority, $summary, $description);
 		break;
+	case 'add_parent':
+		$aid = getIntFromRequest('aid');
+		$parent_id = getIntFromRequest('parent_id');
+		echo add_parent($aid, $parent_id);
+		break;
+	case 'add_child':
+		$aid = getIntFromRequest('aid');
+		$child_id = getIntFromRequest('child_id');
+		echo add_child($aid, $child_id);
+		break;
 	default:
 		echo '';
 		break;
@@ -203,3 +214,41 @@ function get_formulas_results($group, $atid, $extra_fields=array(), $status='',
 	$ret['fields'] = $result;
 	return json_encode($ret);
 }
+
+function add_parent($child_id, $parent_id){
+	$ret = array('message' => '');
+	$artifact = artifact_get_object($child_id);
+	$at = $artifact->getArtifactType();
+	$child = new ArtifactHtml($at, $child_id);
+	if (!$child->setParent($parent_id)) {
+		$ret['message']=$child->getErrorMessage();
+		return json_encode($ret);
+		exit();
+	}
+	$ret['parent_id'] = $parent_id;
+	$ef_parent_arr= $at->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+	$ef_parent = array_shift($ef_parent_arr);
+	$ret['parent_efid'] = $ef_parent['extra_field_id'];
+	$ret['parent_link'] = _artifactid2url($parent_id, 'title');
+	$ret['parent'] = $child->showParent();
+	return json_encode($ret);
+	exit();
+}
+
+function add_child($parent_id, $child_id){
+	$ret = array('message' => '');
+	$artifact = artifact_get_object($child_id);
+	$at = $artifact->getArtifactType();
+	$child = new ArtifactHtml($at, $child_id);
+	if (!$child->setParent($parent_id)) {
+		$ret['message']=$child->getErrorMessage();
+		return json_encode($ret);
+		exit();
+	}
+	$artifact = artifact_get_object($parent_id);
+	$at = $artifact->getArtifactType();
+	$parent= new ArtifactHtml($at, $parent_id);
+	$ret['children'] = $parent->showChildren();
+	return json_encode($ret);
+	exit();
+}
\ No newline at end of file
diff --git a/src/common/tracker/actions/detail.php b/src/common/tracker/actions/detail.php
index ea38857..e343392 100644
--- a/src/common/tracker/actions/detail.php
+++ b/src/common/tracker/actions/detail.php
@@ -252,11 +252,7 @@ if ($group->usesPM()) {
 	</div><?php
 	if (forge_get_config('use_artefacts_dependencies')) { ?>
 		<div id="tabber-dependencies" class="tabbertab">
-			<?php
-				echo '<strong>'._('Parent').'</strong><br>';
-				echo $ah->showParent().'<br>';
-				echo '<strong>'._('Children').'</strong><br>';
-				echo $ah->showChildren();
+			<?php echo $ah->showDependencies()
 			?>
 		</div><?php
 	}
diff --git a/src/common/tracker/actions/mod-limited.php b/src/common/tracker/actions/mod-limited.php
index ec68ede..668ff90 100644
--- a/src/common/tracker/actions/mod-limited.php
+++ b/src/common/tracker/actions/mod-limited.php
@@ -277,11 +277,7 @@ echo $ath->renderFiles($group_id, $ah);
 </div><?php
 if (forge_get_config('use_artefacts_dependencies')) { ?>
 	<div id="tabber-dependencies" class="tabbertab">
-		<?php
-			echo '<strong>'._('Parent').'</strong><br>';
-			echo $ah->showParent().'<br>';
-			echo '<strong>'._('Children').'</strong><br>';
-			echo $ah->showChildren();
+		<?php echo $ah->showDependencies();
 		?>
 	</div><?php
 }
diff --git a/src/common/tracker/actions/mod.php b/src/common/tracker/actions/mod.php
index 637b9d4..825dbf0 100644
--- a/src/common/tracker/actions/mod.php
+++ b/src/common/tracker/actions/mod.php
@@ -355,12 +355,7 @@ echo $ath->renderFiles($group_id, $ah);
 </div><?php
 if (forge_get_config('use_artefacts_dependencies')) { ?>
 	<div id="tabber-dependencies" class="tabbertab">
-		<?php
-			echo '<strong>'._('Parent').'</strong><br>';
-			echo $ah->showParent().'<br>';
-			echo '<strong>'._('Children').'</strong><br>';
-			echo $ah->showChildren();
-		?>
+		<?php echo $ah->showDependencies(); ?>
 	</div><?php
 }
 if (forge_get_config('use_object_associations')) { ?>
diff --git a/src/common/tracker/include/ArtifactHtml.class.php b/src/common/tracker/include/ArtifactHtml.class.php
index 6bc9c67..4a79568 100644
--- a/src/common/tracker/include/ArtifactHtml.class.php
+++ b/src/common/tracker/include/ArtifactHtml.class.php
@@ -229,7 +229,7 @@ function hide_edit_button(id) {
 		$rows= count($children);
 		$return = '';
 		if ($rows > 0){
-			$return = '	<table class="fullwidth">
+			$return = '	<table class="children fullwidth">
 							<tr>
 								<td colspan="2">';
 			$current = '';
@@ -264,7 +264,7 @@ function hide_edit_button(id) {
 		$return = '';
 		if ($parentId){
 			$parent = artifact_get_object($parentId);
-			$return = '	<table class="fullwidth">
+			$return = '	<table class="parent fullwidth">
 							<tr>
 								<td colspan="2">';
 			$parentAt = $parent->getArtifactType();
@@ -284,6 +284,38 @@ function hide_edit_button(id) {
 			$return .= '</td>
 				</tr>
 				</table>';
+		} else {
+			$return = '	<table class="parent fullwidth"></table>';
+		}
+		return $return;
+	}
+
+	function showDependencies() {
+		global $HTML;
+		$return = '';
+		$ef_parent = $this->getArtifactType()->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+		if (count($ef_parent)) {
+			$return .= html_e('input', array('type'=>'hidden','id'=>'aid', 'value'=>$this->getID()));
+			$return .= html_ao('div',array('class'=>'fullwidth'));
+			$return .= html_e('strong',array(),_('Parent')).html_e('br');
+			$return .= $this->showParent();
+			if ($this->hasParent()) {
+				$return .= html_ao('div',array('class'=>'fullwidth addparent hide'));
+			} else {
+				$return .= html_ao('div',array('class'=>'fullwidth addparent'));
+			}
+			$return .= html_e('input', array('type'=>'text', 'id'=>'parent_id', 'value'=>'', 'size'=>20, 'maxlength'=>80, 'pattern'=>'^(?!'.$this->getID().'$)\d*$'));
+			$return .= $HTML->getAddPic(_('Click to add parent'), _('Click to add parent'), array('name'=>'addparent')).html_e('br');
+			$return .= html_ac(html_ap()-1);
+			$return .= html_ac(html_ap()-1).html_e('br');
+			$return .= html_ao('div',array('class'=>'fullwidth'));
+			$return .= html_e('strong',array(),_('Children')).html_e('br');
+			$return .= $this->showChildren();
+			$return .= html_ao('div',array('class'=>'fullwidth addchild'));
+			$return .= html_e('input', array('type'=>'text', 'id'=>'child_id', 'value'=>'', 'size'=>20, 'maxlength'=>80, 'pattern'=>'^(?!'.$this->getID().'$)\d*$'));
+			$return .= $HTML->getAddPic(_('Click to add child'), _('Click to add child'), array('name'=>'addchild'));
+			$return .= html_ac(html_ap()-1);
+			$return .= html_ac(html_ap()-1);
 		}
 		return $return;
 	}
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index f7a98a5..9442251 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -1539,7 +1539,6 @@ class ArtifactTypeHtml extends ArtifactType {
 	var invalidInputMsg = '". _("This choice is not allowed")."';
 	var groupId =".$this->Group->getID().";
 	var atId = ".$this->getID().";";
-
 		$effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
 		if ($effortUnitSet->isAutoconvert()) {
 			$jseffort = <<<'EOS'
@@ -1600,7 +1599,6 @@ EOS;
 			data: 'rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&status='+$("select[name='status_id'] option:selected").text()+'&assigned_to='+$("select[name='assigned_to'] option:selected").text()+'&'+$("[name^='extra_fields'], #tracker-summary, #tracker-description, [name='priority']").serialize(),
 			async: false,
 			dataType: 'json',
-			contentType:"application/json; charset=utf-8",
 			success: function(answer){
 				if(answer['message']) {
 					showMessage(answer['message'], 'error');
@@ -1653,6 +1651,53 @@ EOS;
 			}
 		});
 	});
+
+
+
+
+	$("img[name='addparent']").click(function(){
+		$.ajax({
+			type: 'POST',
+			url: 'index.php',
+			data: 'rtype=ajax&function=add_parent&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&parent_id='+$("input#parent_id").val(),
+			async: false,
+			dataType: 'json',
+			success: function(answer){
+				if(answer['message']) {
+					showMessage(answer['message'], 'error');
+				} else {
+					$("table.parent").replaceWith(answer['parent']);
+					$("input[name='extra_fields["+answer['parent_efid']+"]']").val(answer['parent_id']);
+					$("div#show"+answer['parent_efid']).html(answer['parent_link']);
+					$("input#parent_id").val('');
+					$("div.addparent").addClass('hide');
+				}
+				return true;
+			}
+		});
+	});
+
+
+	$("img[name='addchild']").click(function(){
+		$.ajax({
+			type: 'POST',
+			url: 'index.php',
+			data: 'rtype=ajax&function=add_child&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&child_id='+$("input#child_id").val(),
+			async: false,
+			dataType: 'json',
+			success: function(answer){
+				if(answer['message']) {
+					showMessage(answer['message'], 'error');
+				} else {
+					$("table.children").replaceWith(answer['children']);
+					$("input#child_id").val('');
+				}
+				return true;
+			}
+		});
+	});
+
+
 	$(".autoassign[name^='extra_fields']").change(function(){
 		if ($(this).prop('tagName') == 'SELECT') {
 			var elmnts = $(this).children('option:selected');
diff --git a/src/common/widget/Widget_TrackerComment.class.php b/src/common/widget/Widget_TrackerComment.class.php
index ad11ddc..447f657 100644
--- a/src/common/widget/Widget_TrackerComment.class.php
+++ b/src/common/widget/Widget_TrackerComment.class.php
@@ -172,10 +172,7 @@ class Widget_TrackerComment extends Widget {
 						$ah->showRelations());
 			if (forge_get_config('use_artefacts_dependencies')) {
 				$tabberContent .= html_e('div', array('id' => 'tabber-dependencies', 'class' => 'tabbertab'),
-						html_e('strong',array(),_('Parent')).html_e('br').
-						$ah->showParent().html_e('br').
-						html_e('strong',array(),_('Children')).html_e('br').
-						$ah->showChildren());
+						$ah->showDependencies());
 			}
 			if (forge_get_config('use_object_associations')) {
 				$associationContent = $ah->showAssociations('/tracker/?func=removeassoc&aid='.$ah->getID().'&group_id='.$group_id.'&atid='.$ath->getID());
diff --git a/src/www/include/Layout.class.php b/src/www/include/Layout.class.php
index da8c2b0..d9fa28d 100644
--- a/src/www/include/Layout.class.php
+++ b/src/www/include/Layout.class.php
@@ -1021,6 +1021,10 @@ abstract class Layout extends FFError {
 		return $this->getPicto('ic/add.png', $title, $alt, 20, 20, $otherAttr);
 	}
 
+	function getAddPic($title = '', $alt = '', $otherAttr = array()) {
+		return $this->getPicto('ic/add-16.png', $title, $alt, 16, 16, $otherAttr);
+	}
+
 	function getFolderPic($title = '', $alt = '', $otherAttr = array()) {
 		return $this->getPicto('ic/folder.png', $title, $alt, 20, 20, $otherAttr);
 	}

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

Summary of changes:
 src/common/tracker/Artifact.class.php              | 36 +++++++++++++++-
 src/common/tracker/actions/ajax.php                | 49 ++++++++++++++++++++++
 src/common/tracker/actions/detail.php              |  6 +--
 src/common/tracker/actions/mod-limited.php         |  6 +--
 src/common/tracker/actions/mod.php                 |  7 +---
 src/common/tracker/include/ArtifactHtml.class.php  | 36 +++++++++++++++-
 .../tracker/include/ArtifactTypeHtml.class.php     | 49 +++++++++++++++++++++-
 src/common/widget/Widget_TrackerComment.class.php  |  5 +--
 src/www/include/Layout.class.php                   |  4 ++
 9 files changed, 173 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list