mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-06-20 01:44:42 +02:00
style forms, and associate products with user
This commit is contained in:
parent
e5708e9e5f
commit
e7d6b66f70
11 changed files with 90 additions and 21 deletions
|
@ -209,7 +209,8 @@ angular
|
|||
console.log('fetch products...');
|
||||
$http.get('logged/get-my-products').then((rep) => {
|
||||
|
||||
console.log('ok', rep);
|
||||
// console.log('ok', rep);
|
||||
console.log('rep.data', rep.data)
|
||||
customCategories = [];
|
||||
for (let c of rep.data.categories) {
|
||||
c.hidden = false;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
@import 'pages/nav';
|
||||
@import 'pages/demo';
|
||||
@import 'pages/home';
|
||||
@import 'pages/forms';
|
||||
@import 'pages/history';
|
||||
@import 'pages/dashboard';
|
||||
@import 'pages/special';
|
||||
|
|
43
assets/styles/pages/_forms.scss
Normal file
43
assets/styles/pages/_forms.scss
Normal file
|
@ -0,0 +1,43 @@
|
|||
form {
|
||||
label{
|
||||
min-width: 300px;
|
||||
padding-right: 2rem;
|
||||
padding-bottom: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
textarea,
|
||||
select {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
border: solid 1px #ccc;
|
||||
background: #fff;
|
||||
margin-bottom: 0.5rem;
|
||||
width: 100%;
|
||||
min-width: 50vw;
|
||||
}
|
||||
input {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
border: solid 1px #ccc;
|
||||
margin-bottom: 0.5rem;
|
||||
width: 100%;
|
||||
min-width: 30vw;
|
||||
|
||||
[type="text"] {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
[type="textarea"] {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
button.btn, a {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
border: solid 1px #ccc;
|
||||
background: blue;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
}
|
|
@ -8,11 +8,8 @@ body {
|
|||
font-size: 1rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
.masthead-avatar {
|
||||
width: 2rem;
|
||||
max-height: 2rem;
|
||||
display: inline-block;
|
||||
.main-container-box{
|
||||
padding-left: 5rem;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
|
|
|
@ -29,6 +29,17 @@ final class GroupOfProductsController extends AbstractController
|
|||
$form = $this->createForm(GroupOfProducts1Type::class, $groupOfProduct);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$userFound = $this->getUser();
|
||||
if (!$userFound) {
|
||||
return $this->redirectToRoute('app_login');
|
||||
}
|
||||
$userFound = $this->getUser();
|
||||
if($userFound){
|
||||
$groupOfProduct->setUser($userFound);
|
||||
$userFound->addGroupOfProduct($groupOfProduct);
|
||||
$entityManager->persist($userFound);
|
||||
}
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($groupOfProduct);
|
||||
$entityManager->flush();
|
||||
|
|
|
@ -29,6 +29,13 @@ final class ProductController extends AbstractController
|
|||
$form = $this->createForm(Product1Type::class, $product);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$userFound = $this->getUser();
|
||||
if($userFound){
|
||||
$product->setUser($userFound);
|
||||
$userFound->addProduct($product);
|
||||
$entityManager->persist($userFound);
|
||||
}
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($product);
|
||||
$entityManager->flush();
|
||||
|
@ -56,6 +63,12 @@ final class ProductController extends AbstractController
|
|||
$form = $this->createForm(Product1Type::class, $product);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$userFound = $this->getUser();
|
||||
if($userFound){
|
||||
$product->setUser($userFound);
|
||||
$userFound->addProduct($product);
|
||||
$entityManager->persist($userFound);
|
||||
}
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ class GroupOfProducts
|
|||
private Collection $products;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Selling>
|
||||
* @var Collection<int, Selling>|null
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Selling::class, inversedBy: 'groupOfProducts')]
|
||||
private Collection $sellings;
|
||||
private ?Collection $sellings = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'groupOfProducts')]
|
||||
private ?User $user = null;
|
||||
|
|
|
@ -19,17 +19,19 @@ class GroupOfProducts1Type extends AbstractType
|
|||
->add('name')
|
||||
->add('products', EntityType::class, [
|
||||
'class' => Product::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'name',
|
||||
'multiple' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->add('sellings', EntityType::class, [
|
||||
'class' => Selling::class,
|
||||
'choice_label' => 'id',
|
||||
'multiple' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->add('user', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'name',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
|
|
@ -23,17 +23,19 @@ class Product1Type extends AbstractType
|
|||
->add('comment')
|
||||
->add('groupOfProducts', EntityType::class, [
|
||||
'class' => GroupOfProducts::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'name',
|
||||
'multiple' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->add('sellings', EntityType::class, [
|
||||
'class' => Selling::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'date',
|
||||
'multiple' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->add('user', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'name',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ProductType extends AbstractType
|
|||
->add('stock')
|
||||
->add('groupOfProducts', EntityType::class, [
|
||||
'class' => GroupOfProducts::class,
|
||||
'choice_label' => 'id',
|
||||
'choice_label' => 'name',
|
||||
'multiple' => true,
|
||||
'required' => false,
|
||||
])
|
||||
|
|
|
@ -54,13 +54,12 @@ logged
|
|||
{% include 'logged/nav.html.twig' %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col col-xs-12 col-sm-9 col-sm-offset-3 col-md-9 col-md-offset-3 col-lg-offset-3">
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="main-container-box col col-xs-12 col-sm-9 col-sm-offset-3 col-md-9 col-md-offset-3 col-lg-offset-3">
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'default/footer.html.twig' %}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue