mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-10-04 17:04:54 +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...');
|
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('ok', rep);
|
||||||
|
console.log('rep.data', rep.data)
|
||||||
customCategories = [];
|
customCategories = [];
|
||||||
for (let c of rep.data.categories) {
|
for (let c of rep.data.categories) {
|
||||||
c.hidden = false;
|
c.hidden = false;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
@import 'pages/nav';
|
@import 'pages/nav';
|
||||||
@import 'pages/demo';
|
@import 'pages/demo';
|
||||||
@import 'pages/home';
|
@import 'pages/home';
|
||||||
|
@import 'pages/forms';
|
||||||
@import 'pages/history';
|
@import 'pages/history';
|
||||||
@import 'pages/dashboard';
|
@import 'pages/dashboard';
|
||||||
@import 'pages/special';
|
@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;
|
font-size: 1rem;
|
||||||
line-height: 2rem;
|
line-height: 2rem;
|
||||||
}
|
}
|
||||||
|
.main-container-box{
|
||||||
.masthead-avatar {
|
padding-left: 5rem;
|
||||||
width: 2rem;
|
|
||||||
max-height: 2rem;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#wrapper {
|
#wrapper {
|
||||||
|
|
|
@ -29,6 +29,17 @@ final class GroupOfProductsController extends AbstractController
|
||||||
$form = $this->createForm(GroupOfProducts1Type::class, $groupOfProduct);
|
$form = $this->createForm(GroupOfProducts1Type::class, $groupOfProduct);
|
||||||
$form->handleRequest($request);
|
$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()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$entityManager->persist($groupOfProduct);
|
$entityManager->persist($groupOfProduct);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
|
@ -29,6 +29,13 @@ final class ProductController extends AbstractController
|
||||||
$form = $this->createForm(Product1Type::class, $product);
|
$form = $this->createForm(Product1Type::class, $product);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
$userFound = $this->getUser();
|
||||||
|
if($userFound){
|
||||||
|
$product->setUser($userFound);
|
||||||
|
$userFound->addProduct($product);
|
||||||
|
$entityManager->persist($userFound);
|
||||||
|
}
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$entityManager->persist($product);
|
$entityManager->persist($product);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
@ -56,6 +63,12 @@ final class ProductController extends AbstractController
|
||||||
$form = $this->createForm(Product1Type::class, $product);
|
$form = $this->createForm(Product1Type::class, $product);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
$userFound = $this->getUser();
|
||||||
|
if($userFound){
|
||||||
|
$product->setUser($userFound);
|
||||||
|
$userFound->addProduct($product);
|
||||||
|
$entityManager->persist($userFound);
|
||||||
|
}
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ class GroupOfProducts
|
||||||
private Collection $products;
|
private Collection $products;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, Selling>
|
* @var Collection<int, Selling>|null
|
||||||
*/
|
*/
|
||||||
#[ORM\ManyToMany(targetEntity: Selling::class, inversedBy: 'groupOfProducts')]
|
#[ORM\ManyToMany(targetEntity: Selling::class, inversedBy: 'groupOfProducts')]
|
||||||
private Collection $sellings;
|
private ?Collection $sellings = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'groupOfProducts')]
|
#[ORM\ManyToOne(inversedBy: 'groupOfProducts')]
|
||||||
private ?User $user = null;
|
private ?User $user = null;
|
||||||
|
|
|
@ -19,17 +19,19 @@ class GroupOfProducts1Type extends AbstractType
|
||||||
->add('name')
|
->add('name')
|
||||||
->add('products', EntityType::class, [
|
->add('products', EntityType::class, [
|
||||||
'class' => Product::class,
|
'class' => Product::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'name',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('sellings', EntityType::class, [
|
->add('sellings', EntityType::class, [
|
||||||
'class' => Selling::class,
|
'class' => Selling::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'id',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('user', EntityType::class, [
|
->add('user', EntityType::class, [
|
||||||
'class' => User::class,
|
'class' => User::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'name',
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,19 @@ class Product1Type extends AbstractType
|
||||||
->add('comment')
|
->add('comment')
|
||||||
->add('groupOfProducts', EntityType::class, [
|
->add('groupOfProducts', EntityType::class, [
|
||||||
'class' => GroupOfProducts::class,
|
'class' => GroupOfProducts::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'name',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('sellings', EntityType::class, [
|
->add('sellings', EntityType::class, [
|
||||||
'class' => Selling::class,
|
'class' => Selling::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'date',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('user', EntityType::class, [
|
->add('user', EntityType::class, [
|
||||||
'class' => User::class,
|
'class' => User::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'name',
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ProductType extends AbstractType
|
||||||
->add('stock')
|
->add('stock')
|
||||||
->add('groupOfProducts', EntityType::class, [
|
->add('groupOfProducts', EntityType::class, [
|
||||||
'class' => GroupOfProducts::class,
|
'class' => GroupOfProducts::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'name',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
|
|
|
@ -54,13 +54,12 @@ logged
|
||||||
{% include 'logged/nav.html.twig' %}
|
{% include 'logged/nav.html.twig' %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<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">
|
||||||
<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 %}
|
||||||
{% block body %}
|
{% endblock %}
|
||||||
{% endblock %}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% include 'default/footer.html.twig' %}
|
{% include 'default/footer.html.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue