Skip to content

Commit

Permalink
Merge pull request #759 from GeotrekCE/develop
Browse files Browse the repository at this point in the history
Develop > Main / 3.10.3
  • Loading branch information
camillemonchicourt authored Aug 18, 2022
2 parents 686fe0a + 3841e8a commit 4103366
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 27 deletions.
16 changes: 14 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Changelog

3.10.2 (2022-07-13)
3.10.3 (2022-08-18)
------------------

**🚀 New features**

* Allow to provide translations for filters labels in ``config/filter.json`` (#749)

**🐛 Fixes**

* Enable emails and URL links in touristic events detail pages (#742)
* Translate dates without trying to determine the current timezone (#751)

3.10.2 (2022-07-18)
-------------------

**🐛 Fixes**

* Fix events date filter on map results of Search page (#743)
* Fix events date filter on map results of Search page (#741)
* Link to detail page on images of objects cards rather than images fullscreen (#670)

3.10.1 (2022-07-08)
Expand Down
4 changes: 3 additions & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ In json files, you can just override the primary keys you need. You have to over
- Contact information such as your name, address, phone number and email.
- Links based on the key pair `label`/`url` (can be based on translation labels for multilingual) and/or the key `informationID` whose value is equal to a flatpage identifier.

- `filter.json` to define filters to hide, their order and values (see example in https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/config/filter.json). If you want to hide some of the filter, you have to override their properties with `"display": false`.
- `filter.json` to define filters to hide, their order and values (see example in https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/config/filter.json). If you want to :
- Hide some of filters, you have to override their properties with `"display": false`.
- Change the label for some filters, you need to define `translatedKey`, and copy the values into the translation files.
The `labels` filter contains an additional `withExclude` parameter. Its default value is `true`. By setting it to `true`, the user can filter the search by excluding a label (`withExclude` only works if your version of Geotrek Admin is equal to or higher than [2.77.0](https://github.com/GeotrekCE/Geotrek-admin/releases/tag/2.77.0); please set it to `false` if this is not the case)

- `map.json` to define basemaps URL and attributions, center (y, x), default and max zoom level (see example in https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/customization/config/map.json).
Expand Down
20 changes: 10 additions & 10 deletions frontend/config/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
{
"minValue": 0,
"maxValue": 1,
"label": "0 - 1h"
"translatedKey": "search.filters.durationOptions.H:0-1"
},
{
"minValue": 1,
"maxValue": 2,
"label": "1h - 2h"
"translatedKey": "search.filters.durationOptions.H:1-2"
},
{
"minValue": 2,
"maxValue": 5,
"label": "2h - 5h"
"translatedKey": "search.filters.durationOptions.H:2-5"
},
{
"minValue": 5,
"maxValue": 10,
"label": "5h - 10h"
"translatedKey": "search.filters.durationOptions.H:5-10"
}
]
},
Expand All @@ -69,22 +69,22 @@
{
"minValue": 0,
"maxValue": 5000,
"label": "0 - 5km"
"translatedKey": "search.filters.lengthOptions.KM:0-5"
},
{
"minValue": 5000,
"maxValue": 10000,
"label": "5km - 10km"
"translatedKey": "search.filters.lengthOptions.KM:5-10"
},
{
"minValue": 10000,
"maxValue": 15000,
"label": "10km - 15km"
"translatedKey": "search.filters.lengthOptions.KM:10-15"
},
{
"minValue": 15000,
"maxValue": 50000,
"label": "15km - 50km"
"translatedKey": "search.filters.lengthOptions.KM:15-50"
}
]
},
Expand All @@ -96,12 +96,12 @@
{
"minValue": 0,
"maxValue": 500,
"label": "0 - 500m"
"translatedKey": "search.filters.ascentOptions.M:0-500"
},
{
"minValue": 500,
"maxValue": 1000,
"label": "500m - 1km"
"translatedKey": "search.filters.ascentOptions.M:500-1000"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geotrek-rando-frontend",
"version": "3.10.2",
"version": "3.10.3",
"private": true,
"scripts": {
"debug": "NODE_OPTIONS='--inspect' next ./src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,21 @@ export const DetailsDescription: React.FC<DetailsDescriptionProps> = ({
: {cities.join(', ')}
</div>
)}
{email && <div>{email}</div>}
{website && <div>{website}</div>}

{Boolean(email) && (
<div>
<a href={`mailto:${email as string}`} className="underline">
{email}
</a>
</div>
)}
{Boolean(website) && (
<div>
<a href={website} target="_blank" rel="noopener noreferrer">
{website}
</a>
</div>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,22 @@ export const DetailsPreview: React.FC<DetailsPreviewProps> = ({
{informations.date.beginDate === informations.date.endDate ? (
<FormattedMessage
id={'dates.singleDate'}
values={{ date: intl.formatDate(informations.date.beginDate) }}
values={{
date: new Intl.DateTimeFormat(intl.locale).format(
new Date(informations.date.beginDate),
),
}}
/>
) : (
<FormattedMessage
id={'dates.multipleDates'}
values={{
beginDate: intl.formatDate(informations.date.beginDate),
endDate: intl.formatDate(informations.date.endDate),
beginDate: new Intl.DateTimeFormat(intl.locale).format(
new Date(informations.date.beginDate),
),
endDate: new Intl.DateTimeFormat(intl.locale).format(
new Date(informations.date.endDate),
),
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ const Field: React.FC<Props> = ({ filterState, onSelect, hideLabel }) => {
>
<span className={`flex items-center ${option.pictogramUrl ? 'mr-1' : ''}`}>
{getIcon(option, Boolean(selectedOption))}
{option.label}
{
option.translatedKey !== undefined
? intl.formatMessage({ id: option.translatedKey })
: option.label // Deprecated: Backward compatibility
}
</span>
</button>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const ResultCard: React.FC<
} = props;
const { setHoveredCardId } = useContext(ListAndMapContext);

const intl = useIntl();
const { locale } = useIntl();
const router = useRouter();

return (
Expand Down Expand Up @@ -183,19 +183,27 @@ export const ResultCard: React.FC<
</TagContainer>
{isTouristicEvent(props) && (
<InformationContainer>
{props.informations.date && (
{props.informations.date !== undefined && (
<LocalIconInformation icon={Calendar}>
{props.informations.date.beginDate === props.informations.date.endDate ? (
<FormattedMessage
id={'dates.singleDate'}
values={{ date: intl.formatDate(props.informations.date.beginDate) }}
values={{
date: new Intl.DateTimeFormat(locale).format(
new Date(props.informations.date.beginDate),
),
}}
/>
) : (
<FormattedMessage
id={'dates.multipleDates'}
values={{
beginDate: intl.formatDate(props.informations.date.beginDate),
endDate: intl.formatDate(props.informations.date.endDate),
beginDate: new Intl.DateTimeFormat(locale).format(
new Date(props.informations.date.beginDate),
),
endDate: new Intl.DateTimeFormat(locale).format(
new Date(props.informations.date.endDate),
),
}}
/>
)}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/modules/filters/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export interface RawDuration {
// Config file interface

export interface Option {
label: string;
label?: string;
value: string;
pictogramUrl?: string;
include?: boolean;
translatedKey?: string;
}

export interface FilterWithoutType {
Expand All @@ -60,7 +61,8 @@ export interface FilterConfigWithOptions {
options: {
minValue: number;
maxValue: number;
label: string;
label?: string;
translatedKey?: string;
}[];
withExclude?: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/filters/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const adaptFilterConfigWithOptionsToFilter = (
options: filterConfigWithOptions.options.map(option => ({
value: `${option.minValue}`,
label: option.label,
translatedKey: option.translatedKey,
})),
});

Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translations/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,28 @@
"cities": "poble",
"localization": "Localització",
"duration": "Durada",
"durationOptions": {
"H:0-1": "0 - 1h",
"H:1-2": "1h - 2h",
"H:2-5": "2h - 5h",
"H:5-10": "5h - 10h"
},
"districts": "Sector",
"themes": "Temes",
"routes": "Tipus de recorregut",
"accessibilities": "Accessibilitat",
"ascent": "Denivell positiu",
"ascentOptions": {
"M:0-500": "0 - 500m",
"M:500-1000": "500m - 1km"
},
"length": "Llargada",
"lengthOptions": {
"KM:0-5": "0 - 5km",
"KM:5-10": "5km - 10km",
"KM:10-15": "10km - 15km",
"KM:15-50": "15km - 50km"
},
"structures": "Estructura",
"clearAll": "Esborrar-ho tot",
"filters": "Filtres",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,28 @@
"cities": "Gemeinde",
"localization": "Lokalisierung",
"duration": "Dauer",
"durationOptions": {
"H:0-1": "0 - 1h",
"H:1-2": "1h - 2h",
"H:2-5": "2h - 5h",
"H:5-10": "5h - 10h"
},
"districts": "Sektor",
"themes": "Themen",
"routes": "Streckentyp",
"accessibilities": "Zugänglichkeit",
"ascent": "Positiver Höhenunterschied",
"ascentOptions": {
"M:0-500": "0 - 500m",
"M:500-1000": "500m - 1km"
},
"length": "Länge",
"lengthOptions": {
"KM:0-5": "0 - 5km",
"KM:5-10": "5km - 10km",
"KM:10-15": "10km - 15km",
"KM:15-50": "15km - 50km"
},
"structures": "Struktur",
"clearAll": "Alles löschen",
"filters": "Filter",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,28 @@
"localization": "Localization",
"cities": "City",
"duration": "Duration",
"durationOptions": {
"H:0-1": "0 - 1h",
"H:1-2": "1h - 2h",
"H:2-5": "2h - 5h",
"H:5-10": "5h - 10h"
},
"districts": "District",
"themes": "Themes",
"routes": "Type",
"accessibilities": "Accessibility",
"ascent": "Ascent",
"ascentOptions": {
"M:0-500": "0 - 500m",
"M:500-1000": "500m - 1km"
},
"length": "Length",
"lengthOptions": {
"KM:0-5": "0 - 5km",
"KM:5-10": "5km - 10km",
"KM:10-15": "10km - 15km",
"KM:15-50": "15km - 50km"
},
"structures": "Structure",
"clearAll": "Clear all",
"filters": "Filters",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,28 @@
"cities": "pueblo",
"localization": "Localización",
"duration": "Duración",
"durationOptions": {
"H:0-1": "0 - 1h",
"H:1-2": "1h - 2h",
"H:2-5": "2h - 5h",
"H:5-10": "5h - 10h"
},
"districts": "Sector",
"themes": "Temas",
"routes": "Tipo de recorrido",
"accessibilities": "Accesibilidad",
"ascent": "Denivel positivo",
"ascentOptions": {
"M:0-500": "0 - 500m",
"M:500-1000": "500m - 1km"
},
"length": "Largo",
"lengthOptions": {
"KM:0-5": "0 - 5km",
"KM:5-10": "5km - 10km",
"KM:10-15": "10km - 15km",
"KM:15-50": "15km - 50km"
},
"structures": "Estructura",
"clearAll": "Borrar todo",
"filters": "Filtros",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,28 @@
"cities": "Commune",
"localization": "Localisation",
"duration": "Durée",
"durationOptions": {
"H:0-1": "0 - 1h",
"H:1-2": "1h - 2h",
"H:2-5": "2h - 5h",
"H:5-10": "5h - 10h"
},
"districts": "Secteur",
"themes": "Thèmes",
"routes": "Type de parcours",
"accessibilities": "Accessibilité",
"ascent": "Denivelé positif",
"ascentOptions": {
"M:0-500": "0 - 500m",
"M:500-1000": "500m - 1km"
},
"length": "Longueur",
"lengthOptions": {
"KM:0-5": "0 - 5km",
"KM:5-10": "5km - 10km",
"KM:10-15": "10km - 15km",
"KM:15-50": "15km - 50km"
},
"structures": "Structure",
"clearAll": "Tout effacer",
"filters": "Filtres",
Expand Down
Loading

0 comments on commit 4103366

Please sign in to comment.