stash commit 2

This commit is contained in:
Julie Lenaerts 2021-09-23 14:55:54 +02:00
parent 05c5eaa925
commit a28c996164
8 changed files with 391 additions and 231 deletions

View File

@ -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
{ {

View File

@ -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' => [

View File

@ -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)

View File

@ -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>

View File

@ -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
]);
}
}

View File

@ -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"

View File

@ -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

View File

@ -8,39 +8,45 @@
div.flex-bloc, div.flex-bloc,
div.flex-table { div.flex-table {
display: flex;
align-items: stretch;
align-content: stretch;
box-sizing: border-box;
margin: 1.5em 0;
div.item-bloc {
display: flex; display: flex;
align-items: stretch; @include border-collapse;
align-content: stretch; padding: 1em;
box-sizing: border-box;
margin: 1.5em 0;
div.item-bloc { div.item-row {
display: flex;
div.item-col:last-child {
display: flex; display: flex;
@include border-collapse; }
padding: 1em;
div.item-row {
display: flex;
div.item-col:last-child {
display: flex;
}
}
} }
}
h2, h3, h4, dl, p { h2,
margin: 0; h3,
} h4,
h2, h3, h4 { dl,
color: $blue; p {
} margin: 0;
}
h2,
h3,
h4 {
color: $blue;
}
ul.record_actions { ul.record_actions {
margin: 0; margin: 0;
li { li {
margin-right: 5px; margin-right: 5px;
}
} }
}
} }
/* /*
@ -48,36 +54,43 @@ div.flex-table {
*/ */
div.flex-bloc { div.flex-bloc {
flex-direction: row; flex-direction: row;
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-direction: column; flex-shrink: 1;
margin: 0; flex-basis: auto;
hyphens: auto; flex-direction: column;
margin: 0;
hyphens: auto;
div.item-row { div.item-row {
flex-grow: 1; flex-shrink: 1; flex-basis: auto; flex-grow: 1;
flex-direction: column; flex-shrink: 1;
flex-basis: auto;
flex-direction: column;
div.item-col { div.item-col {
&:first-child {
&:first-child { flex-grow: 0;
flex-grow: 0; flex-shrink: 0; flex-basis: auto; flex-shrink: 0;
} flex-basis: auto;
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
@include separator;
ul.record_actions {
align-self: flex-end;
}
}
}
} }
&:last-child {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
@include separator;
ul.record_actions {
align-self: flex-end;
}
}
}
} }
}
} }
/* /*
@ -85,53 +98,57 @@ div.flex-bloc {
*/ */
div.flex-table { div.flex-table {
flex-direction: column;
div.item-bloc {
flex-direction: column; flex-direction: column;
div.item-bloc { &:nth-child(even) {
flex-direction: column; background-color: $gray-200;
&:nth-child(even) { .chill-user-quote {
background-color: $gray-200; background-color: shade-color($gray-200, 5%);
}
.chill-user-quote {
background-color: shade-color($gray-200, 5%)
}
}
div.item-row {
flex-direction: row;
div.item-col {
&:first-child {
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
justify-content: flex-end;
@include media-breakpoint-down(md) {
@include separator;
}
ul.record_actions {
align-self: flex-start;
}
}
}
@include media-breakpoint-down(md) {
flex-direction: column;
div.item-col {
&:last-child {
ul.record_actions {
align-self: flex-end;
}
}
}
}
}
} }
div.item-row {
flex-direction: row;
div.item-col {
&:first-child {
flex-grow: 0;
flex-shrink: 0;
flex-basis: auto;
}
&:last-child {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
justify-content: flex-end;
@include media-breakpoint-down(md) {
@include separator;
}
ul.record_actions {
align-self: flex-start;
}
}
}
@include media-breakpoint-down(md) {
flex-direction: column;
div.item-col {
&:last-child {
ul.record_actions {
align-self: flex-end;
}
}
}
}
}
}
} }
/* /*
@ -140,54 +157,54 @@ div.flex-table {
*/ */
div.wrap-list { div.wrap-list {
padding: 0; padding: 0;
width: 100%; width: 100%;
div.wl-row { div.wl-row {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
div.wl-col.title { div.wl-col.title {
width: auto; width: auto;
flex-shrink: 0; flex-shrink: 0;
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
//margin-left: 1.5em; //margin-left: 1.5em;
} }
& > * { & > * {
padding-right: 1em; padding-right: 1em;
} }
}
div.wl-col.list {
width: 75%;
margin: auto 0 0 auto;
.wl-item {
margin: 0.1em;
padding: 0em;
display: inline-block;
}
}
} }
&.debug .wl-row { div.wl-col.list {
border: 1px solid $black; width: 75%;
margin: auto 0 0 auto;
div.wl-col.title { .wl-item {
background-color: yellow; margin: 0.1em;
} padding: 0em;
div.wl-col.list { display: inline-block;
background-color: cyan; }
p.wl-item {
background-color: orange;
}
}
} }
}
&.debug .wl-row {
border: 1px solid $black;
div.wl-col.title {
background-color: yellow;
}
div.wl-col.list {
background-color: cyan;
p.wl-item {
background-color: orange;
}
}
}
} }
/* /*
@ -196,43 +213,56 @@ div.wrap-list {
*/ */
div.wrap-header { div.wrap-header {
width: 100%; width: 100%;
div.wh-row {
display: flex;
flex-direction: row;
&:first-child {
align-items: baseline;
}
&:last-child {
}
div.wh-col {
&:first-child {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
&:last-child {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
div.wh-row {
display: flex; display: flex;
flex-direction: row; justify-content: flex-end;
}
}
}
&.debug {
border: 1px solid $black;
div.wh-row {
&:first-child div.wh-col {
&:first-child { &:first-child {
align-items: baseline; background-color: $yellow;
} }
&:last-child {} &:last-child {
background-color: $beige;
div.wh-col {
&:first-child {
flex-grow: 0; flex-shrink: 1; flex-basis: auto;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
justify-content: flex-end;
}
}
}
&.debug {
border: 1px solid $black;
div.wh-row {
&:first-child div.wh-col {
&:first-child { background-color: $yellow; }
&:last-child { background-color: $beige; }
}
&:last-child div.wh-col {
&:first-child { background-color: $orange; }
&:last-child { background-color: $pink; }
}
} }
}
&:last-child div.wh-col {
&:first-child {
background-color: $orange;
}
&:last-child {
background-color: $pink;
}
}
} }
}
} }
/* /*
@ -243,69 +273,67 @@ div.flex-bloc,
div.flex-table, div.flex-table,
div.wrap-list, div.wrap-list,
div.wrap-header { div.wrap-header {
div.separator {
@include separator;
}
div.separator { ul.record_actions {
@include separator; flex-grow: 1;
} flex-shrink: 0;
flex-basis: auto;
ul.record_actions { margin: 0;
flex-grow: 1;
flex-shrink: 0; li {
flex-basis: auto; margin-right: 5px;
margin: 0;
li {
margin-right: 5px;
}
} }
}
} }
/* /*
* FLOATBUTTON * FLOATBUTTON
* p-ê pas convaincant: cet asset est toujours en observation * p-ê pas convaincant: cet asset est toujours en observation
*/ */
div.float-button { div.float-button {
width: 100%;
div.box {
width: 100%; width: 100%;
div.box { div.action {
width: 100%; float: right;
}
}
&.top {
div.action {
padding: 0 0 1em 1em;
}
div.action { // avoid a position relative that make links unclickable
float: right; .fa-ul > li {
} position: initial;
} }
&.top { }
div.action { &.bottom {
padding: 0 0 1em 1em; display: flex;
} overflow: hidden;
div.action {
// avoid a position relative that make links unclickable height: calc(100% - 0em);
.fa-ul > li { shape-outside: inset(calc(100% - 2em) 0 0);
position: initial; display: flex;
} align-items: flex-end;
padding: 0 0 0 1em;
* {
align-self: flex-end !important;
}
} }
&.bottom { }
display: flex; &.debug {
overflow: hidden; padding: 1em;
div.action { border: 1px solid black;
height: calc(100% - 0em); background-color: yellow;
shape-outside: inset(calc(100% - 2em) 0 0); div.action {
display: flex; background-color: transparentize(#00ffff, 0.4);
align-items: flex-end;
padding: 0 0 0 1em;
* {
align-self: flex-end !important;
}
}
}
&.debug {
padding: 1em;
border: 1px solid black;
background-color: yellow;
div.action {
background-color: transparentize(#00ffff, 0.4);
}
} }
}
} }