diff --git a/RELEASE.md b/RELEASE.md index ce234689f..b9309e860 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -32,6 +32,9 @@ ## Versione X.X.X (dd/mm/yyyy) +### Novità + +- Aggiunto nuovo filtro per Data di chiusura del procedimento nel blocco di ricerca Bandi ### Migliorie - Migliorata l'accessibilità del bottone "Cerca". @@ -41,6 +44,8 @@ ### Fix - Migliorato l'allineamento dei filtri nella pagina di Ricerca. +- Sistemato al cambio pagina il reset dei risultati di ricerca nei blocchi di ricerca Bandi, Eventi e UO +- Sistemato layout del menu laterale sinistro nella vista del Bando ## Versione 7.25.3 (07/03/2024) diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index d83cebfdf..9dde4767c 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -2862,6 +2862,21 @@ msgstr "" msgid "searchBlock_categoria_filter" msgstr "" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index e4de414d3..728151494 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -2847,6 +2847,21 @@ msgstr "" msgid "searchBlock_categoria_filter" msgstr "" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "Filter by process closing date" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "Closing from" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "Closing to" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index 6e8160177..48bbdc5c8 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -2856,6 +2856,21 @@ msgstr "Color de botones" msgid "searchBlock_categoria_filter" msgstr "Filtrar por Categoría" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "Filtrar por fecha de cierre del procedimiento" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "Cerrando desde" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "Cerrando a las" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index d1dd853b2..5f35a26f4 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -2864,6 +2864,21 @@ msgstr "" msgid "searchBlock_categoria_filter" msgstr "Catégorie" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "Filtrer par date de clôture de la procédure" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "Fermeture à partir de" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "Clôture à" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index baa64a41c..a63c249bd 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -2847,6 +2847,21 @@ msgstr "" msgid "searchBlock_categoria_filter" msgstr "" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/locales/volto.pot b/locales/volto.pot index 5aea0452a..eb083fcfb 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -2849,6 +2849,21 @@ msgstr "" msgid "searchBlock_categoria_filter" msgstr "" +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Filtro per data di chiusura del procedimento +msgid "searchBlock_chiusura_filter" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura dal +msgid "searchBlock_chiusura_filter_from" +msgstr "" + +#: components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters +# defaultMessage: Chiusura al +msgid "searchBlock_chiusura_filter_to" +msgstr "" + #: components/ItaliaTheme/Blocks/BandiSearch/Sidebar #: components/ItaliaTheme/Blocks/EventSearch/DefaultFilters #: components/ItaliaTheme/Blocks/EventSearch/Sidebar diff --git a/src/actions/index.js b/src/actions/index.js index c563bcc8b..6c4b4ac5d 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -14,8 +14,8 @@ import { getSearchFilters, GET_SEARCH_FILTERS } from './getSearchFilters'; import { getSearchResults, GET_SEARCH_RESULTS } from './getSearchResults'; import { getCalendarResults, GET_CALENDAR_RESULTS } from './calendarSearch'; - import { setOriginalQuery, ORIGINAL_QUERY } from './setOriginalQuery'; +import { resetQuerystringResults } from './resetQuerystringResults'; import { getCalendarDayResults, @@ -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..74c8de98d --- /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 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 3a053b1f8..c4fc46482 100644 --- a/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx +++ b/src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx @@ -13,7 +13,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({ @@ -36,7 +36,7 @@ const messages = defineMessages({ }, }); -const Body = ({ data, inEditMode, path, onChangeBlock }) => { +const Body = ({ data, id, inEditMode, path, onChangeBlock }) => { const intl = useIntl(); const b_size = 6; @@ -48,14 +48,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(); @@ -79,7 +84,9 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { }); if (data.defaultQuerystring) { - query.push(...data.defaultQuerystring.filter(el => el.i !== 'portal_type')); + query.push( + ...data.defaultQuerystring.filter((el) => el.i !== 'portal_type'), + ); } if (data.location && data.location[0]) { @@ -100,7 +107,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, ), ); @@ -120,6 +127,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/DefaultFilters.js b/src/components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters.js index ca118a6de..c936f5292 100644 --- a/src/components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters.js +++ b/src/components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters.js @@ -51,6 +51,10 @@ const messages = defineMessages({ id: 'searchBlock_scadenza_filter', defaultMessage: 'Filtro per data di scadenza del bando', }, + chiusura_filter: { + id: 'searchBlock_chiusura_filter', + defaultMessage: 'Filtro per data di chiusura del procedimento', + }, scadenza_dal: { id: 'searchBlock_scadenza_filter_from', defaultMessage: 'Scadenza dal', @@ -59,6 +63,14 @@ const messages = defineMessages({ id: 'searchBlock_scadenza_filter_to', defaultMessage: 'Scadenza al', }, + chiusura_dal: { + id: 'searchBlock_chiusura_filter_from', + defaultMessage: 'Chiusura dal', + }, + chiusura_al: { + id: 'searchBlock_chiusura_filter_to', + defaultMessage: 'Chiusura al', + }, search_keyword: { id: 'Cerca per parola chiave', defaultMessage: 'Cerca per parola chiave', @@ -103,7 +115,9 @@ const DefaultFilters = (pathSearch) => { // placeholder: intl.formatMessage(messages.tipologia), dispatch: { action: getSearchBandiFilters, - path: subsite ? flattenToAppURL(subsite['@id']) : pathSearch || '/', + path: subsite + ? flattenToAppURL(subsite['@id']) + : pathSearch || '/', stateSelector: 'searchBandiFilters', resultProp: 'tipologie', }, @@ -154,7 +168,9 @@ const DefaultFilters = (pathSearch) => { options: { dispatch: { action: getSearchBandiFilters, - path: subsite ? flattenToAppURL(subsite['@id']) : pathSearch || '/', + path: subsite + ? flattenToAppURL(subsite['@id']) + : pathSearch || '/', stateSelector: 'searchBandiFilters', resultProp: 'offices', }, @@ -182,7 +198,9 @@ const DefaultFilters = (pathSearch) => { options: { dispatch: { action: getSearchBandiFilters, - path: subsite ? flattenToAppURL(subsite['@id']) : pathSearch || '/', + path: subsite + ? flattenToAppURL(subsite['@id']) + : pathSearch || '/', stateSelector: 'searchBandiFilters', resultProp: 'subjects', }, @@ -220,7 +238,6 @@ const DefaultFilters = (pathSearch) => { endLabel: intl.formatMessage(messages.scadenza_al), }, }, - reducer: (value, state) => { return { startDate: value.start ?? state.widget.props.defaultStart, @@ -262,6 +279,65 @@ const DefaultFilters = (pathSearch) => { } }, }, + chiusura_filter: { + label: intl.formatMessage(messages.chiusura_filter), + type: 'chiusura_filter', + widget: { + component: DateFilter, + props: { + // value: { + // startDate: moment().startOf('day'), + // endDate: moment().endOf('day'), + // }, + showClearDates: true, + // defaultStart: moment().startOf('day'), + // defaultEnd: moment().endOf('day'), + isOutsideRange: () => false, + startLabel: intl.formatMessage(messages.chiusura_dal), + endLabel: intl.formatMessage(messages.chiusura_al), + }, + }, + reducer: (value, state) => { + return { + startDate: value.start ?? state.widget.props.defaultStart, + endDate: value.end ?? state.widget.props.defaultEnd, + }; + }, + query: (value, query) => { + const date_fmt = 'YYYY-MM-DD HH:mm'; + if (value?.startDate || value?.endDate) { + if (value?.startDate && !value.endDate) { + let start_v = value.startDate.clone(); + let start = start_v?.startOf('day')?.utc()?.format(date_fmt); + query.push({ + i: 'chiusura_procedimento_bando', + o: 'plone.app.querystring.operation.date.largerThan', //plone.app.querystring.operation.date.largerThan + v: start, + }); + } else if (!value?.startDate && value?.endDate) { + let end_v = value.endDate.clone(); + let end = end_v.add(1, 'd').startOf('day')?.utc().format(date_fmt); + query.push({ + i: 'chiusura_procedimento_bando', + o: 'plone.app.querystring.operation.date.lessThan', //plone.app.querystring.operation.date.lessThan + v: end, + }); + } else { + let start_v = value.startDate.clone(); + let start = start_v.startOf('day')?.utc()?.format(date_fmt); + + let end_v = value.endDate.clone(); + let end = end_v.add(1, 'd').startOf('day')?.utc()?.format(date_fmt); + + query.push({ + i: 'chiusura_procedimento_bando', + o: 'plone.app.querystring.operation.date.between', + v: [start, end], + }); + } + } + }, + }, }; }; 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; @@ -48,22 +48,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 ); }); @@ -103,7 +106,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { query: query, b_size: b_size, }, - 'events_search', + id + '_events_search', page, ), ); @@ -127,6 +130,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 }) => { )} {
0 && ( - -
- {intl.formatMessage(messages.tipologia)}: -
- - {item.tipologia_bando?.title} + {show_tipologia && + item.tipologia_bando?.title?.length > 0 && ( + +
+ {intl.formatMessage(messages.tipologia)}: +
+ + {item.tipologia_bando?.title} +
-
- )} + )} {/* Data di ultima modifica */} {show_data_ultima_modifica && item.modified && ( - +
{intl.formatMessage(messages.ultima_modifica)}:
diff --git a/src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx b/src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx index df22ad239..c1b0ad5c5 100644 --- a/src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx +++ b/src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx @@ -12,6 +12,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({ @@ -34,7 +35,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 +45,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(); @@ -90,7 +96,7 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => { query: query, b_size: b_size, }, - 'uo_search', + id + '_uo_search', page, ), ); @@ -110,6 +116,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 }) => { )} {
{ showtassonomiaargomenti={true} showbandostate={true} /> -
+