Skip to content

Commit

Permalink
Adapt MantisBT UI to use due_date warning levels
Browse files Browse the repository at this point in the history
  • Loading branch information
dregad committed Feb 2, 2020
1 parent c4660a5 commit 3222547
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
7 changes: 4 additions & 3 deletions bug_update_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,11 @@
# Due Date
echo '<th class="category"><label for="due_date">' . lang_get( 'due_date' ) . '</label></th>';

if( bug_is_overdue( $t_bug_id ) ) {
echo '<td class="overdue">';
} else {
$t_level = bug_overdue_level( $t_bug_id );
if( $t_level === false ) {
echo '<td>';
} else {
echo '<td class="due-', $t_level, '">';
}

if( access_has_bug_level( config_get( 'due_date_update_threshold' ), $t_bug_id ) ) {
Expand Down
8 changes: 4 additions & 4 deletions bug_view_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@
if( $t_flags['due_date_show'] ) {
echo '<th class="bug-due-date category">', lang_get( 'due_date' ), '</th>';

if( $t_issue_view['overdue'] ) {
echo '<td class="bug-due-date overdue">', $t_issue_view['due_date'], '</td>';
} else {
echo '<td class="bug-due-date">', $t_issue_view['due_date'], '</td>';
$t_css = 'bug-due-date';
if( $t_issue_view['overdue'] !== false ) {
$t_css .= ' due-' . $t_issue_view['overdue'];
}
echo '<td class="' . $t_css . '">', $t_issue_view['due_date'], '</td>';
} else {
$t_spacer += 2;
}
Expand Down
36 changes: 26 additions & 10 deletions core/columns_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1634,20 +1634,17 @@ function print_column_tags( BugData $p_bug, $p_columns_target = COLUMNS_TARGET_V
* @access public
*/
function print_column_due_date( BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
$t_overdue = '';

if( !access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) ||
date_is_null( $p_bug->due_date )
) {
$t_css = '';
$t_value = '&#160;';
} else {
if( bug_is_overdue( $p_bug->id ) ) {
$t_overdue = ' overdue';
}
$t_css = " due-" . bug_overdue_level( $p_bug->id );
$t_value = string_display_line( date( config_get( 'short_date_format' ), $p_bug->due_date ) );
}

printf( '<td class="column-due-date%s">%s</td>', $t_overdue, $t_value );
printf( '<td class="column-due-date%s">%s</td>', $t_css, $t_value );
}

/**
Expand All @@ -1663,10 +1660,29 @@ function print_column_overdue( BugData $p_bug, $p_columns_target = COLUMNS_TARGE
echo '<td class="column-overdue">';

if( access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) &&
!date_is_null( $p_bug->due_date ) &&
bug_is_overdue( $p_bug->id ) ) {
$t_overdue_text_hover = sprintf( lang_get( 'overdue_since' ), date( config_get( 'short_date_format' ), $p_bug->due_date ) );
echo '<i class="fa fa-times-circle-o" title="' . string_display_line( $t_overdue_text_hover ) . '"></i>';
!date_is_null( $p_bug->due_date )
) {
$t_level = bug_overdue_level( $p_bug->id );
if( $t_level === 0 ) {
$t_icon = 'fa-times-circle-o';
$t_overdue_text_hover = sprintf(
lang_get( 'overdue_since' ),
date( config_get( 'short_date_format' ), $p_bug->due_date )
);
} else {
$t_icon = $t_level === false ? 'fa-info-circle' : 'fa-warning';

$t_duration = $p_bug->due_date - db_now();
if( $t_duration <= SECONDS_PER_DAY ) {
$t_overdue_text_hover = lang_get( 'overdue_one_day' );
} else {
$t_overdue_text_hover = sprintf(
lang_get( 'overdue_days' ),
ceil( $t_duration / SECONDS_PER_DAY )
);
}
}
echo '<i class="fa ' . $t_icon . '" title="' . string_display_line( $t_overdue_text_hover ) . '"></i>';
} else {
echo '&#160;';
}
Expand Down
2 changes: 1 addition & 1 deletion core/commands/IssueViewPageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function process() {
# Due date
$t_flags['due_date_show'] = in_array( 'due_date', $t_fields ) && access_has_bug_level( config_get( 'due_date_view_threshold' ), $t_issue_id );
if( $t_flags['due_date_show'] ) {
$t_issue_view['overdue'] = bug_is_overdue( $t_issue_id );
$t_issue_view['overdue'] = bug_overdue_level( $t_issue_id );

if( isset( $t_issue['due_date'] ) ) {
$t_issue_view['due_date'] = date( config_get( 'normal_date_format' ), strtotime( $t_issue['due_date'] ) );
Expand Down
6 changes: 4 additions & 2 deletions css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ tr.bugnote .bugnote-note { background-color: #e8e8e8; color: #000000; width: 75%
.color-global { background-color: LightBlue; }
.color-project { background-color: LightGreen; }

td.overdue { background-color: #d15b47; color: #ffffff; font-weight: bold; }
td.print-overdue { font-weight: bold; }
td.due-0, td.overdue { background-color: red; color: #ffffff; font-weight: bold; }
td.due-1 { background-color: darkorange; color: #ffffff; font-weight: bold; }
td.due-2 { background-color: green; color: #ffffff; font-weight: bold; }
td.print-overdue { font-weight: bold; }

.collapse-link { cursor: pointer; }

Expand Down
2 changes: 2 additions & 0 deletions lang/strings_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,8 @@ $s_copy_columns_to = 'Copy Columns To';
$s_due_date = 'Due Date';
$s_overdue = 'Overdue';
$s_overdue_since = 'Overdue since %1$s';
$s_overdue_one_day = 'Overdue in less than a day';
$s_overdue_days = 'Overdue in %1$d days';

#account_view_page.php
$s_view_account_title = 'User Information';
Expand Down

0 comments on commit 3222547

Please sign in to comment.