umap-project 3.3.2__py3-none-any.whl → 3.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. umap/__init__.py +1 -1
  2. umap/context_processors.py +4 -1
  3. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/cs_CZ/LC_MESSAGES/django.po +43 -33
  5. umap/locale/da/LC_MESSAGES/django.mo +0 -0
  6. umap/locale/da/LC_MESSAGES/django.po +43 -33
  7. umap/locale/de/LC_MESSAGES/django.mo +0 -0
  8. umap/locale/de/LC_MESSAGES/django.po +64 -53
  9. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  10. umap/locale/el/LC_MESSAGES/django.po +35 -29
  11. umap/locale/en/LC_MESSAGES/django.po +47 -41
  12. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  13. umap/locale/es/LC_MESSAGES/django.po +43 -33
  14. umap/locale/et/LC_MESSAGES/django.mo +0 -0
  15. umap/locale/et/LC_MESSAGES/django.po +58 -54
  16. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  17. umap/locale/eu/LC_MESSAGES/django.po +43 -33
  18. umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
  19. umap/locale/fa_IR/LC_MESSAGES/django.po +43 -33
  20. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  21. umap/locale/fr/LC_MESSAGES/django.po +36 -30
  22. umap/locale/gl/LC_MESSAGES/django.mo +0 -0
  23. umap/locale/gl/LC_MESSAGES/django.po +43 -33
  24. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  25. umap/locale/hu/LC_MESSAGES/django.po +35 -29
  26. umap/locale/is/LC_MESSAGES/django.mo +0 -0
  27. umap/locale/is/LC_MESSAGES/django.po +43 -33
  28. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  29. umap/locale/it/LC_MESSAGES/django.po +43 -33
  30. umap/locale/nl/LC_MESSAGES/django.mo +0 -0
  31. umap/locale/nl/LC_MESSAGES/django.po +35 -29
  32. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  33. umap/locale/pl/LC_MESSAGES/django.po +114 -103
  34. umap/locale/pt/LC_MESSAGES/django.mo +0 -0
  35. umap/locale/pt/LC_MESSAGES/django.po +43 -33
  36. umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
  37. umap/locale/th_TH/LC_MESSAGES/django.po +310 -109
  38. umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  39. umap/locale/zh_TW/LC_MESSAGES/django.po +80 -70
  40. umap/management/commands/switch_user.py +2 -2
  41. umap/migrations/0018_datalayer_uuid.py +1 -1
  42. umap/models.py +7 -3
  43. umap/settings/local.py.sample +1 -1
  44. umap/static/umap/base.css +89 -32
  45. umap/static/umap/content.css +129 -33
  46. umap/static/umap/css/bar.css +82 -20
  47. umap/static/umap/css/browser.css +163 -0
  48. umap/static/umap/css/contextmenu.css +15 -0
  49. umap/static/umap/css/dialog.css +36 -16
  50. umap/static/umap/css/form.css +123 -33
  51. umap/static/umap/css/icon.css +46 -3
  52. umap/static/umap/css/panel.css +7 -3
  53. umap/static/umap/css/popup.css +34 -8
  54. umap/static/umap/css/tooltip.css +8 -4
  55. umap/static/umap/img/16-white.svg +26 -8
  56. umap/static/umap/img/16.svg +1 -1
  57. umap/static/umap/img/source/16-white.svg +36 -18
  58. umap/static/umap/img/source/16.svg +1 -1
  59. umap/static/umap/js/components/alerts/alert.css +69 -31
  60. umap/static/umap/js/components/alerts/alert.js +20 -2
  61. umap/static/umap/js/components/base.js +1 -1
  62. umap/static/umap/js/modules/browser.js +69 -61
  63. umap/static/umap/js/modules/caption.js +10 -7
  64. umap/static/umap/js/modules/data/features.js +89 -63
  65. umap/static/umap/js/modules/data/fields.js +446 -0
  66. umap/static/umap/js/modules/data/layer.js +116 -196
  67. umap/static/umap/js/modules/domutils.js +109 -0
  68. umap/static/umap/js/modules/filters.js +780 -0
  69. umap/static/umap/js/modules/form/builder.js +8 -5
  70. umap/static/umap/js/modules/form/fields.js +111 -221
  71. umap/static/umap/js/modules/formatter.js +24 -1
  72. umap/static/umap/js/modules/help.js +4 -3
  73. umap/static/umap/js/modules/i18n.js +1 -1
  74. umap/static/umap/js/modules/importer.js +1 -1
  75. umap/static/umap/js/modules/importers/opendata.js +15 -0
  76. umap/static/umap/js/modules/importers/openrouteservice.js +6 -1
  77. umap/static/umap/js/modules/managers.js +2 -1
  78. umap/static/umap/js/modules/permissions.js +39 -31
  79. umap/static/umap/js/modules/rendering/controls.js +11 -9
  80. umap/static/umap/js/modules/rendering/icon.js +3 -8
  81. umap/static/umap/js/modules/rendering/layers/base.js +3 -3
  82. umap/static/umap/js/modules/rendering/layers/classified.js +18 -11
  83. umap/static/umap/js/modules/rendering/layers/cluster.js +23 -11
  84. umap/static/umap/js/modules/rendering/layers/heat.js +27 -21
  85. umap/static/umap/js/modules/rendering/map.js +1 -0
  86. umap/static/umap/js/modules/rendering/template.js +50 -23
  87. umap/static/umap/js/modules/rendering/ui.js +33 -25
  88. umap/static/umap/js/modules/rules.js +38 -44
  89. umap/static/umap/js/modules/schema.js +3 -6
  90. umap/static/umap/js/modules/share.js +5 -4
  91. umap/static/umap/js/modules/tableeditor.js +50 -38
  92. umap/static/umap/js/modules/templates.js +2 -3
  93. umap/static/umap/js/modules/ui/bar.js +55 -23
  94. umap/static/umap/js/modules/ui/dialog.js +38 -27
  95. umap/static/umap/js/modules/ui/panel.js +23 -8
  96. umap/static/umap/js/modules/ui/tooltip.js +6 -5
  97. umap/static/umap/js/modules/umap.js +158 -51
  98. umap/static/umap/js/modules/utils.js +24 -2
  99. umap/static/umap/js/umap.core.js +1 -110
  100. umap/static/umap/locale/am_ET.js +52 -17
  101. umap/static/umap/locale/am_ET.json +52 -17
  102. umap/static/umap/locale/ar.js +52 -17
  103. umap/static/umap/locale/ar.json +52 -17
  104. umap/static/umap/locale/ast.js +52 -17
  105. umap/static/umap/locale/ast.json +52 -17
  106. umap/static/umap/locale/bg.js +52 -17
  107. umap/static/umap/locale/bg.json +52 -17
  108. umap/static/umap/locale/br.js +48 -22
  109. umap/static/umap/locale/br.json +48 -22
  110. umap/static/umap/locale/ca.js +52 -17
  111. umap/static/umap/locale/ca.json +52 -17
  112. umap/static/umap/locale/cs_CZ.js +52 -17
  113. umap/static/umap/locale/cs_CZ.json +52 -17
  114. umap/static/umap/locale/da.js +54 -17
  115. umap/static/umap/locale/da.json +54 -17
  116. umap/static/umap/locale/de.js +102 -67
  117. umap/static/umap/locale/de.json +102 -67
  118. umap/static/umap/locale/el.js +52 -17
  119. umap/static/umap/locale/el.json +52 -17
  120. umap/static/umap/locale/en.js +54 -16
  121. umap/static/umap/locale/en.json +54 -16
  122. umap/static/umap/locale/en_US.json +52 -17
  123. umap/static/umap/locale/es.js +54 -17
  124. umap/static/umap/locale/es.json +54 -17
  125. umap/static/umap/locale/et.js +91 -56
  126. umap/static/umap/locale/et.json +91 -56
  127. umap/static/umap/locale/eu.js +84 -49
  128. umap/static/umap/locale/eu.json +84 -49
  129. umap/static/umap/locale/fa_IR.js +52 -17
  130. umap/static/umap/locale/fa_IR.json +52 -17
  131. umap/static/umap/locale/fi.js +52 -17
  132. umap/static/umap/locale/fi.json +52 -17
  133. umap/static/umap/locale/fr.js +54 -17
  134. umap/static/umap/locale/fr.json +54 -17
  135. umap/static/umap/locale/gl.js +52 -17
  136. umap/static/umap/locale/gl.json +52 -17
  137. umap/static/umap/locale/he.js +52 -17
  138. umap/static/umap/locale/he.json +52 -17
  139. umap/static/umap/locale/hr.js +52 -17
  140. umap/static/umap/locale/hr.json +52 -17
  141. umap/static/umap/locale/hu.js +59 -24
  142. umap/static/umap/locale/hu.json +59 -24
  143. umap/static/umap/locale/id.js +52 -17
  144. umap/static/umap/locale/id.json +52 -17
  145. umap/static/umap/locale/is.js +52 -17
  146. umap/static/umap/locale/is.json +52 -17
  147. umap/static/umap/locale/it.js +52 -17
  148. umap/static/umap/locale/it.json +52 -17
  149. umap/static/umap/locale/ja.js +52 -17
  150. umap/static/umap/locale/ja.json +52 -17
  151. umap/static/umap/locale/ko.js +52 -17
  152. umap/static/umap/locale/ko.json +52 -17
  153. umap/static/umap/locale/lt.js +52 -17
  154. umap/static/umap/locale/lt.json +52 -17
  155. umap/static/umap/locale/ms.js +52 -17
  156. umap/static/umap/locale/ms.json +52 -17
  157. umap/static/umap/locale/nl.js +52 -17
  158. umap/static/umap/locale/nl.json +52 -17
  159. umap/static/umap/locale/no.js +52 -17
  160. umap/static/umap/locale/no.json +52 -17
  161. umap/static/umap/locale/pl.js +53 -17
  162. umap/static/umap/locale/pl.json +53 -17
  163. umap/static/umap/locale/pl_PL.json +52 -17
  164. umap/static/umap/locale/pt.js +52 -17
  165. umap/static/umap/locale/pt.json +52 -17
  166. umap/static/umap/locale/pt_BR.js +52 -17
  167. umap/static/umap/locale/pt_BR.json +52 -17
  168. umap/static/umap/locale/pt_PT.js +52 -17
  169. umap/static/umap/locale/pt_PT.json +52 -17
  170. umap/static/umap/locale/ro.js +52 -17
  171. umap/static/umap/locale/ro.json +52 -17
  172. umap/static/umap/locale/ru.js +52 -17
  173. umap/static/umap/locale/ru.json +52 -17
  174. umap/static/umap/locale/si.js +1 -1
  175. umap/static/umap/locale/si.json +1 -1
  176. umap/static/umap/locale/sk_SK.js +52 -17
  177. umap/static/umap/locale/sk_SK.json +52 -17
  178. umap/static/umap/locale/sl.js +52 -17
  179. umap/static/umap/locale/sl.json +52 -17
  180. umap/static/umap/locale/sr.js +52 -17
  181. umap/static/umap/locale/sr.json +52 -17
  182. umap/static/umap/locale/sv.js +52 -17
  183. umap/static/umap/locale/sv.json +52 -17
  184. umap/static/umap/locale/th_TH.js +52 -17
  185. umap/static/umap/locale/th_TH.json +52 -17
  186. umap/static/umap/locale/tr.js +52 -17
  187. umap/static/umap/locale/tr.json +52 -17
  188. umap/static/umap/locale/uk_UA.js +52 -17
  189. umap/static/umap/locale/uk_UA.json +52 -17
  190. umap/static/umap/locale/vi.js +52 -17
  191. umap/static/umap/locale/vi.json +52 -17
  192. umap/static/umap/locale/vi_VN.json +52 -17
  193. umap/static/umap/locale/zh.js +52 -17
  194. umap/static/umap/locale/zh.json +52 -17
  195. umap/static/umap/locale/zh_CN.json +52 -17
  196. umap/static/umap/locale/zh_TW.Big5.json +52 -17
  197. umap/static/umap/locale/zh_TW.js +53 -17
  198. umap/static/umap/locale/zh_TW.json +53 -17
  199. umap/static/umap/map.css +63 -226
  200. umap/static/umap/unittests/utils.js +18 -0
  201. umap/static/umap/vars.css +23 -5
  202. umap/templates/umap/components/alerts/alert.html +32 -29
  203. umap/templates/umap/css.html +2 -1
  204. umap/templates/umap/login_popup_end.html +18 -9
  205. umap/templates/umap/user_map_table.html +7 -2
  206. umap/tests/integration/conftest.py +10 -6
  207. umap/tests/integration/test_anonymous_owned_map.py +90 -37
  208. umap/tests/integration/test_basics.py +25 -1
  209. umap/tests/integration/test_browser.py +37 -0
  210. umap/tests/integration/test_cluster.py +110 -0
  211. umap/tests/integration/test_conditional_rules.py +107 -52
  212. umap/tests/integration/test_datalayer.py +9 -16
  213. umap/tests/integration/test_draw_polygon.py +6 -0
  214. umap/tests/integration/test_draw_polyline.py +11 -0
  215. umap/tests/integration/test_edit_marker.py +12 -1
  216. umap/tests/integration/test_export_map.py +19 -0
  217. umap/tests/integration/test_fields.py +541 -0
  218. umap/tests/integration/test_filters.py +616 -0
  219. umap/tests/integration/test_iframe.py +1 -1
  220. umap/tests/integration/test_import.py +38 -42
  221. umap/tests/integration/test_map_preview.py +1 -1
  222. umap/tests/integration/test_picto.py +1 -1
  223. umap/tests/integration/test_popup.py +31 -0
  224. umap/tests/integration/test_remote_data.py +60 -4
  225. umap/tests/integration/test_save.py +1 -1
  226. umap/tests/integration/test_share.py +4 -4
  227. umap/tests/integration/test_tableeditor.py +31 -7
  228. umap/tests/integration/test_websocket_sync.py +71 -20
  229. umap/tests/test_dashboard.py +11 -1
  230. umap/tests/test_statics.py +2 -2
  231. umap/tests/test_utils.py +19 -2
  232. umap/tests/test_views.py +1 -1
  233. umap/urls.py +1 -0
  234. umap/utils.py +8 -1
  235. umap/views.py +5 -0
  236. {umap_project-3.3.2.dist-info → umap_project-3.4.0.dist-info}/METADATA +15 -15
  237. {umap_project-3.3.2.dist-info → umap_project-3.4.0.dist-info}/RECORD +240 -236
  238. umap/static/umap/js/modules/facets.js +0 -164
  239. umap/tests/integration/test_facets_browser.py +0 -279
  240. {umap_project-3.3.2.dist-info → umap_project-3.4.0.dist-info}/WHEEL +0 -0
  241. {umap_project-3.3.2.dist-info → umap_project-3.4.0.dist-info}/entry_points.txt +0 -0
  242. {umap_project-3.3.2.dist-info → umap_project-3.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,164 +0,0 @@
1
- import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js'
2
- import { translate } from './i18n.js'
3
- import * as Utils from './utils.js'
4
-
5
- export default class Facets {
6
- constructor(umap) {
7
- this._umap = umap
8
- this.selected = {}
9
- }
10
-
11
- compute(names, defined) {
12
- const properties = {}
13
- let selected
14
-
15
- for (const name of names) {
16
- const type = defined.get(name).type
17
- properties[name] = { type: type }
18
- selected = this.selected[name] || {}
19
- selected.type = type
20
- if (!['date', 'datetime', 'number'].includes(type)) {
21
- properties[name].choices = []
22
- selected.choices = selected.choices || []
23
- }
24
- this.selected[name] = selected
25
- }
26
-
27
- this._umap.datalayers.browsable().map((datalayer) => {
28
- datalayer.features.forEach((feature) => {
29
- for (const name of names) {
30
- let value = feature.properties[name]
31
- const type = defined.get(name).type
32
- const parser = this.getParser(type)
33
- value = parser(value)
34
- switch (type) {
35
- case 'date':
36
- case 'datetime':
37
- case 'number':
38
- if (!Number.isNaN(value)) {
39
- // Special cases where we want to be lousy when checking isNaN without
40
- // coercing to a Number first because we handle multiple types.
41
- // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/
42
- // Reference/Global_Objects/Number/isNaN
43
- // biome-ignore lint/suspicious/noGlobalIsNan: see above.
44
- if (isNaN(properties[name].min) || properties[name].min > value) {
45
- properties[name].min = value
46
- }
47
- // biome-ignore lint/suspicious/noGlobalIsNan: see above.
48
- if (isNaN(properties[name].max) || properties[name].max < value) {
49
- properties[name].max = value
50
- }
51
- }
52
- break
53
- default:
54
- value = value || translate('<empty value>')
55
- if (!properties[name].choices.includes(value)) {
56
- properties[name].choices.push(value)
57
- }
58
- }
59
- }
60
- })
61
- })
62
- return properties
63
- }
64
-
65
- isActive() {
66
- for (const { type, min, max, choices } of Object.values(this.selected)) {
67
- if (min !== undefined || max !== undefined || choices?.length) {
68
- return true
69
- }
70
- }
71
- return false
72
- }
73
-
74
- build() {
75
- const defined = this.getDefined()
76
- const names = [...defined.keys()]
77
- const facetProperties = this.compute(names, defined)
78
-
79
- const fields = names.map((name) => {
80
- const criteria = facetProperties[name]
81
- let handler = 'FacetSearchChoices'
82
- switch (criteria.type) {
83
- case 'number':
84
- handler = 'FacetSearchNumber'
85
- break
86
- case 'date':
87
- handler = 'FacetSearchDate'
88
- break
89
- case 'datetime':
90
- handler = 'FacetSearchDateTime'
91
- break
92
- }
93
- const label = defined.get(name).label
94
- return [
95
- `selected.${name}`,
96
- {
97
- criteria: criteria,
98
- handler: handler,
99
- label: label,
100
- },
101
- ]
102
- })
103
-
104
- return fields
105
- }
106
-
107
- getDefined() {
108
- const defaultType = 'checkbox'
109
- const allowedTypes = [defaultType, 'radio', 'number', 'date', 'datetime']
110
- const defined = new Map()
111
- if (!this._umap.properties.facetKey) return defined
112
- return (this._umap.properties.facetKey || '').split(',').reduce((acc, curr) => {
113
- let [name, label, type] = curr.split('|')
114
- type = allowedTypes.includes(type) ? type : defaultType
115
- acc.set(name, { label: label || name, type: type })
116
- return acc
117
- }, defined)
118
- }
119
-
120
- getParser(type) {
121
- switch (type) {
122
- case 'number':
123
- return Number.parseFloat
124
- case 'datetime':
125
- return (v) => new Date(v)
126
- case 'date':
127
- return Utils.parseNaiveDate
128
- default:
129
- return (v) => String(v || '')
130
- }
131
- }
132
-
133
- dumps(parsed) {
134
- const dumped = []
135
- for (const [property, { label, type }] of parsed) {
136
- dumped.push([property, label, type].filter(Boolean).join('|'))
137
- }
138
- const oldValue = this._umap.properties.facetKey
139
- this._umap.properties.facetKey = dumped.join(',')
140
- this._umap.sync.update(
141
- 'properties.facetKey',
142
- this._umap.properties.facetKey,
143
- oldValue
144
- )
145
- }
146
-
147
- has(property) {
148
- return this.getDefined().has(property)
149
- }
150
-
151
- add(property, label, type) {
152
- const defined = this.getDefined()
153
- if (!defined.has(property)) {
154
- defined.set(property, { label, type })
155
- this.dumps(defined)
156
- }
157
- }
158
-
159
- remove(property) {
160
- const defined = this.getDefined()
161
- defined.delete(property)
162
- this.dumps(defined)
163
- }
164
- }
@@ -1,279 +0,0 @@
1
- import copy
2
- import re
3
-
4
- import pytest
5
- from playwright.sync_api import expect
6
-
7
- from ..base import DataLayerFactory
8
-
9
- pytestmark = pytest.mark.django_db
10
-
11
-
12
- DATALAYER_DATA1 = {
13
- "type": "FeatureCollection",
14
- "features": [
15
- {
16
- "type": "Feature",
17
- "properties": {
18
- "mytype": "even",
19
- "name": "Point 2",
20
- "mynumber": 10,
21
- "mydate": "2024/04/14 12:19:17",
22
- },
23
- "geometry": {"type": "Point", "coordinates": [0.065918, 48.385442]},
24
- },
25
- {
26
- "type": "Feature",
27
- "properties": {
28
- "mytype": "odd",
29
- "name": "Point 1",
30
- "mynumber": 12,
31
- "mydate": "2024/03/13 12:20:20",
32
- },
33
- "geometry": {"type": "Point", "coordinates": [3.55957, 49.767074]},
34
- },
35
- ],
36
- "_umap_options": {
37
- "name": "Calque 1",
38
- },
39
- }
40
-
41
-
42
- DATALAYER_DATA2 = {
43
- "type": "FeatureCollection",
44
- "features": [
45
- {
46
- "type": "Feature",
47
- "properties": {
48
- "mytype": "even",
49
- "name": "Point 4",
50
- "mynumber": 10,
51
- "mydate": "2024/08/18 13:14:15",
52
- },
53
- "geometry": {"type": "Point", "coordinates": [0.856934, 45.290347]},
54
- },
55
- {
56
- "type": "Feature",
57
- "properties": {
58
- "mytype": "odd",
59
- "name": "Point 3",
60
- "mynumber": 14,
61
- "mydate": "2024-04-14T10:19:17.000Z",
62
- },
63
- "geometry": {"type": "Point", "coordinates": [4.372559, 47.945786]},
64
- },
65
- ],
66
- "_umap_options": {
67
- "name": "Calque 2",
68
- },
69
- }
70
-
71
-
72
- DATALAYER_DATA3 = {
73
- "type": "FeatureCollection",
74
- "features": [
75
- {
76
- "type": "Feature",
77
- "properties": {"name": "a polygon"},
78
- "geometry": {
79
- "type": "Polygon",
80
- "coordinates": [
81
- [
82
- [2.12, 49.57],
83
- [1.08, 49.02],
84
- [2.51, 47.55],
85
- [3.19, 48.77],
86
- [2.12, 49.57],
87
- ]
88
- ],
89
- },
90
- },
91
- ],
92
- "_umap_options": {"name": "Calque 2", "browsable": False},
93
- }
94
-
95
-
96
- def test_simple_facet_search(live_server, page, map):
97
- map.settings["properties"]["onLoadPanel"] = "datafilters"
98
- map.settings["properties"]["facetKey"] = "mytype|My type,mynumber|My Number|number"
99
- map.settings["properties"]["showLabel"] = True
100
- map.save()
101
- DataLayerFactory(map=map, data=DATALAYER_DATA1)
102
- DataLayerFactory(map=map, data=DATALAYER_DATA2)
103
- DataLayerFactory(map=map, data=DATALAYER_DATA3)
104
- page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.948/1.670")
105
- panel = page.locator(".panel.left.on")
106
- expect(panel).to_have_class(re.compile(".*expanded.*"))
107
- expect(panel.locator(".umap-browser")).to_be_visible()
108
- # From a non browsable datalayer, should not be impacted
109
- paths = page.locator(".leaflet-overlay-pane path")
110
- expect(paths).to_be_visible()
111
- expect(panel).to_be_visible()
112
- # Facet name
113
- expect(page.get_by_text("My type")).to_be_visible()
114
- # Facet values
115
- oven = page.get_by_text("even")
116
- odd = page.get_by_text("odd")
117
- expect(oven).to_be_visible()
118
- expect(odd).to_be_visible()
119
- expect(paths).to_be_visible()
120
- markers = page.locator(".leaflet-marker-icon")
121
- expect(markers).to_have_count(4)
122
- # Tooltips
123
- expect(page.get_by_role("tooltip", name="Point 1")).to_be_visible()
124
- expect(page.get_by_role("tooltip", name="Point 2")).to_be_visible()
125
- expect(page.get_by_role("tooltip", name="Point 3")).to_be_visible()
126
- expect(page.get_by_role("tooltip", name="Point 4")).to_be_visible()
127
-
128
- # Datalist
129
- expect(panel.get_by_text("Point 1")).to_be_visible()
130
- expect(panel.get_by_text("Point 2")).to_be_visible()
131
- expect(panel.get_by_text("Point 3")).to_be_visible()
132
- expect(panel.get_by_text("Point 4")).to_be_visible()
133
-
134
- # Now let's filter
135
- odd.click()
136
- expect(markers).to_have_count(2)
137
- expect(page.get_by_role("tooltip", name="Point 2")).to_be_hidden()
138
- expect(page.get_by_role("tooltip", name="Point 4")).to_be_hidden()
139
- expect(page.get_by_role("tooltip", name="Point 1")).to_be_visible()
140
- expect(page.get_by_role("tooltip", name="Point 3")).to_be_visible()
141
- expect(panel.get_by_text("Point 2")).to_be_hidden()
142
- expect(panel.get_by_text("Point 4")).to_be_hidden()
143
- expect(panel.get_by_text("Point 1")).to_be_visible()
144
- expect(panel.get_by_text("Point 3")).to_be_visible()
145
- expect(paths).to_be_visible
146
- # Now let's filter
147
- odd.click()
148
- expect(markers).to_have_count(4)
149
- expect(paths).to_be_visible()
150
-
151
- # Let's filter using the number facet
152
- expect(page.get_by_text("My Number")).to_be_visible()
153
- expect(page.get_by_label("Min")).to_have_value("10")
154
- expect(page.get_by_label("Max")).to_have_value("14")
155
- page.get_by_label("Min").fill("11")
156
- page.keyboard.press("Tab") # Move out of the input, so the "change" event is sent
157
- expect(markers).to_have_count(2)
158
- expect(paths).to_be_visible()
159
- page.get_by_label("Max").fill("13")
160
- page.keyboard.press("Tab")
161
- expect(markers).to_have_count(1)
162
-
163
- # Now let's combine
164
- page.get_by_label("Min").fill("10")
165
- page.keyboard.press("Tab")
166
- expect(markers).to_have_count(3)
167
- odd.click()
168
- expect(markers).to_have_count(1)
169
- expect(paths).to_be_visible()
170
-
171
-
172
- def test_date_facet_search(live_server, page, map):
173
- map.settings["properties"]["onLoadPanel"] = "datafilters"
174
- map.settings["properties"]["facetKey"] = "mydate|Date filter|date"
175
- map.save()
176
- DataLayerFactory(map=map, data=DATALAYER_DATA1)
177
- DataLayerFactory(map=map, data=DATALAYER_DATA2)
178
- page.goto(f"{live_server.url}{map.get_absolute_url()}#6/47.5/-1.5")
179
- markers = page.locator(".leaflet-marker-icon")
180
- expect(markers).to_have_count(4)
181
- expect(page.get_by_text("Date Filter")).to_be_visible()
182
- expect(page.get_by_label("From")).to_have_value("2024-03-13")
183
- expect(page.get_by_label("Until")).to_have_value("2024-08-18")
184
- page.get_by_label("From").fill("2024-03-14")
185
- expect(markers).to_have_count(3)
186
- page.get_by_label("Until").fill("2024-08-17")
187
- expect(markers).to_have_count(2)
188
-
189
-
190
- def test_choice_with_empty_value(live_server, page, map):
191
- map.settings["properties"]["onLoadPanel"] = "datafilters"
192
- map.settings["properties"]["facetKey"] = "mytype|My type"
193
- map.save()
194
- data = copy.deepcopy(DATALAYER_DATA1)
195
- data["features"][0]["properties"]["mytype"] = ""
196
- del data["features"][1]["properties"]["mytype"]
197
- DataLayerFactory(map=map, data=data)
198
- DataLayerFactory(map=map, data=DATALAYER_DATA2)
199
- page.goto(f"{live_server.url}{map.get_absolute_url()}#6/47.5/-1.5")
200
- expect(page.get_by_text("<empty value>")).to_be_visible()
201
- markers = page.locator(".leaflet-marker-icon")
202
- expect(markers).to_have_count(4)
203
- page.get_by_text("<empty value>").click()
204
- expect(markers).to_have_count(2)
205
-
206
-
207
- def test_number_with_zero_value(live_server, page, map):
208
- map.settings["properties"]["onLoadPanel"] = "datafilters"
209
- map.settings["properties"]["facetKey"] = "mynumber|Filter|number"
210
- map.save()
211
- data = copy.deepcopy(DATALAYER_DATA1)
212
- data["features"][0]["properties"]["mynumber"] = 0
213
- DataLayerFactory(map=map, data=data)
214
- DataLayerFactory(map=map, data=DATALAYER_DATA2)
215
- page.goto(f"{live_server.url}{map.get_absolute_url()}#6/47.5/-1.5")
216
- expect(page.get_by_label("Min")).to_have_value("0")
217
- expect(page.get_by_label("Max")).to_have_value("14")
218
- page.get_by_label("Min").fill("1")
219
- page.keyboard.press("Tab") # Move out of the input, so the "change" event is sent
220
- markers = page.locator(".leaflet-marker-icon")
221
- expect(markers).to_have_count(3)
222
-
223
-
224
- def test_facets_search_are_persistent_when_closing_panel(live_server, page, map):
225
- map.settings["properties"]["onLoadPanel"] = "datafilters"
226
- map.settings["properties"]["facetKey"] = "mytype|My type,mynumber|My Number|number"
227
- map.save()
228
- DataLayerFactory(map=map, data=DATALAYER_DATA1)
229
- DataLayerFactory(map=map, data=DATALAYER_DATA2)
230
- page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.948/1.670")
231
- panel = page.locator(".panel.left")
232
-
233
- # Facet values
234
- odd = page.get_by_label("odd")
235
- markers = page.locator(".leaflet-marker-icon")
236
- expect(markers).to_have_count(4)
237
-
238
- # Datalist in the browser
239
- expect(panel.get_by_text("Point 1")).to_be_visible()
240
- expect(panel.get_by_text("Point 2")).to_be_visible()
241
- expect(panel.get_by_text("Point 3")).to_be_visible()
242
- expect(panel.get_by_text("Point 4")).to_be_visible()
243
-
244
- # Now let's filter
245
- odd.click()
246
- expect(page.locator(".filters summary")).to_have_attribute("data-badge", " ")
247
- expect(page.locator(".umap-control-browse")).to_have_attribute("data-badge", " ")
248
- expect(markers).to_have_count(2)
249
- expect(panel.get_by_text("Point 2")).to_be_hidden()
250
- expect(panel.get_by_text("Point 4")).to_be_hidden()
251
- expect(panel.get_by_text("Point 1")).to_be_visible()
252
- expect(panel.get_by_text("Point 3")).to_be_visible()
253
-
254
- # Let's filter using the number facet
255
- expect(panel.get_by_label("Min")).to_have_value("10")
256
- expect(panel.get_by_label("Max")).to_have_value("14")
257
- page.get_by_label("Min").fill("13")
258
- page.keyboard.press("Tab") # Move out of the input, so the "change" event is sent
259
- expect(panel.get_by_label("Min")).to_have_attribute("data-modified", "true")
260
- expect(markers).to_have_count(1)
261
- expect(panel.get_by_text("Point 2")).to_be_hidden()
262
- expect(panel.get_by_text("Point 4")).to_be_hidden()
263
- expect(panel.get_by_text("Point 1")).to_be_hidden()
264
- expect(panel.get_by_text("Point 3")).to_be_visible()
265
-
266
- # Close panel
267
- expect(panel.locator(".filters summary")).to_have_attribute("data-badge", " ")
268
- expect(page.locator(".umap-control-browse")).to_have_attribute("data-badge", " ")
269
- panel.get_by_role("button", name="Close").click()
270
- page.get_by_role("button", name="Open browser").click()
271
- expect(panel.get_by_label("Min")).to_have_value("13")
272
- expect(panel.get_by_label("Min")).to_have_attribute("data-modified", "true")
273
- expect(panel.get_by_label("odd")).to_be_checked()
274
-
275
- # Datalist in the browser should be inchanged
276
- expect(panel.get_by_text("Point 2")).to_be_hidden()
277
- expect(panel.get_by_text("Point 4")).to_be_hidden()
278
- expect(panel.get_by_text("Point 1")).to_be_hidden()
279
- expect(panel.get_by_text("Point 3")).to_be_visible()