Moving tasks - buttons and empty form
This commit is contained in:
parent
ff4a209d99
commit
fd39819304
5 changed files with 76 additions and 4 deletions
|
@ -277,9 +277,15 @@ 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_list' , $tasks , array(
|
$box = Loader::View( 'box' , 'Tasks' ,
|
||||||
'deps' , 'assigned' , 'completed' ) ) )
|
Loader::View( 'tasks_list' , $tasks ,
|
||||||
->addButton( BoxButton::create( 'Add task' , 'tasks/add?to=' . $this->item->id )
|
array( 'deps' , 'assigned' , 'completed' ) ) );
|
||||||
|
if ( !empty( $tasks ) ) {
|
||||||
|
$box->addButton( BoxButton::create( 'Move tasks' , 'tasks/move?type=i&id=' . $this->item->id )
|
||||||
|
->setClass( 'icon move' ) );
|
||||||
|
}
|
||||||
|
$box->addButton( BoxButton::create( 'Add task' , 'tasks/add?to=' . $this->item->id )
|
||||||
->setClass( 'list-add' ) );
|
->setClass( 'list-add' ) );
|
||||||
|
return $box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,10 @@ class Ctrl_TaskListSubtasks
|
||||||
Loader::View( 'tasks_list' , $this->task->subtasks , array( 'deps' , 'assigned' , 'completed' ) ) );
|
Loader::View( 'tasks_list' , $this->task->subtasks , array( 'deps' , 'assigned' , 'completed' ) ) );
|
||||||
|
|
||||||
if ( $this->task->completed_by === null ) {
|
if ( $this->task->completed_by === null ) {
|
||||||
|
if ( !empty( $this->task->subtasks ) ) {
|
||||||
|
$box->addButton( BoxButton::create( 'Move sub-tasks' , 'tasks/move?type=s&id=' . $this->task->id )
|
||||||
|
->setClass( 'icon move' ) );
|
||||||
|
}
|
||||||
$box->addButton( BoxButton::create( 'Add sub-task' , 'tasks/add?parent=' . $this->task->id )
|
$box->addButton( BoxButton::create( 'Add sub-task' , 'tasks/add?parent=' . $this->task->id )
|
||||||
->setClass( 'list-add' ) );
|
->setClass( 'list-add' ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ $package[ 'ctrls' ][] = 'task_details';
|
||||||
$package[ 'ctrls' ][] = 'task_list_subtasks';
|
$package[ 'ctrls' ][] = 'task_list_subtasks';
|
||||||
$package[ 'ctrls' ][] = 'task_move_down';
|
$package[ 'ctrls' ][] = 'task_move_down';
|
||||||
$package[ 'ctrls' ][] = 'task_move_up';
|
$package[ 'ctrls' ][] = 'task_move_up';
|
||||||
|
$package[ 'ctrls' ][] = 'task_move';
|
||||||
$package[ 'ctrls' ][] = 'task_notes';
|
$package[ 'ctrls' ][] = 'task_notes';
|
||||||
$package[ 'ctrls' ][] = 'toggle_task';
|
$package[ 'ctrls' ][] = 'toggle_task';
|
||||||
$package[ 'ctrls' ][] = 'view_task';
|
$package[ 'ctrls' ][] = 'view_task';
|
||||||
|
|
|
@ -786,3 +786,63 @@ class Ctrl_TaskMoveUp
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Ctrl_TaskMove
|
||||||
|
extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct( )
|
||||||
|
{
|
||||||
|
$this->dTasks = Loader::DAO( 'tasks' );
|
||||||
|
$this->dItems = Loader::DAO( 'items' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle( Page $page )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$id = (int) $this->getParameter( 'id' );
|
||||||
|
$type = $this->getParameter( 'type' );
|
||||||
|
} catch ( ParameterException $e ) {
|
||||||
|
return 'tasks';
|
||||||
|
}
|
||||||
|
|
||||||
|
$subtasks = ( $type === 's' );
|
||||||
|
$failure = $subtasks ? 'tasks' : 'items';
|
||||||
|
|
||||||
|
// Get the parent
|
||||||
|
if ( $subtasks ) {
|
||||||
|
$parent = $this->dTasks->get( $id );
|
||||||
|
} else {
|
||||||
|
$parent = $this->dItems->get( $id );
|
||||||
|
}
|
||||||
|
if ( $parent === null ) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent's empty, go back to displaying it
|
||||||
|
$failure .= '/view?id=' . $id;
|
||||||
|
if ( $subtasks ) {
|
||||||
|
$tasks = $parent->subtasks;
|
||||||
|
$name = $parent->title;
|
||||||
|
} else {
|
||||||
|
$tasks = $this->dTasks->getTasksAt( $parent );
|
||||||
|
$name = $parent->name;
|
||||||
|
}
|
||||||
|
if ( empty( $tasks ) ) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate form
|
||||||
|
$page->setTitle( $name . ': move tasks' );
|
||||||
|
$form = Loader::Create( 'Form' , 'Move tasks' , 'move-tasks' )
|
||||||
|
->addField( Loader::Create( 'Field' , 'type' , 'hidden' )
|
||||||
|
->setDefaultValue( $subtasks ? 's' : 'i' ) )
|
||||||
|
->addField( Loader::Create( 'Field' , 'id' , 'hidden' )
|
||||||
|
->setDefaultValue( $id ) ) ;
|
||||||
|
// $this->addDependencySelector( $form , $task->possibleDependencies , $task->parent_task === null );
|
||||||
|
return $form->setURL( $failure )
|
||||||
|
// ->addController( Loader::Ctrl( 'dependency_add' ) )
|
||||||
|
->controller( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Page_TasksTasks
|
||||||
'view' => 'view_task' ,
|
'view' => 'view_task' ,
|
||||||
'deps/add' => 'dependency_add_form' ,
|
'deps/add' => 'dependency_add_form' ,
|
||||||
'deps/delete' => 'dependency_delete_form' ,
|
'deps/delete' => 'dependency_delete_form' ,
|
||||||
|
'move' => 'task_move' ,
|
||||||
'move/down' => 'task_move_down' ,
|
'move/down' => 'task_move_down' ,
|
||||||
'move/up' => 'task_move_up' ,
|
'move/up' => 'task_move_up' ,
|
||||||
'notes/edit' => 'edit_note_form' ,
|
'notes/edit' => 'edit_note_form' ,
|
||||||
|
|
Loading…
Reference in a new issue