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

climbing: Add climbing restriction + show authors on routes #404

Merged
merged 2 commits into from
Jul 8, 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
2 changes: 2 additions & 0 deletions src/components/FeaturePanel/Climbing/ClimbingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SuggestEdit } from '../SuggestEdit';
import { PanelContent, PanelSidePadding } from '../../utils/PanelHelpers';
import { FeatureHeading } from '../FeatureHeading';
import { ParentLink } from '../ParentLink';
import { ClimbingRestriction } from './ClimbingRestriction';

export const ClimbingPanel = ({ footer, showTagsTable }) => {
const { feature } = useFeatureContext();
Expand All @@ -27,6 +28,7 @@ export const ClimbingPanel = ({ footer, showTagsTable }) => {
<PanelSidePadding>
<FeatureHeading />
<ParentLink />
<ClimbingRestriction />
</PanelSidePadding>
<ImageSlider />
<OsmError />
Expand Down
30 changes: 30 additions & 0 deletions src/components/FeaturePanel/Climbing/ClimbingRestriction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { Alert, AlertTitle } from '@mui/material';
import { useFeatureContext } from '../../utils/FeatureContext';
import { t } from '../../../services/intl';

export const ClimbingRestriction = () => {
const { feature } = useFeatureContext();
jvaclavik marked this conversation as resolved.
Show resolved Hide resolved

if (!feature.tags.climbing) {
return null;
}

const restriction = feature.tags['climbing:restriction'];
const restrictionTimeDescription =
feature.tags['climbing:restriction:time_description'];

if (!restriction && !restrictionTimeDescription) {
return null;
}

return (
<Alert
severity={restriction === 'yes' ? 'error' : 'warning'}
sx={{ mt: 2 }}
>
<AlertTitle>{t('featurepanel.climbing_restriction')}</AlertTitle>
{restrictionTimeDescription}
</Alert>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const osmToClimbingRoutes = (feature: Feature): Array<ClimbingRoute> => {
difficulty: getDifficulty(route.tags),
paths,
photoToKeyMap,
author: route.tags.author,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use feature.tags.author instead of adding a new field? We will have to move all of it nevertheless.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted but it needs broader refactoring. Right now we have temp object for editing with ClimbingRoute type, so this whole needs to be refactored.

feature: route,
};
});
Expand Down
1 change: 1 addition & 0 deletions src/components/FeaturePanel/Climbing/utils/emptyRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ClimbingRoute } from '../types';
export const emptyRoute: ClimbingRoute = {
id: '',
name: '',
author: '',
difficulty: { grade: '', gradeSystem: 'uiaa' },
length: '',
paths: {},
Expand Down
3 changes: 3 additions & 0 deletions src/components/FeaturePanel/FeaturePanelInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ImageSlider } from './ImagePane/ImageSlider';
import { SuggestEdit } from './SuggestEdit';
import { FeatureOpenPlaceGuideLink } from './FeatureOpenPlaceGuideLink';
import { CragsInArea } from './CragsInArea';
import { ClimbingRestriction } from './Climbing/ClimbingRestriction';

const Flex = styled.div`
flex: 1;
Expand Down Expand Up @@ -99,6 +100,8 @@ export const FeaturePanelInner = () => {
<FeatureHeading />
<ParentLink />

<ClimbingRestriction />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zbycz what about this? I know it shouldn't be here because it's generic FeaturePanel, but where to put it if it's for all features with climbing tag?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK to have parts of feature panel, which are rendered only sometimes.

In future we could extend FeaturedTags to accomodate this, or even extend iD tagging scheme.


<OsmError />
<CragsInArea />
</PanelSidePadding>
Expand Down
8 changes: 4 additions & 4 deletions src/components/FeaturePanel/OsmError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ export const OsmError = () => {

if (code === 'unknown') {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error_unknown')}
</Alert>
);
}

if (code === 'network') {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error_network')}
</Alert>
);
}

if (code) {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error', { code })}
</Alert>
);
}

if (Object.keys(feature.tags).length === 0 && !feature.point) {
return (
<Alert variant="outlined" severity="info">
<Alert variant="outlined" severity="info" sx={{ mb: 2 }}>
{t('featurepanel.info_no_tags')}
</Alert>
);
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default {
'featurepanel.uncertain_image': 'Je zobrazena nejbližší fotka uliční úrovně. Může ukazovat jiný objekt.',
'featurepanel.inline_edit_title': 'Upravit',
'featurepanel.objects_around': 'Objekty v okolí',
'featurepanel.climbing_restriction': 'Lezecké omezení',

'opening_hours.open': 'Otevřeno: __todayTime__',
'opening_hours.now_closed_but_today': 'Nyní zavřeno, dnes: __todayTime__',
Expand Down
1 change: 1 addition & 0 deletions src/locales/vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
'featurepanel.inline_edit_title': 'Edit',
'featurepanel.objects_around': 'Nearby objects',
'featurepanel.more_in_openplaceguide': 'More information on __instanceName__',
'featurepanel.climbing_restriction': 'Climbing restriction',

'opening_hours.open': 'Open: __todayTime__',
'opening_hours.now_closed_but_today': 'Closed now - Open __todayTime__',
Expand Down
Loading