mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
stash commit 2
This commit is contained in:
parent
05c5eaa925
commit
a28c996164
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\AsideActivityBundle\Entity;
|
namespace Chill\AsideActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -20,8 +21,20 @@ class AsideActivityCategory
|
|||||||
*/
|
*/
|
||||||
private int $id;
|
private int $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json", length=255)
|
||||||
|
*/
|
||||||
|
private array $title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent")
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private bool $isActive = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
|
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
|
||||||
|
* @ORM\JoinColumn(nullable=true)
|
||||||
*/
|
*/
|
||||||
private $parent;
|
private $parent;
|
||||||
|
|
||||||
@ -30,15 +43,10 @@ class AsideActivityCategory
|
|||||||
*/
|
*/
|
||||||
private $children;
|
private $children;
|
||||||
|
|
||||||
/**
|
public function __construct()
|
||||||
* @ORM\Column(type="json", length=255)
|
{
|
||||||
*/
|
$this->children = new ArrayCollection();
|
||||||
private array $title;
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private bool $isActive = true;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
|
@ -4,19 +4,35 @@ namespace Chill\AsideActivityBundle\Form;
|
|||||||
|
|
||||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
final class AsideActivityCategoryType extends AbstractType
|
final class AsideActivityCategoryType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder->add('title', TranslatableStringFormType::class,
|
$builder->add('title', TranslatableStringFormType::class,
|
||||||
[
|
[
|
||||||
'label' => 'Nom',
|
'label' => 'Nom',
|
||||||
])
|
])
|
||||||
|
->add('parent', EntityType::class, [
|
||||||
|
'class' => AsideActivityCategory::class,
|
||||||
|
'required' => false,
|
||||||
|
'choice_label' => function (AsideActivityCategory $category){
|
||||||
|
return $this->translatableStringHelper->localize($category->getTitle());
|
||||||
|
}
|
||||||
|
])
|
||||||
->add('isActive', ChoiceType::class,
|
->add('isActive', ChoiceType::class,
|
||||||
[
|
[
|
||||||
'choices' => [
|
'choices' => [
|
||||||
|
@ -4,6 +4,7 @@ namespace Chill\AsideActivityBundle\Form;
|
|||||||
|
|
||||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||||
|
use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||||
@ -19,22 +20,25 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
final class AsideActivityFormType extends AbstractType
|
final class AsideActivityFormType extends AbstractType
|
||||||
{
|
{
|
||||||
protected array $timeChoices;
|
protected array $timeChoices;
|
||||||
private TranslatableStringHelper $translatableStringHelper;
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
private TokenStorageInterface $storage;
|
private TokenStorageInterface $storage;
|
||||||
|
private CategoryRender $categoryRender;
|
||||||
|
|
||||||
public function __construct (
|
public function __construct (
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
ParameterBagInterface $parameterBag,
|
ParameterBagInterface $parameterBag,
|
||||||
TokenStorageInterface $storage
|
TokenStorageInterface $storage,
|
||||||
|
CategoryRender $categoryRender
|
||||||
){
|
){
|
||||||
$this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration');
|
$this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration');
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
|
$this->CategoryRender = $categoryRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
@ -78,7 +82,9 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
'class' => AsideActivityCategory::class,
|
'class' => AsideActivityCategory::class,
|
||||||
'placeholder' => 'Choose the activity category',
|
'placeholder' => 'Choose the activity category',
|
||||||
'choice_label' => function (AsideActivityCategory $asideActivityCategory) {
|
'choice_label' => function (AsideActivityCategory $asideActivityCategory) {
|
||||||
return $this->translatableStringHelper->localize($asideActivityCategory->getTitle());
|
$options = [];
|
||||||
|
return $this->categoryRender->renderString($asideActivityCategory, $options);
|
||||||
|
// return $this->translatableStringHelper->localize($asideActivityCategory->getTitle());
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
->add('duration', ChoiceType::class, $durationTimeOptions)
|
->add('duration', ChoiceType::class, $durationTimeOptions)
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
{% set reversed_parents = parents|reverse %}
|
||||||
|
<span class="chill-entity entity-social-issue">
|
||||||
|
<span class="badge bg-chill-l-gray text-dark">
|
||||||
|
{%- for p in reversed_parents %}
|
||||||
|
<span class="parent-{{ loop.revindex0 }}">
|
||||||
|
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}
|
||||||
|
</span>
|
||||||
|
{%- endfor -%}
|
||||||
|
<span class="child">
|
||||||
|
{{ asideActivityCategory.title|localize_translatable_string }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\AsideActivityBundle\Templating\Entity;
|
||||||
|
|
||||||
|
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||||
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
|
final class CategoryRender implements ChillEntityRenderInterface
|
||||||
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
private EngineInterface $engine;
|
||||||
|
|
||||||
|
public const SEPERATOR_KEY = 'default.separator';
|
||||||
|
public const DEFAULT_ARGS = [
|
||||||
|
self::SEPERATOR_KEY => ' > '
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->engine = $engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AsideActivityCategory $asideActivityCategory
|
||||||
|
*/
|
||||||
|
public function renderString($asideActivityCategory, array $options): string
|
||||||
|
{
|
||||||
|
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||||
|
|
||||||
|
$titles[] = $this->translatableStringHelper->localize($asideActivityCategory->getTitle());
|
||||||
|
|
||||||
|
while ($asideActivityCategory->hasParent()) {
|
||||||
|
$asideActivityCategory = $asideActivityCategory->getParent();
|
||||||
|
$titles[] = $this->translatableStringHelper->localize($asideActivityCategory->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
$titles = array_reverse($titles);
|
||||||
|
|
||||||
|
return implode($options[self::SEPERATOR_KEY], $titles);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AsideActivityCategory $asideActivityCategory
|
||||||
|
*/
|
||||||
|
public function supports($asideActivityCategory, array $options): bool
|
||||||
|
{
|
||||||
|
return $asideActivityCategory instanceof AsideActivityCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildParents(AsideActivityCategory $asideActivityCategory)
|
||||||
|
{
|
||||||
|
$parents = [];
|
||||||
|
|
||||||
|
while($asideActivityCategory->hasParent()) {
|
||||||
|
$asideActivityCategory = $parents[] = $asideActivityCategory->getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AsideActivityCategory $asideActivityCategory
|
||||||
|
*/
|
||||||
|
public function renderBox($asideActivityCategory, array $options): string
|
||||||
|
{
|
||||||
|
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||||
|
$parents = $this->buildParents($asideActivityCategory);
|
||||||
|
|
||||||
|
return $this->engine->render('@ChillAsideActivity/asideActivityCategory/asideActivityCategory.html.twig',
|
||||||
|
[
|
||||||
|
'asideActivityCategory' => $asideActivityCategory,
|
||||||
|
'parents' => $parents,
|
||||||
|
'options' => $options
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,12 @@
|
|||||||
services:
|
services:
|
||||||
Chill\AsideActivityBundle\DataFixtures\:
|
Chill\AsideActivityBundle\DataFixtures\:
|
||||||
resource: './../DataFixtures'
|
resource: "./../DataFixtures"
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
|
|
||||||
|
Chill\AsideActivityBundle\Templating\Entity\:
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
resource: "../Templating/Entity"
|
||||||
|
tags:
|
||||||
|
- "chill.render_entity"
|
||||||
|
@ -19,7 +19,9 @@ final class Version20210922182907 extends AbstractMigration
|
|||||||
|
|
||||||
public function up(Schema $schema): void
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD parent VARCHAR(255) DEFAULT NULL');
|
$this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD parent_id INT DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD CONSTRAINT FK_7BF90DBE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_asideactivity.AsideActivityCategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('CREATE INDEX IDX_7BF90DBE727ACA70 ON chill_asideactivity.asideactivitycategory (parent_id)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
|
@ -28,10 +28,16 @@ div.flex-table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h2, h3, h4, dl, p {
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
dl,
|
||||||
|
p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
h2, h3, h4 {
|
h2,
|
||||||
|
h3,
|
||||||
|
h4 {
|
||||||
color: $blue;
|
color: $blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,23 +58,30 @@ div.flex-bloc {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
div.item-bloc {
|
div.item-bloc {
|
||||||
flex-grow: 0; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 0;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
hyphens: auto;
|
hyphens: auto;
|
||||||
|
|
||||||
div.item-row {
|
div.item-row {
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
div.item-col {
|
div.item-col {
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
flex-basis: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
@include separator;
|
@include separator;
|
||||||
|
|
||||||
ul.record_actions {
|
ul.record_actions {
|
||||||
@ -94,7 +107,7 @@ div.flex-table {
|
|||||||
background-color: $gray-200;
|
background-color: $gray-200;
|
||||||
|
|
||||||
.chill-user-quote {
|
.chill-user-quote {
|
||||||
background-color: shade-color($gray-200, 5%)
|
background-color: shade-color($gray-200, 5%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +116,15 @@ div.flex-table {
|
|||||||
|
|
||||||
div.item-col {
|
div.item-col {
|
||||||
&:first-child {
|
&:first-child {
|
||||||
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
flex-basis: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
@include media-breakpoint-down(md) {
|
@include media-breakpoint-down(md) {
|
||||||
@ -205,14 +222,19 @@ div.wrap-header {
|
|||||||
&:first-child {
|
&:first-child {
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
}
|
}
|
||||||
&:last-child {}
|
&:last-child {
|
||||||
|
}
|
||||||
|
|
||||||
div.wh-col {
|
div.wh-col {
|
||||||
&:first-child {
|
&:first-child {
|
||||||
flex-grow: 0; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 0;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
}
|
}
|
||||||
&:last-child {
|
&:last-child {
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: auto;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
@ -224,12 +246,20 @@ div.wrap-header {
|
|||||||
border: 1px solid $black;
|
border: 1px solid $black;
|
||||||
div.wh-row {
|
div.wh-row {
|
||||||
&:first-child div.wh-col {
|
&:first-child div.wh-col {
|
||||||
&:first-child { background-color: $yellow; }
|
&:first-child {
|
||||||
&:last-child { background-color: $beige; }
|
background-color: $yellow;
|
||||||
|
}
|
||||||
|
&:last-child {
|
||||||
|
background-color: $beige;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&:last-child div.wh-col {
|
&:last-child div.wh-col {
|
||||||
&:first-child { background-color: $orange; }
|
&:first-child {
|
||||||
&:last-child { background-color: $pink; }
|
background-color: $orange;
|
||||||
|
}
|
||||||
|
&:last-child {
|
||||||
|
background-color: $pink;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +273,6 @@ div.flex-bloc,
|
|||||||
div.flex-table,
|
div.flex-table,
|
||||||
div.wrap-list,
|
div.wrap-list,
|
||||||
div.wrap-header {
|
div.wrap-header {
|
||||||
|
|
||||||
div.separator {
|
div.separator {
|
||||||
@include separator;
|
@include separator;
|
||||||
}
|
}
|
||||||
@ -260,7 +289,6 @@ div.wrap-header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLOATBUTTON
|
* FLOATBUTTON
|
||||||
* p-ê pas convaincant: cet asset est toujours en observation
|
* p-ê pas convaincant: cet asset est toujours en observation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user