From 8721f7cf98a5594ff288942022998bb8316e18a9 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 5 Jul 2019 09:19:49 +0200 Subject: [PATCH] svg --- .../CoreBundle/Resources/public/css/style.css | 2 + .../CoreBundle/Resources/views/base.html.twig | 2 +- .../Controller/PageController.php | 8 ++- .../Controller/PagetemplateController.php | 57 ++++++++++--------- .../PortalBundle/Form/PageSubmitType.php | 50 +++++++++++++++- .../PortalBundle/Resources/config/routing.yml | 5 ++ 6 files changed, 93 insertions(+), 31 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css index ffa77464..4ac385e3 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css @@ -107,6 +107,8 @@ body { .navbar-default .navbar-right { float:right; + top: 0px; + right:50px; } .navbarheader { display: none } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig index 3b3691b8..f4337ce0 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig @@ -57,7 +57,7 @@ {% endif %} - {{ app.session.get('appname') }} +
{{ app.session.get('appname') }}
{% if not app.session.get('subappname') is empty %} {{ app.session.get('subappname') }} {% endif %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php index 355505f3..6dba0ef5 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php @@ -424,7 +424,13 @@ class PageController extends Controller $em = $this->getDoctrine()->getManager(); $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 if($access=="config") { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagetemplateController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagetemplateController.php index 8105e9a0..04f65663 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagetemplateController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagetemplateController.php @@ -117,34 +117,6 @@ class PagetemplateController extends Controller 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") { $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) { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php index a6030b2a..17dd2fec 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php @@ -7,13 +7,20 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType; + use Symfony\Component\OptionsResolver\OptionsResolver; +use Doctrine\ORM\EntityRepository; + class PageSubmitType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { + $access=$options["access"]; + $builder ->add('submit', SubmitType::class, [ "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"), @@ -28,9 +35,50 @@ class PageSubmitType extends AbstractType 'label' => 'Catégorie de Page', 'class' => 'CadolesPortalBundle:Pagecategory', '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, [ 'label' => 'Ordre', ]) diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml index a379a652..06ce3c66 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml @@ -247,6 +247,11 @@ cadoles_portal_config_pagetemplate_view: path: /config/template/view/{id} 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 ================================================================================================================================================= #-- Access config