Compare commits

...

16 commits

Author SHA1 Message Date
Stefan Warnat
d7717c2291
Merge fa82f8ef0a into 4dd50690b1 2025-02-11 08:56:23 -05:00
Yohan Boniface
4dd50690b1
chore: bump ruff from 0.9.3 to 0.9.6 (#2499) 2025-02-11 12:16:20 +01:00
Yohan Boniface
f0e87bab83
Fix broken showLabel=null (on hover) (#2490)
Broken since c27e675152
2025-02-11 12:14:52 +01:00
dependabot[bot]
238de28098
chore: bump ruff from 0.9.3 to 0.9.6
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.3 to 0.9.6.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/0.9.3...0.9.6)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 10:58:25 +00:00
Yohan Boniface
c5467e42d5
chore: bump mkdocs-material from 9.5.50 to 9.6.3 (#2496) 2025-02-11 11:57:17 +01:00
Yohan Boniface
14c388b063
chore: bump pytest-django from 4.9.0 to 4.10.0 (#2495) 2025-02-11 11:56:39 +01:00
Yohan Boniface
e3c5acd52b
chore: bump moto[s3] from 5.0.27 to 5.0.28 (#2498) 2025-02-11 11:56:08 +01:00
Yohan Boniface
c044afb43d
chore: bump django from 5.1.5 to 5.1.6 (#2497) 2025-02-11 11:55:36 +01:00
Yohan Boniface
c5417178c4 fix: "null" value was not honoured in showLabel field 2025-02-11 11:48:01 +01:00
dependabot[bot]
cfef25748b
chore: bump moto[s3] from 5.0.27 to 5.0.28
Bumps [moto[s3]](https://github.com/getmoto/moto) from 5.0.27 to 5.0.28.
- [Release notes](https://github.com/getmoto/moto/releases)
- [Changelog](https://github.com/getmoto/moto/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getmoto/moto/compare/5.0.27...5.0.28)

---
updated-dependencies:
- dependency-name: moto[s3]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 17:06:37 +00:00
dependabot[bot]
6c835622c0
chore: bump django from 5.1.5 to 5.1.6
Bumps [django](https://github.com/django/django) from 5.1.5 to 5.1.6.
- [Commits](https://github.com/django/django/compare/5.1.5...5.1.6)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 17:06:31 +00:00
dependabot[bot]
62e23ac49b
chore: bump mkdocs-material from 9.5.50 to 9.6.3
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.50 to 9.6.3.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.50...9.6.3)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 17:06:26 +00:00
dependabot[bot]
a78cdd227e
chore: bump pytest-django from 4.9.0 to 4.10.0
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.9.0 to 4.10.0.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst)
- [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.9.0...v4.10.0)

---
updated-dependencies:
- dependency-name: pytest-django
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 17:06:20 +00:00
Yohan Boniface
64068af393 fix: do not save "null" instead of null for showLabel 2025-02-07 21:56:02 +01:00
Yohan Boniface
6793a6bdc7 fix: do not modify schema while iterating on it 2025-02-07 21:50:11 +01:00
Stefan Warnat
fa82f8ef0a feat(helm): custom template support with helm charts 2024-12-30 14:42:18 +00:00
11 changed files with 102 additions and 35 deletions

View file

@ -0,0 +1,12 @@
{{ if .Values.umap.templates}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "umap.fullname" . }}-templates
labels:
{{- include "umap.labels" . | nindent 4 }}
data:
{{- range $k, $v := .Values.umap.templates }}
{{ $k }}: {{ $v | quote }}
{{- end }}
{{end}}

View file

@ -13,6 +13,7 @@ spec:
metadata: metadata:
annotations: annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret-config.yaml") . | sha256sum }} checksum/config: {{ include (print $.Template.BasePath "/secret-config.yaml") . | sha256sum }}
checksum/templates: {{ include (print $.Template.BasePath "/configmap-templates.yaml") . | sha256sum }}
checksum/env: {{ include (print $.Template.BasePath "/secret-env.yaml") . | sha256sum }} checksum/env: {{ include (print $.Template.BasePath "/secret-env.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }} {{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
@ -77,6 +78,14 @@ spec:
- name: data - name: data
mountPath: /srv/umap/uploads/ mountPath: /srv/umap/uploads/
{{- end }} {{- end }}
{{- if .Values.umap.templates}}
{{- range $k, $v := .Values.umap.templates }}
- name: templates
mountPath: /venv/lib/python3.11/site-packages/umap/templates/umap/{{- $k }}
subPath: {{ $k }}
{{- end }}
{{- end }}
volumes: volumes:
- name: config - name: config
secret: secret:
@ -88,6 +97,12 @@ spec:
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ include "umap.pvcName" . }} claimName: {{ include "umap.pvcName" . }}
{{- end }} {{- end }}
{{- if .Values.umap.templates}}
- name: templates
configMap:
name: {{ include "umap.fullname" . }}-templates
{{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}

View file

@ -77,6 +77,17 @@ umap:
SECRET_KEY: CHANGE_ME SECRET_KEY: CHANGE_ME
STATIC_ROOT: /srv/umap/static STATIC_ROOT: /srv/umap/static
MEDIA_ROOT: /srv/umap/uploads MEDIA_ROOT: /srv/umap/uploads
templates: {}
# Overwrite templates like footer.html or header.html
# footer.html: |
# <a href="/imprint">Imprint</a>
# header.html: |
# custom Header
#
# It is not recommended to overwrite other templates!
# list of templates: https://github.com/umap-project/umap/tree/master/umap/templates/umap
# You can also provide umap.conf content here: # You can also provide umap.conf content here:
config: | config: |
from umap.settings.base import * from umap.settings.base import *

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.14.3 pymdown-extensions==10.14.3
mkdocs-material==9.5.50 mkdocs-material==9.6.3
mkdocs-static-i18n==1.3.0 mkdocs-static-i18n==1.3.0

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.14.3 pymdown-extensions==10.14.3
mkdocs-material==9.5.50 mkdocs-material==9.6.3
mkdocs-static-i18n==1.3.0 mkdocs-static-i18n==1.3.0

View file

@ -28,7 +28,7 @@ classifiers = [
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
] ]
dependencies = [ dependencies = [
"Django==5.1.5", "Django==5.1.6",
"django-agnocomplete==2.2.0", "django-agnocomplete==2.2.0",
"django-environ==0.12.0", "django-environ==0.12.0",
"django-probes==1.7.0", "django-probes==1.7.0",
@ -44,10 +44,10 @@ dependencies = [
[project.optional-dependencies] [project.optional-dependencies]
dev = [ dev = [
"hatch==1.14.0", "hatch==1.14.0",
"ruff==0.9.3", "ruff==0.9.6",
"djlint==1.36.4", "djlint==1.36.4",
"mkdocs==1.6.1", "mkdocs==1.6.1",
"mkdocs-material==9.5.50", "mkdocs-material==9.6.3",
"mkdocs-static-i18n==1.3.0", "mkdocs-static-i18n==1.3.0",
"vermin==1.6.0", "vermin==1.6.0",
"pymdown-extensions==10.14.3", "pymdown-extensions==10.14.3",
@ -58,11 +58,11 @@ test = [
"factory-boy==3.3.3", "factory-boy==3.3.3",
"playwright>=1.39", "playwright>=1.39",
"pytest==8.3.4", "pytest==8.3.4",
"pytest-django==4.9.0", "pytest-django==4.10.0",
"pytest-playwright==0.7.0", "pytest-playwright==0.7.0",
"pytest-rerunfailures==15.0", "pytest-rerunfailures==15.0",
"pytest-xdist>=3.5.0,<4", "pytest-xdist>=3.5.0,<4",
"moto[s3]==5.0.27" "moto[s3]==5.0.28"
] ]
docker = [ docker = [
"uwsgi==2.0.28", "uwsgi==2.0.28",

View file

@ -63,7 +63,7 @@ export class Form extends Utils.WithEvents {
try { try {
value = value[sub] value = value[sub]
} catch { } catch {
console.log(field) console.debug(field)
} }
} }
return value return value
@ -142,49 +142,50 @@ export class MutatingForm extends Form {
slugKey: 'PropertyInput', slugKey: 'PropertyInput',
labelKey: 'PropertyInput', labelKey: 'PropertyInput',
} }
for (const [key, schema] of Object.entries(SCHEMA)) { for (const [key, defaults] of Object.entries(SCHEMA)) {
if (schema.type === Boolean) { const properties = Object.assign({}, defaults)
if (schema.nullable) schema.handler = 'NullableChoices' if (properties.type === Boolean) {
else schema.handler = 'Switch' if (properties.nullable) properties.handler = 'NullableChoices'
} else if (schema.type === 'Text') { else properties.handler = 'Switch'
schema.handler = 'Textarea' } else if (properties.type === 'Text') {
} else if (schema.type === Number) { properties.handler = 'Textarea'
if (schema.step) schema.handler = 'Range' } else if (properties.type === Number) {
else schema.handler = 'IntInput' if (properties.step) properties.handler = 'Range'
} else if (schema.choices) { else properties.handler = 'IntInput'
const text_length = schema.choices.reduce( } else if (properties.choices) {
const text_length = properties.choices.reduce(
(acc, [_, label]) => acc + label.length, (acc, [_, label]) => acc + label.length,
0 0
) )
// Try to be smart and use MultiChoice only // Try to be smart and use MultiChoice only
// for choices where labels are shorts… // for choices where labels are shorts…
if (text_length < 40) { if (text_length < 40) {
schema.handler = 'MultiChoice' properties.handler = 'MultiChoice'
} else { } else {
schema.handler = 'Select' properties.handler = 'Select'
schema.selectOptions = schema.choices properties.selectOptions = properties.choices
} }
} else { } else {
switch (key) { switch (key) {
case 'color': case 'color':
case 'fillColor': case 'fillColor':
schema.handler = 'ColorPicker' properties.handler = 'ColorPicker'
break break
case 'iconUrl': case 'iconUrl':
schema.handler = 'IconUrl' properties.handler = 'IconUrl'
break break
case 'licence': case 'licence':
schema.handler = 'LicenceChooser' properties.handler = 'LicenceChooser'
break break
} }
} }
if (customHandlers[key]) { if (customHandlers[key]) {
schema.handler = customHandlers[key] properties.handler = customHandlers[key]
} }
// Input uses this key for its type attribute // Input uses this key for its type attribute
delete schema.type delete properties.type
this.defaultProperties[key] = schema this.defaultProperties[key] = properties
} }
} }
@ -202,7 +203,7 @@ export class MutatingForm extends Form {
getTemplate(helper) { getTemplate(helper) {
let template let template
if (helper.properties.inheritable) { if (helper.properties.inheritable) {
const extraClassName = helper.get(true) === undefined ? ' undefined' : '' const extraClassName = this.getter(helper.field) === undefined ? ' undefined' : ''
template = ` template = `
<div class="umap-field-${helper.name} formbox inheritable${extraClassName}"> <div class="umap-field-${helper.name} formbox inheritable${extraClassName}">
<div class="header" data-ref=header> <div class="header" data-ref=header>

View file

@ -80,11 +80,13 @@ class BaseElement {
this.input.value = '' this.input.value = ''
} }
get(own) { get() {
if (!this.properties.inheritable || own) return this.builder.getter(this.field) if (!this.properties.inheritable) return this.builder.getter(this.field)
const path = this.field.split('.') const path = this.field.split('.')
const key = path[path.length - 1] const key = path[path.length - 1]
return this.obj.getOption(key) || SCHEMA[key]?.default const value = this.obj.getOption(key)
if (value === undefined) return SCHEMA[key]?.default
return value
} }
toHTML() { toHTML() {
@ -1164,7 +1166,7 @@ Fields.MultiChoice = class extends BaseElement {
Fields.TernaryChoices = class extends Fields.MultiChoice { Fields.TernaryChoices = class extends Fields.MultiChoice {
getDefault() { getDefault() {
return 'null' return null
} }
toJS() { toJS() {
@ -1195,7 +1197,7 @@ Fields.NullableChoices = class extends Fields.TernaryChoices {
this.properties.choices || [ this.properties.choices || [
[true, translate('always')], [true, translate('always')],
[false, translate('never')], [false, translate('never')],
['null', translate('hidden')], [null, translate('hidden')],
] ]
) )
} }

View file

@ -450,7 +450,7 @@ export const SCHEMA = {
choices: [ choices: [
[true, translate('always')], [true, translate('always')],
[false, translate('never')], [false, translate('never')],
['null', translate('on hover')], [null, translate('on hover')],
], ],
}, },
slideshow: { slideshow: {

View file

@ -210,3 +210,19 @@ def test_sortkey_impacts_datalayerindex(map, live_server, page):
assert "Z First" == first_listed_feature.text_content() assert "Z First" == first_listed_feature.text_content()
assert "Y Second" == second_listed_feature.text_content() assert "Y Second" == second_listed_feature.text_content()
assert "X Third" == third_listed_feature.text_content() assert "X Third" == third_listed_feature.text_content()
def test_hover_tooltip_setting_should_be_persistent(live_server, map, page):
map.settings["properties"]["showLabel"] = None
map.edit_status = Map.ANONYMOUS
map.save()
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
page.get_by_role("button", name="Map advanced properties").click()
page.get_by_text("Default interaction options").click()
expect(page.get_by_text("on hover")).to_be_visible()
expect(page.locator(".umap-field-showLabel")).to_match_aria_snapshot("""
- text: Display label
- button "clear"
- text: always never on hover
""")
expect(page.locator(".umap-field-showLabel input[value=null]")).to_be_checked()

View file

@ -181,3 +181,13 @@ def test_only_visible_markers_are_added_to_dom(live_server, map, page):
) )
expect(markers).to_have_count(1) expect(markers).to_have_count(1)
expect(tooltips).to_have_count(1) expect(tooltips).to_have_count(1)
def test_should_display_tooltip_on_hover(live_server, map, page, bootstrap):
map.settings["properties"]["showLabel"] = None
map.settings["properties"]["labelKey"] = "Foo {name}"
map.save()
page.goto(f"{live_server.url}{map.get_absolute_url()}")
expect(page.get_by_text("Foo test marker")).to_be_hidden()
page.locator(".leaflet-marker-icon").hover()
expect(page.get_by_text("Foo test marker")).to_be_visible()