feat: add a back button to importers dialog (#2364)
Some checks failed
Test & Docs / tests (postgresql, 3.10) (push) Has been cancelled
Test & Docs / tests (postgresql, 3.12) (push) Has been cancelled
Test & Docs / lint (push) Has been cancelled
Test & Docs / docs (push) Has been cancelled

![image](https://github.com/user-attachments/assets/99445f06-f48f-4b0b-88f6-f696e067416d)
This commit is contained in:
Yohan Boniface 2024-12-13 15:49:45 +01:00 committed by GitHub
commit 09faa763f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -64,7 +64,10 @@ export default class Importer extends Utils.WithTemplate {
this.TYPES = ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap'] this.TYPES = ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap']
this.IMPORTERS = [] this.IMPORTERS = []
this.loadImporters() this.loadImporters()
this.dialog = new Dialog({ className: 'importers dark' }) this.dialog = new Dialog({
className: 'importers dark',
back: () => this.showImporters(),
})
} }
loadImporters() { loadImporters() {
@ -172,7 +175,7 @@ export default class Importer extends Utils.WithTemplate {
button.addEventListener('click', () => plugin.open(this)) button.addEventListener('click', () => plugin.open(this))
grid.appendChild(button) grid.appendChild(button)
} }
this.dialog.open({ template: element, cancel: false, accept: false }) this.dialog.open({ template: element, cancel: false, accept: false, back: false })
} }
build() { build() {

View file

@ -6,6 +6,7 @@ const TEMPLATE = `
<form method="dialog" data-ref="form"> <form method="dialog" data-ref="form">
<ul class="buttons"> <ul class="buttons">
<li><i class="icon icon-16 icon-close" data-close></i></li> <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> </ul>
<h3 data-ref="message" id="${Math.round(Date.now()).toString(36)}"></h3> <h3 data-ref="message" id="${Math.round(Date.now()).toString(36)}"></h3>
<fieldset data-ref="fieldset" role="document"> <fieldset data-ref="fieldset" role="document">
@ -123,6 +124,10 @@ export default class Dialog extends WithTemplate {
} else { } else {
this.elements.template.innerHTML = dialog.template || '' 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.focusable = this.getFocusable()
this.hasFormData = this.elements.fieldset.elements.length > 0 this.hasFormData = this.elements.fieldset.elements.length > 0