Skip to content

Commit

Permalink
IBX-6339: As an editor I'd like use facets to filter global search re…
Browse files Browse the repository at this point in the history
…sults
  • Loading branch information
adamwojs committed Sep 5, 2023
1 parent f23997b commit 436e044
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
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
Expand Up @@ -21,7 +21,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': aggregations.get('content_types')
}) }}
</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 +67,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': aggregations.get('sections')
}) }}
</div>
{% endif %}
<div class="ibexa-filters__item ibexa-filters__item--subtree">
Expand Down

0 comments on commit 436e044

Please sign in to comment.