"Blocked tasks" display

Tasks that have missing dependencies will be displayed in a red-ish
colour on the item views and in the full tasks list. Added a "blocked
tasks" mode to the tasks list page.
This commit is contained in:
Emmanuel BENOîT 2012-02-05 22:22:16 +01:00
parent bbf2c4a13c
commit 55438e6661
4 changed files with 97 additions and 10 deletions

View file

@ -24,13 +24,26 @@ class DAO_Tasks
'SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title, ' 'SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title, '
. 't.task_description AS description, t.task_added AS added_at, ' . 't.task_description AS description, t.task_added AS added_at, '
. 'u1.user_email AS added_by, ct.completed_task_time AS completed_at, ' . 'u1.user_email AS added_by, ct.completed_task_time AS completed_at, '
. 'u2.user_email AS completed_by , t.task_priority AS priority ' . 'u2.user_email AS completed_by , t.task_priority AS priority , '
. 'bd.bad_deps AS missing_dependencies '
. 'FROM tasks t ' . 'FROM tasks t '
. 'INNER JOIN users u1 ON u1.user_id = t.user_id ' . 'INNER JOIN users u1 ON u1.user_id = t.user_id '
. 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id ' . 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id '
. 'LEFT OUTER JOIN users u2 ON u2.user_id = ct.user_id ' . 'LEFT OUTER JOIN users u2 ON u2.user_id = ct.user_id '
. 'ORDER BY ( CASE WHEN ct.task_id IS NULL THEN t.task_priority ELSE -1 END ) DESC , ' . 'LEFT OUTER JOIN ('
. 't.task_added DESC' )->execute( ); . 'SELECT td.task_id , COUNT(*) AS bad_deps '
. 'FROM task_dependencies td '
. 'LEFT OUTER JOIN completed_tasks dct '
. 'ON dct.task_id = td.task_id_depends '
. 'WHERE dct.task_id IS NULL '
. 'GROUP BY td.task_id'
. ') AS bd ON bd.task_id = t.task_id '
. 'ORDER BY ( CASE '
. 'WHEN ct.task_id IS NULL THEN '
. 't.task_priority '
. 'ELSE '
. '-1 '
. 'END ) DESC , bd.bad_deps ASC NULLS FIRST , t.task_added DESC' )->execute( );
} }
public function getAllActiveTasks( ) public function getAllActiveTasks( )
@ -39,14 +52,43 @@ class DAO_Tasks
'SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title, ' 'SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title, '
. 't.task_description AS description, t.task_added AS added_at, ' . 't.task_description AS description, t.task_added AS added_at, '
. 'u1.user_email AS added_by, NULL AS completed_at, NULL AS completed_by , ' . 'u1.user_email AS added_by, NULL AS completed_at, NULL AS completed_by , '
. 't.task_priority AS priority ' . 't.task_priority AS priority , NULL::INT AS missing_dependencies '
. 'FROM tasks t ' . 'FROM tasks t '
. 'INNER JOIN users u1 ON u1.user_id = t.user_id ' . 'INNER JOIN users u1 ON u1.user_id = t.user_id '
. 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id ' . 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id '
. 'WHERE ct.task_id IS NULL ' . 'LEFT OUTER JOIN ('
. 'SELECT td.task_id , td.task_id_depends AS bad_dep '
. 'FROM task_dependencies td '
. 'LEFT OUTER JOIN completed_tasks dct '
. 'ON dct.task_id = td.task_id_depends '
. 'WHERE dct.task_id IS NULL'
. ') AS bd ON bd.task_id = t.task_id '
. 'WHERE ct.task_id IS NULL AND bd.bad_dep IS NULL '
. 'ORDER BY t.task_priority DESC , t.task_added DESC' )->execute( ); . 'ORDER BY t.task_priority DESC , t.task_added DESC' )->execute( );
} }
public function getAllBlockedTasks( )
{
return $this->query(
'SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title, '
. 't.task_description AS description, t.task_added AS added_at, '
. 'u1.user_email AS added_by, NULL AS completed_at, NULL AS completed_by , '
. 't.task_priority AS priority , bd.bad_deps AS missing_dependencies '
. 'FROM tasks t '
. 'INNER JOIN users u1 ON u1.user_id = t.user_id '
. 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id '
. 'LEFT OUTER JOIN ('
. 'SELECT td.task_id , COUNT(*) AS bad_deps '
. 'FROM task_dependencies td '
. 'LEFT OUTER JOIN completed_tasks dct '
. 'ON dct.task_id = td.task_id_depends '
. 'WHERE dct.task_id IS NULL '
. 'GROUP BY td.task_id'
. ') AS bd ON bd.task_id = t.task_id '
. 'WHERE ct.task_id IS NULL AND bd.bad_deps <> 0 '
. 'ORDER BY t.task_priority DESC , bd.bad_deps DESC , t.task_added DESC' )->execute( );
}
public function getTasksAt( Data_Item $item ) public function getTasksAt( Data_Item $item )
{ {
@ -54,14 +96,27 @@ class DAO_Tasks
'SELECT t.task_id AS id, t.task_title AS title, ' 'SELECT t.task_id AS id, t.task_title AS title, '
. 't.task_description AS description, t.task_added AS added_at, ' . 't.task_description AS description, t.task_added AS added_at, '
. 'u1.user_email AS added_by, ct.completed_task_time AS completed_at, ' . 'u1.user_email AS added_by, ct.completed_task_time AS completed_at, '
. 'u2.user_email AS completed_by , t.task_priority AS priority ' . 'u2.user_email AS completed_by , t.task_priority AS priority , '
. 'bd.bad_deps AS missing_dependencies '
. 'FROM tasks t ' . 'FROM tasks t '
. 'INNER JOIN users u1 ON u1.user_id = t.user_id ' . 'INNER JOIN users u1 ON u1.user_id = t.user_id '
. 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id ' . 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id '
. 'LEFT OUTER JOIN users u2 ON u2.user_id = ct.user_id ' . 'LEFT OUTER JOIN users u2 ON u2.user_id = ct.user_id '
. 'LEFT OUTER JOIN ('
. 'SELECT td.task_id , COUNT(*) AS bad_deps '
. 'FROM task_dependencies td '
. 'LEFT OUTER JOIN completed_tasks dct '
. 'ON dct.task_id = td.task_id_depends '
. 'WHERE dct.task_id IS NULL '
. 'GROUP BY td.task_id'
. ') AS bd ON bd.task_id = t.task_id '
. 'WHERE t.item_id = $1' . 'WHERE t.item_id = $1'
. 'ORDER BY ( CASE WHEN ct.task_id IS NULL THEN t.task_priority ELSE -1 END ) DESC , ' . 'ORDER BY ( CASE '
. 't.task_added DESC' )->execute( $item->id ); . 'WHEN ct.task_id IS NULL THEN '
. 't.task_priority '
. 'ELSE '
. '-1 '
. 'END ) DESC , bd.bad_deps ASC NULLS FIRST , t.task_added DESC' )->execute( $item->id );
} }

