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

fix: use correct icon for layer download advanced action #2224

Merged
merged 1 commit into from
Oct 21, 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
1 change: 1 addition & 0 deletions umap/static/umap/img/24-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions umap/static/umap/img/24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions umap/static/umap/img/source/24-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions umap/static/umap/img/source/24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions umap/static/umap/js/modules/data/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably miss an extension?

Copy link
Member Author

Choose a reason for hiding this comment

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

Meeh, good point!

Copy link
Member Author

Choose a reason for hiding this comment

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

humm, actually, the downloaded file does have an extension. I guess because we are calling the back office, which set one. So does the download attribute still make sense ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's not the backend that sets this extension. Can it be firefox adding it, as the backend sets the content-type to `application/geo+json ?

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the content of this.options.name at this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

The name of the layer ;)

image

const download = Utils.loadTemplate(`
<a class="button" href="${this._dataUrl()}" download="${filename}">
<i class="icon icon-24 icon-download"></i>${translate('Download')}
</a>`)
advancedButtons.appendChild(download)
}
const backButton = DomUtil.createButtonIcon(
undefined,
Expand Down
4 changes: 1 addition & 3 deletions umap/static/umap/js/modules/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down
6 changes: 5 additions & 1 deletion umap/static/umap/js/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}