backoffice: add link from map view to table view (#13764) #734

Merged
fpeters merged 1 commits from wip/13764-map-to-listing-link into main 2023-10-01 08:54:21 +02:00
3 changed files with 13 additions and 1 deletions

View File

@ -1479,6 +1479,11 @@ def test_backoffice_map(pub):
resp = resp.click('Plot on a Map')
assert 'tile.example.net/' in resp.text
# check query string is kept
resp = app.get('/backoffice/management/form-title/map?filter=all')
resp = resp.click('Management view')
assert resp.request.url.endswith('?filter=all')
def test_backoffice_geojson(pub):
create_user(pub)

View File

@ -895,8 +895,10 @@ class FormPage(Directory, TempfileDirectoryMixin):
' <li><a rel="popup" data-base-href="export-spreadsheet" data-autoclose-dialog="true" '
'href="export-spreadsheet%s">%s</a></li>'
) % (qs, self.export_data_label)
if self.formdef.geolocations:
if self.formdef.geolocations and not self.view_type == 'map':
r += htmltext(' <li><a data-base-href="map" href="map%s">%s</a></li>') % (qs, _('Plot on a Map'))
elif self.view_type == 'map':
r += htmltext(' <li><a data-base-href="./" href="./%s">%s</a></li>') % (qs, _('Management view'))
if (
'stats' in self._q_exports
and not get_publisher().has_site_option('disable-internal-statistics')

View File

@ -217,6 +217,11 @@ $(document).on('backoffice-filter-change', function(event, listing_settings) {
if (typeof(wcs_draw_graphs) !== 'undefined') {
wcs_draw_graphs();
}
} else if ($html.find('#backoffice-map').length) {
// update sidebar links query strings
$('a[data-base-href]').each(function(idx, elem) {
$(elem).attr('href', $(elem).data('base-href') + '?' + listing_settings.qs);
});
} else {
// no appropriate content, do not replace.
return;