Dependency display
Task views now include the list of dependencies and reverse dependencies. In addition, it is impossible to mark a task as completed if it has unsatisfied dependencies, and it is impossible to re-activate a task that has completed reverse dependencies.
This commit is contained in:
parent
9677ad4dd3
commit
fd50fda73a
6 changed files with 121 additions and 11 deletions
includes/t-data
|
@ -98,6 +98,27 @@ class DAO_Tasks
|
|||
. 'INNER JOIN users u USING (user_id) '
|
||||
. 'WHERE n.task_id = $1 '
|
||||
. 'ORDER BY n.note_added DESC' )->execute( $id );
|
||||
$task->dependencies = $this->query(
|
||||
'SELECT t.task_id AS id , t.task_title AS title , t.item_id AS item , '
|
||||
. 'i.item_name AS item_name , '
|
||||
. '( ct.completed_task_time IS NOT NULL ) AS completed '
|
||||
. 'FROM task_dependencies td '
|
||||
. 'INNER JOIN tasks t ON t.task_id = td.task_id_depends '
|
||||
. 'INNER JOIN items i USING ( item_id ) '
|
||||
. 'LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id '
|
||||
. 'WHERE td.task_id = $1 '
|
||||
. 'ORDER BY i.item_name , t.task_priority , t.task_title' )->execute( $id );
|
||||
$task->reverseDependencies = $this->query(
|
||||
'SELECT t.task_id AS id , t.task_title AS title , t.item_id AS item , '
|
||||
. 'i.item_name AS item_name , '
|
||||
. '( ct.completed_task_time IS NOT NULL ) AS completed '
|
||||
. 'FROM task_dependencies td '
|
||||
. 'INNER JOIN tasks t USING( task_id ) '
|
||||
. 'INNER JOIN items i USING ( item_id ) '
|
||||
. 'LEFT OUTER JOIN completed_tasks ct USING ( task_id ) '
|
||||
. 'WHERE td.task_id_depends = $1 '
|
||||
. 'ORDER BY i.item_name , t.task_priority , t.task_title' )->execute( $id );
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
||||
|
@ -113,6 +134,30 @@ class DAO_Tasks
|
|||
}
|
||||
|
||||
|
||||
public function canFinish( $task )
|
||||
{
|
||||
assert( $task->completed_at == null );
|
||||
foreach ( $task->dependencies as $dependency ) {
|
||||
if ( $dependency->completed != 't' ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function canRestart( $task )
|
||||
{
|
||||
assert( $task->completed_at != null );
|
||||
foreach ( $task->reverseDependencies as $dependency ) {
|
||||
if ( $dependency->completed == 't' ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function delete( $task )
|
||||
{
|
||||
$this->query( 'DELETE FROM tasks WHERE task_id = $1' )->execute( $task );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue