From cde14b9052c63886994acb5787027bcb847d74e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Thu, 28 Sep 2023 13:42:43 +0200 Subject: [PATCH 1/2] IBX-6649: Added support for spell checking --- .../Resources/public/scss/_search-form.scss | 9 +++++++ .../translations/ibexa_search.en.xliff | 5 ++++ .../themes/admin/ui/search/results.html.twig | 27 +++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/bundle/Resources/public/scss/_search-form.scss b/src/bundle/Resources/public/scss/_search-form.scss index a828f1f666..d91c36521a 100644 --- a/src/bundle/Resources/public/scss/_search-form.scss +++ b/src/bundle/Resources/public/scss/_search-form.scss @@ -109,6 +109,15 @@ display: flex; } + &__spellcheck-suggestion { + font-style: italic; + font-size: $ibexa-text-font-size-small; + + a { + font-weight: bold; + } + } + .ibexa-btn--secondary.ibexa-btn { max-width: 100%; overflow: hidden; diff --git a/src/bundle/Resources/translations/ibexa_search.en.xliff b/src/bundle/Resources/translations/ibexa_search.en.xliff index bb849c2243..8dceb5d98d 100644 --- a/src/bundle/Resources/translations/ibexa_search.en.xliff +++ b/src/bundle/Resources/translations/ibexa_search.en.xliff @@ -176,6 +176,11 @@ Section key: search.section + + Did you mean "%s"? + Did you mean "%s"? + key: search.spellcheck.suggestion + Subtree Subtree diff --git a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig index 2968a53d4c..625b474554 100644 --- a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig @@ -17,10 +17,21 @@

{{ 'search.no_results.title'|trans({'%query%': form.query.vars.value})|desc('No results found for "%query%"') }}

+ {% if spellcheck is not null and spellcheck.incorrect %} +
+ {% set suggestion_link %} + + {{ spellcheck.query }} + + {% endset %} + + {{ 'search.spellcheck.suggestion'|trans|desc('Did you mean "%s"?')|e('html')|format(suggestion_link)|raw }} +
+ {% endif %}
{% for hint in no_results_hints %}
-
+
@@ -182,7 +193,19 @@ } %} {% trans_default_domain 'ibexa_search' %} {% block between_header_and_table %} - + {% if spellcheck is not null and spellcheck.incorrect %} +
+ {% set suggestion_link %} + + {{ spellcheck.query }} + + {% endset %} + + {{ 'search.spellcheck.suggestion'|trans|desc('Did you mean "%s"?')|e('html')|format(suggestion_link)|raw }} +
+ {% endif %} + + {% if form.children.search_language.vars.value != '' %} {{ 'search.in_language'|trans({ '%search_language%': form.children.search_language.vars.data.name, From c4dd925cb1984da397816366db62dde2f30a3e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Tue, 5 Dec 2023 23:47:17 +0100 Subject: [PATCH 2/2] fixup! IBX-6649: Added support for spell checking --- .../public/scss/_search-criteria-tags.scss | 1 - .../Resources/public/scss/_search-form.scss | 13 ++++++- .../translations/ibexa_search.en.xliff | 4 +-- .../admin/ui/search/criteria_tags.html.twig | 10 ++++++ .../themes/admin/ui/search/results.html.twig | 36 ++++--------------- .../admin/ui/search/spellcheck.html.twig | 13 +++++++ 6 files changed, 43 insertions(+), 34 deletions(-) create mode 100644 src/bundle/Resources/views/themes/admin/ui/search/spellcheck.html.twig diff --git a/src/bundle/Resources/public/scss/_search-criteria-tags.scss b/src/bundle/Resources/public/scss/_search-criteria-tags.scss index 4d435a3176..2e1c3062c7 100644 --- a/src/bundle/Resources/public/scss/_search-criteria-tags.scss +++ b/src/bundle/Resources/public/scss/_search-criteria-tags.scss @@ -1,5 +1,4 @@ .ibexa-search-criteria-tags { - border-bottom: calculateRem(1px) solid $ibexa-color-dark-200; padding-bottom: calculateRem(8px); &__tag { diff --git a/src/bundle/Resources/public/scss/_search-form.scss b/src/bundle/Resources/public/scss/_search-form.scss index d91c36521a..bfcadd685b 100644 --- a/src/bundle/Resources/public/scss/_search-form.scss +++ b/src/bundle/Resources/public/scss/_search-form.scss @@ -36,6 +36,11 @@ margin-top: 0; font-size: $ibexa-text-font-size-extra-large; } + + .ibexa-table-sub-header { + border-bottom: calculateRem(1px) solid $ibexa-color-dark-200; + padding-bottom: calculateRem(8px); + } } &__results-language { @@ -111,13 +116,19 @@ &__spellcheck-suggestion { font-style: italic; - font-size: $ibexa-text-font-size-small; a { + font-style: normal; font-weight: bold; } } + &__no-results { + .ibexa-search-form__spellcheck-suggestion { + color: $ibexa-color-dark-400; + } + } + .ibexa-btn--secondary.ibexa-btn { max-width: 100%; overflow: hidden; diff --git a/src/bundle/Resources/translations/ibexa_search.en.xliff b/src/bundle/Resources/translations/ibexa_search.en.xliff index 8dceb5d98d..075b566281 100644 --- a/src/bundle/Resources/translations/ibexa_search.en.xliff +++ b/src/bundle/Resources/translations/ibexa_search.en.xliff @@ -177,8 +177,8 @@ key: search.section - Did you mean "%s"? - Did you mean "%s"? + Did you mean %s? + Did you mean %s? key: search.spellcheck.suggestion diff --git a/src/bundle/Resources/views/themes/admin/ui/search/criteria_tags.html.twig b/src/bundle/Resources/views/themes/admin/ui/search/criteria_tags.html.twig index 2e41198f1e..59724d6fd9 100644 --- a/src/bundle/Resources/views/themes/admin/ui/search/criteria_tags.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/search/criteria_tags.html.twig @@ -1,6 +1,16 @@ {% trans_default_domain 'ibexa_search' %}
+ {% if form.children.search_language.vars.value != '' %} +
+
+ {{ 'search.in_language'|trans({ + '%search_language%': form.children.search_language.vars.data.name, + })|desc('in %search_language%')}} +
+
+ {% endif %} + {% if form.content_types.vars.data is not empty %} {% for content_type in form.content_types.vars.data %} {{ include('@ibexadesign/ui/search_tag.html.twig', { diff --git a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig index 625b474554..03ef057d71 100644 --- a/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/search/results.html.twig @@ -17,17 +17,9 @@

{{ 'search.no_results.title'|trans({'%query%': form.query.vars.value})|desc('No results found for "%query%"') }}

- {% if spellcheck is not null and spellcheck.incorrect %} -
- {% set suggestion_link %} - - {{ spellcheck.query }} - - {% endset %} - {{ 'search.spellcheck.suggestion'|trans|desc('Did you mean "%s"?')|e('html')|format(suggestion_link)|raw }} -
- {% endif %} + {% include '@ibexadesign/ui/search/spellcheck.html.twig' %} +
{% for hint in no_results_hints %}
@@ -193,26 +185,10 @@ } %} {% trans_default_domain 'ibexa_search' %} {% block between_header_and_table %} - {% if spellcheck is not null and spellcheck.incorrect %} -
- {% set suggestion_link %} - - {{ spellcheck.query }} - - {% endset %} - - {{ 'search.spellcheck.suggestion'|trans|desc('Did you mean "%s"?')|e('html')|format(suggestion_link)|raw }} -
- {% endif %} - - - {% if form.children.search_language.vars.value != '' %} - {{ 'search.in_language'|trans({ - '%search_language%': form.children.search_language.vars.data.name, - })|desc('in %search_language%')}} - {% endif %} - - {% include '@ibexadesign/ui/search/criteria_tags.html.twig' %} +
+ {% include '@ibexadesign/ui/search/criteria_tags.html.twig' %} + {% include '@ibexadesign/ui/search/spellcheck.html.twig' %} +
{% endblock %} {% endembed %} diff --git a/src/bundle/Resources/views/themes/admin/ui/search/spellcheck.html.twig b/src/bundle/Resources/views/themes/admin/ui/search/spellcheck.html.twig new file mode 100644 index 0000000000..76b9837c2b --- /dev/null +++ b/src/bundle/Resources/views/themes/admin/ui/search/spellcheck.html.twig @@ -0,0 +1,13 @@ +{% trans_default_domain 'ibexa_search' %} + +{% if spellcheck is not null and spellcheck.incorrect %} +
+ {% set suggestion_link %} + + {{ spellcheck.query }} + + {% endset %} + + {{ 'search.spellcheck.suggestion'|trans|desc('Did you mean %s?')|e('html')|format(suggestion_link)|raw }} +
+{% endif %}