View Issue Details

IDProjectCategoryView StatusLast Update
0012387mantisbtfeaturepublic2011-05-27 05:27
Reportersveyret Assigned To 
PrioritynormalSeveritytweakReproducibilityalways
Status newResolutionopen 
Product Version1.2.3 
Summary0012387: Condensed project menu bar
Description

In my compagny, we have more than 200 projects. Having too many projects causes some graphical problems for users :

  1. In the dropdown, due to the » sign in front of all subproject, it is very difficult to locate and select the project we want.
  2. If we display the project menu bar, it take a whole screen only for the project list.

I created a patch which adds the ability to have a “condensed view” of the project. It adds a new configuration option :
$g_show_projects_condensed = OFF;

When kept OFF, this option has no effect. If set to ON :

  1. In the dropdown for the project list each project appears only once, sorted by name, and without the » sign, and so can be selected by typing its first letters. This has no effect of the extended project browser.
  2. In the project menu bar, we see only the selected project, its parents (if known) and its direct children, which make this menu bar far more simple.

Sorry again for posting a simple standard patch (to be applied with patch -p1) instead of real git patch.

Tagspatch, redesign
Attached Files
proj-condensed.patch (6,361 bytes)   
diff -Naur mantisbt-1.2.3/config_defaults_inc.php mantisbt-patch/config_defaults_inc.php
--- mantisbt-1.2.3/config_defaults_inc.php	2010-09-22 10:39:51.000000000 +0200
+++ mantisbt-patch/config_defaults_inc.php	2010-09-22 10:49:00.000000000 +0200
@@ -777,6 +777,14 @@
 	$g_show_project_menu_bar = OFF;
 
 	/**
+	 * Show available projects in a condensed mode: only current project,
+	 * its parents and children are displayed in the project menu bar;
+	 * projects are displayed only once in project dropdown.	 
+	 * @global int $g_show_projects_condensed
+	 */
+	$g_show_projects_condensed = OFF;
+
+	/**
 	 * show assigned to names
 	 * This is in the view all pages
 	 * @global int $g_show_assigned_names
diff -Naur mantisbt-1.2.3/core/html_api.php mantisbt-patch/core/html_api.php
--- mantisbt-1.2.3/core/html_api.php	2010-09-22 10:40:42.000000000 +0200
+++ mantisbt-patch/core/html_api.php	2010-09-22 11:30:16.000000000 +0200
@@ -865,9 +865,33 @@
 	echo '<td class="menu">';
 	echo '<a href="' . helper_mantis_url( 'set_project.php?project_id=' . ALL_PROJECTS ) . '">' . lang_get( 'all_projects' ) . '</a>';
 
-	foreach( $t_project_ids as $t_id ) {
-		echo ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . '">' . string_html_specialchars( project_get_field( $t_id, 'name' ) ) . '</a>';
-		print_subproject_menu_bar( $t_id, $t_id . ';' );
+	if( config_get( 'show_projects_condensed' ) == OFF ) {
+		foreach( $t_project_ids as $t_id ) {
+			echo ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . '">' . string_html_specialchars( project_get_field( $t_id, 'name' ) ) . '</a>';
+			print_subproject_menu_bar( $t_id, $t_id . ';' );
+		}
+	} else {
+		# Show only a condensed version of the menu bar
+		$t_project_path = helper_get_current_project_trace();
+		$t_parents = '';
+		if( $t_project_path[0] == ALL_PROJECTS ) array_shift( $t_project_path );
+
+		while( count( $t_project_path ) > 0 && in_array( $t_project_path[0], $t_project_ids ) ) {
+			$t_parents = $t_parents . $t_project_path[0];
+			echo ' &gt; <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_parents ) . '">' . string_html_specialchars( project_get_field( $t_project_path[0], 'name' ) ) . '</a>';
+			$t_parents .= ';';
+			$t_project_ids = current_user_get_accessible_subprojects( $t_project_path[0] );
+			array_shift( $t_project_path );
+		}
+
+		if( count( $t_project_path ) > 0 ) {
+			$t_parents = $t_parents . $t_project_path[ count( $t_project_path ) - 1 ];
+			echo ' &gt;&gt; <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_parents ) . '">' . string_html_specialchars( project_get_field( $t_project_path[ count( $t_project_path ) - 1 ], 'name' ) ) . '</a>';
+			$t_parents .= ';';
+			$t_project_ids = current_user_get_accessible_subprojects( $t_project_path[ count( $t_project_path ) - 1 ] );
+		}
+
+		print_subproject_menu_bar( $t_project_ids, $t_parents );
 	}
 
 	echo '</td>';
@@ -880,11 +904,19 @@
  * @return null
  */
 function print_subproject_menu_bar( $p_project_id, $p_parents = '' ) {
-	$t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
+	$t_recursive = false;
+	$t_subprojects = $p_project_id;
+	if( !is_array( $p_project_id ) ) {
+		$t_recursive = true;
+		$t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
+	}
+
 	$t_char = ':';
 	foreach( $t_subprojects as $t_subproject ) {
 		echo $t_char . ' <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $p_parents . $t_subproject ) . '">' . string_html_specialchars( project_get_field( $t_subproject, 'name' ) ) . '</a>';
-		print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
+		if( $t_recursive ) {
+			print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
+		}
 		$t_char = ',';
 	}
 }
diff -Naur mantisbt-1.2.3/core/print_api.php mantisbt-patch/core/print_api.php
--- mantisbt-1.2.3/core/print_api.php	2010-09-22 10:41:12.000000000 +0200
+++ mantisbt-patch/core/print_api.php	2010-09-22 13:56:34.000000000 +0200
@@ -462,7 +462,9 @@
  * @return void
  */
 function print_project_option_list( $p_project_id = null, $p_include_all_projects = true, $p_filter_project_id = null, $p_trace = false ) {
-	$t_project_ids = current_user_get_accessible_projects();
+	$t_condensed = ( config_get( 'show_projects_condensed' ) != OFF );
+	$t_project_ids = $t_condensed ? current_user_get_all_accessible_subprojects( ALL_PROJECTS ) :
+		current_user_get_accessible_projects();
 	project_cache_array_rows( $t_project_ids );
 
 	if( $p_include_all_projects ) {
@@ -471,14 +473,24 @@
 		echo '>' . lang_get( 'all_projects' ) . '</option>' . "\n";
 	}
 
-	$t_project_count = count( $t_project_ids );
-	for( $i = 0;$i < $t_project_count;$i++ ) {
-		$t_id = $t_project_ids[$i];
+	$t_projects = array();
+	foreach( $t_project_ids as $t_id ) {
+		$t_projects[$t_id] = project_get_field( $t_id, 'name' );
+	}
+	asort( $t_projects );
+	if( $t_condensed ) {
+		$t_selected_id = split( ';', $p_project_id );
+		$p_project_id = $t_selected_id[ count( $t_selected_id ) - 1 ];
+	}
+
+	foreach( $t_projects as $t_id => $t_name ) {
 		if( $t_id != $p_filter_project_id ) {
 			echo '<option value="' . $t_id . '"';
 			check_selected( $p_project_id, $t_id );
-			echo '>' . string_attribute( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
-			print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, Array() );
+			echo '>' . string_attribute( $t_name ) . '</option>' . "\n";
+			if( !$t_condensed ) {
+				print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, Array() );
+			}
 		}
 	}
 }
diff -Naur mantisbt-1.2.3/core/user_api.php mantisbt-patch/core/user_api.php
--- mantisbt-1.2.3/core/user_api.php	2010-09-22 10:40:58.000000000 +0200
+++ mantisbt-patch/core/user_api.php	2010-09-22 13:58:39.000000000 +0200
@@ -1001,7 +1001,7 @@
 	/** @todo (thraxisp) Should all top level projects be a sub-project of ALL_PROJECTS implicitly?
 	 *  affects how news and some summaries are generated
 	 */
-	$t_todo = user_get_accessible_subprojects( $p_user_id, $p_project_id );
+	$t_todo = $p_project_id == ALL_PROJECTS ? user_get_accessible_projects( $p_user_id ) : user_get_accessible_subprojects( $p_user_id, $p_project_id );
 	$t_subprojects = Array();
 
 	while( $t_todo ) {
proj-condensed.patch (6,361 bytes)   

Activities

dhx

dhx

2010-10-22 07:43

reporter   ~0027125

Thanks for the patch Stéphane!

I've CC'd Daryn into this bug as he has been working on redesigning this part of MantisBT's UI.

I suggest joining the developer mailing list as it has been busy with discussion on revamping MantisBT's UI. Your ideas, mockups, patches, etc would be warmly welcomed.