diff --git a/.idea/php.xml b/.idea/php.xml
index ca3edb57..9f4bf038 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -190,9 +190,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js
index 4ee5a59c..4be5d133 100755
--- a/assets/js/parts/main.js
+++ b/assets/js/parts/main.js
@@ -209,12 +209,11 @@ angular
console.log('fetch products...');
$http.get('logged/get-my-products').then((rep) => {
- // console.log('ok', rep);
console.log('rep.data', rep.data)
- customCategories = [];
+ let customCategories = [];
for (let c of rep.data.categories) {
c.hidden = false;
- customCategories.push(c);
+ customCategories = Object.create(rep.data.categories);
}
console.log('customCategories', customCategories);
$scope.categories = customCategories;
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 2394d207..b367189e 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -25,12 +25,13 @@ security:
logout:
path: app_logout
# where to redirect after logout
- # target: app_any_route
+ target: dashboard
# Contrôle d'accès
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/logged, roles: ROLE_USER }
+ - { path: ^/dashboard, roles: ROLE_USER }
- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
- { path: ^/authentication_token, roles: PUBLIC_ACCESS }
# - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès à la page de connexion
diff --git a/src/Entity/GroupOfProducts.php b/src/Entity/GroupOfProducts.php
index 428561c0..d0113c99 100644
--- a/src/Entity/GroupOfProducts.php
+++ b/src/Entity/GroupOfProducts.php
@@ -61,10 +61,21 @@ class GroupOfProducts
return $this;
}
- public function getProducts(): ?object
+ /**
+ * @return array
+ */
+ public function getProductsDTO(): array
{
- return $this->products;
+ $productsDTO = [];
+ foreach ($this->products as $product) {
+ $productsDTO[] = $product->toArray();
+ }
+ return $productsDTO;
}
+ public function getProducts(): ?object
+ {
+ return $this->products;
+ }
public function setProducts(object $products): static
{
diff --git a/src/Entity/Product.php b/src/Entity/Product.php
index 038ccb91..78691b9e 100644
--- a/src/Entity/Product.php
+++ b/src/Entity/Product.php
@@ -11,6 +11,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Filter\UserProductsFilter;
use App\DTO\UserDTO;
+use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(paginationEnabled: false)]
#[UserProductsFilter]
@@ -23,9 +24,11 @@ class Product
private ?int $id = null;
#[ORM\Column(length: 255)]
+ #[Groups(['default', 'relation'])]
private ?string $name = null;
#[ORM\Column]
+ #[Groups(['default', 'relation'])]
private ?float $price = null;
#[ORM\Column]
@@ -190,4 +193,14 @@ class Product
return $this;
}
+
+ public function toArray(): array
+ {
+ return [
+ 'id' => $this->id,
+ 'name' => $this->name,
+ 'price' => $this->price,
+ // Ajoutez d'autres propriétés si nécessaire
+ ];
+ }
}
diff --git a/templates/logged/angular/listing-products.html.twig b/templates/logged/angular/listing-products.html.twig
index 712f6efc..6edb5e6f 100755
--- a/templates/logged/angular/listing-products.html.twig
+++ b/templates/logged/angular/listing-products.html.twig
@@ -5,12 +5,11 @@
ng-if="! c.hidden">
- {{ c.name }}
+ {{ c.name }} ({{c.productsDTO.length}}
-