Merge pull request #1749 from umap-project/layers-list-import-panel
fix: update layers list in import panel
This commit is contained in:
commit
e2413d1b83
2 changed files with 34 additions and 13 deletions
|
@ -64,19 +64,6 @@ U.Importer = L.Class.extend({
|
||||||
{ type: 'checkbox', name: 'clear', id: 'datalayer-clear-check' },
|
{ type: 'checkbox', name: 'clear', id: 'datalayer-clear-check' },
|
||||||
this.clearLabel
|
this.clearLabel
|
||||||
)
|
)
|
||||||
let option
|
|
||||||
this.map.eachDataLayerReverse((datalayer) => {
|
|
||||||
if (datalayer.isLoaded() && !datalayer.isRemoteLayer()) {
|
|
||||||
const id = L.stamp(datalayer)
|
|
||||||
option = L.DomUtil.add('option', '', this.layerInput, datalayer.options.name)
|
|
||||||
option.value = id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
L.DomUtil.element(
|
|
||||||
'option',
|
|
||||||
{ value: '', textContent: L._('Import in a new layer') },
|
|
||||||
this.layerInput
|
|
||||||
)
|
|
||||||
L.DomUtil.element(
|
L.DomUtil.element(
|
||||||
'option',
|
'option',
|
||||||
{ value: '', textContent: L._('Choose the data format') },
|
{ value: '', textContent: L._('Choose the data format') },
|
||||||
|
@ -123,6 +110,20 @@ U.Importer = L.Class.extend({
|
||||||
const onLoad = this.map.editPanel.open({ data: { html: this.container } })
|
const onLoad = this.map.editPanel.open({ data: { html: this.container } })
|
||||||
onLoad.then(() => {
|
onLoad.then(() => {
|
||||||
this.fileInput.value = null
|
this.fileInput.value = null
|
||||||
|
this.layerInput.innerHTML = ''
|
||||||
|
let option
|
||||||
|
this.map.eachDataLayerReverse((datalayer) => {
|
||||||
|
if (datalayer.isLoaded() && !datalayer.isRemoteLayer()) {
|
||||||
|
const id = L.stamp(datalayer)
|
||||||
|
option = L.DomUtil.add('option', '', this.layerInput, datalayer.options.name)
|
||||||
|
option.value = id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
L.DomUtil.element(
|
||||||
|
'option',
|
||||||
|
{ value: '', textContent: L._('Import in a new layer') },
|
||||||
|
this.layerInput
|
||||||
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,26 @@ from umap.models import DataLayer
|
||||||
pytestmark = pytest.mark.django_db
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
|
def test_layers_list_is_updated(live_server, tilelayer, page):
|
||||||
|
page.goto(f"{live_server.url}/map/new/")
|
||||||
|
page.get_by_role("link", name="Import data (Ctrl+I)").click()
|
||||||
|
# Should work
|
||||||
|
page.get_by_label("Choose the layer to import").select_option(
|
||||||
|
label="Import in a new layer"
|
||||||
|
)
|
||||||
|
page.get_by_role("link", name="Manage layers").click()
|
||||||
|
page.get_by_role("button", name="Add a layer").click()
|
||||||
|
page.locator('input[name="name"]').click()
|
||||||
|
page.locator('input[name="name"]').fill("foobar")
|
||||||
|
page.get_by_role("link", name="Import data (Ctrl+I)").click()
|
||||||
|
# Should still work
|
||||||
|
page.get_by_label("Choose the layer to import").select_option(
|
||||||
|
label="Import in a new layer"
|
||||||
|
)
|
||||||
|
# Now layer should be visible in the options
|
||||||
|
page.get_by_label("Choose the layer to import").select_option(label="foobar")
|
||||||
|
|
||||||
|
|
||||||
def test_umap_import_from_file(live_server, tilelayer, page):
|
def test_umap_import_from_file(live_server, tilelayer, page):
|
||||||
page.goto(f"{live_server.url}/map/new/")
|
page.goto(f"{live_server.url}/map/new/")
|
||||||
page.get_by_title("Import data").click()
|
page.get_by_title("Import data").click()
|
||||||
|
|
Loading…
Reference in a new issue