From a1a4904f02d384195b743db38a92e526de3f7c25 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 18 Oct 2024 11:50:58 +0200 Subject: [PATCH] fix: use correct icon for layer download advanced action --- umap/static/umap/img/24-white.svg | 1 + umap/static/umap/img/24.svg | 1 + umap/static/umap/img/source/24-white.svg | 5 +++-- umap/static/umap/img/source/24.svg | 5 +++-- umap/static/umap/js/modules/data/layer.js | 13 ++++++------- umap/static/umap/js/modules/share.js | 4 +--- umap/static/umap/js/modules/utils.js | 6 +++++- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/umap/static/umap/img/24-white.svg b/umap/static/umap/img/24-white.svg index 9994fb774..65379fd1e 100644 --- a/umap/static/umap/img/24-white.svg +++ b/umap/static/umap/img/24-white.svg @@ -60,5 +60,6 @@ + diff --git a/umap/static/umap/img/24.svg b/umap/static/umap/img/24.svg index 9c98ddbc2..e25615d0a 100644 --- a/umap/static/umap/img/24.svg +++ b/umap/static/umap/img/24.svg @@ -85,5 +85,6 @@ + diff --git a/umap/static/umap/img/source/24-white.svg b/umap/static/umap/img/source/24-white.svg index 186f6a2e9..e4d9fd89a 100644 --- a/umap/static/umap/img/source/24-white.svg +++ b/umap/static/umap/img/source/24-white.svg @@ -1,8 +1,8 @@ - - + + @@ -74,5 +74,6 @@ + diff --git a/umap/static/umap/img/source/24.svg b/umap/static/umap/img/source/24.svg index 9ec64a942..734401898 100644 --- a/umap/static/umap/img/source/24.svg +++ b/umap/static/umap/img/source/24.svg @@ -1,8 +1,8 @@ - - + + @@ -98,5 +98,6 @@ + diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 8af009259..795a1f7d0 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -802,13 +802,12 @@ export class DataLayer { this ) if (this.umap_id) { - const download = DomUtil.createLink( - 'button umap-download', - advancedButtons, - translate('Download'), - this._dataUrl(), - '_blank' - ) + const filename = Utils.slugify(this.options.name) + const download = Utils.loadTemplate(` + + ${translate('Download')} + `) + advancedButtons.appendChild(download) } const backButton = DomUtil.createButtonIcon( undefined, diff --git a/umap/static/umap/js/modules/share.js b/umap/static/umap/js/modules/share.js index 69a547663..144c252f0 100644 --- a/umap/static/umap/js/modules/share.js +++ b/umap/static/umap/js/modules/share.js @@ -142,9 +142,7 @@ export default class Share { async format(mode) { const type = EXPORT_FORMATS[mode] const content = await type.formatter(this.map) - let name = this.map.options.name || 'data' - name = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() - const filename = name + type.ext + const filename = Utils.slugify(this.map.options.name) + type.ext return { content, filetype: type.filetype, filename } } diff --git a/umap/static/umap/js/modules/utils.js b/umap/static/umap/js/modules/utils.js index 39dff71f6..33aeb55e7 100644 --- a/umap/static/umap/js/modules/utils.js +++ b/umap/static/umap/js/modules/utils.js @@ -407,6 +407,10 @@ export class WithTemplate { } } -export function deepEqual(object1, object2){ +export function deepEqual(object1, object2) { return JSON.stringify(object1) === JSON.stringify(object2) } + +export function slugify(str) { + return (str || 'data').replace(/[^a-z0-9]/gi, '_').toLowerCase() +}