umap-project 2.1.2__py3-none-any.whl → 2.2.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.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (211) hide show
  1. umap/__init__.py +1 -1
  2. umap/context_processors.py +1 -0
  3. umap/locale/br/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/en/LC_MESSAGES/django.po +32 -32
  5. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  6. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  7. umap/locale/ms/LC_MESSAGES/django.mo +0 -0
  8. umap/migrations/0020_alter_tilelayer_url_template.py +19 -0
  9. umap/migrations/0021_remove_map_description.py +16 -0
  10. umap/models.py +10 -6
  11. umap/settings/base.py +1 -0
  12. umap/static/umap/base.css +43 -156
  13. umap/static/umap/content.css +7 -25
  14. umap/static/umap/css/icon.css +112 -0
  15. umap/static/umap/css/panel.css +140 -0
  16. umap/static/umap/img/16-white.svg +5 -1
  17. umap/static/umap/img/16.svg +7 -4
  18. umap/static/umap/img/24-white.svg +3 -1
  19. umap/static/umap/img/24.svg +3 -4
  20. umap/static/umap/img/source/16-white.svg +176 -940
  21. umap/static/umap/img/source/16.svg +8 -5
  22. umap/static/umap/img/source/24-white.svg +5 -3
  23. umap/static/umap/img/source/24.svg +6 -7
  24. umap/static/umap/js/modules/browser.js +97 -73
  25. umap/static/umap/js/modules/dompurify.js +12 -0
  26. umap/static/umap/js/modules/facets.js +149 -0
  27. umap/static/umap/js/modules/global.js +9 -1
  28. umap/static/umap/js/modules/i18n.js +7 -0
  29. umap/static/umap/js/modules/orderable.js +84 -0
  30. umap/static/umap/js/modules/panel.js +76 -0
  31. umap/static/umap/js/modules/request.js +0 -1
  32. umap/static/umap/js/modules/schema.js +324 -223
  33. umap/static/umap/js/modules/urls.js +1 -16
  34. umap/static/umap/js/modules/utils.js +340 -0
  35. umap/static/umap/js/umap.autocomplete.js +40 -25
  36. umap/static/umap/js/umap.controls.js +248 -361
  37. umap/static/umap/js/umap.core.js +77 -366
  38. umap/static/umap/js/umap.datalayer.permissions.js +1 -1
  39. umap/static/umap/js/umap.features.js +65 -43
  40. umap/static/umap/js/umap.forms.js +128 -36
  41. umap/static/umap/js/umap.icon.js +11 -4
  42. umap/static/umap/js/umap.importer.js +78 -58
  43. umap/static/umap/js/umap.js +206 -192
  44. umap/static/umap/js/umap.layer.js +86 -46
  45. umap/static/umap/js/umap.permissions.js +13 -9
  46. umap/static/umap/js/umap.popup.js +26 -30
  47. umap/static/umap/js/umap.share.js +12 -9
  48. umap/static/umap/js/umap.tableeditor.js +4 -6
  49. umap/static/umap/js/umap.ui.js +10 -60
  50. umap/static/umap/locale/am_ET.js +243 -227
  51. umap/static/umap/locale/am_ET.json +21 -9
  52. umap/static/umap/locale/ar.js +243 -227
  53. umap/static/umap/locale/ar.json +21 -9
  54. umap/static/umap/locale/ast.js +243 -227
  55. umap/static/umap/locale/ast.json +21 -9
  56. umap/static/umap/locale/bg.js +243 -227
  57. umap/static/umap/locale/bg.json +21 -9
  58. umap/static/umap/locale/br.js +253 -237
  59. umap/static/umap/locale/br.json +25 -13
  60. umap/static/umap/locale/ca.js +243 -227
  61. umap/static/umap/locale/ca.json +21 -9
  62. umap/static/umap/locale/cs_CZ.js +243 -227
  63. umap/static/umap/locale/cs_CZ.json +21 -9
  64. umap/static/umap/locale/da.js +243 -227
  65. umap/static/umap/locale/da.json +21 -9
  66. umap/static/umap/locale/de.js +243 -227
  67. umap/static/umap/locale/de.json +21 -9
  68. umap/static/umap/locale/el.js +243 -227
  69. umap/static/umap/locale/el.json +21 -9
  70. umap/static/umap/locale/en.js +243 -234
  71. umap/static/umap/locale/en.json +22 -10
  72. umap/static/umap/locale/en_US.json +21 -9
  73. umap/static/umap/locale/es.js +243 -227
  74. umap/static/umap/locale/es.json +21 -9
  75. umap/static/umap/locale/et.js +243 -227
  76. umap/static/umap/locale/et.json +21 -9
  77. umap/static/umap/locale/eu.js +227 -199
  78. umap/static/umap/locale/eu.json +1 -1
  79. umap/static/umap/locale/fa_IR.js +243 -227
  80. umap/static/umap/locale/fa_IR.json +21 -9
  81. umap/static/umap/locale/fi.js +243 -227
  82. umap/static/umap/locale/fi.json +21 -9
  83. umap/static/umap/locale/fr.js +243 -234
  84. umap/static/umap/locale/fr.json +21 -9
  85. umap/static/umap/locale/gl.js +243 -227
  86. umap/static/umap/locale/gl.json +21 -9
  87. umap/static/umap/locale/he.js +243 -227
  88. umap/static/umap/locale/he.json +21 -9
  89. umap/static/umap/locale/hr.js +243 -227
  90. umap/static/umap/locale/hr.json +21 -9
  91. umap/static/umap/locale/hu.js +243 -234
  92. umap/static/umap/locale/hu.json +21 -9
  93. umap/static/umap/locale/id.js +243 -227
  94. umap/static/umap/locale/id.json +21 -9
  95. umap/static/umap/locale/is.js +243 -227
  96. umap/static/umap/locale/is.json +21 -9
  97. umap/static/umap/locale/it.js +243 -234
  98. umap/static/umap/locale/it.json +21 -9
  99. umap/static/umap/locale/ja.js +243 -227
  100. umap/static/umap/locale/ja.json +21 -9
  101. umap/static/umap/locale/ko.js +243 -227
  102. umap/static/umap/locale/ko.json +21 -9
  103. umap/static/umap/locale/lt.js +243 -227
  104. umap/static/umap/locale/lt.json +21 -9
  105. umap/static/umap/locale/ms.js +243 -234
  106. umap/static/umap/locale/ms.json +22 -10
  107. umap/static/umap/locale/nl.js +246 -230
  108. umap/static/umap/locale/nl.json +21 -9
  109. umap/static/umap/locale/no.js +243 -227
  110. umap/static/umap/locale/no.json +21 -9
  111. umap/static/umap/locale/pl.js +243 -227
  112. umap/static/umap/locale/pl.json +21 -9
  113. umap/static/umap/locale/pl_PL.json +21 -9
  114. umap/static/umap/locale/pt.js +243 -227
  115. umap/static/umap/locale/pt.json +21 -9
  116. umap/static/umap/locale/pt_BR.js +243 -227
  117. umap/static/umap/locale/pt_BR.json +21 -9
  118. umap/static/umap/locale/pt_PT.js +243 -227
  119. umap/static/umap/locale/pt_PT.json +21 -9
  120. umap/static/umap/locale/ro.js +243 -227
  121. umap/static/umap/locale/ro.json +21 -9
  122. umap/static/umap/locale/ru.js +243 -227
  123. umap/static/umap/locale/ru.json +21 -9
  124. umap/static/umap/locale/si.js +1 -1
  125. umap/static/umap/locale/si.json +1 -1
  126. umap/static/umap/locale/sk_SK.js +243 -227
  127. umap/static/umap/locale/sk_SK.json +21 -9
  128. umap/static/umap/locale/sl.js +243 -227
  129. umap/static/umap/locale/sl.json +21 -9
  130. umap/static/umap/locale/sr.js +243 -227
  131. umap/static/umap/locale/sr.json +21 -9
  132. umap/static/umap/locale/sv.js +243 -227
  133. umap/static/umap/locale/sv.json +21 -9
  134. umap/static/umap/locale/th_TH.js +243 -227
  135. umap/static/umap/locale/th_TH.json +21 -9
  136. umap/static/umap/locale/tr.js +243 -227
  137. umap/static/umap/locale/tr.json +21 -9
  138. umap/static/umap/locale/uk_UA.js +243 -227
  139. umap/static/umap/locale/uk_UA.json +21 -9
  140. umap/static/umap/locale/vi.js +243 -227
  141. umap/static/umap/locale/vi.json +21 -9
  142. umap/static/umap/locale/vi_VN.json +21 -9
  143. umap/static/umap/locale/zh.js +243 -227
  144. umap/static/umap/locale/zh.json +21 -9
  145. umap/static/umap/locale/zh_CN.json +21 -9
  146. umap/static/umap/locale/zh_TW.Big5.json +21 -9
  147. umap/static/umap/locale/zh_TW.js +243 -234
  148. umap/static/umap/locale/zh_TW.json +21 -9
  149. umap/static/umap/map.css +124 -264
  150. umap/static/umap/test/DataLayer.js +1 -1
  151. umap/static/umap/test/Feature.js +0 -226
  152. umap/static/umap/test/Map.js +0 -304
  153. umap/static/umap/test/Polygon.js +0 -256
  154. umap/static/umap/test/Polyline.js +0 -116
  155. umap/static/umap/test/TableEditor.js +10 -10
  156. umap/static/umap/test/Util.js +0 -521
  157. umap/static/umap/test/index.html +1 -5
  158. umap/static/umap/unittests/URLs.js +1 -1
  159. umap/static/umap/unittests/utils.js +610 -0
  160. umap/static/umap/vars.css +9 -0
  161. umap/static/umap/vendors/dompurify/purify.es.mjs +1525 -0
  162. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +1 -0
  163. umap/static/umap/vendors/iconlayers/iconLayers.js +1 -1
  164. umap/templates/umap/css.html +2 -0
  165. umap/templates/umap/js.html +0 -1
  166. umap/templates/umap/map_detail.html +4 -0
  167. umap/templates/umap/map_table.html +12 -10
  168. umap/templatetags/umap_tags.py +5 -0
  169. umap/tests/conftest.py +9 -0
  170. umap/tests/fixtures/test_upload_data.csv +2 -1
  171. umap/tests/fixtures/test_upload_data.umap +171 -0
  172. umap/tests/fixtures/test_upload_data_osm.json +33 -0
  173. umap/tests/integration/conftest.py +16 -0
  174. umap/tests/integration/test_anonymous_owned_map.py +30 -5
  175. umap/tests/integration/test_basics.py +21 -0
  176. umap/tests/integration/test_browser.py +16 -36
  177. umap/tests/integration/test_choropleth.py +89 -0
  178. umap/tests/integration/test_collaborative_editing.py +30 -1
  179. umap/tests/integration/test_dashboard.py +10 -0
  180. umap/tests/integration/test_datalayer.py +132 -0
  181. umap/tests/integration/test_draw_polygon.py +363 -0
  182. umap/tests/integration/test_draw_polyline.py +325 -0
  183. umap/tests/integration/test_edit_datalayer.py +145 -6
  184. umap/tests/integration/test_edit_map.py +202 -0
  185. umap/tests/integration/test_edit_marker.py +120 -0
  186. umap/tests/integration/test_edit_polygon.py +122 -0
  187. umap/tests/integration/test_facets_browser.py +132 -11
  188. umap/tests/integration/test_import.py +407 -10
  189. umap/tests/integration/test_map.py +36 -54
  190. umap/tests/integration/test_map_list.py +28 -0
  191. umap/tests/integration/test_owned_map.py +24 -6
  192. umap/tests/integration/test_picto.py +25 -38
  193. umap/tests/integration/test_querystring.py +9 -15
  194. umap/tests/integration/test_slideshow.py +0 -5
  195. umap/tests/integration/test_statics.py +3 -2
  196. umap/tests/integration/test_tableeditor.py +23 -0
  197. umap/tests/integration/test_tilelayer.py +10 -0
  198. umap/tests/integration/test_view_marker.py +64 -0
  199. umap/tests/integration/test_view_polygon.py +59 -0
  200. umap/tests/integration/test_view_polyline.py +51 -0
  201. umap/tests/test_map_views.py +13 -0
  202. {umap_project-2.1.2.dist-info → umap_project-2.2.0.dist-info}/METADATA +12 -12
  203. {umap_project-2.1.2.dist-info → umap_project-2.2.0.dist-info}/RECORD +206 -187
  204. {umap_project-2.1.2.dist-info → umap_project-2.2.0.dist-info}/WHEEL +1 -1
  205. umap/static/umap/test/Choropleth.js +0 -245
  206. umap/static/umap/test/Permissions.js +0 -74
  207. umap/static/umap/vendors/dompurify/purify.min.js +0 -3
  208. umap/static/umap/vendors/dompurify/purify.min.js.map +0 -1
  209. umap/tests/integration/test_drawing.py +0 -243
  210. {umap_project-2.1.2.dist-info → umap_project-2.2.0.dist-info}/entry_points.txt +0 -0
  211. {umap_project-2.1.2.dist-info → umap_project-2.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -18,134 +18,6 @@ describe('U.FeatureMixin', function () {
18
18
  resetMap()
19
19
  })
20
20
 
21
- describe('#edit()', function () {
22
- let link
23
-
24
- it('should have datalayer features created', function () {
25
- assert.equal(
26
- document.querySelectorAll(
27
- '#map > .leaflet-map-pane > .leaflet-overlay-pane path.leaflet-interactive'
28
- ).length,
29
- 2
30
- )
31
- assert.ok(qs('path[fill="none"]')) // Polyline
32
- assert.ok(qs('path[fill="DarkBlue"]')) // Polygon
33
- })
34
-
35
- it('should toggle edit panel on shift-clic', function () {
36
- enableEdit()
37
- happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true })
38
- assert.ok(qs('form#umap-feature-properties'))
39
- assert.ok(qs('#map.umap-ui'))
40
- happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true })
41
- assert.notOk(qs('#map.umap-ui'))
42
- })
43
-
44
- it('should open datalayer edit panel on ctrl-shift-clic', function () {
45
- enableEdit()
46
- happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true, ctrlKey: true })
47
- assert.ok(qs('div.umap-layer-properties-container'))
48
- })
49
-
50
- it('should take into account styles changes made in the datalayer', function () {
51
- happen.click(
52
- qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
53
- )
54
- var colorInput = qs('form#datalayer-advanced-properties input[name=color]')
55
- changeInputValue(colorInput, 'DarkRed')
56
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
57
- assert.notOk(qs('path[fill="DarkBlue"]'))
58
- assert.ok(qs('path[fill="DarkRed"]'))
59
- })
60
-
61
- it('should open a popup toolbar on feature click', function () {
62
- enableEdit()
63
- happen.click(qs('path[fill="DarkRed"]'))
64
- var toolbar = qs('ul.leaflet-inplace-toolbar')
65
- assert.ok(toolbar)
66
- link = qs('a.umap-toggle-edit', toolbar)
67
- assert.ok(link)
68
- })
69
-
70
- it('should open a form on popup toolbar toggle edit click', function () {
71
- happen.click(link)
72
- var form = qs('form#umap-feature-properties')
73
- var input = qs('form#umap-feature-properties input[name="name"]')
74
- assert.ok(form)
75
- assert.ok(input)
76
- })
77
-
78
- it('should not handle _umap_options has normal property', function () {
79
- assert.notOk(qs('form#umap-feature-properties input[name="_umap_options"]'))
80
- })
81
-
82
- it('should give precedence to feature style over datalayer styles', function () {
83
- var input = qs('#umap-ui-container form input[name="color"]')
84
- assert.ok(input)
85
- changeInputValue(input, 'DarkGreen')
86
- assert.notOk(qs('path[fill="DarkRed"]'))
87
- assert.notOk(qs('path[fill="DarkBlue"]'))
88
- assert.ok(qs('path[fill="DarkGreen"]'))
89
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
90
- })
91
-
92
- it('should remove stroke if set to no', function () {
93
- assert.notOk(qs('path[stroke="none"]'))
94
- var defineButton = qs(
95
- '#umap-feature-shape-properties .formbox:nth-child(4) .define'
96
- )
97
- happen.click(defineButton)
98
- var input = qs('#umap-feature-shape-properties input[name="stroke"]')
99
- assert.ok(input)
100
- input.checked = false
101
- happen.once(input, { type: 'change' })
102
- assert.ok(qs('path[stroke="none"]'))
103
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
104
- })
105
-
106
- it('should not override already set style on features', function () {
107
- happen.click(
108
- qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
109
- )
110
- changeInputValue(qs('#umap-ui-container form input[name=color]'), 'Chocolate')
111
- assert.notOk(qs('path[fill="DarkBlue"]'))
112
- assert.notOk(qs('path[fill="DarkRed"]'))
113
- assert.notOk(qs('path[fill="Chocolate"]'))
114
- assert.ok(qs('path[fill="DarkGreen"]'))
115
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
116
- })
117
-
118
- it('should reset style on cancel click', function () {
119
- clickCancel()
120
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
121
- assert.ok(qs('path[fill="DarkBlue"]'))
122
- assert.notOk(qs('path[fill="DarkRed"]'))
123
- })
124
-
125
- it('should set map.editedFeature on edit', function () {
126
- enableEdit()
127
- assert.notOk(map.editedFeature)
128
- happen.click(qs('path[fill="DarkBlue"]'))
129
- happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
130
- assert.ok(map.editedFeature)
131
- disableEdit()
132
- })
133
-
134
- it('should reset map.editedFeature on panel open', function (done) {
135
- enableEdit()
136
- assert.notOk(map.editedFeature)
137
- happen.click(qs('path[fill="DarkBlue"]'))
138
- happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
139
- assert.ok(map.editedFeature)
140
- map.displayCaption()
141
- window.setTimeout(function () {
142
- assert.notOk(map.editedFeature)
143
- disableEdit()
144
- done()
145
- }, 1001) // CSS transition time.
146
- })
147
- })
148
-
149
21
  describe('#utils()', function () {
150
22
  var poly, marker
151
23
  function setFeatures(datalayer) {
@@ -191,83 +63,6 @@ describe('U.FeatureMixin', function () {
191
63
  })
192
64
  })
193
65
 
194
- describe('#openPopup()', function () {
195
- let poly
196
- before(function () {
197
- datalayer.eachLayer(function (layer) {
198
- if (!poly && layer instanceof L.Polygon) {
199
- poly = layer
200
- }
201
- })
202
- })
203
-
204
- it('should open a popup on click', function () {
205
- assert.notOk(qs('.leaflet-popup-content'))
206
- happen.click(qs('path[fill="DarkBlue"]'))
207
- var title = qs('.leaflet-popup-content')
208
- assert.ok(title)
209
- assert.include(title.innerHTML, 'name poly')
210
- happen.click(qs('#map')) // Close popup
211
- })
212
-
213
- it('should handle locale parameter inside description', function (done) {
214
- poly.properties.description =
215
- 'This is a link to [[https://domain.org/?locale={locale}|Wikipedia]]'
216
- happen.click(qs('path[fill="DarkBlue"]'))
217
- window.setTimeout(function () {
218
- let content = qs('.umap-popup-container')
219
- assert.ok(content)
220
- assert.include(
221
- content.innerHTML,
222
- '<a href="https://domain.org/?locale=en" target="_blank">Wikipedia</a>'
223
- )
224
- happen.click(qs('#map')) // Close popup
225
- done()
226
- }, 500) // No idea why needed…
227
- })
228
- })
229
-
230
- describe('#highlight()', function () {
231
- it('should highlight marker on click', function () {
232
- assert.notOk(qs('.umap-icon-active'))
233
- happen.click(qs('div.leaflet-marker-icon'))
234
- assert.ok(qs('.umap-icon-active'))
235
- happen.click(qs('#map')) // Close popup
236
- assert.notOk(qs('.umap-icon-active'))
237
- })
238
-
239
- it('should still highlight marker after hide() and show()', function () {
240
- datalayer.hide()
241
- datalayer.show()
242
- happen.click(qs('div.leaflet-marker-icon'))
243
- assert.ok(qs('.umap-icon-active'))
244
- })
245
-
246
- it('should highlight path', function () {
247
- happen.click(qs('path[stroke-opacity="0.6"]'))
248
- var path = qs('path[stroke-opacity="1"]')
249
- assert.ok(path)
250
- })
251
-
252
- it('should highlight polygon', function () {
253
- var path = qs('path[fill="DarkBlue"]')
254
- happen.click(path)
255
- assert.isAbove(path.attributes['fill-opacity'].value, 0.5)
256
- })
257
- })
258
-
259
- describe('#tooltip', function () {
260
- it('should have a tooltip when active and allow variables', function () {
261
- map.options.showLabel = true
262
- map.options.labelKey = 'Foo {name}'
263
- datalayer.redraw()
264
- assert.equal(
265
- qs('.leaflet-tooltip-pane .leaflet-tooltip').textContent,
266
- 'Foo name poly'
267
- )
268
- })
269
- })
270
-
271
66
  describe('#properties()', function () {
272
67
  it('should rename property', function () {
273
68
  var poly = datalayer._lineToLayer({}, [
@@ -333,25 +128,4 @@ describe('U.FeatureMixin', function () {
333
128
  })
334
129
  })
335
130
 
336
- describe('#changeDataLayer()', function () {
337
- it('should change style on datalayer select change', function () {
338
- enableEdit()
339
- happen.click(qs('.manage-datalayers'))
340
- happen.click(qs('#umap-ui-container .add-datalayer'))
341
- changeInputValue(qs('form.umap-form input[name="name"]'), 'New layer')
342
- changeInputValue(
343
- qs('form#datalayer-advanced-properties input[name=color]'),
344
- 'MediumAquaMarine'
345
- )
346
- happen.click(qs('path[fill="DarkBlue"]'))
347
- happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
348
- var select = qs('select[name=datalayer]')
349
- select.selectedIndex = 0
350
- happen.once(select, { type: 'change' })
351
- assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
352
- assert.notOk(qs('path[fill="DarkBlue"]'))
353
- assert.ok(qs('path[fill="MediumAquaMarine"]'))
354
- clickCancel()
355
- })
356
- })
357
131
  })
@@ -19,310 +19,6 @@ describe('U.Map', () => {
19
19
  resetMap()
20
20
  })
21
21
 
22
- describe('#init()', () => {
23
- it('should be initialized', function () {
24
- assert.equal(map.options.umap_id, 99)
25
- })
26
-
27
- it('should have created the edit button', function () {
28
- assert.ok(qs('div.leaflet-control-edit-enable'))
29
- })
30
-
31
- it('should have datalayer control div', function () {
32
- assert.ok(qs('div.leaflet-control-browse'))
33
- })
34
-
35
- it('should have datalayer actions div', function () {
36
- assert.ok(qs('div.umap-browse-actions'))
37
- })
38
-
39
- it('should have icon container div', function () {
40
- assert.ok(qs('div.icon_container'))
41
- })
42
-
43
- it('should hide icon container div when hiding datalayer', function () {
44
- var el = qs(
45
- '.leaflet-control-browse #browse_data_toggle_' +
46
- L.stamp(datalayer) +
47
- ' .layer-toggle'
48
- )
49
- happen.click(el)
50
- assert.notOk(qs('div.icon_container'))
51
- })
52
-
53
- it('enable edit on click on toggle button', function () {
54
- var el = qs('div.leaflet-control-edit-enable button')
55
- happen.click(el)
56
- assert.isTrue(L.DomUtil.hasClass(document.body, 'umap-edit-enabled'))
57
- })
58
-
59
- it('should have only one datalayer in its index', function () {
60
- assert.equal(map.datalayers_index.length, 1)
61
- })
62
- })
63
-
64
- describe('#editMetadata()', function () {
65
- var form, input
66
-
67
- it('should build a form on editMetadata control click', function (done) {
68
- var button = qs('a.update-map-settings')
69
- assert.ok(button)
70
- happen.click(button)
71
- form = qs('form.umap-form')
72
- input = qs('form[class="umap-form"] input[name="name"]')
73
- assert.ok(form)
74
- assert.ok(input)
75
- done()
76
- })
77
-
78
- it('should update map name on input change', function () {
79
- var new_name = 'This is a new name'
80
- input.value = new_name
81
- happen.once(input, { type: 'input' })
82
- assert.equal(map.options.name, new_name)
83
- })
84
-
85
- it('should have made Map dirty', function () {
86
- assert.ok(map.isDirty)
87
- })
88
-
89
- it('should have added dirty class on map container', function () {
90
- assert.ok(L.DomUtil.hasClass(map._container, 'umap-is-dirty'))
91
- })
92
- })
93
-
94
- describe('#delete()', function () {
95
- let path = '/map/99/update/delete/',
96
- oldConfirm,
97
- newConfirm = function () {
98
- return true
99
- }
100
-
101
- before(function () {
102
- oldConfirm = window.confirm
103
- window.confirm = newConfirm
104
- })
105
- after(function () {
106
- window.confirm = oldConfirm
107
- })
108
-
109
- it('should ask for confirmation on delete link click', async function () {
110
- let button = qs('a.update-map-settings')
111
- assert.ok(button, 'update map info button exists')
112
- happen.click(button)
113
- let deleteLink = qs('button.umap-delete')
114
- assert.ok(deleteLink, 'delete map button exists')
115
- sinon.spy(window, 'confirm')
116
- await fetchMock.post(path, { redirect: '#' })
117
- happen.click(deleteLink)
118
- assert(window.confirm.calledOnce)
119
- window.confirm.restore()
120
- })
121
- })
122
-
123
- describe('#importData()', function () {
124
- let fileInput, textarea, submit, formatSelect, layerSelect, clearFlag
125
-
126
- it('should build a form on click', function () {
127
- happen.click(qs('a.upload-data'))
128
- fileInput = qs('.umap-upload input[type="file"]')
129
- textarea = qs('.umap-upload textarea')
130
- submit = qs('.umap-upload input[type="button"]')
131
- formatSelect = qs('.umap-upload select[name="format"]')
132
- layerSelect = qs('.umap-upload select[name="datalayer"]')
133
- assert.ok(fileInput)
134
- assert.ok(submit)
135
- assert.ok(textarea)
136
- assert.ok(formatSelect)
137
- assert.ok(layerSelect)
138
- })
139
-
140
- it('should import geojson from textarea', function () {
141
- datalayer.empty()
142
- assert.equal(datalayer._index.length, 0)
143
- textarea.value =
144
- '{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [6.922931671142578, 47.481161607175736]}, "type": "Feature", "properties": {"color": "", "name": "Chez R\u00e9my", "description": ""}}, {"geometry": {"type": "LineString", "coordinates": [[2.4609375, 48.88639177703194], [2.48291015625, 48.76343113791796], [2.164306640625, 48.719961222646276]]}, "type": "Feature", "properties": {"color": "", "name": "P\u00e9rif", "description": ""}}]}'
145
- changeSelectValue(formatSelect, 'geojson')
146
- happen.click(submit)
147
- assert.equal(datalayer._index.length, 2)
148
- })
149
-
150
- it('should remove dot in property name', function () {
151
- datalayer.empty()
152
- assert.equal(datalayer._index.length, 0)
153
- textarea.value =
154
- '{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [6.922931671142578, 47.481161607175736]}, "type": "Feature", "properties": {"color": "", "name": "Chez R\u00e9my", "A . in the name": ""}}, {"geometry": {"type": "LineString", "coordinates": [[2.4609375, 48.88639177703194], [2.48291015625, 48.76343113791796], [2.164306640625, 48.719961222646276]]}, "type": "Feature", "properties": {"color": "", "name": "P\u00e9rif", "with a dot.": ""}}]}'
155
- changeSelectValue(formatSelect, 'geojson')
156
- happen.click(submit)
157
- assert.equal(datalayer._index.length, 2)
158
- assert.ok(datalayer._propertiesIndex.includes('A _ in the name'))
159
- assert.ok(datalayer._propertiesIndex.includes('with a dot_'))
160
- })
161
-
162
- it('should import osm from textarea', function () {
163
- datalayer.empty()
164
- happen.click(qs('a.upload-data'))
165
- textarea = qs('.umap-upload textarea')
166
- submit = qs('.umap-upload input[type="button"]')
167
- formatSelect = qs('.umap-upload select[name="format"]')
168
- assert.equal(datalayer._index.length, 0)
169
- textarea.value =
170
- '{"version": 0.6,"generator": "Overpass API 0.7.55.4 3079d8ea","osm3s": {"timestamp_osm_base": "2018-09-22T05:26:02Z","copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."},"elements": [{"type": "node","id": 3619112991,"lat": 48.9352995,"lon": 2.3570684,"tags": {"information": "map","map_size": "city","map_type": "scheme","tourism": "information"}},{"type": "node","id": 3682500756,"lat": 48.9804426,"lon": 2.2719725,"tags": {"information": "map","level": "0","tourism": "information"}}]}'
171
- changeSelectValue(formatSelect, 'osm')
172
- happen.click(submit)
173
- assert.equal(datalayer._index.length, 2)
174
- assert.equal(
175
- datalayer._layers[datalayer._index[0]].properties.tourism,
176
- 'information'
177
- )
178
- })
179
-
180
- it('should import kml from textarea', function () {
181
- datalayer.empty()
182
- happen.click(qs('a.upload-data'))
183
- textarea = qs('.umap-upload textarea')
184
- submit = qs('.umap-upload input[type="button"]')
185
- formatSelect = qs('.umap-upload select[name="format"]')
186
- assert.equal(datalayer._index.length, 0)
187
- textarea.value = kml_example
188
- changeSelectValue(formatSelect, 'kml')
189
- happen.click(submit)
190
- assert.equal(datalayer._index.length, 3)
191
- })
192
-
193
- it('should import gpx from textarea', function () {
194
- datalayer.empty()
195
- happen.click(qs('a.upload-data'))
196
- textarea = qs('.umap-upload textarea')
197
- submit = qs('.umap-upload input[type="button"]')
198
- formatSelect = qs('.umap-upload select[name="format"]')
199
- assert.equal(datalayer._index.length, 0)
200
- textarea.value = gpx_example
201
- changeSelectValue(formatSelect, 'gpx')
202
- happen.click(submit)
203
- assert.equal(datalayer._index.length, 2)
204
- })
205
-
206
- it('should import csv from textarea', function () {
207
- datalayer.empty()
208
- happen.click(qs('a.upload-data'))
209
- textarea = qs('.umap-upload textarea')
210
- submit = qs('.umap-upload input[type="button"]')
211
- formatSelect = qs('.umap-upload select[name="format"]')
212
- assert.equal(datalayer._index.length, 0)
213
- textarea.value = csv_example
214
- changeSelectValue(formatSelect, 'csv')
215
- happen.click(submit)
216
- assert.equal(datalayer._index.length, 1)
217
- })
218
-
219
- it('should replace content if asked so', function () {
220
- happen.click(qs('a.upload-data'))
221
- textarea = qs('.umap-upload textarea')
222
- submit = qs('.umap-upload input[type="button"]')
223
- formatSelect = qs('.umap-upload select[name="format"]')
224
- clearFlag = qs('.umap-upload input[name="clear"]')
225
- clearFlag.checked = true
226
- assert.equal(datalayer._index.length, 1)
227
- textarea.value = csv_example
228
- changeSelectValue(formatSelect, 'csv')
229
- happen.click(submit)
230
- assert.equal(datalayer._index.length, 1)
231
- })
232
-
233
- it('should import GeometryCollection from textarea', function () {
234
- datalayer.empty()
235
- textarea.value =
236
- '{"type": "GeometryCollection","geometries": [{"type": "Point","coordinates": [-80.66080570220947,35.04939206472683]},{"type": "Polygon","coordinates": [[[-80.66458225250244,35.04496519190309],[-80.66344499588013,35.04603679820616],[-80.66258668899536,35.045580049697556],[-80.66387414932251,35.044280059194946],[-80.66458225250244,35.04496519190309]]]},{"type": "LineString","coordinates": [[-80.66237211227417,35.05950973022538],[-80.66269397735596,35.0592638296087],[-80.66284418106079,35.05893010615862],[-80.66308021545409,35.05833291342246],[-80.66359519958496,35.057753281001425],[-80.66387414932251,35.05740198662245],[-80.66441059112549,35.05703312589789],[-80.66486120223999,35.056787217822475],[-80.66541910171509,35.05650617911516],[-80.66563367843628,35.05631296444281],[-80.66601991653441,35.055891403570705],[-80.66619157791138,35.05545227534804],[-80.66619157791138,35.05517123204622],[-80.66625595092773,35.05489018777713],[-80.6662130355835,35.054222703761525],[-80.6662130355835,35.05392409072499],[-80.66595554351807,35.05290528508858],[-80.66569805145262,35.052044560077285],[-80.66550493240356,35.0514824490509],[-80.665762424469,35.05048117920187],[-80.66617012023926,35.04972582715769],[-80.66651344299316,35.049286665781096],[-80.66692113876343,35.0485313026898],[-80.66700696945189,35.048215102112344],[-80.66707134246826,35.04777593261294],[-80.66704988479614,35.04738946150025],[-80.66696405410767,35.04698542156371],[-80.66681385040283,35.046353007216055],[-80.66659927368164,35.04596652937105],[-80.66640615463257,35.04561518428889],[-80.6659984588623,35.045193568195565],[-80.66552639007568,35.044877354697526],[-80.6649899482727,35.04454357245502],[-80.66449642181396,35.04417465365292],[-80.66385269165039,35.04387600387859],[-80.66303730010986,35.043717894732545]]}]}'
237
- formatSelect = qs('.umap-upload select[name="format"]')
238
- changeSelectValue(formatSelect, 'geojson')
239
- happen.click(submit)
240
- assert.equal(datalayer._index.length, 3)
241
- })
242
-
243
- it('should import multipolygon', function () {
244
- datalayer.empty()
245
- textarea.value =
246
- '{"type": "Feature", "properties": { "name": "Some states" }, "geometry": { "type": "MultiPolygon", "coordinates": [[[[-109, 36], [-109, 40], [-102, 37], [-109, 36]], [[-108, 39], [-107, 37], [-104, 37], [-108, 39]]], [[[-119, 42], [-120, 39], [-114, 41], [-119, 42]]]] }}'
247
- changeSelectValue(formatSelect, 'geojson')
248
- happen.click(submit)
249
- assert.equal(datalayer._index.length, 1)
250
- var layer = datalayer.getFeatureByIndex(0)
251
- assert.equal(layer._latlngs.length, 2) // Two shapes.
252
- assert.equal(layer._latlngs[0].length, 2) // Hole.
253
- })
254
-
255
- it('should import multipolyline', function () {
256
- datalayer.empty()
257
- textarea.value =
258
- '{"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "MultiLineString", "coordinates": [[[-108, 46], [-113, 43]], [[-112, 45], [-115, 44]]] } }]}'
259
- changeSelectValue(formatSelect, 'geojson')
260
- happen.click(submit)
261
- assert.equal(datalayer._index.length, 1)
262
- var layer = datalayer.getFeatureByIndex(0)
263
- assert.equal(layer._latlngs.length, 2) // Two shapes.
264
- })
265
-
266
- it('should import raw umap data from textarea', function () {
267
- //Right now, the import function will try to save and reload. Stop this from happening.
268
- var disabledSaveFunction = map.save
269
- map.save = function () {}
270
- happen.click(qs('a.upload-data'))
271
- var initialLayerCount = Object.keys(map.datalayers).length
272
- formatSelect = qs('.umap-upload select[name="format"]')
273
- textarea = qs('.umap-upload textarea')
274
- textarea.value =
275
- '{ "type": "umap", "geometry": { "type": "Point", "coordinates": [3.0528, 50.6269] }, "properties": { "umap_id": 666, "longCredit": "the illustrious mapmaker", "shortCredit": "the mapmaker", "slideshow": {}, "captionBar": true, "dashArray": "5,5", "fillOpacity": "0.5", "fillColor": "Crimson", "fill": true, "weight": "2", "opacity": "0.9", "smoothFactor": "1", "iconClass": "Drop", "color": "Red", "limitBounds": {}, "tilelayer": { "maxZoom": 18, "url_template": "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg", "minZoom": 0, "attribution": "Map tiles by [[http://stamen.com|Stamen Design]], under [[http://creativecommons.org/licenses/by/3.0|CC BY 3.0]]. Data by [[http://openstreetmap.org|OpenStreetMap]], under [[http://creativecommons.org/licenses/by-sa/3.0|CC BY SA]].", "name": "Watercolor" }, "licence": { "url": "", "name": "No licence set" }, "description": "Map description", "name": "Imported map", "tilelayersControl": true, "onLoadPanel": "caption", "displayPopupFooter": true, "miniMap": true, "moreControl": true, "scaleControl": true, "zoomControl": true, "scrollWheelZoom": true, "datalayersControl": true, "zoom": 6 }, "layers": [{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [4.2939, 50.8893], [4.2441, 50.8196], [4.3869, 50.7642], [4.4813, 50.7929], [4.413, 50.9119], [4.2939, 50.8893] ] ] }, "properties": { "name": "Bruxelles", "description": "polygon" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [3.0528, 50.6269] }, "properties": { "_umap_options": { "color": "Orange" }, "name": "Lille", "description": "une ville" } }], "_umap_options": { "displayOnLoad": true, "name": "Cities", "id": 108, "remoteData": {}, "description": "A layer with some cities", "color": "Navy", "iconClass": "Drop", "smoothFactor": "1", "dashArray": "5,1", "fillOpacity": "0.5", "fillColor": "Blue", "fill": true } }, { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [1.7715, 50.9255], [1.6589, 50.9696], [1.4941, 51.0128], [1.4199, 51.0638], [1.2881, 51.1104] ] }, "properties": { "_umap_options": { "weight": "4" }, "name": "tunnel sous la Manche" } }], "_umap_options": { "displayOnLoad": true, "name": "Tunnels", "id": 109, "remoteData": {} } }]}'
276
- formatSelect.value = 'umap'
277
- submit = qs('.umap-upload input[type="button"]')
278
- happen.click(submit)
279
- assert.equal(Object.keys(map.datalayers).length, initialLayerCount + 2)
280
- assert.equal(map.options.name, 'Imported map')
281
- var foundFirstLayer = false
282
- var foundSecondLayer = false
283
- for (var idx in map.datalayers) {
284
- var datalayer = map.datalayers[idx]
285
- if (datalayer.options.name === 'Cities') {
286
- foundFirstLayer = true
287
- assert.equal(datalayer._index.length, 2)
288
- }
289
- if (datalayer.options.name === 'Tunnels') {
290
- foundSecondLayer = true
291
- assert.equal(datalayer._index.length, 1)
292
- }
293
- }
294
- assert.equal(foundFirstLayer, true)
295
- assert.equal(foundSecondLayer, true)
296
- })
297
-
298
- it('should only import options on the whitelist (umap format import)', function () {
299
- assert.equal(map.options.umap_id, 99)
300
- })
301
-
302
- it('should update title bar (umap format import)', function () {
303
- var title = qs('#map div.umap-main-edit-toolbox button.map-name')
304
- assert.equal(title.innerHTML, 'Imported map')
305
- })
306
-
307
- it('should reinitialize controls (umap format import)', function () {
308
- var minimap = qs('#map div.leaflet-control-container div.leaflet-control-minimap')
309
- assert.ok(minimap)
310
- })
311
-
312
- it('should update the tilelayer switcher control (umap format import)', function () {
313
- //The tilelayer in the imported data isn't in the tilelayer list (set in _pre.js), there should be no selection on the tilelayer switcher
314
- var selectedLayer = qs('.umap-tilelayer-switcher-container li.selected')
315
- assert.equal(selectedLayer, null)
316
- })
317
-
318
- it('should set the tilelayer (umap format import)', function () {
319
- assert.equal(
320
- map.selected_tilelayer._url,
321
- 'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg'
322
- )
323
- })
324
- })
325
-
326
22
  describe('#localizeUrl()', function () {
327
23
  it('should replace known variables', function () {
328
24
  assert.equal(