Skip to content

Commit

Permalink
Add PageSize component and keep filter form to the side
Browse files Browse the repository at this point in the history
  • Loading branch information
rskuipers committed Feb 10, 2024
1 parent 5fac3fd commit 7d56f2b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 0 additions & 2 deletions assets/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useDebounce } from "stimulus-use";
export default class extends Controller {
static debounces = ['search']

activeElement;

connect() {
useDebounce(this);
}
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/WeDevelopUXTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use WeDevelop\UXTable\DataProvider\DoctrineORMProvider;
use WeDevelop\UXTable\Security\OpenerSigner;
use WeDevelop\UXTable\Twig\Component\Filter;
use WeDevelop\UXTable\Twig\Component\PageSize;
use WeDevelop\UXTable\Twig\Component\SortLink;
use WeDevelop\UXTable\Twig\Component\Table;
use WeDevelop\UXTable\Twig\OpenerExtension;
Expand Down Expand Up @@ -53,6 +54,11 @@ public function load(array $configs, ContainerBuilder $container): void
->setAutoconfigured(true)
;

$container->register(PageSize::class, PageSize::class)
->setAutowired(true)
->setAutoconfigured(true)
;

$container->registerForAutoconfiguration(DataProviderInterface::class)
->addTag(DataProviderInterface::class);

Expand Down
16 changes: 16 additions & 0 deletions src/Twig/Component/PageSize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace WeDevelop\UXTable\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
use WeDevelop\UXTable\Table\TableInterface;

#[AsTwigComponent(name: 'UXTable:PageSize', template: '@WeDevelopUXTable/components/PageSize.html.twig')]
final class PageSize
{
public TableInterface $table;

public array $variables = [];
}
2 changes: 1 addition & 1 deletion templates/components/Filter.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div{{ attributes }}>
{{ form_widget(this.table.formView.filter[this.filter], this.variables) }}
{{ form_widget(this.table.formView.filter[this.filter], this.variables | merge({'attr': {'form': 'wedevelop-ux-table-' ~ this.table.name}})) }}
</div>
3 changes: 3 additions & 0 deletions templates/components/PageSize.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div{{ attributes }}>
{{ form_widget(this.table.formView.pageSize, this.variables | merge({'attr': {'form': 'wedevelop-ux-table-' ~ this.table.name}})) }}
</div>
10 changes: 5 additions & 5 deletions templates/components/Table.html.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div{{ attributes }}>
<section {{ stimulus_controller('wedevelopnl/ux-table/ux-table') }}>
<turbo-frame id="ux-table-{{ this.table.name }}" data-turbo-action="advance">
{{ form_start(table.formView) }}
{% block content %}{% endblock %}
{% for field in this.preservationForm %}
{{ form_widget(field) }}
{% endfor %}
{% block content %}{% endblock %}
{{ form_start(table.formView, {'attr': {'id': 'wedevelop-ux-table-' ~ this.table.name}}) }}
{% for field in this.preservationForm %}
{{ form_widget(field) }}
{% endfor %}
{{ form_end(table.formView) }}
</turbo-frame>
</section>
Expand Down

0 comments on commit 7d56f2b

Please sign in to comment.