wip: rename presets to datasets

This commit is contained in:
Yohan Boniface 2024-06-11 11:01:42 +02:00
parent 2c9623aff6
commit a70307ea29
4 changed files with 15 additions and 11 deletions

View file

@ -260,6 +260,7 @@ UMAP_DEFAULT_EDIT_STATUS = None
UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False
UMAP_HOME_FEED = "latest"
UMAP_EXPERIMENTAL_IMPORTERS = {
# "overpass": {"url": "https://overpass-api.de/api/interpreter"},
# "geodatamine": {},
# "communesfr": {},
# "presets": {

View file

@ -10,9 +10,10 @@ class Autocomplete extends SingleMixin(BaseAjax) {
}
}
export class Importer {
constructor() {
this.name = 'Communes'
constructor(map, options) {
this.name = options.name || 'Communes'
}
async open(importer) {
@ -24,6 +25,7 @@ export class Importer {
textContent: "Importer les contours d'une commune française.",
})
const options = {
placeholder: 'Commune…',
url: 'https://geo.api.gouv.fr/communes?nom={q}&limit=5',
on_select: (choice) => {
importer.url = `https://geo.api.gouv.fr/communes?code=${choice.item.value}&format=geojson&geometry=contour`

View file

@ -3,24 +3,25 @@ import { translate } from '../i18n.js'
export class Importer {
constructor(map, options) {
this.name = 'Presets'
this.name = options.name || 'Datasets'
this.choices = options?.choices
}
async open(importer) {
const container = DomUtil.create('div', 'formbox')
DomUtil.element({tagName: 'h3', textContent: this.name, parent: container})
const select = DomUtil.create('select', '', container)
const noPreset = DomUtil.element({
tagName: 'option',
parent: select,
value: '',
textContent: translate('Choose a preset'),
textContent: translate('Choose a dataset'),
})
for (const preset of this.choices) {
for (const dataset of this.choices) {
const option = DomUtil.create('option', '', select)
option.value = preset.url
option.textContent = preset.label
option.dataset.format = preset.format || 'geojson'
option.value = dataset.url
option.textContent = dataset.label
option.dataset.format = dataset.format || 'geojson'
}
const confirm = () => {
if (select.value) {
@ -29,11 +30,11 @@ export class Importer {
}
importer.dialog.close()
}
L.DomUtil.createButton('', container, 'OK', confirm)
L.DomUtil.createButton('', container, translate('Choose this dataset'), confirm)
importer.dialog.open({
content: container,
className: 'presets dark',
className: 'datasets dark',
})
}
}

View file

@ -139,7 +139,7 @@ L.DomUtil.createButtonIcon = (parent, className, title, size = 16) => {
L.DomUtil.createTitle = (parent, text, className, tag = 'h3') => {
const title = L.DomUtil.create(tag, '', parent)
L.DomUtil.createIcon(title, className)
if (className) L.DomUtil.createIcon(title, className)
L.DomUtil.add('span', '', title, text)
return title
}