Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init date filters #75

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/Entity/Talk.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class Talk implements ResourceInterface
#[ORM\JoinColumn(nullable: false)]
private ?Speaker $speaker = null;

#[ORM\Column]
private ?\DateTimeImmutable $startsAt = null;

#[ORM\Column]
private ?\DateTimeImmutable $endsAt = null;

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -91,4 +97,24 @@ public function setSpeaker(?Speaker $speaker): void
{
$this->speaker = $speaker;
}

public function getStartsAt(): ?\DateTimeImmutable
{
return $this->startsAt;
}

public function setStartsAt(\DateTimeImmutable $startsAt): void
{
$this->startsAt = $startsAt;
}

public function getEndsAt(): ?\DateTimeImmutable
{
return $this->endsAt;
}

public function setEndsAt(\DateTimeImmutable $endsAt): void
{
$this->endsAt = $endsAt;
}
}
12 changes: 12 additions & 0 deletions app/Factory/TalkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ public function withSpeaker(Proxy|Speaker $speaker): self
return $this->with(['speaker' => $speaker]);
}

public function withStartingDate(\DateTimeImmutable $startsAt): self
{
return $this->with(['startsAt' => $startsAt]);
}

public function withEndingDate(\DateTimeImmutable $endsAt): self
{
return $this->with(['endsAt' => $endsAt]);
}

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()),
];
}
}
12 changes: 12 additions & 0 deletions app/Grid/TalkGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
use Sylius\Bundle\GridBundle\Builder\ActionGroup\BulkActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\ItemActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\MainActionGroup;
use Sylius\Bundle\GridBundle\Builder\Field\DateTimeField;
use Sylius\Bundle\GridBundle\Builder\Field\StringField;
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\GridBuilderInterface;
use Sylius\Bundle\GridBundle\Grid\AbstractGrid;
Expand All @@ -38,11 +40,16 @@ public static function getName(): string
public function buildGrid(GridBuilderInterface $gridBuilder): void
{
$gridBuilder
->addOrderBy('startsAt')
->addFilter(
EntityFilter::create('speaker', Speaker::class)
->setLabel('app.ui.speaker')
->addFormOption('choice_label', 'fullName'),
)
->addFilter(
DateFilter::create('startsAt')
->setLabel('app.ui.starts_at'),
)
->addField(
TwigField::create('avatar', 'speaker/grid/field/image.html.twig')
->setPath('speaker'),
Expand All @@ -58,6 +65,11 @@ public function buildGrid(GridBuilderInterface $gridBuilder): void
->setPath('speaker.fullName')
->setSortable(true, 'speaker.firstName'),
)
->addField(
DateTimeField::create('startsAt', 'Y-m-d H:i')
->setLabel('app.ui.starts_at')
->setSortable(true),
)
->addActionGroup(
MainActionGroup::create(
CreateAction::create(),
Expand Down
28 changes: 28 additions & 0 deletions app/Story/DefaultTalksStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function build(): void
Joachim will share his extensive experience in creating Sylius plugins and bundles. He will discuss the best practices for plugin development, focusing on aspects such as code quality, dependency management, and optimizing the developer experience to build effective and maintainable plugins.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00'))
->create()
;

Expand All @@ -40,6 +42,8 @@ public function build(): void
Jacques will introduce the NoCommerce plugin, which transforms Sylius into a robust framework for building a variety of websites beyond e-commerce. He will explain how this plugin can make Sylius a versatile alternative to WordPress for non-commercial sites, detailing the integration process and unique benefits.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 11:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 11:45:00'))
->create()
;

Expand All @@ -51,6 +55,8 @@ public function build(): void
Francis will provide a comprehensive overview of the Sylius payment system, focusing on its history and upcoming developments in Sylius 2.0. He will discuss the challenges faced in building the system and how new features will improve payment handling and integration.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 12:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 12:30:00'))
->create()
;

Expand All @@ -63,6 +69,8 @@ public function build(): void
Luca and Manuele will explain how to customize the Sylius Price Calculator for complex B2B pricing models. The talk will cover practical examples of how to implement these changes and ensure accurate pricing through automated testing.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 12:45:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 13:30:00'))
->create()
;

Expand All @@ -74,6 +82,8 @@ public function build(): void
Viorel will discuss how Freshful leverages Sylius to create personalized, consumer-centric solutions. The presentation will cover how detailed user profiling and a modular architecture allow for tailored e-grocery experiences that enhance customer satisfaction and engagement.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 16:15:00'))
->create()
;

Expand All @@ -86,6 +96,8 @@ public function build(): void
Łukasz and Mateusz will explore different methods for managing background tasks in Sylius applications. They will cover basic techniques using Symfony console commands, more advanced approaches with Symfony Messenger, and sophisticated strategies for high availability and fault tolerance.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 16:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 17:15:00'))
->create()
;

Expand All @@ -97,6 +109,8 @@ public function build(): void
Guillaume will demonstrate how to build a semantic search experience using PHP and Meilisearch. He will cover how to leverage recent advancements in machine learning and search engine technology to improve search accuracy and user experience in your applications.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 17:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 18:00:00'))
->create()
;

Expand All @@ -108,6 +122,8 @@ public function build(): void
Loïc will showcase how to enhance the frontend of your Sylius application using Hotwire and Symfony UX. He will provide live examples of how these tools can improve the user interface and experience, focusing on making the frontend more dynamic and responsive.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00'))
->create()
;

Expand All @@ -119,6 +135,8 @@ public function build(): void
Loïc will cover the evolution of the Sylius admin panel, from its initial use of Bootstrap to the current integration with tools like the Sylius Grid component and Twig Hooks. He will discuss how these changes improve the admin panel's functionality and how they can be applied to any Symfony project.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 11:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 11:45:00'))
->create()
;

Expand All @@ -130,6 +148,8 @@ public function build(): void
Thomas will provide strategies for preparing your Sylius application for peak traffic during events like Black Friday. He will explain how to use tools like Blackfire and Platform.sh for performance optimization and load testing to ensure your app remains stable under high demand.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 12:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 12:30:00'))
->create()
;

Expand All @@ -141,6 +161,8 @@ public function build(): void
Romain will share the story behind the inception and development of Gally, an open-source search engine solution for product discovery. You’ll learn how to build a REST/GraphQL layer on top of Elasticsearch using API Platform and Symfony. Romain will cover key technical principles, such as Elasticsearch index abstraction, automatic mapping computation, and GraphQL stitching. Additionally, you'll discover how Gally can be leveraged in a Composable Commerce approach, including various architectural use cases like Headless Sylius, Headful Sylius, and external applications, such as vendor tablets.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 12:45:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 13:30:00'))
->create()
;

