Cleanup and improvement of tasks lists
Removed duplicate code in task lists views (now using a single class with constructor parameters). Added specific display for assigned tasks that have missing dependencies.
This commit is contained in:
parent
dae65c0b4b
commit
634ed8f5ee
5 changed files with 67 additions and 64 deletions
|
@ -277,7 +277,8 @@ class Ctrl_ItemTasks
|
||||||
{
|
{
|
||||||
$tasks = Loader::DAO( 'tasks' )->getTasksAt( $this->item );
|
$tasks = Loader::DAO( 'tasks' )->getTasksAt( $this->item );
|
||||||
|
|
||||||
return Loader::View( 'box' , 'Tasks' , Loader::View( 'tasks' , $tasks ) )
|
return Loader::View( 'box' , 'Tasks' , Loader::View( 'tasks_list' , $tasks , array(
|
||||||
|
'deps' , 'assigned' , 'completed' ) ) )
|
||||||
->addButton( BoxButton::create( 'Add task' , 'tasks/add?to=' . $this->item->id )
|
->addButton( BoxButton::create( 'Add task' , 'tasks/add?to=' . $this->item->id )
|
||||||
->setClass( 'list-add' ) );
|
->setClass( 'list-add' ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,9 @@ $package[ 'ctrls' ][] = 'task_notes';
|
||||||
$package[ 'ctrls' ][] = 'toggle_task';
|
$package[ 'ctrls' ][] = 'toggle_task';
|
||||||
$package[ 'ctrls' ][] = 'view_task';
|
$package[ 'ctrls' ][] = 'view_task';
|
||||||
|
|
||||||
$package[ 'views' ][] = 'all_tasks';
|
$package[ 'views' ][] = 'tasks_list';
|
||||||
$package[ 'views' ][] = 'tasks';
|
$package[ 'views' ][] = 'task_dependencies';
|
||||||
$package[ 'views' ][] = 'task_details';
|
$package[ 'views' ][] = 'task_details';
|
||||||
$package[ 'views' ][] = 'task_note';
|
$package[ 'views' ][] = 'task_note';
|
||||||
$package[ 'views' ][] = 'task_dependencies';
|
|
||||||
|
|
||||||
$package[ 'pages' ][] = 'tasks_tasks';
|
$package[ 'pages' ][] = 'tasks_tasks';
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Ctrl_AllTasks
|
||||||
}
|
}
|
||||||
|
|
||||||
$tree = Loader::DAO( 'items' )->getTree( );
|
$tree = Loader::DAO( 'items' )->getTree( );
|
||||||
$box = Loader::View( 'box' , $title , Loader::View( 'all_tasks' , $tasks , $mode ) )
|
$box = Loader::View( 'box' , $title , Loader::View( 'tasks_list' , $tasks ) )
|
||||||
->addButton( BoxButton::create( $bTitle , 'tasks?mode=' . $bMode )
|
->addButton( BoxButton::create( $bTitle , 'tasks?mode=' . $bMode )
|
||||||
->setClass( 'icon refresh' ) );
|
->setClass( 'icon refresh' ) );
|
||||||
if ( !empty( $tree ) ) {
|
if ( !empty( $tree ) ) {
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class View_TasksBase
|
class View_TasksList
|
||||||
extends BaseURLAwareView
|
extends BaseURLAwareView
|
||||||
{
|
{
|
||||||
protected $tasks;
|
protected $tasks;
|
||||||
protected $dao;
|
protected $dao;
|
||||||
|
|
||||||
|
|
||||||
protected function __construct( )
|
public function __construct( $tasks , $features = array( 'item' , 'assigned' , 'deps' , 'completed' ) )
|
||||||
{
|
{
|
||||||
|
$this->tasks = $tasks;
|
||||||
|
$this->features = array_combine( $features , array_fill( 0 , count( $features ) , 1 ) );
|
||||||
$this->dao = Loader::DAO( 'tasks' );
|
$this->dao = Loader::DAO( 'tasks' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,70 +60,42 @@ abstract class View_TasksBase
|
||||||
->appendElement( HTML::make( 'a' )
|
->appendElement( HTML::make( 'a' )
|
||||||
->setAttribute( 'href' , $this->base . '/tasks/view?id=' . $task->id )
|
->setAttribute( 'href' , $this->base . '/tasks/view?id=' . $task->id )
|
||||||
->appendText( $task->title ) ) );
|
->appendText( $task->title ) ) );
|
||||||
$cell = array_merge( $cell , $this->generateSpecificLines( $task ) );
|
$this->addItem( $cell , $task );
|
||||||
|
$classes = array( );
|
||||||
|
|
||||||
$addedAt = strtotime( $task->added_at );
|
$addedAt = strtotime( $task->added_at );
|
||||||
$addedAtDate = date( 'd/m/o' , $addedAt );
|
$addedAtDate = date( 'd/m/o' , $addedAt );
|
||||||
$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 ) {
|
if ( $task->completed_by !== null ) {
|
||||||
$end = 'ies';
|
$this->generateCompletedTask( $cell , $classes , $task );
|
||||||
} else {
|
} else {
|
||||||
$end = 'y';
|
if ( $task->missing_dependencies !== null ) {
|
||||||
|
$this->generateMissingDependencies( $cell , $classes , $task );
|
||||||
|
}
|
||||||
|
if ( $task->assigned_to !== null ) {
|
||||||
|
$this->generateAssignedTask( $cell , $classes , $task );
|
||||||
}
|
}
|
||||||
array_push( $cell ,
|
|
||||||
$md = HTML::make( 'dd' )->appendText( "{$task->missing_dependencies} missing dependenc$end" ) );
|
|
||||||
if ( $task->total_missing_dependencies != $task->missing_dependencies ) {
|
|
||||||
$md->appendText( " ({$task->total_missing_dependencies} when counting transitive dependencies)" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $classes ) ) {
|
||||||
foreach ( $cell as $entry ) {
|
foreach ( $cell as $entry ) {
|
||||||
$entry->setAttribute( 'class' , 'missing-deps' );
|
$entry->setAttribute( 'class' , join( ' ' , $classes ) );
|
||||||
}
|
|
||||||
} elseif ( $task->assigned_to !== null ) {
|
|
||||||
array_push( $cell , HTML::make( 'dd' )->appendText( 'Assigned to ' . $task->assigned_to ) );
|
|
||||||
foreach ( $cell as $entry ) {
|
|
||||||
$entry->setAttribute( 'class' , 'assigned' );
|
|
||||||
}
|
|
||||||
} elseif ( $task->completed_by !== null ) {
|
|
||||||
$completedAt = strtotime( $task->completed_at );
|
|
||||||
$completedAtDate = date( 'd/m/o' , $completedAt );
|
|
||||||
$completedAtTime = date( 'H:i:s' , $completedAt );
|
|
||||||
array_push( $cell , HTML::make( 'dd' )->appendText(
|
|
||||||
"Completed $completedAtDate at $completedAtTime by {$task->completed_by}" ) );
|
|
||||||
|
|
||||||
foreach ( $cell as $entry ) {
|
|
||||||
$entry->setAttribute( 'class' , 'completed' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract function generateSpecificLines( $task );
|
protected function addItem( &$cell , $task )
|
||||||
|
{
|
||||||
|
if ( ! array_key_exists( 'item' , $this->features ) ) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item = Loader::DAO( 'items' )->get( $task->item );
|
||||||
class View_AllTasks
|
|
||||||
extends View_TasksBase
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct( $tasks )
|
|
||||||
{
|
|
||||||
parent::__construct( );
|
|
||||||
$this->tasks = $tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateSpecificLines( $task )
|
|
||||||
{
|
|
||||||
return array( HTML::make( 'dd' )->append( $this->formatPlaceLineage( $task->item ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private function formatPlaceLineage( $item )
|
|
||||||
{
|
|
||||||
$item = Loader::DAO( 'items' )->get( $item );
|
|
||||||
$lineage = $item->lineage;
|
$lineage = $item->lineage;
|
||||||
array_push( $lineage , $item->id );
|
array_push( $lineage , $item->id );
|
||||||
|
|
||||||
|
@ -136,26 +110,52 @@ class View_AllTasks
|
||||||
}
|
}
|
||||||
array_unshift( $contents, 'On ' );
|
array_unshift( $contents, 'On ' );
|
||||||
|
|
||||||
return $contents;
|
array_push( $cell , HTML::make( 'dd' )->append( $contents ) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function generateMissingDependencies( &$cell , &$classes , $task )
|
||||||
class View_Tasks
|
|
||||||
extends View_TasksBase
|
|
||||||
{
|
{
|
||||||
public function __construct( $tasks )
|
if ( ! array_key_exists( 'deps' , $this->features ) ) {
|
||||||
{
|
return;
|
||||||
parent::__construct( );
|
|
||||||
$this->tasks = $tasks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $task->missing_dependencies > 1 ) {
|
||||||
protected function generateSpecificLines( $task )
|
$end = 'ies';
|
||||||
{
|
} else {
|
||||||
return array( );
|
$end = 'y';
|
||||||
|
}
|
||||||
|
array_push( $cell ,
|
||||||
|
$md = HTML::make( 'dd' )->appendText( "{$task->missing_dependencies} missing dependenc$end" ) );
|
||||||
|
if ( $task->total_missing_dependencies != $task->missing_dependencies ) {
|
||||||
|
$md->appendText( " ({$task->total_missing_dependencies} when counting transitive dependencies)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
array_push( $classes , 'missing-deps' );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateAssignedTask( &$cell , &$classes , $task )
|
||||||
|
{
|
||||||
|
if ( ! array_key_exists( 'assigned' , $this->features ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push( $cell , HTML::make( 'dd' )->appendText( 'Assigned to ' . $task->assigned_to ) );
|
||||||
|
array_push( $classes , 'assigned' );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateCompletedTask( &$cell , &$classes , $task )
|
||||||
|
{
|
||||||
|
if ( ! array_key_exists( 'completed' , $this->features ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$completedAt = strtotime( $task->completed_at );
|
||||||
|
$completedAtDate = date( 'd/m/o' , $completedAt );
|
||||||
|
$completedAtTime = date( 'H:i:s' , $completedAt );
|
||||||
|
array_push( $cell , HTML::make( 'dd' )->appendText(
|
||||||
|
"Completed $completedAtDate at $completedAtTime by {$task->completed_by}" ) );
|
||||||
|
array_push( $classes , 'completed' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,9 @@ dl.tasks .missing-deps, dl.tasks .missing-deps * {
|
||||||
dl.tasks .assigned, dl.tasks .assigned * {
|
dl.tasks .assigned, dl.tasks .assigned * {
|
||||||
color: #1f7f1f
|
color: #1f7f1f
|
||||||
}
|
}
|
||||||
|
dl.tasks .missing-deps.assigned, dl.tasks .missing-deps.assigned * {
|
||||||
|
color: #7f7f1f
|
||||||
|
}
|
||||||
|
|
||||||
dl.tasks dt.sub-title.completed {
|
dl.tasks dt.sub-title.completed {
|
||||||
color: #bfbfbf;
|
color: #bfbfbf;
|
||||||
|
|
Loading…
Reference in a new issue