Task assignment
Tasks can be assigned to users. An user may decide to "claim" a task directly, which will assign the task to him. Otherwise, it is possible to set some arbitrary user as the assignee or remove the assignee completely through the edition form. Marking a task as completed will remove the assignee, while re-activating a task will assign it to the user who re-activated it. Also, fixed a bug which allowed a completed task to be edited.
This commit is contained in:
parent
850d2fa8d4
commit
56741bccaa
12 changed files with 180 additions and 80 deletions
includes/t-tasks
|
@ -51,20 +51,6 @@ abstract class View_TasksBase
|
|||
return $result;
|
||||
}
|
||||
|
||||
protected abstract function generateItem( $task );
|
||||
}
|
||||
|
||||
|
||||
class View_AllTasks
|
||||
extends View_TasksBase
|
||||
{
|
||||
|
||||
public function __construct( $tasks )
|
||||
{
|
||||
parent::__construct( );
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
protected function generateItem( $task )
|
||||
{
|
||||
$cell = array( );
|
||||
|
@ -72,8 +58,7 @@ class View_AllTasks
|
|||
->appendElement( HTML::make( 'a' )
|
||||
->setAttribute( 'href' , $this->base . '/tasks/view?id=' . $task->id )
|
||||
->appendText( $task->title ) ) );
|
||||
|
||||
array_push( $cell , HTML::make( 'dd' )->append( $this->formatPlaceLineage( $task->item ) ) );
|
||||
$cell = array_merge( $cell , $this->generateSpecificLines( $task ) );
|
||||
|
||||
$addedAt = strtotime( $task->added_at );
|
||||
$addedAtDate = date( 'd/m/o' , $addedAt );
|
||||
|
@ -95,6 +80,11 @@ class View_AllTasks
|
|||
foreach ( $cell as $entry ) {
|
||||
$entry->setAttribute( 'class' , 'missing-deps' );
|
||||
}
|
||||
} 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 );
|
||||
|
@ -110,6 +100,25 @@ class View_AllTasks
|
|||
return $cell;
|
||||
}
|
||||
|
||||
protected abstract function generateSpecificLines( $task );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
|
@ -142,47 +151,9 @@ class View_Tasks
|
|||
}
|
||||
|
||||
|
||||
protected function generateItem( $task )
|
||||
protected function generateSpecificLines( $task )
|
||||
{
|
||||
$cell = array( );
|
||||
array_push( $cell , HTML::make( 'dt' )
|
||||
->appendElement( HTML::make( 'a' )
|
||||
->setAttribute( 'href' , $this->base . '/tasks/view?id=' . $task->id )
|
||||
->appendText( $task->title ) ) );
|
||||
|
||||
$addedAt = strtotime( $task->added_at );
|
||||
$addedAtDate = date( 'd/m/o' , $addedAt );
|
||||
$addedAtTime = date( 'H:i:s' , $addedAt );
|
||||
array_push( $cell ,
|
||||
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 ,
|
||||
$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)" );
|
||||
}
|
||||
|
||||
foreach ( $cell as $entry ) {
|
||||
$entry->setAttribute( 'class' , 'missing-deps' );
|
||||
}
|
||||
} 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 array( );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -225,6 +196,17 @@ class View_TaskDetails
|
|||
->appendElement( HTML::make( 'dd' )
|
||||
->appendText( Loader::DAO( 'tasks' )
|
||||
->translatePriority( $this->task->priority ) ) );
|
||||
|
||||
if ( $this->task->assigned_to === null ) {
|
||||
$list->appendElement( HTML::make( 'dt' )
|
||||
->setAttribute( 'class' , 'unassigned-task' )
|
||||
->appendText( 'Unassigned!' ) );
|
||||
} else {
|
||||
$list->appendElement( HTML::make( 'dt' )
|
||||
->appendText( 'Assigned to:' ) )
|
||||
->appendElement( HTML::make( 'dd' )
|
||||
->appendText( $this->task->assigned_to ) );
|
||||
}
|
||||
} else {
|
||||
$list->appendElement( HTML::make( 'dt' )
|
||||
->appendText( 'Completed:' ) )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue