mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 20:02:36 +02:00
wip: rename presets to datasets
This commit is contained in:
parent
2c9623aff6
commit
a70307ea29
4 changed files with 15 additions and 11 deletions
|
@ -260,6 +260,7 @@ UMAP_DEFAULT_EDIT_STATUS = None
|
||||||
UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False
|
UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False
|
||||||
UMAP_HOME_FEED = "latest"
|
UMAP_HOME_FEED = "latest"
|
||||||
UMAP_EXPERIMENTAL_IMPORTERS = {
|
UMAP_EXPERIMENTAL_IMPORTERS = {
|
||||||
|
# "overpass": {"url": "https://overpass-api.de/api/interpreter"},
|
||||||
# "geodatamine": {},
|
# "geodatamine": {},
|
||||||
# "communesfr": {},
|
# "communesfr": {},
|
||||||
# "presets": {
|
# "presets": {
|
||||||
|
|
|
@ -10,9 +10,10 @@ class Autocomplete extends SingleMixin(BaseAjax) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class Importer {
|
export class Importer {
|
||||||
constructor() {
|
constructor(map, options) {
|
||||||
this.name = 'Communes'
|
this.name = options.name || 'Communes'
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(importer) {
|
async open(importer) {
|
||||||
|
@ -24,6 +25,7 @@ export class Importer {
|
||||||
textContent: "Importer les contours d'une commune française.",
|
textContent: "Importer les contours d'une commune française.",
|
||||||
})
|
})
|
||||||
const options = {
|
const options = {
|
||||||
|
placeholder: 'Commune…',
|
||||||
url: 'https://geo.api.gouv.fr/communes?nom={q}&limit=5',
|
url: 'https://geo.api.gouv.fr/communes?nom={q}&limit=5',
|
||||||
on_select: (choice) => {
|
on_select: (choice) => {
|
||||||
importer.url = `https://geo.api.gouv.fr/communes?code=${choice.item.value}&format=geojson&geometry=contour`
|
importer.url = `https://geo.api.gouv.fr/communes?code=${choice.item.value}&format=geojson&geometry=contour`
|
||||||
|
|
|
@ -3,24 +3,25 @@ import { translate } from '../i18n.js'
|
||||||
|
|
||||||
export class Importer {
|
export class Importer {
|
||||||
constructor(map, options) {
|
constructor(map, options) {
|
||||||
this.name = 'Presets'
|
this.name = options.name || 'Datasets'
|
||||||
this.choices = options?.choices
|
this.choices = options?.choices
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(importer) {
|
async open(importer) {
|
||||||
const container = DomUtil.create('div', 'formbox')
|
const container = DomUtil.create('div', 'formbox')
|
||||||
|
DomUtil.element({tagName: 'h3', textContent: this.name, parent: container})
|
||||||
const select = DomUtil.create('select', '', container)
|
const select = DomUtil.create('select', '', container)
|
||||||
const noPreset = DomUtil.element({
|
const noPreset = DomUtil.element({
|
||||||
tagName: 'option',
|
tagName: 'option',
|
||||||
parent: select,
|
parent: select,
|
||||||
value: '',
|
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)
|
const option = DomUtil.create('option', '', select)
|
||||||
option.value = preset.url
|
option.value = dataset.url
|
||||||
option.textContent = preset.label
|
option.textContent = dataset.label
|
||||||
option.dataset.format = preset.format || 'geojson'
|
option.dataset.format = dataset.format || 'geojson'
|
||||||
}
|
}
|
||||||
const confirm = () => {
|
const confirm = () => {
|
||||||
if (select.value) {
|
if (select.value) {
|
||||||
|
@ -29,11 +30,11 @@ export class Importer {
|
||||||
}
|
}
|
||||||
importer.dialog.close()
|
importer.dialog.close()
|
||||||
}
|
}
|
||||||
L.DomUtil.createButton('', container, 'OK', confirm)
|
L.DomUtil.createButton('', container, translate('Choose this dataset'), confirm)
|
||||||
|
|
||||||
importer.dialog.open({
|
importer.dialog.open({
|
||||||
content: container,
|
content: container,
|
||||||
className: 'presets dark',
|
className: 'datasets dark',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -139,7 +139,7 @@ L.DomUtil.createButtonIcon = (parent, className, title, size = 16) => {
|
||||||
|
|
||||||
L.DomUtil.createTitle = (parent, text, className, tag = 'h3') => {
|
L.DomUtil.createTitle = (parent, text, className, tag = 'h3') => {
|
||||||
const title = L.DomUtil.create(tag, '', parent)
|
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)
|
L.DomUtil.add('span', '', title, text)
|
||||||
return title
|
return title
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue