Skip to content
Open
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
1 change: 1 addition & 0 deletions cms/contents/page/translations/sfs_cms_contents.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ admin_page:
publishedAt.header: "Published at"
filter_form:
name.label: "Name"
path.label: "Path"
sites.label: "Sites"
status.label: "Status"
publishedVersionContent.label: "Published version content (case sensitive)"
Expand Down
1 change: 1 addition & 0 deletions cms/contents/page/translations/sfs_cms_contents.es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ admin_page:
publishedAt.header: "Publicada"
filter_form:
name.label: "Nombre"
path.label: "Ruta"
sites.label: "Sitios"
status.label: "Estado"
publishedVersionContent.label: "Contenido publicado (distingue mayúsculas y minúsculas)"
Expand Down
33 changes: 32 additions & 1 deletion src/Form/Admin/Content/ContentListFilterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
use Doctrine\ORM\QueryBuilder;
use Softspring\CmsBundle\Config\CmsConfig;
use Softspring\CmsBundle\Form\Admin\SiteChoiceType;
use Softspring\CmsBundle\Model\RoutePathInterface;
use Softspring\Component\DoctrinePaginator\Form\PaginatorForm;
use Softspring\Component\DoctrinePaginator\Form\QueryBuilderProcessorInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ContentListFilterForm extends PaginatorForm
class ContentListFilterForm extends PaginatorForm implements QueryBuilderProcessorInterface
{
protected CmsConfig $cmsConfig;

Expand Down Expand Up @@ -58,6 +60,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'property_path' => '[name__like]',
]);

$builder->add('path', TextType::class, [
'required' => false,
'property_path' => '[path__like]',
]);

if (sizeof($this->cmsConfig->getSitesForContent($options['content_config']['_id'])) > 1) {
$builder->add('sites', SiteChoiceType::class, [
'required' => false,
Expand All @@ -83,4 +90,28 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'property_path' => '[publishedVersion.data__like]',
]);
}

public function preProcessQueryBuilder(QueryBuilder $qb, array &$filters, array &$orderSort, int &$filtersMode): QueryBuilder
{
$pathFilter = trim((string) ($filters['path__like'] ?? ''));
unset($filters['path__like']);

if ('' === $pathFilter) {
return $qb;
}

$alias = $qb->getDQLPart('from')[0]->getAlias();
$subQb = $this->em->createQueryBuilder();
$subQb
->select('1')
->from(RoutePathInterface::class, 'routePath')
->innerJoin('routePath.route', 'route')
->where("route.content = $alias")
->andWhere('(routePath.path LIKE :content_list_path OR routePath.compiledPath LIKE :content_list_path)');

$qb->andWhere($qb->expr()->exists($subQb->getDQL()));
$qb->setParameter('content_list_path', "%$pathFilter%");

return $qb;
}
}
1 change: 1 addition & 0 deletions templates/admin/content/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<div class="row align-items-end border shadow-sm rounded p-3 collapse show" id="collapseFilter">
{% if filterForm.name is defined %}<div class="col-12 col-md-6 col-lg-2">{{ form_row(filterForm.name) }}</div>{% endif %}
{% if filterForm.sites is defined %}<div class="col-12 col-md-6 col-lg-2">{{ form_row(filterForm.sites, {'attr':{'onchange':'submit()'}}) }}</div>{% endif %}
{% if filterForm.path is defined %}<div class="col-12 col-md-6 col-lg-3">{{ form_row(filterForm.path) }}</div>{% endif %}
{% if filterForm.status is defined %}<div class="col-12 col-md-6 col-lg-2">{{ form_row(filterForm.status, {'attr':{'onchange':'submit()'}}) }}</div>{% endif %}
{% if filterForm.publishedVersionContent is defined %}<div class="col-12 col-md-6 col-lg-4">{{ form_row(filterForm.publishedVersionContent, {'attr':{'onchange':'submit()'}}) }}</div>{% endif %}
<div class="col pb-3">
Expand Down
Loading