Adding multiple dependencies
Added a selector that allows multiple dependencies to be added without going back to the task's page.
This commit is contained in:
parent
fa45d59ea8
commit
d6f170db68
2 changed files with 39 additions and 4 deletions
|
@ -488,6 +488,12 @@ class Ctrl_DependencyAdd
|
|||
implements FormAware
|
||||
{
|
||||
private $form;
|
||||
private $more;
|
||||
|
||||
public function __construct( $more = false )
|
||||
{
|
||||
$this->more = $more;
|
||||
}
|
||||
|
||||
public function setForm( Form $form )
|
||||
{
|
||||
|
@ -496,6 +502,10 @@ class Ctrl_DependencyAdd
|
|||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
if ( $this->more ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = (int) $this->form->field( 'to' )->value( );
|
||||
$dependency = $this->form->field( 'dependency' );
|
||||
$error = Loader::DAO( 'tasks' )->addDependency( $id , $dependency->value( ) );
|
||||
|
@ -503,7 +513,7 @@ class Ctrl_DependencyAdd
|
|||
switch ( $error ) {
|
||||
|
||||
case 0:
|
||||
return true;
|
||||
return $this->checkForMore( );
|
||||
|
||||
case 1:
|
||||
$dependency->putError( 'The task you selected has been deleted.' );
|
||||
|
@ -524,6 +534,16 @@ class Ctrl_DependencyAdd
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private function checkForMore( )
|
||||
{
|
||||
$field = $this->form->field( 'moar' );
|
||||
if ( $field === null || !$field->value( ) ) {
|
||||
return true;
|
||||
}
|
||||
return Loader::Ctrl( 'dependency_add_form' , true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -629,8 +649,14 @@ class Ctrl_DependencyAddFiltering
|
|||
$select->addOption( $task->id , $task->title );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
if ( count( $this->task->possibleDependencies ) > 1 ) {
|
||||
$this->selector->addField( Loader::Create( 'Field' , 'moar' , 'select' )
|
||||
->setDescription( 'Add more dependencies:' )
|
||||
->setMandatory( false )
|
||||
->addOption( '0' , 'No' )
|
||||
->addOption( '1' , 'Yes' ) );
|
||||
}
|
||||
}
|
||||
|
||||
private function getItemsToDisplay( $depsByItem )
|
||||
|
|
|
@ -433,6 +433,12 @@ class Ctrl_EditNoteForm
|
|||
class Ctrl_DependencyAddForm
|
||||
extends Controller
|
||||
{
|
||||
private $more;
|
||||
|
||||
public function __construct( $more = false )
|
||||
{
|
||||
$this->more = $more;
|
||||
}
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
|
@ -458,10 +464,13 @@ class Ctrl_DependencyAddForm
|
|||
->addField( Loader::Create( 'Field' , 'to' , 'hidden' )
|
||||
->setDefaultValue( $id ) )
|
||||
->setURL( 'tasks/view?id=' . $id )
|
||||
->addController( Loader::Ctrl( 'dependency_add' ) );
|
||||
->addController( Loader::Ctrl( 'dependency_add' , $this->more ) );
|
||||
|
||||
// Handle filtering and re-displaying
|
||||
$filters = $this->handleFiltering( $page , $form , $task );
|
||||
|
||||
if ( $this->more ) {
|
||||
return $form->controller( );
|
||||
}
|
||||
return array( $form->controller( ) , $filters );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue