mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
chore: replace native confirm by our styled ones (#2193)
This commit is contained in:
commit
9828c491e3
4 changed files with 33 additions and 28 deletions
|
@ -874,18 +874,21 @@ export class DataLayer {
|
|||
|
||||
async restore(version) {
|
||||
if (!this.map.editEnabled) return
|
||||
if (!confirm(translate('Are you sure you want to restore this version?'))) return
|
||||
const [geojson, response, error] = await this.map.server.get(
|
||||
this.getVersionUrl(version)
|
||||
)
|
||||
if (!error) {
|
||||
if (geojson._storage) geojson._umap_options = geojson._storage // Retrocompat.
|
||||
if (geojson._umap_options) this.setOptions(geojson._umap_options)
|
||||
this.empty()
|
||||
if (this.isRemoteLayer()) this.fetchRemoteData()
|
||||
else this.addData(geojson)
|
||||
this.isDirty = true
|
||||
}
|
||||
this.map.dialog
|
||||
.confirm(translate('Are you sure you want to restore this version?'))
|
||||
.then(async () => {
|
||||
const [geojson, response, error] = await this.map.server.get(
|
||||
this.getVersionUrl(version)
|
||||
)
|
||||
if (!error) {
|
||||
if (geojson._storage) geojson._umap_options = geojson._storage // Retrocompat.
|
||||
if (geojson._umap_options) this.setOptions(geojson._umap_options)
|
||||
this.empty()
|
||||
if (this.isRemoteLayer()) this.fetchRemoteData()
|
||||
else this.addData(geojson)
|
||||
this.isDirty = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
featuresToGeoJSON() {
|
||||
|
@ -1160,8 +1163,11 @@ export class DataLayer {
|
|||
'click',
|
||||
function () {
|
||||
if (!this.isVisible()) return
|
||||
if (!confirm(translate('Are you sure you want to delete this layer?'))) return
|
||||
this._delete()
|
||||
this.map.dialog
|
||||
.confirm(translate('Are you sure you want to delete this layer?'))
|
||||
.then(() => {
|
||||
this._delete()
|
||||
})
|
||||
},
|
||||
this
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ L.Map.mergeOptions({
|
|||
// we cannot rely on this because of the y is overriden by Leaflet
|
||||
// See https://github.com/Leaflet/Leaflet/pull/9201
|
||||
// And let's remove this -y when this PR is merged and released.
|
||||
demoTileInfos: { 's': 'a', 'z': 9, 'x': 265, 'y': 181, '-y': 181, 'r': '' },
|
||||
demoTileInfos: { s: 'a', z: 9, x: 265, y: 181, '-y': 181, r: '' },
|
||||
licences: [],
|
||||
licence: '',
|
||||
enableMarkerDraw: true,
|
||||
|
@ -1658,13 +1658,13 @@ U.Map = L.Map.extend({
|
|||
},
|
||||
|
||||
clone: async function () {
|
||||
if (
|
||||
confirm(L._('Are you sure you want to clone this map and all its datalayers?'))
|
||||
) {
|
||||
const url = this.urls.get('map_clone', { map_id: this.options.umap_id })
|
||||
const [data, response, error] = await this.server.post(url)
|
||||
if (data.redirect) window.location = data.redirect
|
||||
}
|
||||
this.dialog
|
||||
.confirm(L._('Are you sure you want to clone this map and all its datalayers?'))
|
||||
.then(async () => {
|
||||
const url = this.urls.get('map_clone', { map_id: this.options.umap_id })
|
||||
const [data, response, error] = await this.server.post(url)
|
||||
if (data.redirect) window.location = data.redirect
|
||||
})
|
||||
},
|
||||
|
||||
removeDataLayers: function () {
|
||||
|
|
|
@ -60,12 +60,11 @@ def test_cancel_deleting_datalayer_should_restore(
|
|||
expect(layers).to_have_count(1)
|
||||
expect(markers).to_have_count(1)
|
||||
page.get_by_role("link", name="Manage layers").click()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.locator(".panel.right").get_by_title("Delete layer").click()
|
||||
page.get_by_role("button", name="OK").click()
|
||||
expect(markers).to_have_count(0)
|
||||
page.get_by_role("button", name="Open browser").click()
|
||||
expect(page.get_by_text("test datalayer")).to_be_hidden()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.get_by_role("button", name="Cancel edits").click()
|
||||
page.locator("dialog").get_by_role("button", name="OK").click()
|
||||
expect(markers).to_have_count(1)
|
||||
|
@ -174,8 +173,8 @@ def test_can_restore_version(live_server, openmap, page, datalayer):
|
|||
page.get_by_role("link", name="Manage layers").click()
|
||||
page.locator(".panel.right").get_by_title("Edit", exact=True).click()
|
||||
page.get_by_text("Versions").click()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.get_by_role("button", name="Restore this version").last.click()
|
||||
page.get_by_role("button", name="OK").click()
|
||||
expect(marker).to_have_class(re.compile(".*umap-ball-icon.*"))
|
||||
|
||||
|
||||
|
@ -196,8 +195,8 @@ def test_deleting_datalayer_should_remove_from_browser_and_layers_list(
|
|||
page.get_by_role("link", name="Manage layers").click()
|
||||
expect(panel.get_by_text("test datalayer")).to_be_visible()
|
||||
expect(edit_panel.get_by_text("test datalayer")).to_be_visible()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.locator(".panel.right").get_by_title("Delete layer").click()
|
||||
page.get_by_role("button", name="OK").click()
|
||||
expect(panel.get_by_text("test datalayer")).to_be_hidden()
|
||||
expect(edit_panel.get_by_text("test datalayer")).to_be_hidden()
|
||||
|
||||
|
@ -210,6 +209,6 @@ def test_deleting_datalayer_should_remove_from_caption(
|
|||
page.get_by_role("button", name="About").click()
|
||||
page.get_by_role("link", name="Manage layers").click()
|
||||
expect(panel.get_by_text("test datalayer")).to_be_visible()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.locator(".panel.right").get_by_title("Delete layer").click()
|
||||
page.get_by_role("button", name="OK").click()
|
||||
expect(panel.get_by_text("test datalayer")).to_be_hidden()
|
||||
|
|
|
@ -234,8 +234,8 @@ def test_can_delete_datalayer(live_server, map, login, datalayer):
|
|||
expect(layers).to_have_count(1)
|
||||
expect(markers).to_have_count(1)
|
||||
page.get_by_role("link", name="Manage layers").click()
|
||||
page.once("dialog", lambda dialog: dialog.accept())
|
||||
page.locator(".panel.right").get_by_title("Delete layer").click()
|
||||
page.get_by_role("button", name="OK").click()
|
||||
with page.expect_response(re.compile(r".*/datalayer/delete/.*")):
|
||||
page.get_by_role("button", name="Save").click()
|
||||
expect(markers).to_have_count(0)
|
||||
|
|
Loading…
Reference in a new issue