Skip to content

Commit

Permalink
Merge pull request #547 from GeotrekCE/develop
Browse files Browse the repository at this point in the history
Develop > Main / Prepare 3.5.4
  • Loading branch information
camillemonchicourt authored Jan 20, 2022
2 parents 3492e3a + 8a021b0 commit decc652
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 20 deletions.
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

3.5.4 (2022-01-20)
------------------

**🐛 Fixes**

* Do not display empty filters (#518 by @dtrucs)
* Correctly display tags inside list descriptions items (#540 by @dtrucs)
* Sort activities by order defined in API (#539 by @dtrucs)
* Fix sitemap generation when Outdoor module is disabled (by @dtrucs)

3.5.3 (2021-12-17)
------------------

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.5.3",
"version": "3.5.4",
"private": true,
"scripts": {
"debug": "NODE_OPTIONS='--inspect' next ./src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,26 @@ const StyledListWithSteps = styled(HtmlText)`
}
& > ol > li {
counter-increment: item;
display: flex;
align-items: center;
padding-top: ${getSpacing(4)};
margin-top: ${getSpacing(4)};
${desktopOnly(css`
padding-top: ${getSpacing(10)};
margin-top: ${getSpacing(10)};
`)}
position: relative;
padding-left: ${getSpacing(12)};
}
& > ol > li:first-child {
padding: 0;
margin-top: 0;
}
& > ol > li::before {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
font-size: 14px;
content: counter(item);
border-radius: 100%;
width: ${getSpacing(6.5)};
height: ${getSpacing(6.5)};
flex: none;
margin-right: ${getSpacing(3.5)};
color: white;
background-color: ${colorPalette.redMarker};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Object {
id="details_descriptionContent"
>
<div
class="utils__HtmlText-sc-16l79i-0 DetailsDescription__StyledListWithSteps-sc-136483c-0 jgscmn djlvYe"
class="utils__HtmlText-sc-16l79i-0 DetailsDescription__StyledListWithSteps-sc-136483c-0 jgscmn kpWlwT"
>
<p>
Du parking remonter la vallée du Sélé par le sentier qui suit la rive gauche du torrent de Celse Nière. Après une longue montée en faux plat, le sentier remonte des lacets raides jusqu'à la jonction avec le sentier du refuge du Sélé (1993 m).
Expand Down Expand Up @@ -72,7 +72,7 @@ Object {
id="details_descriptionContent"
>
<div
class="utils__HtmlText-sc-16l79i-0 DetailsDescription__StyledListWithSteps-sc-136483c-0 jgscmn djlvYe"
class="utils__HtmlText-sc-16l79i-0 DetailsDescription__StyledListWithSteps-sc-136483c-0 jgscmn kpWlwT"
>
<p>
Du parking remonter la vallée du Sélé par le sentier qui suit la rive gauche du torrent de Celse Nière. Après une longue montée en faux plat, le sentier remonte des lacets raides jusqu'à la jonction avec le sentier du refuge du Sélé (1993 m).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ interface Props {
}

const ShowFilters: React.FC<Props> = ({ item, setFilterSelectedOptions, hideLabel = false }) => {
// The API can send empty item
if (item.label === '' && item.options.length === 0) {
return null;
}
return item.options.length > 10 ? (
<SelectableDropdown
key={item.id}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/modules/activities/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export const adaptActivities = (rawActivities: Partial<RawListActivity>[]): Acti
export const adaptActivitiesFilter = (
rawActivities: Partial<RawListActivity>[],
): ActivityFilter[] =>
rawActivities.filter(isCompleteRawListActivity).map(({ name, pictogram, id }) => ({
rawActivities.filter(isCompleteRawListActivity).map(({ name, pictogram, id, order = null }) => ({
name,
pictogram,
id: `${id}`,
order,
type: 'PRACTICE',
}));
17 changes: 13 additions & 4 deletions frontend/src/modules/activities/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const getActivity = async (
return adaptActivity(rawActivity);
};

const sortedActivitiesByOrder = (a: ActivityFilter, b: ActivityFilter) =>
(a.order ?? Infinity) - (b.order ?? Infinity);

export const getActivityBarContent = async (language: string): Promise<ActivityFilter[]> => {
const [rawPractices, rawTouristicContentCategories, rawOutdoorPractices, rawTouristicEvents] =
await Promise.all([
Expand All @@ -46,9 +49,15 @@ export const getActivityBarContent = async (language: string): Promise<ActivityF
]);

return [
...adaptActivitiesFilter(rawPractices.results),
...adaptOutdoorPracticesForActivities(rawOutdoorPractices ? rawOutdoorPractices.results : []),
...adaptTouristicContentCategoryList(rawTouristicContentCategories.results),
...adaptTouristicEventTypesForActivities(rawTouristicEvents ? rawTouristicEvents.results : []),
...adaptActivitiesFilter(rawPractices.results).sort(sortedActivitiesByOrder),
...adaptOutdoorPracticesForActivities(
rawOutdoorPractices ? rawOutdoorPractices.results : [],
).sort(sortedActivitiesByOrder),
...adaptTouristicContentCategoryList(rawTouristicContentCategories.results).sort(
sortedActivitiesByOrder,
),
...adaptTouristicEventTypesForActivities(
rawTouristicEvents ? rawTouristicEvents.results : [],
).sort(sortedActivitiesByOrder),
];
};
1 change: 1 addition & 0 deletions frontend/src/modules/activities/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export interface ActivityChoices {

export interface ActivityFilter extends Activity {
id: string;
order: null | number;
type: 'PRACTICE' | 'OUTDOOR_PRACTICE' | 'CATEGORY' | 'TOURISTIC_EVENT_TYPE';
}
5 changes: 3 additions & 2 deletions frontend/src/modules/outdoorPractice/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActivityFilter } from '../activities/interface';
import { OUTDOOR_ID } from '../filters/constant';
import { FilterWithoutType } from '../filters/interface';
import { OutdoorPractice, OutdoorPracticeChoices, RawOutdoorPractice } from './interface';
import { OutdoorPracticeChoices, RawOutdoorPractice } from './interface';

export const adaptOutdoorPractices = ({
rawOutdoorPractices,
Expand All @@ -23,9 +23,10 @@ export const adaptOutdoorPractices = ({
export const adaptOutdoorPracticesForActivities = (
rawOutdoorPractices: RawOutdoorPractice[],
): ActivityFilter[] =>
rawOutdoorPractices.map(({ name, id, pictogram }) => ({
rawOutdoorPractices.map(({ name, id, pictogram, order = null }) => ({
id,
name,
order,
pictogram,
type: 'OUTDOOR_PRACTICE',
}));
Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/outdoorPractice/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface RawOutdoorPractice {
id: string;
order: null | number;
sector: number;
name: string;
pictogram: string;
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/modules/touristicContentCategory/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export const adaptTouristicContentCategoryList = (
): ActivityFilter[] =>
rawToutisticContentCategories
.filter(isCompleteRawListTouristicContentCategory)
.map(({ label, pictogram, id }) => ({
.map(({ label, pictogram, id, order = null }) => ({
name: label,
pictogram,
id: `${id}`,
order,
type: 'CATEGORY',
}));

Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/touristicContentCategory/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface RawTouristicContentCategory {
id: number;
pictogram: string;
label: string;
order: null | number;
types: TouristicContentType[];
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/modules/touristicEventType/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export const adaptTouristicEventTypes = ({
export const adaptTouristicEventTypesForActivities = (
rawTouristicEventTypes: RawTouristicEventType[],
): ActivityFilter[] =>
rawTouristicEventTypes.map(({ type, id, pictogram }) => ({
rawTouristicEventTypes.map(({ type, id, pictogram, order = null }) => ({
id,
name: type,
order,
pictogram,
type: 'TOURISTIC_EVENT_TYPE',
}));
Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/touristicEventType/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface RawTouristicEventType {
id: string;
order: null | number;
type: string;
pictogram: string;
}
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/sitemap.xml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
)
.join('');

const outdoorSites = await getOutdoorSiteForLanguage(language);
const outdoorSites = getGlobalConfig().enableOutdoor
? await getOutdoorSiteForLanguage(language)
: [];
const outdoorSitesUrls = outdoorSites
.map(({ id, name }) =>
name && id
Expand All @@ -97,7 +99,9 @@ const getApiContentForLanguage = async (language: string): Promise<string> => {
)
.join('');

const outdoorCourses = await getOutdoorCourseForLanguage(language);
const outdoorCourses = getGlobalConfig().enableOutdoor
? await getOutdoorCourseForLanguage(language)
: [];
const outdoorCoursesUrls = outdoorCourses
.map(({ id, name }) =>
name && id
Expand Down

0 comments on commit decc652

Please sign in to comment.