Skip to content

Commit

Permalink
feat: add a back button to importers dialog (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface authored Dec 13, 2024
2 parents fe06a0f + b578cec commit 09faa76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions umap/static/umap/js/modules/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export default class Importer extends Utils.WithTemplate {
this.TYPES = ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap']
this.IMPORTERS = []
this.loadImporters()
this.dialog = new Dialog({ className: 'importers dark' })
this.dialog = new Dialog({
className: 'importers dark',
back: () => this.showImporters(),
})
}

loadImporters() {
Expand Down Expand Up @@ -172,7 +175,7 @@ export default class Importer extends Utils.WithTemplate {
button.addEventListener('click', () => plugin.open(this))
grid.appendChild(button)
}
this.dialog.open({ template: element, cancel: false, accept: false })
this.dialog.open({ template: element, cancel: false, accept: false, back: false })
}

build() {
Expand Down
5 changes: 5 additions & 0 deletions umap/static/umap/js/modules/ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TEMPLATE = `
<form method="dialog" data-ref="form">
<ul class="buttons">
<li><i class="icon icon-16 icon-close" data-close></i></li>
<li hidden data-ref="back"><i class="icon icon-16 icon-back"></i></li>
</ul>
<h3 data-ref="message" id="${Math.round(Date.now()).toString(36)}"></h3>
<fieldset data-ref="fieldset" role="document">
Expand Down Expand Up @@ -123,6 +124,10 @@ export default class Dialog extends WithTemplate {
} else {
this.elements.template.innerHTML = dialog.template || ''
}
this.elements.back.hidden = !dialog.back
if (dialog.back) {
this.elements.back.addEventListener('click', dialog.back)
}

this.focusable = this.getFocusable()
this.hasFormData = this.elements.fieldset.elements.length > 0
Expand Down

0 comments on commit 09faa76

Please sign in to comment.