Expand All @@ -152,6 +174,8 @@ public function build(): void
Details of this presentation will be announced soon.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 16:15:00'))
->create()
;

Expand All @@ -163,6 +187,8 @@ public function build(): void
Stephan will demonstrate how DDEV simplifies the use of Docker and Docker Compose for Sylius applications. The talk will include a step-by-step guide on installing and integrating DDEV into a Sylius project and how to extend its capabilities for better development workflows.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 15:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 17:15:00'))
->create()
;

Expand All @@ -174,6 +200,8 @@ public function build(): void
Ksenia will share her approach to improving developer documentation. She will offer tips on how clear and effective documentation can streamline project development, enhance collaboration, and improve overall project outcomes.
TEXT
)
->withStartingDate(new \DateTimeImmutable('2024-11-13 17:30:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 18:00:00'))
->create()
;
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"symfony/dotenv": "^6.4 || ^7.0",
"symfony/flex": "^2.4",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/maker-bundle": "^1.61",
"symfony/runtime": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
Expand Down
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true],
];
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 @@ -26,6 +26,7 @@
'delete' => '@SyliusBootstrapAdminUi/shared/grid/bulk_action/delete.html.twig',
],
'filter' => [
'date' => '@SyliusBootstrapAdminUi/shared/grid/filter/date.html.twig',
'entity' => '@SyliusBootstrapAdminUi/shared/grid/filter/entity.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,6 @@
{% form_theme form '@SyliusBootstrapAdminUi/shared/form_theme.html.twig' %}

<div class="sylius-filters__date">
{{ form_row(form.from, { attr: {'class': 'input-group'}, 'label': 'sylius.ui.date_filter', 'label_translation_parameters': {'%label%': filter.label|trans, '%altLabel%': form.from.vars.label|trans} }) }}
{{ form_row(form.to, { attr: {'class': 'input-group'} }) }}
</div>
3 changes: 3 additions & 0 deletions src/UiTranslations/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ sylius:
contains: Contains
create: Create
dashboard: Dashboard
date_filter: '%label% | %altLabel%'
delete: Delete
details: Details
edit: Edit
error: Error
filter: Filter
filters: Filters
from: From
info: Info
new: New
no_results: No results found
Expand All @@ -26,6 +28,7 @@ sylius:
search_menu: 'Search menu'
success: Success
this_form_contains_errors: 'This form contains errors.'
to: To
update: Update
value: Value
warning: Warning
9 changes: 9 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@
"src/Kernel.php"
]
},
"symfony/maker-bundle": {
"version": "1.61",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/routing": {
"version": "5.4",
"recipe": {
Expand Down
4 changes: 4 additions & 0 deletions tests/Functional/TalkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ public function testBrowsingTalks(): void
TalkFactory::new()
->withTitle('Boost Your Sylius Frontend with Hotwire, aka Symfony UX')
->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Loïc', 'lastName' => 'Caillieux']))
->withStartingDate(new \DateTimeImmutable('2024-11-13 10:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 10:45:00'))
->create()
;

TalkFactory::new()
->withTitle('Admin Panel (R)evolution for Your Symfony Projects')
->withSpeaker(SpeakerFactory::findOrCreate(['firstName' => 'Loïc', 'lastName' => 'Frémont']))
->withStartingDate(new \DateTimeImmutable('2024-11-13 11:00:00'))
->withEndingDate(new \DateTimeImmutable('2024-11-13 11:45:00'))
->create()
;

Expand Down
2 changes: 2 additions & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ app:
books: Books
company_name: Company name
configuration: Configuration
ends_at: Ends at
first_name: First name
last_name: Last name
library: Library
show_talks: Show talks
speaker: Speaker
speakers: Speakers
starts_at: Starts at
talk: Talk
talks: Talks
Loading