From fdf48e9e4072c86ed3db69cda18625872f81219c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Tue, 1 Oct 2024 09:54:17 +0200 Subject: [PATCH] Init select filter with talk track --- app/Entity/Talk.php | 14 ++ app/Enum/Track.php | 21 +++ app/Factory/TalkFactory.php | 7 + app/Grid/TalkGrid.php | 10 ++ app/Story/DefaultTalksStory.php | 125 ++++++++++++++++++ .../config/app/grid/templates.php | 1 + .../shared/grid/filter/select.html.twig | 3 + translations/messages.en.yaml | 4 + 8 files changed, 185 insertions(+) create mode 100644 app/Enum/Track.php create mode 100644 src/BootstrapAdminUi/templates/shared/grid/filter/select.html.twig diff --git a/app/Entity/Talk.php b/app/Entity/Talk.php index e50b2e2c..4ace5f49 100644 --- a/app/Entity/Talk.php +++ b/app/Entity/Talk.php @@ -13,6 +13,7 @@ namespace App\Entity; +use App\Enum\Track; use App\Form\TalkType; use App\Grid\TalkGrid; use App\Repository\TalkRepository; @@ -63,6 +64,9 @@ class Talk implements ResourceInterface #[ORM\Column] private ?\DateTimeImmutable $endsAt = null; + #[ORM\Column(enumType: Track::class)] + private ?Track $track = null; + public function getId(): ?int { return $this->id; @@ -117,4 +121,14 @@ public function setEndsAt(\DateTimeImmutable $endsAt): void { $this->endsAt = $endsAt; } + + public function getTrack(): ?Track + { + return $this->track; + } + + public function setTrack(Track $track): void + { + $this->track = $track; + } } diff --git a/app/Enum/Track.php b/app/Enum/Track.php new file mode 100644 index 00000000..6b0dc026 --- /dev/null +++ b/app/Enum/Track.php @@ -0,0 +1,21 @@ +with(['endsAt' => $endsAt]); } + public function withTrack(Track $track): self + { + return $this->with(['track' => $track]); + } + protected function defaults(): array|callable { return [ @@ -61,6 +67,7 @@ protected function defaults(): array|callable 'title' => self::faker()->text(255), 'startsAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()), 'endsAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()), + 'track' => self::faker()->randomElement(Track::cases()), ]; } } diff --git a/app/Grid/TalkGrid.php b/app/Grid/TalkGrid.php index 774e397f..8f70e79a 100644 --- a/app/Grid/TalkGrid.php +++ b/app/Grid/TalkGrid.php @@ -15,6 +15,7 @@ use App\Entity\Speaker; use App\Entity\Talk; +use App\Enum\Track; use Sylius\Bundle\GridBundle\Builder\Action\CreateAction; use Sylius\Bundle\GridBundle\Builder\Action\DeleteAction; use Sylius\Bundle\GridBundle\Builder\Action\UpdateAction; @@ -26,6 +27,7 @@ use Sylius\Bundle\GridBundle\Builder\Field\TwigField; use Sylius\Bundle\GridBundle\Builder\Filter\DateFilter; use Sylius\Bundle\GridBundle\Builder\Filter\EntityFilter; +use Sylius\Bundle\GridBundle\Builder\Filter\SelectFilter; use Sylius\Bundle\GridBundle\Builder\GridBuilderInterface; use Sylius\Bundle\GridBundle\Grid\AbstractGrid; use Sylius\Bundle\GridBundle\Grid\ResourceAwareGridInterface; @@ -50,6 +52,14 @@ public function buildGrid(GridBuilderInterface $gridBuilder): void DateFilter::create('startsAt') ->setLabel('app.ui.starts_at'), ) + ->addFilter( + SelectFilter::create('track', [ + 'app.ui.biz' => Track::BIZ->value, + 'app.ui.tech_one' => Track::TECH_ONE->value, + 'app.ui.tech_two' => Track::TECH_TWO->value, + ]) + ->setLabel('app.ui.track'), + ) ->addField( TwigField::create('avatar', 'speaker/grid/field/image.html.twig') ->setPath('speaker'), diff --git a/app/Story/DefaultTalksStory.php b/app/Story/DefaultTalksStory.php index 1fe28ed4..bf7a3bf3 100644 --- a/app/Story/DefaultTalksStory.php +++ b/app/Story/DefaultTalksStory.php @@ -13,6 +13,7 @@ namespace App\Story; +use App\Enum\Track; use App\Factory\SpeakerFactory; use App\Factory\TalkFactory; use Zenstruck\Foundry\Story; @@ -20,6 +21,114 @@ final class DefaultTalksStory extends Story { public function build(): void + { + $this->createBizTalks(); + $this->createTechOneTalks(); + $this->createTechTwoTalks(); + } + + private function createBizTalks(): void + { + TalkFactory::new() + ->withTitle('The Missing Piece in the Developer\'s Toolkit: Communication') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Stéphane', 'lastName' => 'Decock'])) + ->withDescription( + <<<'TEXT' + This talk will explore the vital role of communication in software development. Stéphane will discuss how effective communication can bridge the gap between developers and stakeholders, reduce misunderstandings, and lead to more successful projects. He will also provide techniques to help developers articulate complex ideas clearly and understand stakeholder needs better. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('TBA') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Hélèna', 'lastName' => 'Gravelier'])) + ->withDescription( + <<<'TEXT' + Details of this presentation will be announced soon. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 11:00:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 11:45:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('TBA') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Przemysław', 'lastName' => 'Połeć'])) + ->withDescription( + <<<'TEXT' + Details of this presentation will be announced soon. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:00:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 12:30:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('Transforming the Retail Industry with Sylius') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Zrinka', 'lastName' => 'Dedic'])) + ->withDescription( + <<<'TEXT' + Zrinka will share how Locastic utilized Sylius to transform the retail operations of Tommy.hr. The presentation will cover the specific strategies and changes implemented using Sylius to improve efficiency and operational effectiveness in the retail sector. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:45:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 13:15:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('Building a Sustainable Accessibility Program for Your Team') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Kuba', 'lastName' => 'Zwoliński'])) + ->withDescription( + <<<'TEXT' + Kuba will outline the key elements needed to create a sustainable accessibility program within an organization. He will focus on developing an accessibility culture, integrating accessibility into your workflows from the beginning, and preparing for upcoming European regulations like the European Accessibility Act. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 15:45:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 16:15:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('Multiple Webshops with Case-Specific Sales Processes on One Sylius Instance - A Case Study') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Gregor', 'lastName' => 'Šink'])) + ->withDescription( + <<<'TEXT' + Gregor will present a case study of DZS, a Slovenian publishing house, which integrated multiple webshops into a single Sylius instance. The talk will cover how this consolidation catered to different customer needs (B2C, B2B, CMS) under one platform, providing a unique experience for each user while reducing operating expenses. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 16:30:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 17:15:00')) + ->withTrack(Track::BIZ) + ->create() + ; + + TalkFactory::new() + ->withTitle('When Sylius Meets Beer: A Refresh That’s Brewing Up a Storm') + ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Julien', 'lastName' => 'Jacottet'])) + ->withDescription( + <<<'TEXT' + Julien, CTO of Mezcalito, will take you through the journey of Une Petite Mousse, a popular online beer shop, and their successful transition from an internal solution to Sylius. He will share the challenges they overcame, the innovative solutions they developed, and how Sylius helped brew up tangible, sparkling results. + TEXT + ) + ->withStartingDate(new \DateTimeImmutable('2024-11-13 17:30:00')) + ->withEndingDate(new \DateTimeImmutable('2024-11-13 18:00:00')) + ->withTrack(Track::BIZ) + ->create() + ; + } + + private function createTechOneTalks(): void { TalkFactory::new() ->withTitle('Create World-Class Sylius Plugins') @@ -31,6 +140,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -44,6 +154,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 11:00:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 11:45:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -57,6 +168,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:00:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 12:30:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -71,6 +183,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:45:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 13:30:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -84,6 +197,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 16:15:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -98,6 +212,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 16:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 17:15:00')) + ->withTrack(Track::TECH_ONE) ->create() ; @@ -111,9 +226,13 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 17:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 18:00:00')) + ->withTrack(Track::TECH_ONE) ->create() ; + } + private function createTechTwoTalks(): void + { TalkFactory::new() ->withTitle('Boost Your Sylius Frontend with Hotwire, aka Symfony UX') ->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Loïc', 'lastName' => 'Caillieux'])) @@ -124,6 +243,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00')) + ->withTrack(Track::TECH_TWO) ->create() ; @@ -150,6 +270,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:00:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 12:30:00')) + ->withTrack(Track::TECH_TWO) ->create() ; @@ -163,6 +284,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 12:45:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 13:30:00')) + ->withTrack(Track::TECH_TWO) ->create() ; @@ -176,6 +298,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 16:15:00')) + ->withTrack(Track::TECH_TWO) ->create() ; @@ -189,6 +312,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 17:15:00')) + ->withTrack(Track::TECH_TWO) ->create() ; @@ -202,6 +326,7 @@ public function build(): void ) ->withStartingDate(new \DateTimeImmutable('2024-11-13 17:30:00')) ->withEndingDate(new \DateTimeImmutable('2024-11-13 18:00:00')) + ->withTrack(Track::TECH_TWO) ->create() ; } diff --git a/src/BootstrapAdminUi/config/app/grid/templates.php b/src/BootstrapAdminUi/config/app/grid/templates.php index dd188077..ed385e16 100644 --- a/src/BootstrapAdminUi/config/app/grid/templates.php +++ b/src/BootstrapAdminUi/config/app/grid/templates.php @@ -28,6 +28,7 @@ 'filter' => [ 'date' => '@SyliusBootstrapAdminUi/shared/grid/filter/date.html.twig', 'entity' => '@SyliusBootstrapAdminUi/shared/grid/filter/entity.html.twig', + 'select' => '@SyliusBootstrapAdminUi/shared/grid/filter/select.html.twig', 'string' => '@SyliusBootstrapAdminUi/shared/grid/filter/string.html.twig', ], ], diff --git a/src/BootstrapAdminUi/templates/shared/grid/filter/select.html.twig b/src/BootstrapAdminUi/templates/shared/grid/filter/select.html.twig new file mode 100644 index 00000000..f0db6f3a --- /dev/null +++ b/src/BootstrapAdminUi/templates/shared/grid/filter/select.html.twig @@ -0,0 +1,3 @@ +{% form_theme form '@SyliusBootstrapAdminUi/shared/form_theme.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index b3c57bac..e81c2b2b 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -1,6 +1,7 @@ app: ui: author: Author + biz: Biz book: Book books: Books company_name: Company name @@ -15,3 +16,6 @@ app: starts_at: Starts at talk: Talk talks: Talks + tech_one: Tech#1 + tech_two: Tech#2 + track: Track