From 82481e4d445f0890d1f5f6113e5966176e82d4d5 Mon Sep 17 00:00:00 2001 From: iRohitSingh <61353484+iRohitSingh@users.noreply.github.com> Date: Wed, 31 Jul 2024 05:57:42 +0530 Subject: [PATCH] Fix search block showing no option select in sort on property (#5055) Co-authored-by: David Glick --- .../volto/locales/ca/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/de/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/en/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/es/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/eu/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/fi/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/fr/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/hi/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/it/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/ja/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/nl/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/pt/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/pt_BR/LC_MESSAGES/volto.po | 10 ++ .../volto/locales/ro/LC_MESSAGES/volto.po | 10 ++ packages/volto/locales/volto.pot | 10 ++ .../volto/locales/zh_CN/LC_MESSAGES/volto.po | 10 ++ packages/volto/news/5055.bugfix | 1 + .../Blocks/Search/components/SortOn.jsx | 141 +++++++++++------- .../theme/themes/pastanaga/extras/blocks.less | 6 + 19 files changed, 253 insertions(+), 55 deletions(-) create mode 100644 packages/volto/news/5055.bugfix diff --git a/packages/volto/locales/ca/LC_MESSAGES/volto.po b/packages/volto/locales/ca/LC_MESSAGES/volto.po index 97299c5c52..882f8df983 100644 --- a/packages/volto/locales/ca/LC_MESSAGES/volto.po +++ b/packages/volto/locales/ca/LC_MESSAGES/volto.po @@ -3414,6 +3414,11 @@ msgstr "Ordena" msgid "Sort on options" msgstr "Ordena les opcions" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3424,6 +3429,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/de/LC_MESSAGES/volto.po b/packages/volto/locales/de/LC_MESSAGES/volto.po index 3ae526f295..1089694cd9 100644 --- a/packages/volto/locales/de/LC_MESSAGES/volto.po +++ b/packages/volto/locales/de/LC_MESSAGES/volto.po @@ -3413,6 +3413,11 @@ msgstr "Sortieren nach" msgid "Sort on options" msgstr "Sortieroptionen" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3423,6 +3428,11 @@ msgstr "Transaktionen nach Nutzernamen, Pfad oder Datum sortieren" msgid "Sorted" msgstr "Sortiert" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/en/LC_MESSAGES/volto.po b/packages/volto/locales/en/LC_MESSAGES/volto.po index 309d263b01..29f2346b6e 100644 --- a/packages/volto/locales/en/LC_MESSAGES/volto.po +++ b/packages/volto/locales/en/LC_MESSAGES/volto.po @@ -3408,6 +3408,11 @@ msgstr "" msgid "Sort on options" msgstr "" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3418,6 +3423,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/es/LC_MESSAGES/volto.po b/packages/volto/locales/es/LC_MESSAGES/volto.po index bcd3892d27..50bc4e1924 100644 --- a/packages/volto/locales/es/LC_MESSAGES/volto.po +++ b/packages/volto/locales/es/LC_MESSAGES/volto.po @@ -3415,6 +3415,11 @@ msgstr "Ordenar por" msgid "Sort on options" msgstr "Ordenar por opciones" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3425,6 +3430,11 @@ msgstr "Ordenar transacciones por nombre de usuario, ruta o fecha" msgid "Sorted" msgstr "Ordenado" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/eu/LC_MESSAGES/volto.po b/packages/volto/locales/eu/LC_MESSAGES/volto.po index db6c019cb4..6c145f58f7 100644 --- a/packages/volto/locales/eu/LC_MESSAGES/volto.po +++ b/packages/volto/locales/eu/LC_MESSAGES/volto.po @@ -3415,6 +3415,11 @@ msgstr "Ordenazioa" msgid "Sort on options" msgstr "Ordenatu aukeren arabera" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3425,6 +3430,11 @@ msgstr "Ordenatu transakzioak erabiltzaile-izen, bide edo dataren arabera" msgid "Sorted" msgstr "Ordenatuta" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/fi/LC_MESSAGES/volto.po b/packages/volto/locales/fi/LC_MESSAGES/volto.po index a894243780..34a787d7b8 100644 --- a/packages/volto/locales/fi/LC_MESSAGES/volto.po +++ b/packages/volto/locales/fi/LC_MESSAGES/volto.po @@ -3413,6 +3413,11 @@ msgstr "Järjestys" msgid "Sort on options" msgstr "Lajittelun vaihtoehdot" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3423,6 +3428,11 @@ msgstr "Lajittele nimen, polun tai päivämäärän perusteella" msgid "Sorted" msgstr "Lajiteltu" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/fr/LC_MESSAGES/volto.po b/packages/volto/locales/fr/LC_MESSAGES/volto.po index 92c6836cb5..f50775acbd 100644 --- a/packages/volto/locales/fr/LC_MESSAGES/volto.po +++ b/packages/volto/locales/fr/LC_MESSAGES/volto.po @@ -3415,6 +3415,11 @@ msgstr "Trier sur" msgid "Sort on options" msgstr "Options de tri" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3425,6 +3430,11 @@ msgstr "Trier les transaction par utilisateur, chemin ou date" msgid "Sorted" msgstr "Trié" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/hi/LC_MESSAGES/volto.po b/packages/volto/locales/hi/LC_MESSAGES/volto.po index 7acbc22305..a6fc3900ed 100644 --- a/packages/volto/locales/hi/LC_MESSAGES/volto.po +++ b/packages/volto/locales/hi/LC_MESSAGES/volto.po @@ -3408,6 +3408,11 @@ msgstr "क्रमबद्ध करें द्वारा" msgid "Sort on options" msgstr "क्रमबद्ध करें द्वारा विकल्प" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3418,6 +3423,11 @@ msgstr "उपयोगकर्ता-नाम, पथ या तिथि द msgid "Sorted" msgstr "क्रमबद्ध किया गया" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/it/LC_MESSAGES/volto.po b/packages/volto/locales/it/LC_MESSAGES/volto.po index 11f9e88370..a00ed897bd 100644 --- a/packages/volto/locales/it/LC_MESSAGES/volto.po +++ b/packages/volto/locales/it/LC_MESSAGES/volto.po @@ -3408,6 +3408,11 @@ msgstr "Ordina per" msgid "Sort on options" msgstr "Opzioni di ordinamento" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3418,6 +3423,11 @@ msgstr "Ordina transazioni per Username, Percorso o Data" msgid "Sorted" msgstr "Ordinato" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/ja/LC_MESSAGES/volto.po b/packages/volto/locales/ja/LC_MESSAGES/volto.po index b9b6ceb98f..f6cd3cb259 100644 --- a/packages/volto/locales/ja/LC_MESSAGES/volto.po +++ b/packages/volto/locales/ja/LC_MESSAGES/volto.po @@ -3413,6 +3413,11 @@ msgstr "ソート順" msgid "Sort on options" msgstr "" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3423,6 +3428,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/nl/LC_MESSAGES/volto.po b/packages/volto/locales/nl/LC_MESSAGES/volto.po index efdef3cd6f..567f561d6d 100644 --- a/packages/volto/locales/nl/LC_MESSAGES/volto.po +++ b/packages/volto/locales/nl/LC_MESSAGES/volto.po @@ -3412,6 +3412,11 @@ msgstr "" msgid "Sort on options" msgstr "" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3422,6 +3427,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/pt/LC_MESSAGES/volto.po b/packages/volto/locales/pt/LC_MESSAGES/volto.po index d245b26dfb..2c97866879 100644 --- a/packages/volto/locales/pt/LC_MESSAGES/volto.po +++ b/packages/volto/locales/pt/LC_MESSAGES/volto.po @@ -3413,6 +3413,11 @@ msgstr "" msgid "Sort on options" msgstr "" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3423,6 +3428,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/pt_BR/LC_MESSAGES/volto.po b/packages/volto/locales/pt_BR/LC_MESSAGES/volto.po index 364922d608..1a322f378e 100644 --- a/packages/volto/locales/pt_BR/LC_MESSAGES/volto.po +++ b/packages/volto/locales/pt_BR/LC_MESSAGES/volto.po @@ -3414,6 +3414,11 @@ msgstr "Ordenado por" msgid "Sort on options" msgstr "Opções de ordenação" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3424,6 +3429,11 @@ msgstr "Ordenar transações por Nome de Usuário, Caminho ou Data" msgid "Sorted" msgstr "Ordenado" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/ro/LC_MESSAGES/volto.po b/packages/volto/locales/ro/LC_MESSAGES/volto.po index 7c203620ef..ec596db862 100644 --- a/packages/volto/locales/ro/LC_MESSAGES/volto.po +++ b/packages/volto/locales/ro/LC_MESSAGES/volto.po @@ -3408,6 +3408,11 @@ msgstr "Sortare pe" msgid "Sort on options" msgstr "Sortare pe opțiuni" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3418,6 +3423,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/volto.pot b/packages/volto/locales/volto.pot index d38fea965b..861418c388 100644 --- a/packages/volto/locales/volto.pot +++ b/packages/volto/locales/volto.pot @@ -3410,6 +3410,11 @@ msgstr "" msgid "Sort on options" msgstr "" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3420,6 +3425,11 @@ msgstr "" msgid "Sorted" msgstr "" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/locales/zh_CN/LC_MESSAGES/volto.po b/packages/volto/locales/zh_CN/LC_MESSAGES/volto.po index 50d2927f3a..a2bfa17bbc 100644 --- a/packages/volto/locales/zh_CN/LC_MESSAGES/volto.po +++ b/packages/volto/locales/zh_CN/LC_MESSAGES/volto.po @@ -3414,6 +3414,11 @@ msgstr "排序" msgid "Sort on options" msgstr "根据选项排序" +#. Default: "Sort on {value}" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sort on {value}" +msgstr "" + #. Default: "Sort transactions by User-Name, Path or Date" #: components/manage/Controlpanels/UndoControlpanel msgid "Sort transactions by User-Name, Path or Date" @@ -3424,6 +3429,11 @@ msgstr "按用户名、路径或日期对事务进行排序" msgid "Sorted" msgstr "排序" +#. Default: "Sorted on" +#: components/manage/Blocks/Search/components/SortOn +msgid "Sorted on" +msgstr "" + #. Default: "Source" #: components/manage/Blocks/HTML/Edit #: components/manage/Controlpanels/Relations/BrokenRelations diff --git a/packages/volto/news/5055.bugfix b/packages/volto/news/5055.bugfix new file mode 100644 index 0000000000..d089f7d0b4 --- /dev/null +++ b/packages/volto/news/5055.bugfix @@ -0,0 +1 @@ +Fix search block showing no option select in sort on property @iRohitSingh \ No newline at end of file diff --git a/packages/volto/src/components/manage/Blocks/Search/components/SortOn.jsx b/packages/volto/src/components/manage/Blocks/Search/components/SortOn.jsx index 01502ac685..de32097c3a 100644 --- a/packages/volto/src/components/manage/Blocks/Search/components/SortOn.jsx +++ b/packages/volto/src/components/manage/Blocks/Search/components/SortOn.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Button } from 'semantic-ui-react'; import { defineMessages, injectIntl } from 'react-intl'; import cx from 'classnames'; @@ -23,6 +22,10 @@ const messages = defineMessages({ id: 'Sort on', defaultMessage: 'Sort on', }, + sortOnButtonTitle: { + id: 'Sort on {value}', + defaultMessage: 'Sort on {value}', + }, ascending: { id: 'Ascending', defaultMessage: 'Ascending', @@ -31,6 +34,10 @@ const messages = defineMessages({ id: 'Descending', defaultMessage: 'Descending', }, + sortedOn: { + id: 'Sorted on', + defaultMessage: 'Sorted on', + }, }); const SortOn = (props) => { @@ -48,9 +55,17 @@ const SortOn = (props) => { const { sortable_indexes } = querystring; const Select = reactSelect.default; - const activeSortOn = sortOn || data?.query?.sort_on || ''; + const defaultSortOn = data?.query?.sort_on || ''; + const activeSortOn = sortOn || defaultSortOn; + + let { sortOnOptions = [] } = data; + sortOnOptions = [defaultSortOn, ...sortOnOptions]; + sortOnOptions = [...new Set(sortOnOptions)]; - const { sortOnOptions = [] } = data; + const showSelectField = sortOnOptions.length > 1; + if (!showSelectField && !activeSortOn) { + return; + } const value = { value: activeSortOn || intl.formatMessage(messages.noSelection), label: @@ -62,59 +77,75 @@ const SortOn = (props) => { return (
- - {intl.formatMessage(messages.sortOn)} - - ({ + value: k, + label: + sortable_indexes[k]?.title || + k || + intl.formatMessage(messages.noSelection), + })), + ]} + isSearchable={false} + value={value} + onChange={(data) => { + !isEditMode && setSortOn(data.value); + }} + /> + + ) : ( + + {intl.formatMessage(messages.sortedOn)} + {value.label} + + )}
- - + {activeSortOn ? ( + <> + + + + ) : null}
); }; diff --git a/packages/volto/theme/themes/pastanaga/extras/blocks.less b/packages/volto/theme/themes/pastanaga/extras/blocks.less index 8be103cb0c..099bba9913 100644 --- a/packages/volto/theme/themes/pastanaga/extras/blocks.less +++ b/packages/volto/theme/themes/pastanaga/extras/blocks.less @@ -1120,6 +1120,12 @@ div.image-upload-widget-image { flex-direction: row; align-items: center; margin-right: 0.5em; + + .sorted-label-value { + margin-right: 0.5em; + margin-left: 0.7em; + color: @lightGrey; + } } .sort-label {