From 601c16ac27ae8e212ec3790f36196488e5eb3e6d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 17:00:23 +0200 Subject: [PATCH 01/30] first commit: rendez-vous menu entry deleted from task usermenubuilder. Start sous-types --- .../src/Entity/AsideActivityCategory.php | 59 ++++++++++++++++++- .../src/config/services/menu.yaml | 2 +- .../ChillTaskBundle/Menu/UserMenuBuilder.php | 20 +++---- 3 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 6c580394b..1aa2b7d2a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Chill\AsideActivityBundle\Entity; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -21,6 +20,16 @@ class AsideActivityCategory */ private int $id; + /** + * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children") + */ + private $parent; + + /** + * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, mappedBy="parent") + */ + private $children; + /** * @ORM\Column(type="json", length=255) */ @@ -59,4 +68,52 @@ class AsideActivityCategory return $this; } + + public function getParent(): ?self + { + return $this->parent; + } + + public function hasParent(): bool + { + return $this->parent !== null; + } + + public function setParent(?self $parent): self + { + $this->parent = $parent; + + return $this; + } + + /** + * @return Collection|self[] + */ + public function getChildren(): Collection + { + return $this->children; + } + + public function addChild(self $child): self + { + if (!$this->children->contains($child)) { + $this->children[] = $child; + $child->setParent($this); + } + + return $this; + } + + public function removeChild(self $child): self + { + if ($this->children->removeElement($child)) { + // set the owning side to null (unless already changed) + if ($child->getParent() === $this) { + $child->setParent(null); + } + } + + return $this; + } + } diff --git a/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml b/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml index 614391a0e..909f82381 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml +++ b/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml @@ -1,5 +1,5 @@ services: Chill\AsideActivityBundle\Menu\: - resource: './../../Menu' + resource: "./../../Menu" autowire: true autoconfigure: true diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index 632961953..0330699ad 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -115,16 +115,16 @@ class UserMenuBuilder implements LocalMenuBuilderInterface 'icon' => 'tasks' ]); - $menu->addChild("My calendar list", [ - 'route' => 'chill_calendar_calendar_list', - 'routeParameters' => [ - 'user_id' => $user->getId(), - ] - ]) - ->setExtras([ - 'order' => -9, - 'icon' => 'tasks' - ]); + // $menu->addChild("My calendar list", [ + // 'route' => 'chill_calendar_calendar_list', + // 'routeParameters' => [ + // 'user_id' => $user->getId(), + // ] + // ]) + // ->setExtras([ + // 'order' => -9, + // 'icon' => 'tasks' + // ]); /* $menu->addChild("My aside activities", [ From d2ce4865c0644ccac2452d87b4b19523110792e5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 21 Sep 2021 11:42:18 +0200 Subject: [PATCH 02/30] display all aside activities created for and created by user with temporary badge --- .../Controller/AsideActivityController.php | 3 +- .../views/asideActivity/list.html.twig | 38 ++++++++----------- .../src/translations/messages.fr.yml | 3 +- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 88e53c8d2..59bbf821b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -17,7 +17,8 @@ final class AsideActivityController extends CRUDController $qb = parent::buildQueryEntities($action, $request); if ('index' === $action) { - $qb->andWhere($qb->expr()->eq('e.agent', ':user')); + $qb->where($qb->expr()->eq('e.agent', ':user')); + $qb->orWhere($qb->expr()->eq('e.createdBy', ':user')); $qb->setParameter('user', $this->getUser()); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig index d0e02e3d2..cf747be72 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig @@ -19,7 +19,6 @@ class="flex-table my-4 list-records"> {# Sort activities according to date in descending order #} {% for entity in entities %} - {% set t = entity.type %}
@@ -29,6 +28,10 @@ {{ entity.type.title | localize_translatable_string }} +

{{ 'Created for' | trans }} + : + {{ entity.agent }}

+ {% if entity.date %}

{{ entity.date|format_date('long') }}

{% endif %} @@ -43,34 +46,23 @@
    - {% if entity.createdBy %} -
  • - {{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }} -
  • - {% endif %} +
  • + + {{ 'Created by'|trans }} + : + {{ entity.createdBy.usernameCanonical }} + +
- {# {% - if entity.note is not empty - or entity.createdBy|length > 0 - %} -
- {% if entity.note is not empty %} -
- {{ entity.note|chill_markdown_to_html }} -
- {% endif %} - -
- {% endif %} #}
      -
    • - -
    • +
    • + +
    • @@ -82,7 +74,7 @@ {% endfor %}
- {{ chill_pagination(paginator) }} + {{ chill_pagination(paginator) }} - - {% endif %} + {% endif %} -{% endblock %} + {% endblock %} From 15897b4f332c4da9eef501dc67372d79a4ba00cb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 Sep 2021 20:35:46 +0200 Subject: [PATCH 09/30] asideactivity category entity changed to have parent and children properties --- .../src/migrations/Version20210922182907.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php new file mode 100644 index 000000000..7699f86f3 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD parent VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory DROP parent'); + } +} From 05c5eaa925906d4a2107b78fe3bd65cbb81f6cf9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 23 Sep 2021 14:54:11 +0200 Subject: [PATCH 10/30] stash commit --- .../src/Entity/AsideActivityCategory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 1aa2b7d2a..3ebe6f28a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -26,7 +26,7 @@ class AsideActivityCategory private $parent; /** - * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, mappedBy="parent") + * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") */ private $children; From a28c996164769189f23f1a0b36e02f8ae15630fb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 23 Sep 2021 14:55:54 +0200 Subject: [PATCH 11/30] stash commit 2 --- .../src/Entity/AsideActivityCategory.php | 26 +- .../src/Form/AsideActivityCategoryType.php | 18 +- .../src/Form/AsideActivityFormType.php | 12 +- .../asideActivityCategory.html.twig | 13 + .../src/Templating/Entity/CategoryRender.php | 80 +++ .../src/config/services.yaml | 15 +- .../src/migrations/Version20210922182907.php | 4 +- .../public/chill/scss/flex_table.scss | 454 ++++++++++-------- 8 files changed, 391 insertions(+), 231 deletions(-) create mode 100644 src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig create mode 100644 src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 3ebe6f28a..e82bb9ec8 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Chill\AsideActivityBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -20,8 +21,20 @@ class AsideActivityCategory */ 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\JoinColumn(nullable=true) */ private $parent; @@ -30,15 +43,10 @@ class AsideActivityCategory */ private $children; - /** - * @ORM\Column(type="json", length=255) - */ - private array $title; - - /** - * @ORM\Column(type="boolean") - */ - private bool $isActive = true; + public function __construct() + { + $this->children = new ArrayCollection(); + } public function getId(): ?int { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index 1bfc6ed37..c7357b603 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -4,19 +4,35 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; 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\Extension\Core\Type\ChoiceType; - use Symfony\Component\Form\FormBuilderInterface; final class AsideActivityCategoryType extends AbstractType { + + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) + { + $this->translatableStringHelper = $translatableStringHelper; + } + public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('title', TranslatableStringFormType::class, [ '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, [ 'choices' => [ diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index d7e5a7700..46f54471f 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -4,6 +4,7 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; +use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; @@ -19,22 +20,25 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; - +use Symfony\Component\Templating\EngineInterface; final class AsideActivityFormType extends AbstractType { protected array $timeChoices; private TranslatableStringHelper $translatableStringHelper; private TokenStorageInterface $storage; + private CategoryRender $categoryRender; public function __construct ( TranslatableStringHelper $translatableStringHelper, ParameterBagInterface $parameterBag, - TokenStorageInterface $storage + TokenStorageInterface $storage, + CategoryRender $categoryRender ){ $this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration'); $this->translatableStringHelper = $translatableStringHelper; $this->storage = $storage; + $this->CategoryRender = $categoryRender; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -78,7 +82,9 @@ final class AsideActivityFormType extends AbstractType 'class' => AsideActivityCategory::class, 'placeholder' => 'Choose the activity category', '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) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig new file mode 100644 index 000000000..17077db14 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig @@ -0,0 +1,13 @@ +{% set reversed_parents = parents|reverse %} + + + {%- for p in reversed_parents %} + + {{ p.title|localize_translatable_string }}{{ options['default.separator'] }} + + {%- endfor -%} + + {{ asideActivityCategory.title|localize_translatable_string }} + + + diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php new file mode 100644 index 000000000..8bab0986c --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -0,0 +1,80 @@ + ' > ' + ]; + + 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 + ]); + } +} \ No newline at end of file diff --git a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml index 8ff656fdc..ede446723 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml +++ b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml @@ -1,5 +1,12 @@ services: - Chill\AsideActivityBundle\DataFixtures\: - resource: './../DataFixtures' - autowire: true - autoconfigure: true + Chill\AsideActivityBundle\DataFixtures\: + resource: "./../DataFixtures" + autowire: true + autoconfigure: true + + Chill\AsideActivityBundle\Templating\Entity\: + autowire: true + autoconfigure: true + resource: "../Templating/Entity" + tags: + - "chill.render_entity" diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php index 7699f86f3..00948e210 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php @@ -19,7 +19,9 @@ final class Version20210922182907 extends AbstractMigration 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 diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss index 21ecde267..69f3f30f2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss @@ -8,39 +8,45 @@ div.flex-bloc, div.flex-table { + display: flex; + align-items: stretch; + align-content: stretch; + box-sizing: border-box; + margin: 1.5em 0; + + div.item-bloc { display: flex; - align-items: stretch; - align-content: stretch; - box-sizing: border-box; - margin: 1.5em 0; + @include border-collapse; + padding: 1em; - div.item-bloc { + div.item-row { + display: flex; + + div.item-col:last-child { display: flex; - @include border-collapse; - padding: 1em; - - div.item-row { - display: flex; - - div.item-col:last-child { - display: flex; - } - } + } } + } - h2, h3, h4, dl, p { - margin: 0; - } - h2, h3, h4 { - color: $blue; - } + h2, + h3, + h4, + dl, + p { + margin: 0; + } + h2, + h3, + h4 { + color: $blue; + } - ul.record_actions { - margin: 0; - li { - margin-right: 5px; - } + ul.record_actions { + margin: 0; + li { + margin-right: 5px; } + } } /* @@ -48,36 +54,43 @@ div.flex-table { */ div.flex-bloc { - flex-direction: row; - flex-wrap: wrap; + flex-direction: row; + flex-wrap: wrap; - div.item-bloc { - flex-grow: 0; flex-shrink: 1; flex-basis: auto; - flex-direction: column; - margin: 0; - hyphens: auto; + div.item-bloc { + flex-grow: 0; + flex-shrink: 1; + flex-basis: auto; + flex-direction: column; + margin: 0; + hyphens: auto; - div.item-row { - flex-grow: 1; flex-shrink: 1; flex-basis: auto; - flex-direction: column; + div.item-row { + flex-grow: 1; + flex-shrink: 1; + flex-basis: auto; + flex-direction: column; - 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; - @include separator; - - ul.record_actions { - align-self: flex-end; - } - } - } + 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; + @include separator; + + ul.record_actions { + align-self: flex-end; + } + } + } } + } } /* @@ -85,53 +98,57 @@ div.flex-bloc { */ div.flex-table { + flex-direction: column; + + div.item-bloc { flex-direction: column; - div.item-bloc { - flex-direction: column; + &:nth-child(even) { + background-color: $gray-200; - &:nth-child(even) { - background-color: $gray-200; - - .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; - } - } - } - } - } + .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; + } + } + } + } + } + } } /* @@ -140,54 +157,54 @@ div.flex-table { */ div.wrap-list { - padding: 0; - width: 100%; + padding: 0; + width: 100%; - div.wl-row { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: space-between; + div.wl-row { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; - div.wl-col.title { - width: auto; - flex-shrink: 0; + div.wl-col.title { + width: auto; + flex-shrink: 0; - @include media-breakpoint-up(md) { - //margin-left: 1.5em; - } + @include media-breakpoint-up(md) { + //margin-left: 1.5em; + } - & > * { - padding-right: 1em; - } - } - - div.wl-col.list { - width: 75%; - margin: auto 0 0 auto; - - .wl-item { - margin: 0.1em; - padding: 0em; - display: inline-block; - } - } + & > * { + padding-right: 1em; + } } - &.debug .wl-row { - border: 1px solid $black; + div.wl-col.list { + width: 75%; + margin: auto 0 0 auto; - div.wl-col.title { - background-color: yellow; - } - div.wl-col.list { - background-color: cyan; - - p.wl-item { - background-color: orange; - } - } + .wl-item { + margin: 0.1em; + padding: 0em; + display: inline-block; + } } + } + + &.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 { - 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; - flex-direction: row; + justify-content: flex-end; + } + } + } + &.debug { + border: 1px solid $black; + div.wh-row { + &:first-child div.wh-col { &:first-child { - align-items: baseline; + background-color: $yellow; } - &: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; - - 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 { + background-color: $beige; } + } + &: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.wrap-list, div.wrap-header { + div.separator { + @include separator; + } - div.separator { - @include separator; - } - - ul.record_actions { - flex-grow: 1; - flex-shrink: 0; - flex-basis: auto; - margin: 0; - - li { - margin-right: 5px; - } + ul.record_actions { + flex-grow: 1; + flex-shrink: 0; + flex-basis: auto; + margin: 0; + + li { + margin-right: 5px; } + } } - /* * FLOATBUTTON * p-ê pas convaincant: cet asset est toujours en observation */ div.float-button { + width: 100%; + + div.box { width: 100%; - div.box { - width: 100%; + div.action { + float: right; + } + } + &.top { + div.action { + padding: 0 0 1em 1em; + } - div.action { - float: right; - } + // avoid a position relative that make links unclickable + .fa-ul > li { + position: initial; } - &.top { - div.action { - padding: 0 0 1em 1em; - } - - // avoid a position relative that make links unclickable - .fa-ul > li { - position: initial; - } + } + &.bottom { + display: flex; + overflow: hidden; + div.action { + height: calc(100% - 0em); + shape-outside: inset(calc(100% - 2em) 0 0); + display: flex; + align-items: flex-end; + padding: 0 0 0 1em; + * { + align-self: flex-end !important; + } } - &.bottom { - display: flex; - overflow: hidden; - div.action { - height: calc(100% - 0em); - shape-outside: inset(calc(100% - 2em) 0 0); - display: flex; - 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); - } + } + &.debug { + padding: 1em; + border: 1px solid black; + background-color: yellow; + div.action { + background-color: transparentize(#00ffff, 0.4); } + } } From 960db6aefcb4892cba03a1d854171cbb8689a8f7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Sep 2021 14:41:37 +0200 Subject: [PATCH 12/30] fast aside activity creation implemented --- .../Controller/AsideActivityController.php | 26 +++++++++++++++++++ .../src/Form/AsideActivityFormType.php | 4 +-- .../src/Menu/SectionMenuBuilder.php | 21 ++++++++++++--- .../src/config/services.yaml | 10 +++++++ .../src/translations/messages.fr.yml | 1 + .../Resources/views/layout.html.twig | 3 +++ 6 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 59bbf821b..8984b79f4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Chill\AsideActivityBundle\Controller; +use Chill\AsideActivityBundle\Entity\AsideActivity; +use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository; use Chill\MainBundle\CRUD\Controller\CRUDController; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\Request; @@ -12,6 +14,14 @@ use Doctrine\Common\Collections\Criteria; final class AsideActivityController extends CRUDController { + + private $categoryRepository; + + public function __construct(AsideActivityCategoryRepository $categoryRepository) + { + $this->categoryRepository = $categoryRepository; + } + protected function buildQueryEntities(string $action, Request $request) { $qb = parent::buildQueryEntities($action, $request); @@ -38,5 +48,21 @@ final class AsideActivityController extends CRUDController return parent::orderQuery($action, $query, $request, $paginator); } + public function createEntity(string $action, Request $request): object + { + $asideActivity = new AsideActivity(); + $duration = $request->query->get('duration', '300'); + $duration = \DateTime::createFromFormat('U', $duration); + $asideActivity->setDuration($duration); + + $categoryId = $request->query->get('type', 7); + $category = $this->categoryRepository->find($categoryId); + $asideActivity->setType($category); + + $note = $request->query->get('note', null); + $asideActivity->setNote($note); + + return $asideActivity; + } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 46f54471f..59bd50874 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -25,7 +25,6 @@ use Symfony\Component\Templating\EngineInterface; final class AsideActivityFormType extends AbstractType { protected array $timeChoices; - private TranslatableStringHelper $translatableStringHelper; private TokenStorageInterface $storage; private CategoryRender $categoryRender; @@ -38,7 +37,7 @@ final class AsideActivityFormType extends AbstractType $this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration'); $this->translatableStringHelper = $translatableStringHelper; $this->storage = $storage; - $this->CategoryRender = $categoryRender; + $this->categoryRender = $categoryRender; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -84,7 +83,6 @@ final class AsideActivityFormType extends AbstractType 'choice_label' => function (AsideActivityCategory $asideActivityCategory) { $options = []; return $this->categoryRender->renderString($asideActivityCategory, $options); - // return $this->translatableStringHelper->localize($asideActivityCategory->getTitle()); }, ]) ->add('duration', ChoiceType::class, $durationTimeOptions) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index b9776b92b..14e450b3e 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -4,6 +4,7 @@ namespace Chill\AsideActivityBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Knp\Menu\MenuItem; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -27,12 +28,24 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { - $menu->addChild($this->translator->trans('Create an aside activity'), [ - 'route' => 'chill_crud_aside_activity_new' + $menu->addChild($this->translator->trans('Create an aside activity'), [ + 'route' => 'chill_crud_aside_activity_new' + ]) + ->setExtras([ + 'order' => 11, + 'icons' => [ 'plus' ] + ]); + $menu->addChild($this->translator->trans('Phonecall'), [ + 'route' => 'chill_crud_aside_activity_new', + 'routeParameters' => [ + 'type' => 1, + 'duration' => 900, + 'note' => 'Pas des remarques' + ] ]) ->setExtras([ - 'order' => 11, - 'icons' => [ 'plus' ] + 'order' => 12, + 'icons' => ['plus'] ]); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml index ede446723..34bb6da33 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml +++ b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml @@ -10,3 +10,13 @@ services: resource: "../Templating/Entity" tags: - "chill.render_entity" + + Chill\AsideActivityBundle\Repository\: + resource: "../Repository" + autowire: true + autoconfigure: true + + Chill\AsideActivityBundle\Controller\: + resource: "../Controller" + autowire: true + autoconfigure: true diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index 086ca3dc2..9f7d1bf35 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -169,3 +169,4 @@ The activity has been successfully removed.: L'activité a été supprimée. Create an aside activity: "Creér une activité annexe" Aside activity configuration menu: "Menu de configuration des activités annexes" Aside activity configuration: "Configuration des activités annexes" +Phonecall: "Appel téléphonique" diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index dc500642c..f6699a575 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -92,6 +92,9 @@ + {{ chill_widget('homepage', {} ) }} {% endblock %} From b87c995d22e39f99833e97e045972929cd258515 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Sep 2021 14:42:07 +0200 Subject: [PATCH 13/30] fix UserMenuBuilder so that menu entry is not visible for admin menu --- .../ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php index 22424bc84..4858e6ee7 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php @@ -72,7 +72,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { - + if ($this->authorizationChecker->isGranted('ROLE_USER')){ $menu->addChild("My aside activities", [ 'route' => 'chill_crud_aside_activity_index' ]) @@ -80,6 +80,8 @@ class UserMenuBuilder implements LocalMenuBuilderInterface 'order' => 10, 'icon' => 'tasks' ]); + } + } public static function getMenuIds(): array From 6301c4c10b57d3d20e68973a5b31cd728397c232 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Sep 2021 14:42:37 +0200 Subject: [PATCH 14/30] optimisation twig template --- .../src/Resources/views/asideActivity/view.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig index 6df3d6958..1bd328308 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig @@ -7,7 +7,7 @@ {% block content -%}
- {% include 'ChillAsideActivityBundle:asideActivity:_view.html.twig' %} + {% include '@ChillAsideActivity/asideActivity/_view.html.twig' %}
{% endblock content %} From e35f002f2b3efbb61f26f847c4b38d332624a4fd Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 19:05:03 +0200 Subject: [PATCH 15/30] improvements based on draft review of MR 153 --- .../Controller/AsideActivityController.php | 3 + .../ChillAsideActivityExtension.php | 2 +- .../src/Form/AsideActivityCategoryType.php | 8 +- .../src/Menu/SectionMenuBuilder.php | 1 - .../Admin/layout_asideactivity.html.twig | 2 +- .../views/asideActivity/_index.html.twig | 0 .../views/asideActivity/_view.html.twig | 4 +- .../views/asideActivity/index.html.twig | 93 +++++++++++++++- .../views/asideActivity/list.html.twig | 101 ------------------ .../src/migrations/Version20210706124644.php | 5 +- .../src/migrations/Version20210804082249.php | 5 +- .../src/migrations/Version20210806140343.php | 5 +- .../src/migrations/Version20210806140710.php | 5 +- .../src/migrations/Version20210810084456.php | 5 +- .../src/migrations/Version20210922182907.php | 5 +- .../src/translations/messages.fr.yml | 13 --- .../translations/messages.fr.yml | 88 ++++++++------- 17 files changed, 154 insertions(+), 191 deletions(-) delete mode 100644 src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_index.html.twig delete mode 100644 src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 8984b79f4..a0362ec12 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -57,6 +57,9 @@ final class AsideActivityController extends CRUDController $asideActivity->setDuration($duration); $categoryId = $request->query->get('type', 7); + if($categoryId === null){ + return $this->createNotFoundException('You must give a valid category id'); + } $category = $this->categoryRepository->find($categoryId); $asideActivity->setType($category); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php index fa1353c71..59e77c3e9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php @@ -87,7 +87,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte 'controller' => \Chill\AsideActivityBundle\Controller\AsideActivityController::class, 'actions' => [ 'index' => [ - 'template' => '@ChillAsideActivity/asideActivity/list.html.twig', + 'template' => '@ChillAsideActivity/asideActivity/index.html.twig', 'role' => 'ROLE_USER' ], 'new' => [ diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index c7357b603..39ddc826b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -3,6 +3,7 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; +use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -15,9 +16,10 @@ final class AsideActivityCategoryType extends AbstractType protected $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(TranslatableStringHelper $translatableStringHelper, CategoryRender $categoryRender) { $this->translatableStringHelper = $translatableStringHelper; + $this->categoryRender = $categoryRender; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -29,8 +31,10 @@ final class AsideActivityCategoryType extends AbstractType ->add('parent', EntityType::class, [ 'class' => AsideActivityCategory::class, 'required' => false, + 'label' => 'Type', 'choice_label' => function (AsideActivityCategory $category){ - return $this->translatableStringHelper->localize($category->getTitle()); + $options = []; + return $this->categoryRender->renderString($category, $options); } ]) ->add('isActive', ChoiceType::class, diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index 14e450b3e..7ae0be27a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -40,7 +40,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'routeParameters' => [ 'type' => 1, 'duration' => 900, - 'note' => 'Pas des remarques' ] ]) ->setExtras([ diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig index f0242c085..08b01cdbd 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig @@ -9,6 +9,6 @@ {% block layout_wvm_content %} {% block admin_content %} -

{{ 'Aside activity configuration' |trans }}

+

{{ 'Aside activity configuration'|trans }}

{% endblock %} {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_index.html.twig deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig index 4601adab1..209214f65 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig @@ -3,7 +3,7 @@
{{ 'Type'|trans }}
-
{{ entity.type.title | localize_translatable_string }}
+
{{ entity.type.title|localize_translatable_string }}
{{ 'Created by'|trans }}
{{ entity.createdBy }}
@@ -37,7 +37,7 @@
  • - + {{ 'Back to the list'|trans }} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig index 0e8ea0506..ef1bc7f74 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig @@ -1,8 +1,91 @@ -{% extends '@ChillMain/layout.html.twig' %} +{% extends "@ChillMain/layout.html.twig" %} -{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} +{% block title %} + {{ 'Aside activity list'|trans }} +{% endblock title %} {% block content %} - {% embed '@ChillAsideActivity/AsideActivity/_index.html.twig' %} - {% endembed %} -{% endblock content %} \ No newline at end of file +
    +

    {{ 'My aside activities'|trans }}

    + + {% if entities|length == 0 %} +

    + {{ "There aren't any aside activities."|trans }} + +

    + {% else %} + +
    + + {% for entity in entities %} + +
    +
    + +
    +

    + {{ entity.type.title|localize_translatable_string }} +

    +
    + {% if entity.date %} + {{ entity.date|format_date('long') }} + {% endif %} + {% if entity.date %} + + + + {{ entity.duration|date('H:i') }} + + + {% endif %} +
    +
    +
    +
    +
      +
    • + + {{ 'By'|trans }}: + {{ entity.createdBy.usernameCanonical }} + +
    • +
    • + + {{ 'For'|trans }}: + {{ entity.agent.usernameCanonical }} + + +
    • +
    +
    +
      +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    +
    +
    +
    +
    +
    + {% endfor %} +
    + + {{ chill_pagination(paginator) }} + + + {% endif %} + + {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig deleted file mode 100644 index c6da4816b..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{% extends "@ChillMain/layout.html.twig" %} - -{% block title %} - {{ 'Aside activity list' |trans }} -{% endblock title %} - -{% block content %} -
    -

    {{ 'My aside activities' |trans }}

    - - {% if entities|length == 0 %} -

    - {{ "There aren't any aside activities."|trans }} - -

    - {% else %} - -
    - - {% for entity in entities %} - -
    -
    - -
    -

    - {{ entity.type.title | localize_translatable_string }} -

    -
    - {% if entity.date %} - {{ entity.date|format_date('long') }} - {% endif %} - {% if entity.date %} - - - - {{ entity.duration|date('H:i') }} - - - {% endif %} -
    -
    -
    -
    -
    -
      -
    • - - {{ 'By'|trans }}: - {{ entity.createdBy.usernameCanonical }} - -
    • -
    • - - {{ 'For'|trans }}: - {{ entity.agent.usernameCanonical }} - - -
    • -
    -
    -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
    -
    -
    -
    -
    - -
    -
    -
    -

    {{ entity.note }}

    -
    -
    -
    -
    - {% endfor %} -
    - - {{ chill_pagination(paginator) }} - - - {% endif %} - - {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php index 59fa35be4..13bee6404 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210706124644 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Aside activity category entity created'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php index c96084ea8..85b99c572 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210804082249 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Aside activity entity created'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php index 62b568407..75c7b81b2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210806140343 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Duration changed to type integer'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php index 92320e639..5c572e650 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210806140710 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Duration changed back to timestamp'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php index 29d6be7f3..2984108c2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210810084456 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'createdat, updatedat and date given a type timestamp'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php index 00948e210..13ba8749c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210922182907 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Parent and children added to aside activity category entity'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index 9f7d1bf35..979f95bac 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -14,7 +14,6 @@ present: présent not present: absent Delete: Supprimer Update: Mettre à jour -Update activity: Modifier l'activité Aside activity data: Données de l'activité annexe There aren't any aside activities.: Aucune activité annexe enregistrée. Type: Type @@ -41,14 +40,8 @@ crud: title_edit: Edition d'une catégorie de type d'activité #forms -Activity creation: Nouvelle activité annexe Create a new aside activity type: Nouvelle categorie d'activité annexe -Create: Créer Back to the list: Retour à la liste -Save activity: Sauver l'activité -Reset form: Remise à zéro du formulaire -Choose the agent for whom this activity is created: Choissisez l'utilisateur pour qui l'activité est creéé. -Choose the activity category: Choissisez le type d'activité Choose the duration: Choisir la durée Choose a category: Choisir un categorie Is active: Actif @@ -154,12 +147,6 @@ days: jours #list My aside activities: Mes activités annexes -Date: Date -By: Par -For: Pour -Created by: Créé par -Created for: Créé pour - #Aside activity delete Delete aside activity: Supprimer une activité annexe Are you sure you want to remove the aside activity concerning "%name%" ?: Êtes-vous sûr de vouloir supprimer une activité annexe qui concerne "%name%" ? diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index f799f20b6..037ac443e 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -1,7 +1,7 @@ "This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License": "Ce programme est un logiciel libre: vous pouvez le redistribuer et/ou le modifier selon les termes de la licence GNU Affero GPL" User manual: Manuel d'utilisation Search: Rechercher -'Search persons, ...': 'Recherche des personnes, ...' +"Search persons, ...": "Recherche des personnes, ..." Person name: Nom / Prénom de la personne Login: Connexion Logout: Se déconnecter @@ -33,7 +33,7 @@ Cancel: Annuler Save: Enregistrer This form contains errors: Ce formulaire contient des erreurs Choose an user: Choisir un utilisateur -'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': "Vous allez quitter la page alors que des données n'ont pas été enregistrées. Êtes vous sûr de vouloir partir ?" +"You are going to leave a page with unsubmitted data. Are you sure you want to leave ?": "Vous allez quitter la page alors que des données n'ont pas été enregistrées. Êtes vous sûr de vouloir partir ?" No value: Aucune information Last updated by: Dernière mise à jour par Last updated on: Dernière mise à jour le @@ -71,24 +71,24 @@ Postal code: Code postal Valid from: Valide à partir du Choose a postal code: Choisir un code postal address: - address_homeless: L'adresse est-elle celle d'un domicile fixe ? - real address: Adresse d'un domicile - consider homeless: N'est pas l'adresse d'un domicile (SDF) + address_homeless: L'adresse est-elle celle d'un domicile fixe ? + real address: Adresse d'un domicile + consider homeless: N'est pas l'adresse d'un domicile (SDF) address more: - floor: ét - corridor: coul - steps: esc - flat: appart - buildingName: résidence - extra: '' - distribution: cedex + floor: ét + corridor: coul + steps: esc + flat: appart + buildingName: résidence + extra: "" + distribution: cedex Create a new address: Créer une nouvelle adresse #serach Your search is empty. Please provide search terms.: La recherche est vide. Merci de fournir des termes de recherche. The domain %domain% is unknow. Please check your search.: Le domaine de recherche "%domain%" est inconnu. Merci de vérifier votre recherche. -Invalid terms : Recherche invalide -You should not have more than one domain. : Vous ne devriez pas avoir plus d'un domaine de recherche. +Invalid terms: Recherche invalide +You should not have more than one domain.: Vous ne devriez pas avoir plus d'un domaine de recherche. #used for page title Search %pattern%: Recherche de "%pattern%" Results %start%-%end% of %total%: Résultats %start%-%end% sur %total% @@ -113,9 +113,9 @@ Permissions Menu: Gestion des droits Permissions management of your chill installation: Gestion des permissions de votre instance #admin section -'Administration interface': Interface d'administration +"Administration interface": Interface d'administration Welcome to the admin section !: > - Bienvenue dans l'interface d'administration ! + Bienvenue dans l'interface d'administration ! #admin section for center's administration Create a new center: Créer un nouveau centre @@ -212,7 +212,6 @@ Problem during download: Problème durant le téléchargement # sans valeur without data: sans valeur - #CSV List Formatter Add a number on first column: La première colonne est un numéro Number: Numéro @@ -230,9 +229,9 @@ Comma separated values (CSV): Valeurs séparées par des virgules (CSV - tableur Choose the format: Choisir le format # select2 -'select2.no_results': Aucun résultat -'select2.error_loading': Erreur de chargement des résultats -'select2.searching': Recherche en cours... +"select2.no_results": Aucun résultat +"select2.error_loading": Erreur de chargement des résultats +"select2.searching": Recherche en cours... # change password Change my password: Modification du mot de passe @@ -260,28 +259,35 @@ Impersonate: Incarner l'utilisateur Impersonate mode: Mode fantôme crud: - # general items - new: - button_action_form: Créer - link_edit: Modifier - save_and_close: Créer & fermer - save_and_show: Créer & voir - save_and_new: Créer & nouveau - success: Les données ont été créées - edit: - button_action_form: Enregistrer - back_to_view: Voir - save_and_close: Enregistrer & fermer - save_and_show: Enregistrer & voir - success: Les données ont été modifiées - delete: - success: Les données ont été supprimées - link_to_form: Supprimer - default: - success: Les données ont été enregistrées - view: - link_duplicate: Dupliquer + # general items + new: + button_action_form: Créer + link_edit: Modifier + save_and_close: Créer & fermer + save_and_show: Créer & voir + save_and_new: Créer & nouveau + success: Les données ont été créées + edit: + button_action_form: Enregistrer + back_to_view: Voir + save_and_close: Enregistrer & fermer + save_and_show: Enregistrer & voir + success: Les données ont été modifiées + delete: + success: Les données ont été supprimées + link_to_form: Supprimer + default: + success: Les données ont été enregistrées + view: + link_duplicate: Dupliquer No entities: Aucun élément CHILL_FOO_SEE: Voir un élément CHILL_FOO_EDIT: Modifier un élément + +#Show templates +Date: Date +By: Par +For: Pour +Created for: Créé pour +Created by: Créé par From baf925100001556749d289d6e093db7760d5d267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 4 Oct 2021 10:17:13 +0200 Subject: [PATCH 16/30] update changelog --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78018c284..7e2691c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ and this project adheres to ## Unreleased + + + +## Test releases + +### test release 2021-10-04 + * [Household editor][UI] Update how household suggestion and addresses are picked; * [AddAddress] Handle address suggestion; * [CenterType][Create a person] when overriding the ACL rules, allow to show a PickCenterType @@ -28,9 +35,5 @@ and this project adheres to https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/37 https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/221 - - -## Test release yyyy-mm-dd - * On-The-Fly modale works for showing, editing and creating person and thirdparty ; * AccompanyingCourse Resume page: list associated persons by household, see household when hover, and show on-the-fly modale when clicking on person ; From e895125d12be49474ea2ba8f6989b6ecb83d3359 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Oct 2021 10:47:09 +0200 Subject: [PATCH 17/30] view template replaced by CRUD view template --- .../views/asideActivity/_view.html.twig | 59 ------------------- .../views/asideActivity/view.html.twig | 55 ++++++++++++++--- 2 files changed, 47 insertions(+), 67 deletions(-) delete mode 100644 src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig deleted file mode 100644 index 209214f65..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_view.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -

    {{ "Aside activity"|trans }}

    - -
    - -
    {{ 'Type'|trans }}
    -
    {{ entity.type.title|localize_translatable_string }}
    - -
    {{ 'Created by'|trans }}
    -
    {{ entity.createdBy }}
    - -
    {{ 'Created for'|trans }}
    -
    {{ entity.agent }}
    - -

    {{ 'Activity data'|trans }}

    - -
    {{ 'Date'|trans }}
    -
    {{ entity.date|format_date('long') }}
    - -
    {{ 'Duration'|trans }}
    -
    {{ entity.duration|date('H:i') }}
    - -
    {{ 'Remark'|trans }}
    - {%- if entity.note is empty -%} -
    - {{ 'No comments'|trans }} -
    - {%- else -%} -
    -
    -
    -

    {{ entity.note }}

    -
    -
    -
    - {%- endif -%} -
    - - diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig index 1bd328308..e2a46d161 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig @@ -1,13 +1,52 @@ -{% extends "@ChillMain/layout.html.twig" %} +{% extends '@ChillMain/layout.html.twig' %} -{% set activeRouteKey = 'chill_aside_activity_list' %} +{% set activeRouteKey = '' %} -{% block title 'Show the aside activity'|trans %} +{% block title %} + {% include('@ChillMain/CRUD/_view_title.html.twig') %} +{% endblock %} -{% block content -%} -
    +{% block content %} + {% embed '@ChillMain/CRUD/_view_content.html.twig' %} + {% block crud_content_header %} +

    {{ ('crud.' ~ crud_name ~ '.title_view')|trans }}

    + {% endblock crud_content_header %} + {% block crud_content_view_details %} +
    - {% include '@ChillAsideActivity/asideActivity/_view.html.twig' %} +
    {{ 'Type'|trans }}
    +
    {{ entity.type.title|localize_translatable_string }}
    -
    -{% endblock content %} +
    {{ 'Created by'|trans }}
    +
    {{ entity.createdBy }}
    + +
    {{ 'Created for'|trans }}
    +
    {{ entity.agent }}
    + +

    {{ 'Activity data'|trans }}

    + +
    {{ 'Date'|trans }}
    +
    {{ entity.date|format_date('long') }}
    + +
    {{ 'Duration'|trans }}
    +
    {{ entity.duration|date('H:i') }}
    + +
    {{ 'Remark'|trans }}
    + {%- if entity.note is empty -%} +
    + {{ 'No comments'|trans }} +
    + {%- else -%} +
    +
    +
    +

    {{ entity.note }}

    +
    +
    +
    + {%- endif -%} +
+ + {% endblock %} + {% endembed %} +{% endblock %} From da19f6844026fb7844e782282e70f986ee76efc5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Oct 2021 11:20:07 +0200 Subject: [PATCH 18/30] Title display of aside activities adjusted to display full title (parent > child > ...) Styling to be discussed --- .../src/Resources/views/asideActivity/index.html.twig | 2 +- .../src/Resources/views/asideActivity/view.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig index ef1bc7f74..a97a29875 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig @@ -24,7 +24,7 @@

- {{ entity.type.title|localize_translatable_string }} + {{ entity.type|chill_entity_render_box }}

{% if entity.date %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig index e2a46d161..75da9a444 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig @@ -15,7 +15,7 @@
{{ 'Type'|trans }}
-
{{ entity.type.title|localize_translatable_string }}
+
{{ entity.type|chill_entity_render_box }}
{{ 'Created by'|trans }}
{{ entity.createdBy }}
From 152a7de1dc85e21fd2820ae21087bb6295fcbf00 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Oct 2021 12:09:26 +0200 Subject: [PATCH 19/30] section menu entries de-activated for role_admin --- .../src/Menu/SectionMenuBuilder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index 7ae0be27a..8a8d65156 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -4,6 +4,7 @@ namespace Chill\AsideActivityBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Knp\Menu\MenuItem; +use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -15,10 +16,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; class SectionMenuBuilder implements LocalMenuBuilderInterface { protected TranslatorInterface $translator; + public AuthorizationCheckerInterface $authorizationChecker; - public function __construct(TranslatorInterface $translator) + public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $authorizationChecker) { $this->translator = $translator; + $this->authorizationChecker = $authorizationChecker; } /** @@ -28,6 +31,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { + if ($this->authorizationChecker->isGranted('ROLE_USER')){ $menu->addChild($this->translator->trans('Create an aside activity'), [ 'route' => 'chill_crud_aside_activity_new' ]) @@ -46,6 +50,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 12, 'icons' => ['plus'] ]); + } } /** From cd6dec5082edb557de7f815f797aee1503777958 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Oct 2021 12:11:27 +0200 Subject: [PATCH 20/30] Display of aside activity title styling changed from badge to normal title display --- .../asideActivityCategory.html.twig | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig index 17077db14..8521b3132 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig @@ -1,13 +1,14 @@ {% set reversed_parents = parents|reverse %} - - - {%- for p in reversed_parents %} - - {{ p.title|localize_translatable_string }}{{ options['default.separator'] }} - - {%- endfor -%} - - {{ asideActivityCategory.title|localize_translatable_string }} + + {# #} + {%- for p in reversed_parents %} + + {{ p.title|localize_translatable_string }}{{ options['default.separator'] }} + {%- endfor -%} + + {{ asideActivityCategory.title|localize_translatable_string }} + {# #} From 27125b838ec89bf6a15cbc8232cbb8d7fcb7aee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 4 Oct 2021 15:15:26 +0200 Subject: [PATCH 21/30] various minor fixes in aside activities --- .../asideActivityCategory.html.twig | 4 +--- .../src/Resources/views/asideActivity/index.html.twig | 6 +++--- .../src/Templating/Entity/CategoryRender.php | 4 ++-- .../src/translations/messages.fr.yml | 2 ++ 4 files changed, 8 insertions(+), 8 deletions(-) rename src/Bundle/ChillAsideActivityBundle/src/Resources/views/{asideActivityCategory => Entity}/asideActivityCategory.html.twig (75%) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig similarity index 75% rename from src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig rename to src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig index 8521b3132..1b31cc765 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/asideActivityCategory.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig @@ -1,7 +1,6 @@ {% set reversed_parents = parents|reverse %} - {# #} + class="chill-entity entity-aside_activity-category"> {%- for p in reversed_parents %} {{ p.title|localize_translatable_string }}{{ options['default.separator'] }} @@ -10,5 +9,4 @@ {{ asideActivityCategory.title|localize_translatable_string }} - {# #} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig index a97a29875..6cc45aeaf 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig @@ -24,7 +24,7 @@

- {{ entity.type|chill_entity_render_box }} + {{ entity.type|chill_entity_render_box }}

{% if entity.date %} @@ -46,13 +46,13 @@
  • {{ 'By'|trans }}: - {{ entity.createdBy.usernameCanonical }} + {{ entity.createdBy|chill_entity_render_box }}
  • {{ 'For'|trans }}: - {{ entity.agent.usernameCanonical }} + {{ entity.agent|chill_entity_render_box }}
  • diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index 8bab0986c..902ed7a68 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -70,11 +70,11 @@ final class CategoryRender implements ChillEntityRenderInterface $options = array_merge(self::DEFAULT_ARGS, $options); $parents = $this->buildParents($asideActivityCategory); - return $this->engine->render('@ChillAsideActivity/asideActivityCategory/asideActivityCategory.html.twig', + return $this->engine->render('@ChillAsideActivity/Entity/asideActivityCategory.html.twig', [ 'asideActivityCategory' => $asideActivityCategory, 'parents' => $parents, 'options' => $options ]); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index 6ee180ad9..c16f6af6a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -49,6 +49,8 @@ Agent: Utilisateur date: Date Duration: Durée Note: Note +Choose the agent for whom this activity is created: Choisissez l'agent pour qui l'activité est créée +Choose the activity category: Choisir la catégorie #Duration minutes: minutes From 27dea97bc6b4251f16270c01d514743846c51093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 4 Oct 2021 15:55:35 +0200 Subject: [PATCH 22/30] fixes minor for admin aside activity --- CHANGELOG.md | 6 ++- .../src/Controller/AdminController.php | 20 -------- .../AsideActivityCategoryController.php | 12 ++++- .../src/Entity/AsideActivityCategory.php | 16 +++++++ .../src/Form/AsideActivityCategoryType.php | 8 ++-- .../src/Form/AsideActivityFormType.php | 9 ++++ .../src/Menu/AdminMenuBuilder.php | 48 +++++++++++++++++++ .../Admin/layout_asideactivity.html.twig | 4 +- .../views/Admin/menu_asideactivity.html.twig | 4 -- .../asideActivityCategory/edit.html.twig | 2 +- .../asideActivityCategory/index.html.twig | 6 ++- .../views/asideActivityCategory/new.html.twig | 2 +- .../src/migrations/Version20211004134012.php | 29 +++++++++++ .../views/Menu/defaultMenu.html.twig | 8 ++-- 14 files changed, 134 insertions(+), 40 deletions(-) delete mode 100644 src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php create mode 100644 src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php delete mode 100644 src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig create mode 100644 src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e2691c63..9050e6e1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,11 @@ and this project adheres to ## Unreleased - +* [Aside activity] Fixes for aside activity + + * categories with child + * fast creation buttons + * add ordering for types ## Test releases diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php deleted file mode 100644 index ae04b2110..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @author Champs Libres - */ -class AdminController extends AbstractController -{ - - public function redirectToAdminIndexAction() - { - return $this->redirectToRoute('chill_main_admin_central'); - } -} \ No newline at end of file diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php index 37f10c343..bf062b50d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php @@ -3,6 +3,9 @@ namespace Chill\AsideActivityBundle\Controller; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; +use Doctrine\ORM\QueryBuilder; +use Symfony\Component\HttpFoundation\Request; /** @@ -10,5 +13,12 @@ use Chill\MainBundle\CRUD\Controller\CRUDController; */ class AsideActivityCategoryController extends CRUDController { + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) + { + /** @var QueryBuilder $query */ + $query->addOrderBy('e.ordering', 'ASC'); -} \ No newline at end of file + return $query; + } + +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index e82bb9ec8..e405f1556 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -32,6 +32,12 @@ class AsideActivityCategory */ private bool $isActive = true; + /** + * @var float + * @ORM\Column(type="float", options={"default": 0.00}) + */ + private float $ordering = 0.00; + /** * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children") * @ORM\JoinColumn(nullable=true) @@ -124,4 +130,14 @@ class AsideActivityCategory return $this; } + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): AsideActivityCategory + { + $this->ordering = $ordering; + return $this; + } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index 39ddc826b..0060ab1b9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -9,11 +9,12 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\FormBuilderInterface; final class AsideActivityCategoryType extends AbstractType { - + protected $translatableStringHelper; public function __construct(TranslatableStringHelper $translatableStringHelper, CategoryRender $categoryRender) @@ -31,13 +32,14 @@ final class AsideActivityCategoryType extends AbstractType ->add('parent', EntityType::class, [ 'class' => AsideActivityCategory::class, 'required' => false, - 'label' => 'Type', + 'label' => 'Parent', 'choice_label' => function (AsideActivityCategory $category){ $options = []; return $this->categoryRender->renderString($category, $options); } ]) - ->add('isActive', ChoiceType::class, + ->add('ordering', NumberType::class) + ->add('isActive', ChoiceType::class, [ 'choices' => [ 'Yes' => true, diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 59bd50874..7c7803816 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -10,6 +10,7 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -80,6 +81,14 @@ final class AsideActivityFormType extends AbstractType 'required' => true, 'class' => AsideActivityCategory::class, 'placeholder' => 'Choose the activity category', + 'query_builder' => function(EntityRepository $er) { + $qb = $er->createQueryBuilder('ac'); + $qb->where($qb->expr()->eq('ac.isActive', 'TRUE')) + ->addOrderBy('ac.ordering', 'ASC') + ; + + return $qb; + }, 'choice_label' => function (AsideActivityCategory $asideActivityCategory) { $options = []; return $this->categoryRender->renderString($asideActivityCategory, $options); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..ecc1a1f90 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php @@ -0,0 +1,48 @@ +security = $security; + } + + public static function getMenuIds(): array + { + return ['admin_index', 'admin_section', 'admin_aside_activity']; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + // all the entries below must have ROLE_ADMIN permissions + if (!$this->security->isGranted('ROLE_ADMIN')) { + return; + } + + if (in_array($menuId, ['admin_index', 'admin_section'])) { + $menu->addChild('Aside activities', [ + 'route' => 'chill_crud_aside_activity_category_index' + ]) + ->setExtras([ + 'order' => 900, + 'explain' => "Configure aside activities categories" + ]); + } else { + $menu + ->addChild('Aside activity categories', [ + 'route' => 'chill_crud_aside_activity_category_index' + ]) + ->setExtras([ + 'order' => '50' + ]); + } + + } +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig index 08b01cdbd..3f44e432d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig @@ -1,9 +1,7 @@ {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} {% block vertical_menu_content %} - {{ chill_menu('admin_aside_activity', { - 'layout': '@ChillAsideActivity/Admin/menu_asideactivity.html.twig', - }) }} + {{ chill_menu('admin_aside_activity') }} {% endblock %} {% block layout_wvm_content %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig deleted file mode 100644 index 34ea309e5..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "@ChillMain/Menu/verticalMenu.html.twig" %} -{% block v_menu_title %} - {{ 'Aside activity configuration menu'|trans }} -{% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig index dacee767c..3fb6fb612 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig @@ -1,4 +1,4 @@ -{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block title %} {% include('@ChillMain/CRUD/_edit_title.html.twig') %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig index d8cb67716..2c8373daf 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig @@ -1,11 +1,12 @@ {% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block admin_content %} -

    {{ 'ActivityType list'|trans }}

    +

    {{ 'Aside Activity Type list'|trans }}

    + @@ -14,7 +15,8 @@ {% for entity in entities %} - + +
    {{ 'Ordering'|trans }} {{ 'Name'|trans }} {{ 'Active'|trans }} {{ 'Actions'|trans }}
    {{ entity.title|localize_translatable_string }}{{ entity.ordering }}{{ entity|chill_entity_render_box }} {%- if entity.isActive -%} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig index d7ac89752..3c8ded234 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig @@ -1,4 +1,4 @@ -{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block title %} {% include('@ChillMain/CRUD/_new_title.html.twig') %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php new file mode 100644 index 000000000..42763638e --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD ordering DOUBLE PRECISION NOT NULL DEFAULT 0.00'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP ordering'); + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig index 67a32b98b..6eada4dd6 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #} \ No newline at end of file + From c41bc7bef962de33b4b1e7cf03b79e84e01aa88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 4 Oct 2021 16:16:34 +0200 Subject: [PATCH 23/30] prevent recursion --- .../src/Entity/AsideActivityCategory.php | 27 ++++++++++++++++++- .../src/translations/validators.fr.yaml | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index e405f1556..09087226c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -7,6 +7,8 @@ namespace Chill\AsideActivityBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * @ORM\Entity @@ -83,11 +85,32 @@ class AsideActivityCategory return $this; } - public function getParent(): ?self + public function getParent(): ?self { return $this->parent; } + /** + * + * @Assert\Callback() + */ + public function preventRecursiveParent(ExecutionContextInterface $context, $payload) + { + if (!$this->hasParent()) { + return; + } + + if ($this->getParent() === $this) { + // replace parent with old parent. This prevent recursive loop + // when displaying form + $this->parent = $this->oldParent; + $context->buildViolation('You must not add twice the same category in the parent tree (previous result returned)') + ->atPath('parent') + ->addViolation() + ; + } + } + public function hasParent(): bool { return $this->parent !== null; @@ -95,6 +118,8 @@ class AsideActivityCategory public function setParent(?self $parent): self { + // cache the old result for changing it during validaiton + $this->oldParent = $this->parent; $this->parent = $parent; return $this; diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml b/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml new file mode 100644 index 000000000..28883568c --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml @@ -0,0 +1 @@ +You must not add twice the same category in the parent tree (previous result returned): Il est interdit d'indiquer la même entité dans l'arbre des parents. Le résultat précédent a été rétabli From ed8a569fea86e69d1a6aa7330db1cdc6c50c9932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 4 Oct 2021 16:30:08 +0200 Subject: [PATCH 24/30] remove obsolete test --- .../Services/ChillMenuTwigFunctionTest.php | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php diff --git a/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php b/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php deleted file mode 100644 index a85ff9710..000000000 --- a/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -namespace Chill\MainBundle\Tests\Services; - -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Component\DomCrawler\Crawler; - -/** - * Test the Twig function 'chill_menu' - * - * @author Julien Fastré - */ -class ChillMenuTwigFunctionTest extends KernelTestCase -{ - - private static $templating; - - public static function setUpBeforeClass() - { - self::bootKernel(array('environment' => 'test')); - static::$templating = static::$container - ->get('templating'); - $pathToBundle = static::$container->getParameter('kernel.bundles_metadata')['ChillMainBundle']['path']; - //load templates in Tests/Resources/views - static::$container->get('twig.loader') - ->addPath($pathToBundle.'/Resources/test/views/', $namespace = 'tests'); - } - - public function testNormalMenu() - { - $content = static::$templating->render('@tests/menus/normalMenu.html.twig'); - $this->assertContains('ul', $content, - "test that the file contains an ul tag" - ); - } -} From 24320cb702df218c44d6d151df748c07966134b8 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 6 Oct 2021 17:28:07 +0200 Subject: [PATCH 25/30] address: alter postalcode entity --- .../ChillMainBundle/Entity/PostalCode.php | 61 +++++++++++++++++++ .../migrations/Version20211006151653.php | 33 ++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20211006151653.php diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 910245680..cd7e8aa5f 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Entity; +use Chill\MainBundle\Doctrine\Model\Point; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; @@ -62,6 +63,30 @@ class PostalCode */ private $origin = 0; + /** + * @var string + * + * @ORM\Column(type="string", length=255, nullable=true) + * @groups({"write", "read"}) + */ + private $refId; + + /** + * @var string + * + * @ORM\Column(type="string", length=255, nullable=true) + * @groups({"write", "read"}) + */ + private $source; + + /** + * @var Point + * + * @ORM\Column(type="point", nullable=true) + * @groups({"write", "read"}) + */ + private $center; + /** * Get id * @@ -169,5 +194,41 @@ class PostalCode { return $this->country; } + + public function getRefId(): ?string + { + return $this->refId; + } + + public function setRefId(?string $refId): self + { + $this->refId = $refId; + + return $this; + } + + public function getSource(): ?string + { + return $this->source; + } + + public function setSource(?string $source): self + { + $this->source = $source; + + return $this; + } + + public function getCenter(): ?Point + { + return $this->center; + } + + public function setCenter(?Point $center): self + { + $this->center = $center; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php new file mode 100644 index 000000000..a6a66ce7e --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_main_postal_code ADD refId VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD source VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD center geometry(POINT,4326) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_postal_code DROP refId'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP source'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP center'); + } +} From 3770318e6a43769110a7f49af2164cb8167649c7 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 6 Oct 2021 21:48:56 +0200 Subject: [PATCH 26/30] enlarge the loadpostalcode command to more fields --- .../Command/LoadPostalCodesCommand.php | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index ba51db779..6b047a04b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -19,6 +19,8 @@ namespace Chill\MainBundle\Command; +use Chill\MainBundle\Doctrine\Model\Point; +use Chill\MainBundle\Entity\Country; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -69,6 +71,9 @@ class LoadPostalCodesCommand extends Command . "using the postal code and name. \n" . "The CSV file must have the following columns: " . "postal code, label, country code." + . "Optionally, the csv file can have the following " + . "columns after the country code: reference code, latitude, longitude, source. " + . "The latitude and longitude columns are supposed to be in WGS84 and expressed in decimal degrees. " . "The CSV file should not have any header row.") ->addArgument('csv_file', InputArgument::REQUIRED, "the path to " . "the csv file. See the help for specifications.") @@ -137,7 +142,7 @@ class LoadPostalCodesCommand extends Command $output->writeln(''.$num.' were added !'); } - private function getCSVResource(InputInterface $input) + public function getCSVResource(InputInterface $input) { $fs = new Filesystem(); $filename = $input->getArgument('csv_file'); @@ -163,7 +168,7 @@ class LoadPostalCodesCommand extends Command } $em = $this->entityManager; $country = $em - ->getRepository('ChillMainBundle:Country') + ->getRepository(Country::class) ->findOneBy(array('countryCode' => $row[2])); if ($country === NULL) { @@ -173,7 +178,7 @@ class LoadPostalCodesCommand extends Command // try to find an existing postal code $existingPC = $em - ->getRepository('ChillMainBundle:PostalCode') + ->getRepository(PostalCode::class) ->findBy(array('code' => $row[0], 'name' => $row[1])); if (count($existingPC) > 0) { @@ -187,6 +192,18 @@ class LoadPostalCodesCommand extends Command ->setCountry($country) ; + if (NULL != $row[3]){ + $postalCode->setRefId($row[3]); + } + + if (NULL != $row[4] & NULL != $row[5]){ + $postalCode->setCenter(Point::fromLonLat((float) $row[5], (float) $row[4])); + } + + if (NULL != $row[6]){ + $postalCode->setSource($row[6]); + } + $errors = $this->validator->validate($postalCode); if ($errors->count() == 0) { From fd73fac1a83fd353db21056a7de7a6769fa52cb9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 7 Oct 2021 12:32:26 +0200 Subject: [PATCH 27/30] adapt migration --- .../ChillMainBundle/migrations/Version20211006151653.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php index a6a66ce7e..c3853b568 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php @@ -19,14 +19,14 @@ final class Version20211006151653 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('ALTER TABLE chill_main_postal_code ADD refId VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD refPostalCodeId VARCHAR(255) DEFAULT NULL'); $this->addSql('ALTER TABLE chill_main_postal_code ADD source VARCHAR(255) DEFAULT NULL'); $this->addSql('ALTER TABLE chill_main_postal_code ADD center geometry(POINT,4326) DEFAULT NULL'); } public function down(Schema $schema): void { - $this->addSql('ALTER TABLE chill_main_postal_code DROP refId'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP refPostalCodeId'); $this->addSql('ALTER TABLE chill_main_postal_code DROP source'); $this->addSql('ALTER TABLE chill_main_postal_code DROP center'); } From 748fe28f8d558fb2c4c504ab009473b75e2c5b12 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 7 Oct 2021 13:42:26 +0200 Subject: [PATCH 28/30] postal code: rename fields to avoid confusion in load fixtures --- .../Command/LoadPostalCodesCommand.php | 4 ++-- .../ChillMainBundle/Entity/PostalCode.php | 20 +++++++++---------- .../migrations/Version20211006151653.php | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 6b047a04b..7655c2ed8 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -193,7 +193,7 @@ class LoadPostalCodesCommand extends Command ; if (NULL != $row[3]){ - $postalCode->setRefId($row[3]); + $postalCode->setRefPostalCodeId($row[3]); } if (NULL != $row[4] & NULL != $row[5]){ @@ -201,7 +201,7 @@ class LoadPostalCodesCommand extends Command } if (NULL != $row[6]){ - $postalCode->setSource($row[6]); + $postalCode->setPostalCodeSource($row[6]); } $errors = $this->validator->validate($postalCode); diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index cd7e8aa5f..8855c40f1 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -69,7 +69,7 @@ class PostalCode * @ORM\Column(type="string", length=255, nullable=true) * @groups({"write", "read"}) */ - private $refId; + private $refPostalCodeId; /** * @var string @@ -77,7 +77,7 @@ class PostalCode * @ORM\Column(type="string", length=255, nullable=true) * @groups({"write", "read"}) */ - private $source; + private $postalCodeSource; /** * @var Point @@ -195,26 +195,26 @@ class PostalCode return $this->country; } - public function getRefId(): ?string + public function getRefPostalCodeId(): ?string { - return $this->refId; + return $this->refPostalCodeId; } - public function setRefId(?string $refId): self + public function setRefPostalCodeId(?string $refPostalCodeId): self { - $this->refId = $refId; + $this->refPostalCodeId = $refPostalCodeId; return $this; } - public function getSource(): ?string + public function getPostalCodeSource(): ?string { - return $this->source; + return $this->postalCodeSource; } - public function setSource(?string $source): self + public function setPostalCodeSource(?string $postalCodeSource): self { - $this->source = $source; + $this->postalCodeSource = $postalCodeSource; return $this; } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php index c3853b568..9f4508ba8 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php @@ -20,14 +20,14 @@ final class Version20211006151653 extends AbstractMigration public function up(Schema $schema): void { $this->addSql('ALTER TABLE chill_main_postal_code ADD refPostalCodeId VARCHAR(255) DEFAULT NULL'); - $this->addSql('ALTER TABLE chill_main_postal_code ADD source VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD postalCodeSource VARCHAR(255) DEFAULT NULL'); $this->addSql('ALTER TABLE chill_main_postal_code ADD center geometry(POINT,4326) DEFAULT NULL'); } public function down(Schema $schema): void { $this->addSql('ALTER TABLE chill_main_postal_code DROP refPostalCodeId'); - $this->addSql('ALTER TABLE chill_main_postal_code DROP source'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP postalCodeSource'); $this->addSql('ALTER TABLE chill_main_postal_code DROP center'); } } From 665b0f8533e35bd83fb762301d72c3966aa837ae Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 7 Oct 2021 13:48:05 +0200 Subject: [PATCH 29/30] postal code: adapt fixtures --- .../DataFixtures/ORM/LoadPostalCodes.php | 404 ++++++++++++++++-- 1 file changed, 364 insertions(+), 40 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php index 6e3d1781b..26ce7415e 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php @@ -22,6 +22,8 @@ namespace Chill\MainBundle\DataFixtures\ORM; +use Chill\MainBundle\Doctrine\Model\Point; +use Chill\MainBundle\Entity\Country; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; @@ -40,21 +42,41 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface return 50; } - public static $refs = array(); + public static $refs = []; public function load(ObjectManager $manager) { - $lines = str_getcsv(self::$codes, "\n"); - $belgium = $manager->getRepository('ChillMainBundle:Country') - ->findOneBy(array('countryCode' => 'BE')); + echo "loading postal codes... \n"; + $this->loadPostalCodeCSV($manager, self::$postalCodeBelgium, 'BE'); + $this->loadPostalCodeCSV($manager, self::$postalCodeFrance, 'FR'); + } + + private function loadPostalCodeCSV(ObjectManager $manager, string $csv, string $countryCode) { + + $lines = str_getcsv($csv, "\n"); + $country = $manager->getRepository(Country::class) + ->findOneBy(['countryCode' => $countryCode]); foreach($lines as $line) { $code = str_getcsv($line); $c = new PostalCode(); - $c->setCountry($belgium) + $c->setCountry($country) ->setCode($code[0]) - ->setName(\ucwords(\strtolower($code[2]))) + ->setName(\ucwords(\strtolower($code[1]))) ; + + if (NULL != $code[3]){ + $c->setRefPostalCodeId($code[3]); + } + + if (NULL != $code[4] & NULL != $code[5]){ + $c->setCenter(Point::fromLonLat((float) $code[5], (float) $code[4])); + } + + if (NULL != $code[6]){ + $c->setPostalCodeSource($code[6]); + } + $manager->persist($c); $ref = 'postal_code_'.$code[0]; @@ -66,40 +88,342 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface $manager->flush(); } - - private static $codes = << Date: Fri, 8 Oct 2021 12:14:45 +0200 Subject: [PATCH 30/30] minor correction following MR review + Changelog --- CHANGELOG.md | 2 ++ .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 2 +- src/Bundle/ChillMainBundle/Entity/PostalCode.php | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9050e6e1c..5a490010a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to ## Unreleased +* add 3 new fields to PostalCode and adapt postal code command and fixtures + * [Aside activity] Fixes for aside activity * categories with child diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 7655c2ed8..21090a61f 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -142,7 +142,7 @@ class LoadPostalCodesCommand extends Command $output->writeln(''.$num.' were added !'); } - public function getCSVResource(InputInterface $input) + private function getCSVResource(InputInterface $input) { $fs = new Filesystem(); $filename = $input->getArgument('csv_file'); diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 8855c40f1..91ce46e17 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -67,7 +67,7 @@ class PostalCode * @var string * * @ORM\Column(type="string", length=255, nullable=true) - * @groups({"write", "read"}) + * @groups({"read"}) */ private $refPostalCodeId; @@ -75,7 +75,7 @@ class PostalCode * @var string * * @ORM\Column(type="string", length=255, nullable=true) - * @groups({"write", "read"}) + * @groups({"read"}) */ private $postalCodeSource; @@ -83,7 +83,7 @@ class PostalCode * @var Point * * @ORM\Column(type="point", nullable=true) - * @groups({"write", "read"}) + * @groups({"read"}) */ private $center;