[Fusionforge-commits] r9337 - in trunk/gforge: common/tracker db www/themes/css www/tracker

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Fri Apr 2 22:41:28 CEST 2010


Author: aljeux
Date: 2010-04-02 22:41:27 +0200 (Fri, 02 Apr 2010)
New Revision: 9337

Added:
   trunk/gforge/db/20100402_add_query_options.sql
Modified:
   trunk/gforge/common/tracker/ArtifactQuery.class.php
   trunk/gforge/www/themes/css/fusionforge.css
   trunk/gforge/www/tracker/browse.php
   trunk/gforge/www/tracker/query.php
Log:
Add an option in tracker queries to display a (nice) progressbar on top of the browse mode when custom status is used.

Modified: trunk/gforge/common/tracker/ArtifactQuery.class.php
===================================================================
--- trunk/gforge/common/tracker/ArtifactQuery.class.php	2010-04-02 20:17:25 UTC (rev 9336)
+++ trunk/gforge/common/tracker/ArtifactQuery.class.php	2010-04-02 20:41:27 UTC (rev 9337)
@@ -121,7 +121,8 @@
 	 *	@param	string	Name of the saved query.
 	 *  @return 	true on success / false on failure.
 	 */
-	function create($name,$status,$assignee,$moddaterange,$sort_col,$sort_ord,$extra_fields,$opendaterange=0,$closedaterange=0,$summary,$description,$followups,$query_type=0) {
+	function create($name,$status,$assignee,$moddaterange,$sort_col,$sort_ord,$extra_fields,$opendaterange=0,$closedaterange=0,
+		$summary,$description,$followups,$query_type=0,$query_options=array()) {
 		//
 		//	data validation
 		//
@@ -621,7 +622,8 @@
 	 *	@param	string	The name of the saved query
 	 *  @return	boolean	success.
 	 */
-	function update($name,$status,$assignee,$moddaterange,$sort_col,$sort_ord,$extra_fields,$opendaterange='',$closedaterange='',$summary,$description,$followups,$query_type=0) {
+	function update($name,$status,$assignee,$moddaterange,$sort_col,$sort_ord,$extra_fields,$opendaterange='',$closedaterange='',
+		$summary,$description,$followups,$query_type=0,$query_options=array()) {
 		if (!$name) {
 			$this->setMissingParamsError();
 			return false;
@@ -651,13 +653,13 @@
 		db_begin();
 		$result = db_query_params ('UPDATE artifact_query
 			SET query_name=$1,
-				query_type=$2
-			WHERE artifact_query_id=$3
-			AND user_id=$4',
+				query_type=$2,
+				query_options=$3
+			WHERE artifact_query_id=$4',
 					   array (htmlspecialchars($name),
 						  $query_type,
-						  $this->getID(),
-						  user_getid())) ;
+						  join('|', $query_options),
+						  $this->getID())) ;
 		if ($result && db_affected_rows($result) > 0) {
 			if (!$this->insertElements($this->getID(),$status,$assignee,$moddaterange,$sort_col,$sort_ord,$extra_fields,$opendaterange,$closedaterange,$summary,$description,$followups)) {
 				db_rollback();

Added: trunk/gforge/db/20100402_add_query_options.sql
===================================================================
--- trunk/gforge/db/20100402_add_query_options.sql	                        (rev 0)
+++ trunk/gforge/db/20100402_add_query_options.sql	2010-04-02 20:41:27 UTC (rev 9337)
@@ -0,0 +1,4 @@
+ALTER TABLE "artifact_query" ADD COLUMN "query_options" text;
+UPDATE "artifact_query" SET query_options='';
+ALTER TABLE "artifact_query" ALTER COLUMN "query_options" SET DEFAULT '';
+ALTER TABLE "artifact_query" ALTER COLUMN "query_options" SET NOT NULL;

Modified: trunk/gforge/www/themes/css/fusionforge.css
===================================================================
--- trunk/gforge/www/themes/css/fusionforge.css	2010-04-02 20:17:25 UTC (rev 9336)
+++ trunk/gforge/www/themes/css/fusionforge.css	2010-04-02 20:41:27 UTC (rev 9337)
@@ -66,4 +66,34 @@
 
 .frs_release_name_version {
     margin: 0 0 0 1em;
-}
\ No newline at end of file
+}
+
+/* Progress bargraph (trackers) */
+table.progress {
+ border: 1px solid #d7d7d7;
+ border-collapse: collapse;
+ border-spacing: 0;
+ margin: 0;
+ padding: 0;
+ margin-top: 1em;
+ empty-cells: show;
+ width: 50%;
+ margin-left: 25%; 
+ margin-right: 25%;
+}
+table.progress_legend {
+ width: 50%;
+ margin-left: 25%; 
+ margin-right: 25%;
+}
+table.progress a, table.progress :link, table.progress :visited,
+table.progress :link:hover, table.progress :visited:hover {
+ border: none;
+ display: block;
+ height: 1.2em;
+ padding: 0;
+ margin: 0;
+ text-decoration: none
+}
+table.progress td { background: #fff; padding: 0 }
+table.progress td :hover { background: none }

Modified: trunk/gforge/www/tracker/browse.php
===================================================================
--- trunk/gforge/www/tracker/browse.php	2010-04-02 20:17:25 UTC (rev 9336)
+++ trunk/gforge/www/tracker/browse.php	2010-04-02 20:41:27 UTC (rev 9337)
@@ -347,6 +347,63 @@
 
 if ($art_arr && count($art_arr) > 0) {
 
+	if ($query_id) {
+		$aq = new ArtifactQuery($ath,$query_id);
+		$has_bargraph = (in_array('bargraph', $aq->getQueryOptions()));
+	} else {
+		$has_bargraph = false;
+	}
+	
+	if ($has_bargraph) {
+		// Display the roadmap block based on the values of the Status field.
+		$colors = array('#a71d16', '#ffa0a0', '#f5f5b5', '#bae0ba', '#16a716');
+		$count = array();
+		$percent = array();
+		foreach($art_arr as $art) {
+			if ($ath->usesCustomStatuses()) {
+				$custom_id = $ath->getCustomStatusField();
+				$extra_data = $art->getExtraFieldDataText();
+				$count[ $extra_data[$custom_id]['value'] ]++;
+			} else {
+				$count[ $art->getStatusName()]++;
+			}
+		}
+		foreach($count as $n => $c) {
+			$percent[$n] = round(100*$c/count($art_arr));
+		}
+		
+		$i=0;
+		$efarr =& $ath->getExtraFields(ARTIFACT_EXTRAFIELDTYPE_STATUS);
+		$keys=array_keys($efarr);
+		$field_id = $keys[0];
+		$states = $ath->getExtraFieldElements($field_id);
+		$graph = '';
+		$legend = '';
+		if (is_array($states)) {
+			foreach($states as $state) {
+				$name = $state['element_name'];
+				if ($count[$name]) {
+					$graph  .= '<td style="background: '.$colors[$i].'; width: '.$percent[$name].'%;">&nbsp;</td>';
+					$legend .= '<td style="white-space: nowrap; width: '.$percent[$name].'%;">'."<i>$name: $count[$name] ($percent[$name]%)</i></td>";
+				}
+				$i++;
+			}
+		}
+	
+		if ($graph) {
+		?>
+		<table class="progress">
+      	<tbody>
+      		<tr><?php echo $graph; ?></tr>
+      	</tbody>
+      	</table>
+      	<table class="progress_legend">
+      		<tr><?php echo $legend ?></tr>
+      	</table>
+	<?php
+		}
+	}
+	
 	if ($set=='custom') {
 		$set .= '&amp;_assigned_to='.$_assigned_to.'&amp;_status='.$_status.'&amp;_sort_col='.$_sort_col.'&amp;_sort_ord='.$_sort_ord;
 		if (array_key_exists($ath->getCustomStatusField(),$_extra_fields)) {

Modified: trunk/gforge/www/tracker/query.php
===================================================================
--- trunk/gforge/www/tracker/query.php	2010-04-02 20:17:25 UTC (rev 9336)
+++ trunk/gforge/www/tracker/query.php	2010-04-02 20:41:27 UTC (rev 9337)
@@ -54,7 +54,10 @@
 		$_summary = getStringFromRequest('_summary');
 		$_description = getStringFromRequest('_description');
 		$_followups = getStringFromRequest('_followups');
-		if (!$aq->create($query_name,$_status,$_assigned_to,$_moddaterange,$_sort_col,$_sort_ord,$extra_fields,$_opendaterange,$_closedaterange,$_summary,$_description,$_followups,$query_type)) {
+		$query_options = array_keys(getArrayFromRequest('query_options'));
+		if (!$aq->create($query_name,$_status,$_assigned_to,$_moddaterange,$_sort_col,$_sort_ord,$extra_fields,$_opendaterange,$_closedaterange,
+			$_summary,$_description,$_followups,$query_type, $query_options)) {
+			form_release_key(getStringFromRequest('form_key'));
 			exit_error('Error',$aq->getErrorMessage());
 		} else {
 			$feedback .= 'Successfully Created';
@@ -101,7 +104,9 @@
 		$_description = getStringFromRequest('_description');
 		$_followups = getStringFromRequest('_followups');
 		$extra_fields = getStringFromRequest('extra_fields');
-		if (!$aq->update($query_name,$_status,$_assigned_to,$_moddaterange,$_sort_col,$_sort_ord,$extra_fields,$_opendaterange,$_closedaterange,$_summary,$_description,$_followups,$query_type)) {
+		$query_options = array_keys(getArrayFromRequest('query_options'));
+		if (!$aq->update($query_name,$_status,$_assigned_to,$_moddaterange,$_sort_col,$_sort_ord,$extra_fields,$_opendaterange,$_closedaterange,
+			$_summary,$_description,$_followups,$query_type, $query_options)) {
 			exit_error('Error',$aq->getErrorMessage());
 		} else {
 			$feedback .= 'Query Updated';
@@ -357,7 +362,15 @@
 		<td>&nbsp;<br />
 		'.html_build_select_box_from_arrays($sort_arr,$sort_name_arr,'_sort_ord',$_sort_ord,false) .'</td>
 	</tr>';
-	echo '
+echo '<tr>
+		<td colspan="2">'.
+		'<p/><strong>Options:</strong><br />
+		<input type="checkbox" name="query_options[bargraph]" '.
+	((in_array('bargraph', $aq->getQueryOptions())) ? 'checked="checked"' : '')
+.'/> Display a short summary box on top of the list (roadmap status).<p/>
+		</td>
+	</tr>';
+echo '
 	</table></form>';
 echo '</fieldset></td></tr></table>';
 $ath->footer(array());




More information about the Fusionforge-commits mailing list