Skip to content

Commit

Permalink
fix: reset of search blocks results (#625)
Browse files Browse the repository at this point in the history
* fix: fixed reset of search blocks results

* docs: updated release.md
  • Loading branch information
SaraBianchi authored Apr 2, 2024
1 parent c5549a7 commit 17048e2
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 25 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions locales/volto.pot
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>\n"
"Language-Team: Plone i18n <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -3285,7 +3285,7 @@ msgid "search_startDate"
msgstr ""

#: helpers/Translations/searchBlockExtendedTranslations
# defaultMessage: Ricerca per: <em>{searchedtext}</em>.
# defaultMessage: Ricerca per: <em>{searchedtext}</em>.
msgid "searchedFor"
msgstr ""

Expand Down
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -61,4 +61,5 @@ export {
ORIGINAL_QUERY,
getSearchBandiFilters,
GET_SEARCH_BANDI_FILTERS,
resetQuerystringResults,
};
18 changes: 18 additions & 0 deletions src/actions/resetQuerystringResults.js
Original file line number Diff line number Diff line change
@@ -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,
};
}
18 changes: 12 additions & 6 deletions src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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,
),
);
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/components/ItaliaTheme/Blocks/BandiSearch/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => {
)}
<Body
data={data}
id={id}
path={getBaseUrl(pathname)}
inEditMode={true}
onChangeBlock={onChangeBlock}
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Blocks/BandiSearch/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const View = ({ data, id, path, properties, block }) => {
<div className="bandi-search">
<Body
data={data}
id={id}
path={getBaseUrl(path)}
properties={properties}
block={block}
Expand Down
20 changes: 12 additions & 8 deletions src/components/ItaliaTheme/Blocks/EventSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getQueryStringResults } from '@plone/volto/actions';
import { flattenToAppURL } from '@plone/volto/helpers';
import CardWithImageTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/CardWithImageTemplate';
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/EventSearch/FiltersConfig';

const messages = defineMessages({
Expand All @@ -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;

Expand All @@ -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
);
});

Expand Down Expand Up @@ -99,7 +102,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => {
query: query,
b_size: b_size,
},
'events_search',
id + '_events_search',
page,
),
);
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/components/ItaliaTheme/Blocks/EventSearch/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => {
)}
<Body
data={data}
id={id}
path={getBaseUrl(pathname)}
inEditMode={true}
onChangeBlock={onChangeBlock}
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Blocks/EventSearch/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const View = ({ data, id, path, properties, block }) => {
<div className="event-search">
<Body
data={data}
id={id}
path={getBaseUrl(path)}
properties={properties}
block={block}
Expand Down
17 changes: 12 additions & 5 deletions src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getQueryStringResults } from '@plone/volto/actions';
import { flattenToAppURL } from '@plone/volto/helpers';
import CardWithImageTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/CardWithImageTemplate';
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/UOSearch/FiltersConfig';

const messages = defineMessages({
Expand All @@ -30,7 +31,7 @@ const messages = defineMessages({
},
});

const Body = ({ data, inEditMode, path, onChangeBlock }) => {
const Body = ({ data, id, inEditMode, path, onChangeBlock }) => {
const intl = useIntl();
const b_size = 6;

Expand All @@ -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();
Expand Down Expand Up @@ -86,7 +92,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => {
query: query,
b_size: b_size,
},
'uo_search',
id + '_uo_search',
page,
),
);
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/components/ItaliaTheme/Blocks/UOSearch/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -24,6 +24,7 @@ const Edit = ({ data, block, onChangeBlock, selected, pathname }) => {
)}
<Body
data={data}
id={id}
path={getBaseUrl(pathname)}
inEditMode={true}
onChangeBlock={onChangeBlock}
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Blocks/UOSearch/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const View = ({ data, id, path, properties, block }) => {
<div className="event-search">
<Body
data={data}
id={id}
path={getBaseUrl(path)}
properties={properties}
block={block}
Expand Down

0 comments on commit 17048e2

Please sign in to comment.