feat: persist and sort by viewed by admins status of teamers
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240623151419 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE teamer ADD viewed TINYINT(1) NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postUp(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->connection->executeQuery('UPDATE teamer SET viewed = 1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE teamer DROP viewed');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,20 +25,17 @@ class IndexController extends AbstractController
|
|||||||
public function index(Request $request): Response
|
public function index(Request $request): Response
|
||||||
{
|
{
|
||||||
$filterDto = $this->filterHandler->getFilterSettings();
|
$filterDto = $this->filterHandler->getFilterSettings();
|
||||||
|
$requestedSorting = $request->query->get('sort');
|
||||||
|
|
||||||
$query = $this
|
$query = $this
|
||||||
->teamerRepository
|
->teamerRepository
|
||||||
->getListQuery($filterDto)
|
->getListQuery($filterDto, $requestedSorting)
|
||||||
;
|
;
|
||||||
|
|
||||||
$pagination = $this->paginator->paginate(
|
$pagination = $this->paginator->paginate(
|
||||||
$query,
|
$query,
|
||||||
$request->query->getInt('page', 1),
|
$request->query->getInt('page', 1),
|
||||||
10,
|
10
|
||||||
[
|
|
||||||
'defaultSortFieldName' => 'teamer.lastName',
|
|
||||||
'defaultSortDirection' => 'asc',
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->render('administrative/teamer/index.html.twig', [
|
return $this->render('administrative/teamer/index.html.twig', [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Controller\Administrative\Teamer;
|
|||||||
|
|
||||||
use App\Controller\Traits\ReturnUrlTrait;
|
use App\Controller\Traits\ReturnUrlTrait;
|
||||||
use App\Entity\Teamer;
|
use App\Entity\Teamer;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@@ -14,10 +15,19 @@ class ProfileController extends AbstractController
|
|||||||
{
|
{
|
||||||
use ReturnUrlTrait;
|
use ReturnUrlTrait;
|
||||||
|
|
||||||
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[Route('/administrative/teamer/profile/{uuid}', name: 'app_administrative_teamer_profile')]
|
#[Route('/administrative/teamer/profile/{uuid}', name: 'app_administrative_teamer_profile')]
|
||||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
public function index(Teamer $teamer, Request $request): Response
|
public function index(Teamer $teamer, Request $request): Response
|
||||||
{
|
{
|
||||||
|
if (false === $teamer->isViewed()) {
|
||||||
|
$teamer->setViewed(true);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_teamer_index');
|
$returnUrl = $this->getReturnUrl($request, 'app_administrative_teamer_index');
|
||||||
|
|
||||||
return $this->render('administrative/teamer/profile.html.twig', [
|
return $this->render('administrative/teamer/profile.html.twig', [
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ class Teamer implements TimestampableEntityInterface
|
|||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?array $crmSelections = null;
|
private ?array $crmSelections = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private bool $viewed = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->uuid = Uuid::v4();
|
$this->uuid = Uuid::v4();
|
||||||
@@ -767,4 +770,16 @@ class Teamer implements TimestampableEntityInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isViewed(): bool
|
||||||
|
{
|
||||||
|
return $this->viewed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setViewed(bool $viewed): static
|
||||||
|
{
|
||||||
|
$this->viewed = $viewed;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class TeamerRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Teamer::class);
|
parent::__construct($registry, Teamer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListQuery(TeamerFilterDto $filterDto): Query
|
public function getListQuery(TeamerFilterDto $filterDto, ?string $requestedSorting = null): Query
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('teamer');
|
$qb = $this->createQueryBuilder('teamer');
|
||||||
|
|
||||||
@@ -40,6 +40,13 @@ class TeamerRepository extends ServiceEntityRepository
|
|||||||
->leftJoin('teamer.user', 'user')
|
->leftJoin('teamer.user', 'user')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (null === $requestedSorting) {
|
||||||
|
$qb
|
||||||
|
->orderBy('teamer.viewed', 'asc')
|
||||||
|
->addOrderBy('teamer.lastName', 'asc')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $filterDto->getName()) {
|
if (null !== $filterDto->getName()) {
|
||||||
$qb
|
$qb
|
||||||
->andWhere($qb->expr()->orX(
|
->andWhere($qb->expr()->orX(
|
||||||
|
|||||||
Reference in New Issue
Block a user