Merge branch 'master' into dependabot/pip/ruff-0.8.4

This commit is contained in:
David Larlet 2024-12-23 13:19:30 -05:00 committed by GitHub
commit f97e8b7691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 70 additions and 55 deletions

View file

@ -1,5 +1,5 @@
# Force rtfd to use a recent version of mkdocs # Force rtfd to use a recent version of mkdocs
mkdocs==1.6.1 mkdocs==1.6.1
pymdown-extensions==10.12 pymdown-extensions==10.13
mkdocs-material==9.5.48 mkdocs-material==9.5.48
mkdocs-static-i18n==1.2.3 mkdocs-static-i18n==1.2.3

View file

@ -1,5 +1,5 @@
# Force rtfd to use a recent version of mkdocs # Force rtfd to use a recent version of mkdocs
mkdocs==1.6.1 mkdocs==1.6.1
pymdown-extensions==10.12 pymdown-extensions==10.13
mkdocs-material==9.5.48 mkdocs-material==9.5.48
mkdocs-static-i18n==1.2.3 mkdocs-static-i18n==1.2.3

View file

@ -43,14 +43,14 @@ dependencies = [
[project.optional-dependencies] [project.optional-dependencies]
dev = [ dev = [
"hatch==1.13.0", "hatch==1.14.0",
"ruff==0.8.4", "ruff==0.8.4",
"djlint==1.36.3", "djlint==1.36.3",
"mkdocs==1.6.1", "mkdocs==1.6.1",
"mkdocs-material==9.5.48", "mkdocs-material==9.5.48",
"mkdocs-static-i18n==1.2.3", "mkdocs-static-i18n==1.2.3",
"vermin==1.6.0", "vermin==1.6.0",
"pymdown-extensions==10.12", "pymdown-extensions==10.13",
"isort==5.13.2", "isort==5.13.2",
] ]
test = [ test = [
@ -61,7 +61,7 @@ test = [
"pytest-playwright==0.6.2", "pytest-playwright==0.6.2",
"pytest-rerunfailures==15.0", "pytest-rerunfailures==15.0",
"pytest-xdist>=3.5.0,<4", "pytest-xdist>=3.5.0,<4",
"moto[s3]==5.0.21" "moto[s3]==5.0.24"
] ]
docker = [ docker = [
"uwsgi==2.0.28", "uwsgi==2.0.28",

View file

@ -0,0 +1,55 @@
export default class DropControl {
constructor(umap, leafletMap, dropzone) {
this._umap = umap
this._leafletMap = leafletMap
this.dropzone = dropzone
}
enable() {
this.controller = new AbortController()
this.dropzone.addEventListener('dragenter', (e) => this.dragenter(e), {
signal: this.controller.signal,
})
this.dropzone.addEventListener('dragover', (e) => this.dragover(e), {
signal: this.controller.signal,
})
this.dropzone.addEventListener('drop', (e) => this.drop(e), {
signal: this.controller.signal,
})
this.dropzone.addEventListener('dragleave', (e) => this.dragleave(e), {
signal: this.controller.signal,
})
}
disable() {
this.controller.abort()
}
dragenter(event) {
event.stopPropagation()
event.preventDefault()
this._leafletMap.scrollWheelZoom.disable()
this.dropzone.classList.add('umap-dragover')
}
dragover(event) {
event.stopPropagation()
event.preventDefault()
}
drop(event) {
this._leafletMap.scrollWheelZoom.enable()
this.dropzone.classList.remove('umap-dragover')
event.stopPropagation()
event.preventDefault()
const importer = this._umap.importer
importer.build()
importer.files = event.dataTransfer.files
importer.submit()
}
dragleave() {
this._leafletMap.scrollWheelZoom.enable()
this.dropzone.classList.remove('umap-dragover')
}
}

View file

@ -124,6 +124,11 @@ export default class Importer extends Utils.WithTemplate {
return this.qs('[type=file]').files return this.qs('[type=file]').files
} }
set files(files) {
this.qs('[type=file]').files = files
this.onFileChange()
}
get raw() { get raw() {
return this.qs('textarea').value return this.qs('textarea').value
} }
@ -213,11 +218,11 @@ export default class Importer extends Utils.WithTemplate {
this.qs('[name=submit').toggleAttribute('disabled', !this.canSubmit()) this.qs('[name=submit').toggleAttribute('disabled', !this.canSubmit())
} }
onFileChange(e) { onFileChange() {
let type = '' let type = ''
let newType let newType
for (const file of e.target.files) { for (const file of this.files) {
newType = U.Utils.detectFileType(file) newType = Utils.detectFileType(file)
if (!type && newType) type = newType if (!type && newType) type = newType
if (type && newType !== type) { if (type && newType !== type) {
type = '' type = ''

View file

@ -12,6 +12,7 @@ import { translate } from '../i18n.js'
import { uMapAlert as Alert } from '../../components/alerts/alert.js' import { uMapAlert as Alert } from '../../components/alerts/alert.js'
import * as Utils from '../utils.js' import * as Utils from '../utils.js'
import * as Icon from './icon.js' import * as Icon from './icon.js'
import DropControl from '../drop.js'
// Those options are not saved on the server, so they can live here // Those options are not saved on the server, so they can live here
// instead of in umap.properties // instead of in umap.properties
@ -96,7 +97,7 @@ const ControlsMixin = {
this._controls.more = new U.MoreControls() this._controls.more = new U.MoreControls()
this._controls.scale = L.control.scale() this._controls.scale = L.control.scale()
this._controls.permanentCredit = new U.PermanentCreditsControl(this) this._controls.permanentCredit = new U.PermanentCreditsControl(this)
this._umap.drop = new U.DropControl(this) this._umap.drop = new DropControl(this._umap, this, this._container)
this._controls.tilelayers = new U.TileLayerControl(this) this._controls.tilelayers = new U.TileLayerControl(this)
}, },

View file

@ -337,52 +337,6 @@ U.DrawToolbar = L.Toolbar.Control.extend({
}, },
}) })
U.DropControl = L.Class.extend({
initialize: function (map) {
this.map = map
this.dropzone = map._container
},
enable: function () {
L.DomEvent.on(this.dropzone, 'dragenter', this.dragenter, this)
L.DomEvent.on(this.dropzone, 'dragover', this.dragover, this)
L.DomEvent.on(this.dropzone, 'drop', this.drop, this)
L.DomEvent.on(this.dropzone, 'dragleave', this.dragleave, this)
},
disable: function () {
L.DomEvent.off(this.dropzone, 'dragenter', this.dragenter, this)
L.DomEvent.off(this.dropzone, 'dragover', this.dragover, this)
L.DomEvent.off(this.dropzone, 'drop', this.drop, this)
L.DomEvent.off(this.dropzone, 'dragleave', this.dragleave, this)
},
dragenter: function (event) {
L.DomEvent.stop(event)
this.map.scrollWheelZoom.disable()
this.dropzone.classList.add('umap-dragover')
},
dragover: (event) => {
L.DomEvent.stop(event)
},
drop: function (event) {
this.map.scrollWheelZoom.enable()
this.dropzone.classList.remove('umap-dragover')
L.DomEvent.stop(event)
for (const file of event.dataTransfer.files) {
this.map._umap.processFileToImport(file)
}
this.map._umap.onceDataLoaded(this.map._umap.fitDataBounds)
},
dragleave: function () {
this.map.scrollWheelZoom.enable()
this.dropzone.classList.remove('umap-dragover')
},
})
U.EditControl = L.Control.extend({ U.EditControl = L.Control.extend({
options: { options: {
position: 'topright', position: 'topright',