Guillaume преди 3 години
родител
ревизия
167e7f98a7
променени са 4 файла, в които са добавени 57 реда и са изтрити 24 реда
  1. +9
    -9
      Repository/Reminder/ReminderRepository.php
  2. +10
    -0
      Resources/assets/app/adminlte/reminder/reminder.scss
  3. +31
    -0
      Resources/views/adminlte/layout.html.twig
  4. +7
    -15
      Twig/TwigExtension.php

+ 9
- 9
Repository/Reminder/ReminderRepository.php Целия файл

@@ -20,7 +20,7 @@ class ReminderRepository extends AbstractRepository

public function findByUser($user)
{
$qb = $this->findByMerchantQuery()
$qb = $this->createQueryBuilder('e')
->leftJoin('e.users', 'u')
->having('COUNT(u.id) = 0')
->orHaving(':user MEMBER OF e.users')
@@ -32,21 +32,21 @@ class ReminderRepository extends AbstractRepository
return $qb->getQuery()->getResult();
}

public function findByEasyAdminConfigAndUser($action, $entity, $user, $id = null)
public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
{
$qb = $this->findByMerchantQuery();
$qb = $this->createQueryBuilder('e');
$qb->leftJoin('e.users', 'u');
$qb->having('COUNT(u.id) = 0');
$qb->orHaving(':user MEMBER OF e.users');
$qb->andWhere('e.done = 0');
$qb->andWhere('e.entityAction LIKE :action');
$qb->andWhere('e.entityName LIKE :entity');
$qb->setParameter('entity', $entity);
$qb->setParameter('action', $action);
$qb->andWhere('e.crudAction LIKE :crudAction');
$qb->andWhere('e.crudControllerFqcn LIKE :entity');
$qb->setParameter('crudAction', $crudAction);
$qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
$qb->setParameter('user', $user);
if ($id) {
if ($entityId) {
$qb->andWhere('e.entityId LIKE :id');
$qb->setParameter('id', $id);
$qb->setParameter('entityId', $entityId);
}
$qb->orderBy('e.dateReminder', 'ASC');
$qb->groupBy('e.id');

+ 10
- 0
Resources/assets/app/adminlte/reminder/reminder.scss Целия файл

@@ -0,0 +1,10 @@

div#reminders {
ul.todo-list {
li {
div.text {
padding-left: 30px ;
}
}
}
}

+ 31
- 0
Resources/views/adminlte/layout.html.twig Целия файл

@@ -104,6 +104,37 @@
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">

{% set reminders = sov_get_reminders() %}
{% if reminders %}
<div class="col-sm-12">
<div id="reminders" class="card card-outline card-danger">
<ul class="todo-list">
{% for reminder in reminders %}
<li>
<label class="big form-check-label">
<input type="checkbox" name="" value="1" class="form-check-input checkbox-valid-reminder" data-url="/admin/?action=setReminderDone&amp;entity=Reminder&amp;id=90">
<span class="checkmark"></span>
</label>
<div class="text">
{{ reminder.description }}
</div>
<div class="tools">
<button type="button" class="btn-sm btn-success" data-toggle="modal" data-target="#modal-reminder-91">
<i class="fas fa-eye"></i>
</button>
<button type="button" class="btn-sm btn-info btn-edit-reminder" data-url="/admin/?action=edit&amp;entity=Reminder&amp;id=91">
<i class="fas fa-edit"></i>
</button>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}


{% set has_help_message = (ea.crud.helpMessage ?? '') is not empty %}
{% block content_header %}
<div class="col-sm-6">

+ 7
- 15
Twig/TwigExtension.php Целия файл

@@ -2,13 +2,12 @@

namespace Lc\SovBundle\Twig;

use App\Repository\ReminderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Factory\Reminder\ReminderFactory;
use Lc\SovBundle\Form\Reminder\ReminderAdminFormType;
use Lc\SovBundle\Model\Reminder\ReminderInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -27,8 +26,6 @@ class TwigExtension extends AbstractExtension
protected $router;
protected $translator;
protected $translatorAdmin;
protected $formFactory;
protected $reminderFactory;

public function __construct(
KernelInterface $kernel,
@@ -38,9 +35,7 @@ class TwigExtension extends AbstractExtension
RequestStack $requestStack,
UrlGeneratorInterface $router,
TranslatorInterface $translator,
TranslatorAdmin $translatorAdmin,
FormFactoryInterface $formFactory,
ReminderFactory $reminderFactory
TranslatorAdmin $translatorAdmin
) {
$this->kernel = $kernel;
$this->parameterBag = $parameterBag;
@@ -50,8 +45,6 @@ class TwigExtension extends AbstractExtension
$this->router = $router;
$this->translator = $translator;
$this->translatorAdmin = $translatorAdmin;
$this->formFactory = $formFactory;
$this->reminderFactory = $reminderFactory;
}

public function getFunctions()
@@ -61,7 +54,7 @@ class TwigExtension extends AbstractExtension
new TwigFunction('homepage_route', [$this, 'homepageRoute']),
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']),
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']),
new TwigFunction('sov_get_form_reminder', [$this, 'getFormReminder']),
new TwigFunction('sov_get_reminders', [$this, 'getReminders']),
);
}

@@ -167,11 +160,10 @@ class TwigExtension extends AbstractExtension
return $this->parameterBag->get('lc_sov.homepage_route');
}

public function getFormReminder()
public function getReminders()
{
$reminder = $this->reminderFactory->create();
$formReminder = $this->formFactory->create(ReminderAdminFormType::class, $reminder);
return $formReminder->createView();
$reminders = $this->em->getRepository(ReminderInterface::class)->findAll() ;
return $reminders;
}

}

Loading…
Отказ
Запис