Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added new date filter in bandiSearch block, fixed reset of search results and sidemenu layout #624

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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)

Expand Down
15 changes: 15 additions & 0 deletions locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions locales/volto.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
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,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,
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 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,
};
}
22 changes: 15 additions & 7 deletions src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;

Expand All @@ -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();
Expand All @@ -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]) {
Expand All @@ -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,
),
);
Expand All @@ -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;
Expand Down
84 changes: 80 additions & 4 deletions src/components/ItaliaTheme/Blocks/BandiSearch/DefaultFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
},
Expand Down Expand Up @@ -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',
},
Expand Down Expand Up @@ -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',
},
Expand Down Expand Up @@ -220,7 +238,6 @@ const DefaultFilters = (pathSearch) => {
endLabel: intl.formatMessage(messages.scadenza_al),
},
},

reducer: (value, state) => {
return {
startDate: value.start ?? state.widget.props.defaultStart,
Expand Down Expand Up @@ -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],
});
}
}
},
},
};
};

Expand Down
Loading
Loading