Skip to content

Commit

Permalink
chore: make that Importer extends WithTemplate
Browse files Browse the repository at this point in the history
Another step is needed to use this.elements instead of this.qs
  • Loading branch information
yohanboniface committed Dec 2, 2024
1 parent 4d1286e commit 88ee836
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions umap/static/umap/js/modules/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Dialog from './ui/dialog.js'
import * as Utils from './utils.js'

const TEMPLATE = `
<div class="umap-upload">
<h3><i class="icon icon-16 icon-upload"></i><span>${translate('Import data')}</span></h3>
<fieldset class="formbox">
<legend class="counter">${translate('Choose data')}</legend>
Expand Down Expand Up @@ -45,10 +46,12 @@ const TEMPLATE = `
</label>
</fieldset>
<input type="button" class="button" name="submit" value="${translate('Import data')}" />
</div>
`

export default class Importer {
export default class Importer extends Utils.WithTemplate {
constructor(umap) {
super()
this._umap = umap
this.TYPES = ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap']
this.IMPORTERS = []
Expand All @@ -57,7 +60,9 @@ export default class Importer {
}

loadImporters() {
for (const [name, config] of Object.entries(this._umap.properties.importers || {})) {
for (const [name, config] of Object.entries(
this._umap.properties.importers || {}
)) {
const register = (mod) => {
this.IMPORTERS.push(new mod.Importer(this._umap, config))
}
Expand Down Expand Up @@ -168,7 +173,7 @@ export default class Importer {
})
}
this._umap.help.parse(this.container)
DomEvent.on(this.qs('[name=submit]'), 'click', this.submit, this)
this.qs('[name=submit]').addEventListener('click', () => this.submit())
DomEvent.on(this.qs('[type=file]'), 'change', this.onFileChange, this)
for (const element of this.container.querySelectorAll('[onchange]')) {
DomEvent.on(element, 'change', this.onChange, this)
Expand Down

0 comments on commit 88ee836

Please sign in to comment.