diff --git a/assets/controllers/user_controller.js b/assets/controllers/user_controller.js
index f87daae..fa69658 100644
--- a/assets/controllers/user_controller.js
+++ b/assets/controllers/user_controller.js
@@ -21,13 +21,13 @@ export default class extends Controller {
connect() {
this.roleSelect();
- if(this.listValue){
+ if (this.listValue) {
this.table();
}
- if(this.newValue){
+ if (this.newValue) {
this.tableSmall();
}
- if(this.adminValue){
+ if (this.adminValue) {
this.tableSmallAdmin();
}
if (this.listOrganizationValue) {
@@ -143,25 +143,74 @@ export default class extends Controller {
{
title: "Actions",
field: "showUrl",
- hozAlign: "center",
- width: 100,
+ width: 130,
vertAlign: "middle",
headerSort: false,
formatter: (cell) => {
const url = cell.getValue();
- if (url) {
- return `
-
+
+ if (!url) return '';
+
+ // You can get other row data like ID for delete endpoint if needed
+ const rowData = cell.getRow().getData();
+ const deleteId = rowData.id;
+
+ return `
+
+ `;
+ },
+ cellClick: function (e, cell) {
+ const target = e.target.closest('a');
+ if (target && target.classList.contains('delete-user')) {
+ e.preventDefault();
+ const userId = target.getAttribute('data-id');
+
+ if (confirm('Voulez-vous vraiment supprimer cet utilisateur ?')) {
+ // Example delete call (replace URL as needed)
+ fetch(`/user/delete/${userId}`, {
+ method: 'POST',
+ })
+ .then(response => {
+ if (response.ok) {
+ alert('Utilisateur supprimé');
+ cell.getRow().delete(); // Remove row from table
+ } else {
+ alert('Erreur lors de la suppression');
+ }
+ })
+ .catch(() => alert('Erreur lors de la suppression'));
+ }
}
- return '';
}
}];
const tabulator = new Tabulator("#tabulator-userList", {
@@ -329,7 +378,7 @@ export default class extends Controller {
pagination: false,
paginationMode: "remote",
// paginationSize: 5,
- ajaxParams: { orgId: this.orgIdValue },
+ ajaxParams: {orgId: this.orgIdValue},
langs: {
fr: {
ajax: {
@@ -379,6 +428,7 @@ export default class extends Controller {
columns
});
}
+
tableSmallAdmin() {
const columns = [
{
@@ -469,8 +519,6 @@ export default class extends Controller {
];
-
-
const tabulator = new Tabulator("#tabulator-userListSmallAdmin", {
locale: "fr", //'en' for English, 'fr' for French (en is default, no need to include it)
@@ -480,7 +528,7 @@ export default class extends Controller {
pagination: false,
paginationMode: "remote",
// paginationSize: 5,
- ajaxParams: { orgId: this.orgIdValue },
+ ajaxParams: {orgId: this.orgIdValue},
langs: {
fr: {
ajax: {
@@ -622,25 +670,73 @@ export default class extends Controller {
{
title: "Actions",
field: "showUrl",
- hozAlign: "center",
- width: 100,
+ width: 130,
vertAlign: "middle",
headerSort: false,
formatter: (cell) => {
const url = cell.getValue();
- if (url) {
- return `
-
+
+ if (!url) return '';
+
+ // You can get other row data like ID for delete endpoint if needed
+ const rowData = cell.getRow().getData();
+ const deleteId = rowData.id;
+
+ return `
+
+ `;
+ },
+ cellClick: function (e, cell) {
+ const target = e.target.closest('a');
+ if (target && target.classList.contains('delete-user')) {
+ e.preventDefault();
+ const userId = target.getAttribute('data-id');
+
+ if (confirm('Voulez-vous vraiment supprimer cet utilisateur ?')) {
+ fetch(`/user/organization/deactivate/${userId}`, {
+ method: 'POST',
+ })
+ .then(response => {
+ if (response.ok) {
+ alert('Utilisateur supprimé');
+ cell.getRow().delete(); // Remove row from table
+ } else {
+ alert('Erreur lors de la suppression');
+ }
+ })
+ .catch(() => alert('Erreur lors de la suppression'));
+ }
}
- return '';
}
}];
// if (this.statutValue) {
@@ -725,15 +821,15 @@ export default class extends Controller {
locale: "fr",
ajaxURL: "/user/data/organization",
ajaxConfig: "GET",
- ajaxParams: { orgId: this.orgIdValue },
+ ajaxParams: {orgId: this.orgIdValue},
pagination: true,
paginationMode: "remote",
paginationSize: 10,
ajaxResponse: (url, params, response) => response,
- paginationDataSent: { page: "page", size: "size" },
- paginationDataReceived: { last_page: "last_page" },
+ paginationDataSent: {page: "page", size: "size"},
+ paginationDataReceived: {last_page: "last_page"},
ajaxSorting: true,
ajaxFiltering: true,
diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php
index 28bdd08..b32c0d2 100644
--- a/src/Controller/UserController.php
+++ b/src/Controller/UserController.php
@@ -312,7 +312,7 @@ class UserController extends AbstractController
throw $this->createAccessDeniedException(self::ACCESS_DENIED);
}
- #[Route('/delete/{id}', name: 'delete', methods: ['GET'])]
+ #[Route('/delete/{id}', name: 'delete', methods: ['GET', 'POST'])]
public function delete(int $id, Request $request): Response
{
$this->denyAccessUnlessGranted("ROLE_SUPER_ADMIN");
@@ -401,6 +401,7 @@ class UserController extends AbstractController
// Map to array (keep isConnected)
$data = array_map(function (User $user) {
return [
+ 'id' => $user->getId(),
'pictureUrl' => $user->getPictureUrl(),
'name' => $user->getSurname(),
'prenom' => $user->getName(),