From 6729035f1501e3102a3dcdfc8ae2119b4fbdd580 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 13 Dec 2019 16:52:12 +0100 Subject: [PATCH] =?UTF-8?q?alert=20profil=C3=A9e=20par=20niveau01=20(fixes?= =?UTF-8?q?=20#62)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cadoles/CoreBundle/Entity/Niveau01.php | 38 ++++++++++++++++ .../CoreBundle/Resources/public/css/style.css | 6 +-- .../public/themes/transnum/style.css | 7 --- .../Controller/AlertController.php | 5 ++- .../Controller/PagewidgetController.php | 23 ++++++++++ .../src/Cadoles/PortalBundle/Entity/Alert.php | 44 +++++++++++++++++++ .../Cadoles/PortalBundle/Form/AlertType.php | 19 ++++++++ .../Resources/views/Alert/edit.html.twig | 1 + 8 files changed, 131 insertions(+), 12 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php index d4dfeca3..d822d2c7 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php @@ -91,6 +91,10 @@ class Niveau01 */ protected $items; + /** + * @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Alert", mappedBy="niveau01s") + */ + protected $alerts; /** * Constructor @@ -427,4 +431,38 @@ class Niveau01 { return $this->items; } + + /** + * Add alert + * + * @param \Cadoles\PortalBundle\Entity\Alert $alert + * + * @return Niveau01 + */ + public function addAlert(\Cadoles\PortalBundle\Entity\Alert $alert) + { + $this->alerts[] = $alert; + + return $this; + } + + /** + * Remove alert + * + * @param \Cadoles\PortalBundle\Entity\Alert $alert + */ + public function removeAlert(\Cadoles\PortalBundle\Entity\Alert $alert) + { + $this->alerts->removeElement($alert); + } + + /** + * Get alerts + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getAlerts() + { + return $this->alerts; + } } 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 f02d6c5f..025a599e 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 @@ -274,7 +274,7 @@ span.item-drag { .grid-item .item-link img { display: block; max-width: 100%; - max-height: 110px; + //max-height: 110px; height: auto; } @@ -500,7 +500,7 @@ a.item-heart { word-wrap: break-word; width: 100%; display: block; - line-height: initial; + line-height: 14px; padding: 0px; } @@ -513,9 +513,9 @@ a.item-heart { .grid .grid-preview .grid-item-title small { margin-bottom: 10px; + font-size:9px; } - @media (max-width: 991px) { .grid .grid-preview { width:32.666666667%; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/style.css b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/style.css index b3a9bf7e..47bfc2fb 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/style.css +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/style.css @@ -64,14 +64,7 @@ body.simple { min-width: 138px; } -.grid .grid-preview .grid-item-title { - font-size:14px; - line-height: 8px; -} -.grid .grid-preview .grid-item-title small { - font-size:9px; -} .widget-bordered .grid-preview img { border-radius: 0px; diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php index 875cfddf..74c2800f 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php @@ -69,7 +69,7 @@ class AlertController extends Controller $data = new Alert(); // Création du formulaire - $form = $this->createForm(AlertType::class,$data,array("mode"=>"submit")); + $form = $this->createForm(AlertType::class,$data,array("mode"=>"submit","labelniveau01" => $this->GetParameter("labelsniveau01"))); // Récupération des data du formulaire $form->handleRequest($request); @@ -111,7 +111,8 @@ class AlertController extends Controller // Création du formulaire $form = $this->createForm(AlertType::class,$data,array( - "mode" => "update" + "mode" => "update", + "labelniveau01" => $this->GetParameter("labelsniveau01") )); // Récupération des data du formulaire diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php index 0a850723..187e21f7 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -737,6 +737,7 @@ class PagewidgetController extends Controller // Profilage $user=$this->getUser(); $roles=($user?$user->getRoles():["ROLE_ANONYME"]); + $niveau01=($user?$user->getNiveau01():null); $groups=($user?$user->getGroups():[]); // Initialisation du calcul des alerts @@ -765,6 +766,28 @@ class PagewidgetController extends Controller } } + // Récupération par Niveau01 + $qb = $em->createQueryBuilder(); + $qb->select('alert') + ->from("CadolesPortalBundle:Alert", 'alert') + ->where(":niveau01 MEMBER OF alert.niveau01s") + ->andWhere('alert.publishedat <= :today') + ->andWhere($qb->expr()->orX( + $qb->expr()->gt('alert.unpublishedat', ':today'), + $qb->expr()->isNull('alert.unpublishedat') + )) + ->setParameter("niveau01",$niveau01) + ->setParameter('today', date('Y-m-d')); + + if($idalertcategory && $alertcategoryfilter) { + $qb->andWhere("alert.alertcategory=:alertcategory") + ->setParameter("alertcategory",$alertcategoryfilter); + } + $alertsniveau01s=$qb->getQuery()->getResult(); + foreach($alertsniveau01s as $alertsniveau01) { + if(!$alerts->contains($alertsniveau01s)) $alerts->add($alertsniveau01); + } + // Récupération des alerts par group foreach($groups as $group) { $qb = $em->createQueryBuilder(); diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php index f8cf6ecb..fef762ef 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php @@ -82,6 +82,16 @@ class Alert */ protected $groups; + /** + * @ORM\ManyToMany(targetEntity="Cadoles\CoreBundle\Entity\Niveau01", inversedBy="alerts", cascade={"persist"}) + * @ORM\JoinTable(name="alertniveau01", + * joinColumns={@ORM\JoinColumn(name="alert", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="niveau01", referencedColumnName="id")} + * ) + */ + protected $niveau01s; + + // Is Online public function isOnline() { @@ -346,4 +356,38 @@ class Alert { return $this->groups; } + + /** + * Add niveau01 + * + * @param \Cadoles\CoreBundle\Entity\Niveau01 $niveau01 + * + * @return Alert + */ + public function addNiveau01(\Cadoles\CoreBundle\Entity\Niveau01 $niveau01) + { + $this->niveau01s[] = $niveau01; + + return $this; + } + + /** + * Remove niveau01 + * + * @param \Cadoles\CoreBundle\Entity\Niveau01 $niveau01 + */ + public function removeNiveau01(\Cadoles\CoreBundle\Entity\Niveau01 $niveau01) + { + $this->niveau01s->removeElement($niveau01); + } + + /** + * Get niveau01s + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getNiveau01s() + { + return $this->niveau01s; + } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php index 3499e4c1..30fb1c57 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php @@ -57,6 +57,24 @@ class AlertType extends AbstractType "disabled" => ($options["mode"]=="delete"?true:false), ]) + ->add('niveau01s', Select2EntityType::class, [ + 'label' => 'Visible pour les '.$options["labelniveau01"], + 'class' => 'CadolesCoreBundle:Niveau01', + 'text_property' => 'label', + 'multiple' => true, + 'remote_route' => 'cadoles_core_ajax_niveau01_list', + 'primary_key' => 'id', + 'text_property' => 'label', + 'minimum_input_length' => 0, + 'page_limit' => 100, + 'allow_clear' => true, + 'delay' => 250, + 'cache' => false, + 'cache_timeout' => 60000, + 'language' => 'fr', + 'placeholder' => 'Selectionner des '.$options["labelniveau01"], + ]) + ->add('groups', Select2EntityType::class, [ 'label' => 'Visible pour les Groupes', 'class' => 'CadolesCoreBundle:Group', @@ -106,6 +124,7 @@ class AlertType extends AbstractType $resolver->setDefaults([ 'data_class' => 'Cadoles\PortalBundle\Entity\Alert', 'mode' => "string", + 'labelniveau01' => "string", ]); } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig index 28b40742..676478c3 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig @@ -60,6 +60,7 @@
{{ form_row(form.roles) }} + {{ form_row(form.niveau01s) }} {{ form_row(form.groups) }}