feat: allow to star a map from query string

Some users hide the star button from their map (to keep the UI clean
I guess), but as a uMap instance administrator I may want to star it
anyway, to make it appear on the home, when using the "starred" feed,
or to save a good showcase.

That's an hidden feature, but we may use it to star a map from a
list at some point.
This commit is contained in:
Yohan Boniface 2024-07-30 11:42:15 +02:00
parent 8c7ff52f5f
commit 76606947bd

View file

@ -306,6 +306,13 @@ U.Map = L.Map.extend({
if (this.options.noControl) return if (this.options.noControl) return
if (L.Util.queryString('share')) { if (L.Util.queryString('share')) {
this.share.open() this.share.open()
} else if (L.Util.queryString('download')) {
const download_url = this.urls.get('map_download', {
map_id: this.options.umap_id,
})
window.location = download_url
} else if (L.Util.queryString('star')) {
await this.star()
} else if (this.options.onLoadPanel === 'databrowser') { } else if (this.options.onLoadPanel === 'databrowser') {
this.panel.setDefaultMode('expanded') this.panel.setDefaultMode('expanded')
this.openBrowser('data') this.openBrowser('data')
@ -331,12 +338,6 @@ U.Map = L.Map.extend({
url.searchParams.delete('edit') url.searchParams.delete('edit')
history.pushState({}, '', url) history.pushState({}, '', url)
} }
if (L.Util.queryString('download')) {
const download_url = this.urls.get('map_download', {
map_id: this.options.umap_id,
})
window.location = download_url
}
}, },
// Merge the given schema with the default one // Merge the given schema with the default one