From 17048e25cd467579118519d8789567b69207394e Mon Sep 17 00:00:00 2001 From: Sara Bianchi <43245702+SaraBianchi@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:08:54 +0200 Subject: [PATCH] fix: reset of search blocks results (#625) * fix: fixed reset of search blocks results * docs: updated release.md --- RELEASE.md | 1 + locales/volto.pot | 4 ++-- src/actions/index.js | 3 ++- src/actions/resetQuerystringResults.js | 18 +++++++++++++++++ .../ItaliaTheme/Blocks/BandiSearch/Body.jsx | 18 +++++++++++------ .../ItaliaTheme/Blocks/BandiSearch/Edit.jsx | 3 ++- .../ItaliaTheme/Blocks/BandiSearch/View.jsx | 1 + .../ItaliaTheme/Blocks/EventSearch/Body.jsx | 20 +++++++++++-------- .../ItaliaTheme/Blocks/EventSearch/Edit.jsx | 3 ++- .../ItaliaTheme/Blocks/EventSearch/View.jsx | 1 + .../ItaliaTheme/Blocks/UOSearch/Body.jsx | 17 +++++++++++----- .../ItaliaTheme/Blocks/UOSearch/Edit.jsx | 3 ++- .../ItaliaTheme/Blocks/UOSearch/View.jsx | 1 + 13 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 src/actions/resetQuerystringResults.js diff --git a/RELEASE.md b/RELEASE.md index 583fb3e9e..6e35caf9e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -57,6 +57,7 @@ - Sistemata la visualizzazione dei blocchi elenco all'interno del blocco griglia - L'etichetta della Card con Nastro (Blocco Elenco) non si sovrappone più all'immagine del nastro. - Aggiustato il layout della card per il CT persone quando è impostata un'immagine. +- Sistemato bug su blocchi di ricerca Bandi, Eventi e UO nei quali rimanevano memorizzati i risultati di ricerca anche se si lasciava la pagina con questi blocchi. ## Versione 11.8.0 (19/03/2024) diff --git a/locales/volto.pot b/locales/volto.pot index dc2b876cf..7f8ce3912 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2024-03-27T15:08:22.683Z\n" +"POT-Creation-Date: 2024-03-28T15:22:56.240Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -3285,7 +3285,7 @@ msgid "search_startDate" msgstr "" #: helpers/Translations/searchBlockExtendedTranslations -# defaultMessage: Ricerca per: {searchedtext}. +# defaultMessage: Ricerca per: {searchedtext}. msgid "searchedFor" msgstr "" diff --git a/src/actions/index.js b/src/actions/index.js index c563bcc8b..4c7e4676c 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -14,7 +14,7 @@ import { getSearchFilters, GET_SEARCH_FILTERS } from './getSearchFilters'; import { getSearchResults, GET_SEARCH_RESULTS } from './getSearchResults'; import { getCalendarResults, GET_CALENDAR_RESULTS } from './calendarSearch'; - +import { resetQuerystringResults } from './resetQuerystringResults'; import { setOriginalQuery, ORIGINAL_QUERY } from './setOriginalQuery'; import { @@ -61,4 +61,5 @@ export { ORIGINAL_QUERY, getSearchBandiFilters, GET_SEARCH_BANDI_FILTERS, + resetQuerystringResults, }; diff --git a/src/actions/resetQuerystringResults.js b/src/actions/resetQuerystringResults.js new file mode 100644 index 000000000..7ef3e3c66 --- /dev/null +++ b/src/actions/resetQuerystringResults.js @@ -0,0 +1,18 @@ +/* +- il reducer del type RESET_QUERYSTRING_RESULTS viene già dichiarato in Volto nel file reducers/querystringsearch/querystringsearch.js +*/ + +export const RESET_QUERYSTRING_RESULTS = 'RESET_QUERYSTRING_RESULTS'; + +/** + * Reset querystring results function. + * @function resetQuerystringResults + * @param {string} subrequest Key of the subrequest. + * @returns {Object} Search content action. + */ +export function resetQuerystringResults(subrequest = null) { + return { + type: RESET_QUERYSTRING_RESULTS, + subrequest, + }; +} diff --git a/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx b/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx index b12cef130..2c807e508 100644 --- a/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx +++ b/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx @@ -9,7 +9,7 @@ import { getQueryStringResults } from '@plone/volto/actions'; import { flattenToAppURL } from '@plone/volto/helpers'; import BandiInEvidenceTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate'; import { Pagination } from 'design-comuni-plone-theme/components/ItaliaTheme'; - +import { resetQuerystringResults } from 'design-comuni-plone-theme/actions'; import FiltersConfig from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/BandiSearch/FiltersConfig'; const messages = defineMessages({ @@ -32,7 +32,7 @@ const messages = defineMessages({ }, }); -const Body = ({ data, inEditMode, path, onChangeBlock }) => { +const Body = ({ data, id, inEditMode, path, onChangeBlock }) => { const intl = useIntl(); const b_size = 6; @@ -44,14 +44,19 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { const dispatch = useDispatch(); const querystringResults = useSelector((state) => { - return state.querystringsearch?.subrequests?.bandi_search; + return state.querystringsearch?.subrequests?.[id + '_bandi_search']; }); const items = useSelector((state) => { - return state.querystringsearch?.subrequests?.bandi_search?.items ?? []; + return ( + state.querystringsearch?.subrequests?.[id + '_bandi_search']?.items ?? [] + ); }); const loading = useSelector((state) => { - return state.querystringsearch?.subrequests?.bandi_search?.loading || false; + return ( + state.querystringsearch?.subrequests?.[id + '_bandi_search']?.loading || + false + ); }); const resultsRef = createRef(); @@ -92,7 +97,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { sort_on: data.sort_on, sort_order: data.sort_order ? 'descending' : 'ascending', }, - 'bandi_search', + id + '_bandi_search', page, ), ); @@ -112,6 +117,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { newState = { ...getInitialState(), }; + dispatch(resetQuerystringResults(id + '_bandi_search')); } else { const f = newState[action.filter]; const defaultReducer = (value, state) => value; diff --git a/src/components/ItaliaTheme/Blocks/BandiSearch/Edit.jsx b/src/components/ItaliaTheme/Blocks/BandiSearch/Edit.jsx index d8f1e5071..7495a50a2 100644 --- a/src/components/ItaliaTheme/Blocks/BandiSearch/Edit.jsx +++ b/src/components/ItaliaTheme/Blocks/BandiSearch/Edit.jsx @@ -14,7 +14,7 @@ const messages = defineMessages({ }, }); -const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { +const Edit = ({ data, id, block, onChangeBlock, selected, pathname }) => { const intl = useIntl(); return ( @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { )} {
{ +const Body = ({ data, id, inEditMode, path, onChangeBlock }) => { const intl = useIntl(); const b_size = 6; @@ -44,22 +44,25 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { const dispatch = useDispatch(); const querystringResults = useSelector((state) => { - return state.querystringsearch?.subrequests?.events_search; + return state.querystringsearch?.subrequests?.[id + '_events_search']; }); const items = useSelector((state) => { - return state.querystringsearch?.subrequests?.events_search?.items ?? []; + return ( + state.querystringsearch?.subrequests?.[id + '_events_search']?.items ?? [] + ); }); const loading = useSelector((state) => { return ( - state.querystringsearch?.subrequests?.events_search?.loading || false + state.querystringsearch?.subrequests?.[id + '_events_search']?.loading || + false ); }); const firstLoading = useSelector((state) => { return ( - !state.querystringsearch?.subrequests?.events_search?.loading && - !state.querystringsearch?.subrequests?.events_search?.loaded + !state.querystringsearch?.subrequests?.[id + '_events_search']?.loading && + !state.querystringsearch?.subrequests?.[id + '_events_search']?.loaded ); }); @@ -99,7 +102,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { query: query, b_size: b_size, }, - 'events_search', + id + '_events_search', page, ), ); @@ -123,6 +126,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { newState = { ...getInitialState(), }; + dispatch(resetQuerystringResults(id + '_events_search')); } else { const f = newState[action.filter]; const defaultReducer = (value, state) => value; diff --git a/src/components/ItaliaTheme/Blocks/EventSearch/Edit.jsx b/src/components/ItaliaTheme/Blocks/EventSearch/Edit.jsx index f7749ccbc..dd175a093 100644 --- a/src/components/ItaliaTheme/Blocks/EventSearch/Edit.jsx +++ b/src/components/ItaliaTheme/Blocks/EventSearch/Edit.jsx @@ -14,7 +14,7 @@ const messages = defineMessages({ }, }); -const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { +const Edit = ({ data, id, block, onChangeBlock, selected, pathname }) => { const intl = useIntl(); return ( @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { )} {
{ +const Body = ({ data, id, inEditMode, path, onChangeBlock }) => { const intl = useIntl(); const b_size = 6; @@ -40,14 +41,19 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { const dispatch = useDispatch(); const querystringResults = useSelector((state) => { - return state.querystringsearch?.subrequests?.uo_search; + return state.querystringsearch?.subrequests?.[id + '_uo_search']; }); const items = useSelector((state) => { - return state.querystringsearch?.subrequests?.uo_search?.items ?? []; + return ( + state.querystringsearch?.subrequests?.[id + '_uo_search']?.items ?? [] + ); }); const loading = useSelector((state) => { - return state.querystringsearch?.subrequests?.uo_search?.loading || false; + return ( + state.querystringsearch?.subrequests?.[id + '_uo_search']?.loading || + false + ); }); const resultsRef = createRef(); @@ -86,7 +92,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { query: query, b_size: b_size, }, - 'uo_search', + id + '_uo_search', page, ), ); @@ -106,6 +112,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { newState = { ...getInitialState(), }; + dispatch(resetQuerystringResults(id + '_uo_search')); } else { const f = newState[action.filter]; const defaultReducer = (value, state) => value; diff --git a/src/components/ItaliaTheme/Blocks/UOSearch/Edit.jsx b/src/components/ItaliaTheme/Blocks/UOSearch/Edit.jsx index 3b0480dae..96223efc5 100644 --- a/src/components/ItaliaTheme/Blocks/UOSearch/Edit.jsx +++ b/src/components/ItaliaTheme/Blocks/UOSearch/Edit.jsx @@ -14,7 +14,7 @@ const messages = defineMessages({ }, }); -const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { +const Edit = ({ data, id, block, onChangeBlock, selected, pathname }) => { const intl = useIntl(); return ( @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => { )} {