View file

@ -15,6 +15,11 @@ class Ctrl_AllTasks
if ( $mode == 'active' ) { if ( $mode == 'active' ) {
$tasks = Loader::DAO( 'tasks' )->getAllActiveTasks( ); $tasks = Loader::DAO( 'tasks' )->getAllActiveTasks( );
$title = 'Active tasks'; $title = 'Active tasks';
$bTitle = 'Display active tasks';
$bMode = 'blocked';
} elseif ( $mode == 'blocked' ) {
$tasks = Loader::DAO( 'tasks' )->getAllBlockedTasks( );
$title = 'Blocked tasks';
$bTitle = 'Display all tasks'; $bTitle = 'Display all tasks';
$bMode = 'all'; $bMode = 'all';
} else { } else {

View file

@ -80,8 +80,19 @@ class View_AllTasks
$addedAtTime = date( 'H:i:s' , $addedAt ); $addedAtTime = date( 'H:i:s' , $addedAt );
array_push( $cell , array_push( $cell ,
HTML::make( 'dd' )->appendText( "Added $addedAtDate at $addedAtTime by {$task->added_by}" ) ); HTML::make( 'dd' )->appendText( "Added $addedAtDate at $addedAtTime by {$task->added_by}" ) );
if ( $task->missing_dependencies !== null ) {
if ( $task->missing_dependencies > 1 ) {
$end = 'ies';
} else {
$end = 'y';
}
array_push( $cell ,
HTML::make( 'dd' )->appendText( "{$task->missing_dependencies} missing dependenc$end" ) );
if ( $task->completed_by !== null ) { foreach ( $cell as $entry ) {
$entry->setAttribute( 'class' , 'missing-deps' );
}
} elseif ( $task->completed_by !== null ) {
$completedAt = strtotime( $task->completed_at ); $completedAt = strtotime( $task->completed_at );
$completedAtDate = date( 'd/m/o' , $completedAt ); $completedAtDate = date( 'd/m/o' , $completedAt );
$completedAtTime = date( 'H:i:s' , $completedAt ); $completedAtTime = date( 'H:i:s' , $completedAt );
@ -142,7 +153,19 @@ class View_Tasks
array_push( $cell , array_push( $cell ,
HTML::make( 'dd' )->appendText( "Added $addedAtDate at $addedAtTime by {$task->added_by}" ) ); HTML::make( 'dd' )->appendText( "Added $addedAtDate at $addedAtTime by {$task->added_by}" ) );
if ( $task->completed_by !== null ) { if ( $task->missing_dependencies !== null ) {
if ( $task->missing_dependencies > 1 ) {
$end = 'ies';
} else {
$end = 'y';
}
array_push( $cell ,
HTML::make( 'dd' )->appendText( "{$task->missing_dependencies} missing dependenc$end" ) );
foreach ( $cell as $entry ) {
$entry->setAttribute( 'class' , 'missing-deps' );
}
} elseif ( $task->completed_by !== null ) {
$completedAt = strtotime( $task->completed_at ); $completedAt = strtotime( $task->completed_at );
$completedAtDate = date( 'd/m/o' , $completedAt ); $completedAtDate = date( 'd/m/o' , $completedAt );
$completedAtTime = date( 'H:i:s' , $completedAt ); $completedAtTime = date( 'H:i:s' , $completedAt );

View file

@ -389,6 +389,10 @@ dl.tasks .completed, dl.tasks .completed * {
color: #3f3f3f color: #3f3f3f
} }
dl.tasks .missing-deps, dl.tasks .missing-deps * {
color: #7f3f3f
}
dl.tasks dt.sub-title.completed { dl.tasks dt.sub-title.completed {
color: #bfbfbf; color: #bfbfbf;
text-shadow: 1px 1px 2px #3f3f3f; text-shadow: 1px 1px 2px #3f3f3f;