From b578ceced45663ee89d76f2ef5decdec81fef651 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 13 Dec 2024 12:27:41 +0100 Subject: [PATCH] feat: add a back button to importers dialog --- umap/static/umap/js/modules/importer.js | 7 +++++-- umap/static/umap/js/modules/ui/dialog.js | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/modules/importer.js b/umap/static/umap/js/modules/importer.js index 658a604b..02ebd340 100644 --- a/umap/static/umap/js/modules/importer.js +++ b/umap/static/umap/js/modules/importer.js @@ -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() { @@ -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() { diff --git a/umap/static/umap/js/modules/ui/dialog.js b/umap/static/umap/js/modules/ui/dialog.js index cc7d1a1e..0168fafa 100644 --- a/umap/static/umap/js/modules/ui/dialog.js +++ b/umap/static/umap/js/modules/ui/dialog.js @@ -6,6 +6,7 @@ const TEMPLATE = `

@@ -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