added statut to user organization link
This commit is contained in:
parent
2d84ee8ec4
commit
75e5921be1
|
|
@ -628,9 +628,12 @@ export default class extends Controller {
|
|||
title: "<b>Statut</b>", field: "statut", vertAlign: "middle",
|
||||
formatter: (cell) => {
|
||||
const statut = cell.getValue();
|
||||
if (statut) {
|
||||
console.log("Statut value:", statut);
|
||||
if (statut === "INVITED") {
|
||||
return `<span class="badge bg-primary">Invité</span>`
|
||||
} else if (statut === "ACTIVE") {
|
||||
return `<span class="badge bg-success">Actif</span>`
|
||||
} else {
|
||||
}else{
|
||||
return `<span class="badge bg-secondary">Inactif</span>`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?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 Version20251028154635 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 users_organizations ADD statut VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE users_organizations DROP statut');
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ class UserController extends AbstractController
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
//TODO : REMOVE DEAD CODE due to the use of tabulator in the frontend
|
||||
#[Route('/view/{id}', name: 'show', methods: ['GET'])]
|
||||
public function view(int $id, Request $request): Response
|
||||
{
|
||||
|
|
@ -145,9 +145,7 @@ class UserController extends AbstractController
|
|||
if ($picture) {
|
||||
$this->userService->handleProfilePicture($user, $picture);
|
||||
}
|
||||
// else {
|
||||
// $user->setPictureUrl("");
|
||||
// }
|
||||
|
||||
//FOR TEST PURPOSES, SETTING A DEFAULT RANDOM PASSWORD
|
||||
$user->setPassword($this->userService->generateRandomPassword());
|
||||
if ($orgId) {
|
||||
|
|
@ -156,8 +154,11 @@ class UserController extends AbstractController
|
|||
$uo = new UsersOrganizations();
|
||||
$uo->setUsers($user);
|
||||
$uo->setOrganization($org);
|
||||
$uo->setStatut("INVITED");
|
||||
$uo->setIsActive(false);
|
||||
$this->entityManager->persist($uo);
|
||||
$this->actionService->createAction("Create new user", $user, $org, "Added user to organization" . $user->getUserIdentifier() . " for organization " . $org->getName());
|
||||
return $this->redirectToRoute('organization_show', ['id' => $orgId]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +428,7 @@ class UserController extends AbstractController
|
|||
$actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||
if ($this->userService->hasAccessTo($actingUser, true) && $this->isGranted("ROLE_ADMIN")) {
|
||||
$totalUsers = $this->userRepository->count(['isDeleted' => false, 'isActive' => true]);
|
||||
return $this->render('user/indexTest.html.twig', [
|
||||
return $this->render('user/index.html.twig', [
|
||||
'users' => $totalUsers
|
||||
]);
|
||||
}
|
||||
|
|
@ -444,7 +445,8 @@ class UserController extends AbstractController
|
|||
$actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||
if ($this->userService->hasAccessTo($actingUser, true) && $this->isGranted("ROLE_ADMIN")) {
|
||||
$orgId = $request->query->get('orgId');
|
||||
$uos = $this->uoRepository->findBy(['organization' => $orgId, 'isActive' =>true], limit: 5, orderBy: ['createdAt' => 'DESC']);
|
||||
$uos = $this->uoRepository->findBy(['organization' => $orgId, 'statut' => ["ACCEPTED", "INVITED"]],
|
||||
orderBy: ['createdAt' => 'DESC'], limit: 5);
|
||||
|
||||
|
||||
// Map to array (keep isConnected)
|
||||
|
|
@ -543,22 +545,7 @@ class UserController extends AbstractController
|
|||
$rows = $qb->setFirstResult($offset)->setMaxResults($size)->getQuery()->getResult();
|
||||
|
||||
// Map to array
|
||||
$data = array_map(function (UsersOrganizations $uo) {
|
||||
$user = $uo->getUsers();
|
||||
return [
|
||||
'pictureUrl' => $user->getPictureUrl(),
|
||||
'name' => $user->getSurname(),
|
||||
'prenom' => $user->getName(),
|
||||
'email' => $user->getEmail(),
|
||||
'isConnected' => $this->userService->isUserConnected($user->getUserIdentifier()),
|
||||
'statut' => $uo->isActive(),
|
||||
'showUrl' => $this->generateUrl('user_show', [
|
||||
'id' => $user->getId(),
|
||||
'organizationId' => $uo->getOrganization()->getId(),
|
||||
]),
|
||||
'id' => $user->getId(),
|
||||
];
|
||||
}, $rows);
|
||||
$data = $this->userService->formatStatutForOrganizations($rows);
|
||||
|
||||
// Return Tabulator-compatible response
|
||||
$lastPage = (int)ceil($total / $size);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ class UsersOrganizations
|
|||
#[ORM\OneToMany(targetEntity: UserOrganizatonApp::class, mappedBy: 'userOrganization')]
|
||||
private Collection $userOrganizatonApps;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $statut = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isActive = true; // Default value for isActive
|
||||
|
|
@ -117,4 +120,16 @@ class UsersOrganizations
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatut(): ?string
|
||||
{
|
||||
return $this->statut;
|
||||
}
|
||||
|
||||
public function setStatut(?string $statut): static
|
||||
{
|
||||
$this->statut = $statut;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,4 +379,27 @@ class UserService
|
|||
$token->revoke();
|
||||
}
|
||||
}
|
||||
|
||||
public function formatStatutForOrganizations(array $rows): array
|
||||
{
|
||||
$formatted = array_map(function (UsersOrganizations $uo) {
|
||||
$user = $uo->getUsers();
|
||||
if ($uo->getStatut() == "INVITED") {
|
||||
$statut = "INVITED";
|
||||
} else {
|
||||
$statut = $uo->isActive() ? "ACTIVE" : "INACTIVE";
|
||||
}
|
||||
return [
|
||||
'pictureUrl' => $user->getPictureUrl(),
|
||||
'name' => $user->getSurname(),
|
||||
'prenom' => $user->getName(),
|
||||
'email' => $user->getEmail(),
|
||||
'isConnected' => $this->isUserConnected($user->getUserIdentifier()),
|
||||
'statut' => $statut,
|
||||
'showUrl' => '/user/view/' . $user->getId() . '?organizationId=' . $uo->getOrganization()->getId(),
|
||||
'id' => $user->getId(),
|
||||
];
|
||||
}, $rows);
|
||||
return $formatted;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue