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

IBX-6339: As an Editor I'd like use facets to filter global search results #871

Merged
merged 3 commits into from
Sep 16, 2023
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
22 changes: 20 additions & 2 deletions src/bundle/Resources/views/themes/admin/ui/form_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@
{%- block _search_content_types_widget -%}
<div class="ibexa-content-type-selector accordion">
{%- set groups = choices -%}
{%- if terms is defined %}
{%- set groups = choices|ibexa_choices_as_facets(
terms,
(choice, term) => choice.data.identifier == term.getKey().identifier
) -%}
{%- endif -%}

{%- for group_label, group_choices in groups -%}
{% set group_id = group_label|slug %}
<div class="ibexa-content-type-selector__group accordion-item">
Expand Down Expand Up @@ -129,7 +136,11 @@

{%- block search_type_choice_widget_options -%}
<li class="ibexa-content-type-selector__item">
{{ form_widget(form[choice.value], {'attr': {'data-name': choice.label}, 'label_attr': {'class': 'checkbox-inline'}}) }}
{{ form_widget(form[choice.value], {
'attr': {'data-name': choice.label},
'label': choice.label,
'label_attr': {'class': 'checkbox-inline'}
}) }}
</li>
{%- endblock -%}

Expand Down Expand Up @@ -278,7 +289,14 @@
{%- endblock -%}

{%- block _search_section_widget -%}
{{ form_widget(form) }}
{%- if terms is defined %}
{% set choices = choices|ibexa_choices_as_facets(
terms,
(choice, term) => choice.data.id == term.getKey().id
) %}
{%- endif -%}

{{ form_widget(form, { choices: choices }) }}
{%- endblock -%}

{%- block _search_search_language_widget -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{% trans_default_domain 'ibexa_search' %}

{% set content_type_terms = null %}
{% if aggregations is defined and aggregations.has('content_types') %}
{% set content_type_terms = aggregations.get('content_types') %}
{% endif %}

{% set sections_terms = null %}
{% if aggregations is defined and aggregations.has('sections') %}
{% set sections_terms = aggregations.get('sections') %}
{% endif %}

<div class="ibexa-filters ibexa-search-form__filters">
<div class="ibexa-filters__header">
<h3 class="ibexa-filters__title">{{ 'search.filters.title'|trans|desc('Filters') }}</h3>
Expand All @@ -21,7 +31,10 @@
<select class="form-control ibexa-filters__select ibexa-filters__select--content-type" hidden>
<option class="ibexa-filters__option ibexa-filters__option--hidden" data-default="{{ 'search.any.content.type'|trans|desc('Any Content Type') }}" value="">{{ 'search.any.content.type'|trans|desc('Any Content Type') }}</option>
</select>
{{ form_widget(form.content_types, {'attr': {'class': 'ibexa-filters__select'}}) }}
{{ form_widget(form.content_types, {
'attr': {'class': 'ibexa-filters__select'},
'terms': content_type_terms
}) }}
</div>
<div class="ibexa-filters__item ibexa-filters__item--modified">
<label class="ibexa-label">{{ 'search.last.modified'|trans|desc('Last modified') }}</label>
Expand Down Expand Up @@ -64,7 +77,10 @@
{% if form.section is defined %}
<div class="ibexa-filters__item ibexa-filters__item--section">
<label class="ibexa-label">{{ 'search.section'|trans|desc('Section') }}</label>
{{ form_widget(form.section, {'attr': {'class': 'ibexa-filters__select'}}) }}
{{ form_widget(form.section, {
'attr': {'class': 'ibexa-filters__select'},
'terms': sections_terms
}) }}
</div>
{% endif %}
<div class="ibexa-filters__item ibexa-filters__item--subtree">
Expand Down