Skip to content

Commit

Permalink
Init select filter with talk track
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Oct 1, 2024
1 parent 5246b62 commit fdf48e9
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/Entity/Talk.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace App\Entity;

use App\Enum\Track;
use App\Form\TalkType;
use App\Grid\TalkGrid;
use App\Repository\TalkRepository;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
21 changes: 21 additions & 0 deletions app/Enum/Track.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Enum;

enum Track: string
{
case BIZ = 'biz';
case TECH_ONE = 'tech_one';
case TECH_TWO = 'tech_two';
}
7 changes: 7 additions & 0 deletions app/Factory/TalkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use App\Entity\Speaker;
use App\Entity\Talk;
use App\Enum\Track;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\Proxy;

Expand Down Expand Up @@ -54,13 +55,19 @@ public function withEndingDate(\DateTimeImmutable $endsAt): self
return $this->with(['endsAt' => $endsAt]);
}

public function withTrack(Track $track): self
{
return $this->with(['track' => $track]);
}

protected function defaults(): array|callable
{
return [
'speaker' => SpeakerFactory::new(),
'title' => self::faker()->text(255),
'startsAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()),
'endsAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()),
'track' => self::faker()->randomElement(Track::cases()),
];
}
}
10 changes: 10 additions & 0 deletions app/Grid/TalkGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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'),
Expand Down
125 changes: 125 additions & 0 deletions app/Story/DefaultTalksStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,122 @@

namespace App\Story;

use App\Enum\Track;
use App\Factory\SpeakerFactory;
use App\Factory\TalkFactory;
use Zenstruck\Foundry\Story;

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')
Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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']))
Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;

Expand All @@ -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()
;
}
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapAdminUi/config/app/grid/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% form_theme form '@SyliusBootstrapAdminUi/shared/form_theme.html.twig' %}

{{ form_row(form, {'label': filter.label}) }}
4 changes: 4 additions & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
app:
ui:
author: Author
biz: Biz
book: Book
books: Books
company_name: Company name
Expand All @@ -15,3 +16,6 @@ app:
starts_at: Starts at
talk: Talk
talks: Talks
tech_one: Tech#1
tech_two: Tech#2
track: Track

0 comments on commit fdf48e9

Please sign in to comment.