From c2c65a2cc25dee69d98ad186c04e6d72b85c874e Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 4 Apr 2024 10:46:53 -0400 Subject: [PATCH] Ability to share a particular map type --- app/static/app/js/components/Map.jsx | 1 + app/static/app/js/components/ShareButton.jsx | 4 +++- app/static/app/js/components/SharePopup.jsx | 13 +++++++++---- app/views/public.py | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/static/app/js/components/Map.jsx b/app/static/app/js/components/Map.jsx index 5bbd2f2f4..a807c4585 100644 --- a/app/static/app/js/components/Map.jsx +++ b/app/static/app/js/components/Map.jsx @@ -648,6 +648,7 @@ _('Example:'), ref={(ref) => { this.shareButton = ref; }} task={this.state.singleTask} linksTarget="map" + queryParams={{t: this.props.mapType}} /> : ""} ; return ( diff --git a/app/static/app/js/components/SharePopup.jsx b/app/static/app/js/components/SharePopup.jsx index b93d2902c..812f38a72 100644 --- a/app/static/app/js/components/SharePopup.jsx +++ b/app/static/app/js/components/SharePopup.jsx @@ -15,7 +15,8 @@ class SharePopup extends React.Component{ task: PropTypes.object.isRequired, linksTarget: PropTypes.oneOf(['map', '3d']).isRequired, placement: PropTypes.string, - taskChanged: PropTypes.func + taskChanged: PropTypes.func, + queryParams: PropTypes.object }; static defaultProps = { placement: 'top', @@ -38,7 +39,11 @@ class SharePopup extends React.Component{ } getRelShareLink = () => { - return `/public/task/${this.props.task.id}/${this.props.linksTarget}/`; + let url = `/public/task/${this.props.task.id}/${this.props.linksTarget}/`; + if (this.props.queryParams){ + url += Utils.toSearchQuery(this.props.queryParams); + } + return url; } componentDidMount(){ @@ -86,8 +91,8 @@ class SharePopup extends React.Component{ } render(){ - const shareLink = Utils.absoluteUrl(this.state.relShareLink); - const iframeUrl = Utils.absoluteUrl(`public/task/${this.state.task.id}/iframe/${this.props.linksTarget}/`); + const shareLink = Utils.absoluteUrl(this.getRelShareLink()); + const iframeUrl = Utils.absoluteUrl(`public/task/${this.state.task.id}/iframe/${this.props.linksTarget}/${Utils.toSearchQuery(this.props.queryParams)}`); const iframeCode = ``; return (
{ e.stopPropagation(); }} className={"sharePopup " + this.props.placement}> diff --git a/app/views/public.py b/app/views/public.py index 37ec67aae..a5ecff02a 100644 --- a/app/views/public.py +++ b/app/views/public.py @@ -29,7 +29,8 @@ def handle_map(request, template, task_pk=None, hide_title=False): 'map-items': json.dumps([task.get_map_items()]), 'title': task.name if not hide_title else '', 'public': 'true', - 'share-buttons': 'false' if settings.DESKTOP_MODE else 'true' + 'share-buttons': 'false' if settings.DESKTOP_MODE else 'true', + 'selected-map-type': request.GET.get('t', 'auto'), }.items() })