This commit is contained in:
afornerot 2019-07-05 09:19:49 +02:00
parent 0bfa961d84
commit 8721f7cf98
6 changed files with 93 additions and 31 deletions

View File

@ -107,6 +107,8 @@ body {
.navbar-default .navbar-right { .navbar-default .navbar-right {
float:right; float:right;
top: 0px;
right:50px;
} }
.navbarheader { display: none } .navbarheader { display: none }

View File

@ -57,7 +57,7 @@
<img id="logo" src="/{{ alias }}/{{ app.session.get('sublogo') }}" style="height:{{ heightheader-40 }}px;"> <img id="logo" src="/{{ alias }}/{{ app.session.get('sublogo') }}" style="height:{{ heightheader-40 }}px;">
{% endif %} {% endif %}
<span style="height:{{ heightheader }}px; line-height:{{ heightheader }}px;"> <span style="height:{{ heightheader }}px; line-height:{{ heightheader }}px;">
{{ app.session.get('appname') }} <div>{{ app.session.get('appname') }}</div>
{% if not app.session.get('subappname') is empty %} {% if not app.session.get('subappname') is empty %}
<small>{{ app.session.get('subappname') }}</small> <small>{{ app.session.get('subappname') }}</small>
{% endif %} {% endif %}

View File

@ -424,7 +424,13 @@ class PageController extends Controller
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->labelentity)->find($id); $entity = $em->getRepository($this->labelentity)->find($id);
if (!$entity) throw $this->createNotFoundException('Unable to find entity.'); if (!$entity) {
return $this->render('CadolesCoreBundle:Core:reconnect.html.twig', [
'useheader' => false,
'usemenu' => false,
'usesidebar' => false,
]);
}
// Permissions // Permissions
if($access=="config") { if($access=="config") {

View File

@ -117,34 +117,6 @@ class PagetemplateController extends Controller
return new Response(json_encode($output), 200); return new Response(json_encode($output), 200);
} }
public function ajaxseleclistAction(Request $request)
{
// S'assurer que c'est un appel ajax
if (!$request->isXmlHttpRequest()) {
return new JsonResponse(array('message' => 'Interdit'), 400);
}
$output=array();
$em = $this->getDoctrine()->getManager();
$page_limit=$request->query->get('page_limit');
$q=$request->query->get('q');
$qb = $em->createQueryBuilder();
$qb->select('table')->from("CadolesPortalBundle:Page",'table')
->where('table.name LIKE :value')
->setParameter("value", "%".$q."%")
->orderBy('table.name');
$datas=$qb->setFirstResult(0)->setMaxResults($page_limit)->getQuery()->getResult();
foreach($datas as $data) {
array_push($output,array("id"=>$data->getId(),"text"=>$data->getName()));
}
$response = new Response(json_encode($output));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
private function entityForm(Page $entity,$access="config") private function entityForm(Page $entity,$access="config")
{ {
$route=str_replace("_config_","_".$access."_",$this->routeprimary); $route=str_replace("_config_","_".$access."_",$this->routeprimary);
@ -263,7 +235,36 @@ class PagetemplateController extends Controller
} }
public function ajaxseleclistAction(Request $request)
{
// S'assurer que c'est un appel ajax
if (!$request->isXmlHttpRequest()) {
return new JsonResponse(array('message' => 'Interdit'), 400);
}
$output=array();
$em = $this->getDoctrine()->getManager();
$page_limit=$request->query->get('page_limit');
$q=$request->query->get('q');
$usage=$request->query->get('usage');
$qb = $em->createQueryBuilder();
$qb->select('table')->from("CadolesPortalBundle:Page",'table')
->where('table.name LIKE :value')
->andWhere('table.parentfor=:usage')
->setParameter("value", "%".$q."%")
->setParameter("usage", $usage)
->orderBy('table.name');
$datas=$qb->setFirstResult(0)->setMaxResults($page_limit)->getQuery()->getResult();
foreach($datas as $data) {
array_push($output,array("id"=>$data->getId(),"text"=>$data->getName()));
}
$response = new Response(json_encode($output));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
public function viewAction($id,$access=null) { public function viewAction($id,$access=null) {

View File

@ -7,13 +7,20 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\EntityRepository;
class PageSubmitType extends AbstractType class PageSubmitType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$access=$options["access"];
$builder $builder
->add('submit', SubmitType::class, [ ->add('submit', SubmitType::class, [
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"), "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
@ -28,9 +35,50 @@ class PageSubmitType extends AbstractType
'label' => 'Catégorie de Page', 'label' => 'Catégorie de Page',
'class' => 'CadolesPortalBundle:Pagecategory', 'class' => 'CadolesPortalBundle:Pagecategory',
'choice_label' => 'name', 'choice_label' => 'name',
'placeholder' => '-- Sélectionnez une catégorie --' 'placeholder' => '-- Sélectionnez une catégorie --',
'query_builder' => function(EntityRepository $er) use ($access) {
if($access=="config")
return $er->createQueryBuilder('pc')
->select('pc');
else
return $er->createQueryBuilder('pc')
->select('pc')
->where('pc.id>0');
},
]) ])
->add('usage', ChoiceType::class, [
"label" => 'Usage',
"mapped" => false,
"choices" => ["Personnel" => 'user',"Groupe de Travail" => 'group'],
"disabled" => ($options["mode"]=="delete"?true:false),
])
->add('page',
Select2EntityType::class, array(
'label' => "Modèle de Page",
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => false,
'multiple' => false,
'remote_route' => 'cadoles_portal_user_pagetemplate_ajax_selectlist',
'class' => 'Cadoles\PortalBundle\Entity\PageTemplate',
'req_params' => ['usage' => 'parent.children[usage]'],
'primary_key' => 'id',
'text_property' => 'name',
'minimum_input_length' => 0,
'page_limit' => 10,
'allow_clear' => true,
'delay' => 250,
'cache' => false,
'cache_timeout' => 60000, // if 'cache' is true
'language' => 'fr',
'placeholder' => 'Selectionner un modèle de page',
'attr' => array("class" => "form-control", "style" => "margin-bottom:15px")
)
)
->add('roworder', IntegerType::class, [ ->add('roworder', IntegerType::class, [
'label' => 'Ordre', 'label' => 'Ordre',
]) ])

View File

@ -247,6 +247,11 @@ cadoles_portal_config_pagetemplate_view:
path: /config/template/view/{id} path: /config/template/view/{id}
defaults: { _controller: CadolesPortalBundle:Pagetemplate:view, access: config } defaults: { _controller: CadolesPortalBundle:Pagetemplate:view, access: config }
cadoles_portal_user_pagetemplate_ajax_selectlist:
path: /user/template/selectlist
defaults: { _controller: CadolesPortalBundle:Pagetemplate:ajaxseleclist, access: user }
#== PAGE ================================================================================================================================================= #== PAGE =================================================================================================================================================
#-- Access config #-- Access config