Skip to content

Commit

Permalink
Status legend on "My View" independent of current filter
Browse files Browse the repository at this point in the history
Implementation of #11554 introduced a new functionality to show just
status colors of current filter in legend, or even suppress the display
of the legend. This makes sense on "Views Issues" page but not on "My
View" page.

This introduces a new parameter for html_status_legend(), allowing the
caller to determine whether the legend should take the filter into
consideration or not (by default, it does not and will display all valid
status for the workflow).

Only "My View" page uses the new parameter.

Fixes #19573
  • Loading branch information
dregad committed May 19, 2015
1 parent 38cc098 commit ca2da7d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
58 changes: 32 additions & 26 deletions core/html_api.php
Expand Up @@ -1345,18 +1345,22 @@ function print_summary_menu( $p_page = '' ) {

/**
* Print the color legend for the status colors
* @param bool $p_restrict_by_filter If true, only display status visible in current filter
* @return void
*/
function html_status_legend() {
# Don't show the legend if only one status is selected by the current filter
$t_current_filter = current_user_get_bug_filter();
if( $t_current_filter === false ) {
$t_current_filter = filter_get_default();
}
$t_simple_filter = $t_current_filter['_view_type'] == 'simple';
if( $t_simple_filter ) {
if( !filter_field_is_any( $t_current_filter[FILTER_PROPERTY_STATUS][0] ) ) {
return;
function html_status_legend( $p_restrict_by_filter = false ) {

if( $p_restrict_by_filter ) {
# Don't show the legend if only one status is selected by the current filter
$t_current_filter = current_user_get_bug_filter();
if( $t_current_filter === false ) {
$t_current_filter = filter_get_default();
}
$t_simple_filter = $t_current_filter['_view_type'] == 'simple';
if( $t_simple_filter ) {
if( !filter_field_is_any( $t_current_filter[FILTER_PROPERTY_STATUS][0] ) ) {
return;
}
}
}

Expand All @@ -1376,25 +1380,27 @@ function html_status_legend() {
}
}

# Remove status values that won't appear as a result of the current filter
foreach( $t_status_array as $t_status => $t_name ) {
if( $t_simple_filter ) {
if( !filter_field_is_none( $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0] ) &&
$t_status >= $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0] ) {
unset( $t_status_array[$t_status] );
}
} else {
if( !in_array( META_FILTER_ANY, $t_current_filter[FILTER_PROPERTY_STATUS] ) &&
!in_array( $t_status, $t_current_filter[FILTER_PROPERTY_STATUS] ) ) {
unset( $t_status_array[$t_status] );
if( $p_restrict_by_filter ) {
# Remove status values that won't appear as a result of the current filter
foreach( $t_status_array as $t_status => $t_name ) {
if( $t_simple_filter ) {
if( !filter_field_is_none( $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0] ) &&
$t_status >= $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0] ) {
unset( $t_status_array[$t_status] );
}
} else {
if( !in_array( META_FILTER_ANY, $t_current_filter[FILTER_PROPERTY_STATUS] ) &&
!in_array( $t_status, $t_current_filter[FILTER_PROPERTY_STATUS] ) ) {
unset( $t_status_array[$t_status] );
}
}
}
}

# If there aren't at least two statuses showable by the current filter,
# don't draw the status bar
if( count( $t_status_array ) <= 1 ) {
return;
# If there aren't at least two statuses showable by the current filter,
# don't draw the status bar
if( count( $t_status_array ) <= 1 ) {
return;
}
}

echo '<br />';
Expand Down
4 changes: 2 additions & 2 deletions view_all_inc.php
Expand Up @@ -91,7 +91,7 @@
$t_legend_position = config_get( 'status_legend_position' );

if( ( $t_legend_position & STATUS_LEGEND_POSITION_TOP ) == STATUS_LEGEND_POSITION_TOP ) {
html_status_legend();
html_status_legend( true );
}
?>
<br />
Expand Down Expand Up @@ -256,7 +256,7 @@ function write_bug_rows( array $p_rows ) {
<?php

if( ( $t_legend_position & STATUS_LEGEND_POSITION_BOTTOM ) == STATUS_LEGEND_POSITION_BOTTOM ) {
html_status_legend();
html_status_legend( true );
}

# -- ====================== FILTER FORM ========================= --
Expand Down

0 comments on commit ca2da7d

Please sign in to comment.