mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-10-04 17:04:54 +02:00
list products with DTO
This commit is contained in:
parent
cd4b678002
commit
0d672d5447
7 changed files with 57 additions and 11 deletions
26
.idea/php.xml
generated
26
.idea/php.xml
generated
|
@ -190,9 +190,33 @@
|
||||||
<path value="$PROJECT_DIR$/vendor/nelmio/cors-bundle" />
|
<path value="$PROJECT_DIR$/vendor/nelmio/cors-bundle" />
|
||||||
<path value="$PROJECT_DIR$/vendor/laminas/laminas-code" />
|
<path value="$PROJECT_DIR$/vendor/laminas/laminas-code" />
|
||||||
<path value="$PROJECT_DIR$/vendor/friendsofphp/proxy-manager-lts" />
|
<path value="$PROJECT_DIR$/vendor/friendsofphp/proxy-manager-lts" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/psr/clock" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/asset-mapper" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/ux-turbo" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/type-info" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/stimulus-bundle" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/clock" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php83" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/fakerphp/faker" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/masterminds/html5" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/hydra" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/serializer" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/documentation" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/metadata" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/state" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/doctrine-orm" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/openapi" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/validator" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/symfony" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/json-schema" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/http-cache" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/doctrine-common" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/api-platform/jsonld" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfonycasts/verify-email-bundle" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/symfonycasts/reset-password-bundle" />
|
||||||
</include_path>
|
</include_path>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="7" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.4" />
|
||||||
<component name="PhpUnit">
|
<component name="PhpUnit">
|
||||||
<phpunit_settings>
|
<phpunit_settings>
|
||||||
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml.dist" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
|
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml.dist" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
|
||||||
|
|
|
@ -209,12 +209,11 @@ angular
|
||||||
console.log('fetch products...');
|
console.log('fetch products...');
|
||||||
$http.get('logged/get-my-products').then((rep) => {
|
$http.get('logged/get-my-products').then((rep) => {
|
||||||
|
|
||||||
// console.log('ok', rep);
|
|
||||||
console.log('rep.data', rep.data)
|
console.log('rep.data', rep.data)
|
||||||
customCategories = [];
|
let customCategories = [];
|
||||||
for (let c of rep.data.categories) {
|
for (let c of rep.data.categories) {
|
||||||
c.hidden = false;
|
c.hidden = false;
|
||||||
customCategories.push(c);
|
customCategories = Object.create(rep.data.categories);
|
||||||
}
|
}
|
||||||
console.log('customCategories', customCategories);
|
console.log('customCategories', customCategories);
|
||||||
$scope.categories = customCategories;
|
$scope.categories = customCategories;
|
||||||
|
|
|
@ -25,12 +25,13 @@ security:
|
||||||
logout:
|
logout:
|
||||||
path: app_logout
|
path: app_logout
|
||||||
# where to redirect after logout
|
# where to redirect after logout
|
||||||
# target: app_any_route
|
target: dashboard
|
||||||
|
|
||||||
# Contrôle d'accès
|
# Contrôle d'accès
|
||||||
access_control:
|
access_control:
|
||||||
- { path: ^/admin, roles: ROLE_ADMIN }
|
- { path: ^/admin, roles: ROLE_ADMIN }
|
||||||
- { path: ^/logged, roles: ROLE_USER }
|
- { path: ^/logged, roles: ROLE_USER }
|
||||||
|
- { path: ^/dashboard, roles: ROLE_USER }
|
||||||
- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
|
- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
|
||||||
- { path: ^/authentication_token, roles: PUBLIC_ACCESS }
|
- { path: ^/authentication_token, roles: PUBLIC_ACCESS }
|
||||||
# - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès à la page de connexion
|
# - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès à la page de connexion
|
||||||
|
|
|
@ -61,10 +61,21 @@ class GroupOfProducts
|
||||||
return $this;
|
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
|
public function setProducts(object $products): static
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use App\Filter\UserProductsFilter;
|
use App\Filter\UserProductsFilter;
|
||||||
use App\DTO\UserDTO;
|
use App\DTO\UserDTO;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
#[ApiResource(paginationEnabled: false)]
|
#[ApiResource(paginationEnabled: false)]
|
||||||
#[UserProductsFilter]
|
#[UserProductsFilter]
|
||||||
|
@ -23,9 +24,11 @@ class Product
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
|
#[Groups(['default', 'relation'])]
|
||||||
private ?string $name = null;
|
private ?string $name = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
#[Groups(['default', 'relation'])]
|
||||||
private ?float $price = null;
|
private ?float $price = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
@ -190,4 +193,14 @@ class Product
|
||||||
|
|
||||||
return $this;
|
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
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@
|
||||||
ng-if="! c.hidden">
|
ng-if="! c.hidden">
|
||||||
|
|
||||||
<h2 ng-class="{'hidden':c.hidden}" class="title">
|
<h2 ng-class="{'hidden':c.hidden}" class="title">
|
||||||
{{ c.name }}
|
{{ c.name }} ({{c.productsDTO.length}}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="product-listing" >
|
<div class="product-listing" >
|
||||||
<span ng-repeat="p in c.products track by p.id"
|
<span ng-repeat="p in c.productsDTO track by p.id"
|
||||||
class="product-box"
|
class="product-box"
|
||||||
|
|
||||||
>
|
>
|
||||||
<button class="product-button text-left" ng-class="{ 'active' : p.enabled}" ng-click="addProduct( p )">
|
<button class="product-button text-left" ng-class="{ 'active' : p.enabled}" ng-click="addProduct( p )">
|
||||||
<img class="product-image" src="{{p.image}}" alt="image" ng-if="p.image.length">
|
<img class="product-image" src="{{p.image}}" alt="image" ng-if="p.image.length">
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<i class="fa fa-user"></i>
|
<i class="fa fa-user"></i>
|
||||||
|
|
||||||
<label for="sellingComment">
|
<label for="sellingComment">
|
||||||
|
|
||||||
Client actuel: {{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span>
|
Client actuel: {{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span>
|
||||||
</label>
|
</label>
|
||||||
<button type="button" class="deleter pull-right" ng-click="sellingComment = ''">
|
<button type="button" class="deleter pull-right" ng-click="sellingComment = ''">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue