optimisation sur selection du projet associé à une tache (ref #138)
This commit is contained in:
parent
eac7f63094
commit
6fb6fe6ab1
|
@ -28,14 +28,16 @@ class ProjecttaskController extends Controller
|
||||||
return $this->createForm(ProjecttaskType::class, $entity, [
|
return $this->createForm(ProjecttaskType::class, $entity, [
|
||||||
"mode" => "update",
|
"mode" => "update",
|
||||||
"access" => $access,
|
"access" => $access,
|
||||||
"user" => $this->getUser()
|
"user" => $this->getUser(),
|
||||||
|
"projecttask" => $entity
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $this->createForm(ProjecttaskType::class, $entity, [
|
return $this->createForm(ProjecttaskType::class, $entity, [
|
||||||
"mode" => "submit",
|
"mode" => "submit",
|
||||||
"access" => $access,
|
"access" => $access,
|
||||||
"user" => $this->getUser()
|
"user" => $this->getUser(),
|
||||||
|
"projecttask" => $entity
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ProjecttaskType extends AbstractType
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$user=$options['user'];
|
$user=$options['user'];
|
||||||
|
$projecttask=$options['projecttask'];
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('submit', SubmitType::class, [
|
->add('submit', SubmitType::class, [
|
||||||
|
@ -80,28 +81,46 @@ class ProjecttaskType extends AbstractType
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$builder
|
if(!$projecttask->getProject()) {
|
||||||
->add('project', EntityType::class, [
|
$builder
|
||||||
'label' => 'Projet associé',
|
->add('project', EntityType::class, [
|
||||||
'class' => 'CadolesPortalBundle:Project',
|
'label' => 'Projet associé',
|
||||||
'choice_label' => 'name',
|
'class' => 'CadolesPortalBundle:Project',
|
||||||
"disabled" => ($options["mode"]=="update"?true:false),
|
'choice_label' => 'name',
|
||||||
'placeholder' => '-- Sélectionnez un Projet --',
|
"disabled" => ($options["mode"]=="update"?true:false),
|
||||||
'query_builder' => function(EntityRepository $er) use ($user) {
|
'placeholder' => '-- Sélectionnez un Projet --',
|
||||||
$qb=$er->createQueryBuilder('project');
|
'query_builder' => function(EntityRepository $er) use ($user) {
|
||||||
return $qb->select('project')
|
$qb=$er->createQueryBuilder('project');
|
||||||
->where('project.user=:user')
|
return $qb->select('project')
|
||||||
->orwhere(':user MEMBER OF project.writers')
|
->where('project.user=:user')
|
||||||
|
->orwhere(':user MEMBER OF project.writers')
|
||||||
|
|
||||||
->from('CadolesCoreBundle:UserGroup','usergroup')
|
->from('CadolesCoreBundle:UserGroup','usergroup')
|
||||||
->orwhere('usergroup.group MEMBER OF project.groups AND usergroup.user=:user')
|
->orwhere('usergroup.group MEMBER OF project.groups AND usergroup.user=:user')
|
||||||
|
|
||||||
->from('CadolesCoreBundle:User','user')
|
->from('CadolesCoreBundle:User','user')
|
||||||
->andwhere("user=:user")
|
->andwhere("user=:user")
|
||||||
|
|
||||||
->setparameter('user',$user);
|
->setparameter('user',$user);
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$builder
|
||||||
|
->add('project', EntityType::class, [
|
||||||
|
'label' => 'Projet associé',
|
||||||
|
'class' => 'CadolesPortalBundle:Project',
|
||||||
|
'choice_label' => 'name',
|
||||||
|
"disabled" => ($options["mode"]=="update"?true:false),
|
||||||
|
'placeholder' => '-- Sélectionnez un Projet --',
|
||||||
|
'query_builder' => function(EntityRepository $er) use ($projecttask) {
|
||||||
|
$qb=$er->createQueryBuilder('project');
|
||||||
|
return $qb->select('project')
|
||||||
|
->where('project.id=:project')
|
||||||
|
->setparameter('project',$projecttask->getProject()->getId());
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('user',
|
$builder->add('user',
|
||||||
|
@ -133,7 +152,8 @@ class ProjecttaskType extends AbstractType
|
||||||
'data_class' => 'Cadoles\PortalBundle\Entity\Projecttask',
|
'data_class' => 'Cadoles\PortalBundle\Entity\Projecttask',
|
||||||
'mode' => 'string',
|
'mode' => 'string',
|
||||||
'access' => 'string',
|
'access' => 'string',
|
||||||
'user' => 'Cadoles\CoreBundle\Entity\User'
|
'user' => 'Cadoles\CoreBundle\Entity\User',
|
||||||
|
'projecttask' => 'Cadoles\PortalBundle\Entity\Projecttask'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue