umap-project 2.1.3__py3-none-any.whl → 2.2.0b0__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 (196) 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 +8 -6
  11. umap/settings/base.py +1 -0
  12. umap/static/umap/base.css +29 -151
  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 +82 -73
  25. umap/static/umap/js/modules/dompurify.js +12 -0
  26. umap/static/umap/js/modules/facets.js +148 -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.controls.js +183 -330
  36. umap/static/umap/js/umap.core.js +60 -364
  37. umap/static/umap/js/umap.datalayer.permissions.js +1 -1
  38. umap/static/umap/js/umap.features.js +60 -40
  39. umap/static/umap/js/umap.forms.js +111 -25
  40. umap/static/umap/js/umap.icon.js +11 -4
  41. umap/static/umap/js/umap.importer.js +24 -17
  42. umap/static/umap/js/umap.js +170 -145
  43. umap/static/umap/js/umap.layer.js +71 -40
  44. umap/static/umap/js/umap.permissions.js +9 -11
  45. umap/static/umap/js/umap.popup.js +10 -21
  46. umap/static/umap/js/umap.share.js +11 -8
  47. umap/static/umap/js/umap.tableeditor.js +4 -6
  48. umap/static/umap/js/umap.ui.js +0 -51
  49. umap/static/umap/locale/am_ET.js +242 -227
  50. umap/static/umap/locale/am_ET.json +18 -7
  51. umap/static/umap/locale/ar.js +242 -227
  52. umap/static/umap/locale/ar.json +18 -7
  53. umap/static/umap/locale/ast.js +242 -227
  54. umap/static/umap/locale/ast.json +18 -7
  55. umap/static/umap/locale/bg.js +242 -227
  56. umap/static/umap/locale/bg.json +18 -7
  57. umap/static/umap/locale/br.js +252 -237
  58. umap/static/umap/locale/br.json +22 -11
  59. umap/static/umap/locale/ca.js +242 -227
  60. umap/static/umap/locale/ca.json +18 -7
  61. umap/static/umap/locale/cs_CZ.js +242 -227
  62. umap/static/umap/locale/cs_CZ.json +18 -7
  63. umap/static/umap/locale/da.js +242 -227
  64. umap/static/umap/locale/da.json +18 -7
  65. umap/static/umap/locale/de.js +242 -227
  66. umap/static/umap/locale/de.json +18 -7
  67. umap/static/umap/locale/el.js +242 -227
  68. umap/static/umap/locale/el.json +18 -7
  69. umap/static/umap/locale/en.js +242 -234
  70. umap/static/umap/locale/en.json +19 -8
  71. umap/static/umap/locale/en_US.json +18 -7
  72. umap/static/umap/locale/es.js +242 -227
  73. umap/static/umap/locale/es.json +18 -7
  74. umap/static/umap/locale/et.js +242 -227
  75. umap/static/umap/locale/et.json +18 -7
  76. umap/static/umap/locale/eu.js +227 -199
  77. umap/static/umap/locale/eu.json +1 -1
  78. umap/static/umap/locale/fa_IR.js +242 -227
  79. umap/static/umap/locale/fa_IR.json +18 -7
  80. umap/static/umap/locale/fi.js +242 -227
  81. umap/static/umap/locale/fi.json +18 -7
  82. umap/static/umap/locale/fr.js +242 -234
  83. umap/static/umap/locale/fr.json +18 -7
  84. umap/static/umap/locale/gl.js +242 -227
  85. umap/static/umap/locale/gl.json +18 -7
  86. umap/static/umap/locale/he.js +242 -227
  87. umap/static/umap/locale/he.json +18 -7
  88. umap/static/umap/locale/hr.js +242 -227
  89. umap/static/umap/locale/hr.json +18 -7
  90. umap/static/umap/locale/hu.js +242 -234
  91. umap/static/umap/locale/hu.json +18 -7
  92. umap/static/umap/locale/id.js +242 -227
  93. umap/static/umap/locale/id.json +18 -7
  94. umap/static/umap/locale/is.js +242 -227
  95. umap/static/umap/locale/is.json +18 -7
  96. umap/static/umap/locale/it.js +242 -234
  97. umap/static/umap/locale/it.json +18 -7
  98. umap/static/umap/locale/ja.js +242 -227
  99. umap/static/umap/locale/ja.json +18 -7
  100. umap/static/umap/locale/ko.js +242 -227
  101. umap/static/umap/locale/ko.json +18 -7
  102. umap/static/umap/locale/lt.js +242 -227
  103. umap/static/umap/locale/lt.json +18 -7
  104. umap/static/umap/locale/ms.js +242 -234
  105. umap/static/umap/locale/ms.json +19 -8
  106. umap/static/umap/locale/nl.js +245 -230
  107. umap/static/umap/locale/nl.json +18 -7
  108. umap/static/umap/locale/no.js +242 -227
  109. umap/static/umap/locale/no.json +18 -7
  110. umap/static/umap/locale/pl.js +242 -227
  111. umap/static/umap/locale/pl.json +18 -7
  112. umap/static/umap/locale/pl_PL.json +18 -7
  113. umap/static/umap/locale/pt.js +242 -227
  114. umap/static/umap/locale/pt.json +18 -7
  115. umap/static/umap/locale/pt_BR.js +242 -227
  116. umap/static/umap/locale/pt_BR.json +18 -7
  117. umap/static/umap/locale/pt_PT.js +242 -227
  118. umap/static/umap/locale/pt_PT.json +18 -7
  119. umap/static/umap/locale/ro.js +242 -227
  120. umap/static/umap/locale/ro.json +18 -7
  121. umap/static/umap/locale/ru.js +242 -227
  122. umap/static/umap/locale/ru.json +18 -7
  123. umap/static/umap/locale/si.js +1 -1
  124. umap/static/umap/locale/si.json +1 -1
  125. umap/static/umap/locale/sk_SK.js +242 -227
  126. umap/static/umap/locale/sk_SK.json +18 -7
  127. umap/static/umap/locale/sl.js +242 -227
  128. umap/static/umap/locale/sl.json +18 -7
  129. umap/static/umap/locale/sr.js +242 -227
  130. umap/static/umap/locale/sr.json +18 -7
  131. umap/static/umap/locale/sv.js +242 -227
  132. umap/static/umap/locale/sv.json +18 -7
  133. umap/static/umap/locale/th_TH.js +242 -227
  134. umap/static/umap/locale/th_TH.json +18 -7
  135. umap/static/umap/locale/tr.js +242 -227
  136. umap/static/umap/locale/tr.json +18 -7
  137. umap/static/umap/locale/uk_UA.js +242 -227
  138. umap/static/umap/locale/uk_UA.json +18 -7
  139. umap/static/umap/locale/vi.js +242 -227
  140. umap/static/umap/locale/vi.json +18 -7
  141. umap/static/umap/locale/vi_VN.json +18 -7
  142. umap/static/umap/locale/zh.js +242 -227
  143. umap/static/umap/locale/zh.json +18 -7
  144. umap/static/umap/locale/zh_CN.json +18 -7
  145. umap/static/umap/locale/zh_TW.Big5.json +18 -7
  146. umap/static/umap/locale/zh_TW.js +242 -234
  147. umap/static/umap/locale/zh_TW.json +18 -7
  148. umap/static/umap/map.css +114 -265
  149. umap/static/umap/test/DataLayer.js +463 -0
  150. umap/static/umap/test/Feature.js +0 -226
  151. umap/static/umap/test/TableEditor.js +104 -0
  152. umap/static/umap/test/Util.js +0 -521
  153. umap/static/umap/test/index.html +0 -1
  154. umap/static/umap/unittests/URLs.js +1 -1
  155. umap/static/umap/unittests/utils.js +610 -0
  156. umap/static/umap/vars.css +9 -0
  157. umap/static/umap/vendors/dompurify/purify.es.mjs +1525 -0
  158. umap/static/umap/vendors/iconlayers/iconLayers.js +1 -1
  159. umap/templates/umap/css.html +2 -0
  160. umap/templates/umap/js.html +0 -1
  161. umap/templates/umap/map_detail.html +4 -0
  162. umap/templates/umap/map_table.html +12 -10
  163. umap/templatetags/umap_tags.py +5 -0
  164. umap/tests/integration/conftest.py +12 -1
  165. umap/tests/integration/test_anonymous_owned_map.py +6 -5
  166. umap/tests/integration/test_browser.py +12 -25
  167. umap/tests/integration/test_choropleth.py +1 -1
  168. umap/tests/integration/test_dashboard.py +10 -0
  169. umap/tests/integration/test_datalayer.py +8 -6
  170. umap/tests/integration/test_edit_datalayer.py +24 -19
  171. umap/tests/integration/test_edit_map.py +182 -2
  172. umap/tests/integration/test_edit_marker.py +120 -0
  173. umap/tests/integration/test_edit_polygon.py +122 -0
  174. umap/tests/integration/test_facets_browser.py +104 -14
  175. umap/tests/integration/test_import.py +70 -20
  176. umap/tests/integration/test_map.py +19 -17
  177. umap/tests/integration/test_map_list.py +28 -0
  178. umap/tests/integration/test_owned_map.py +10 -10
  179. umap/tests/integration/test_picto.py +5 -5
  180. umap/tests/integration/test_querystring.py +9 -15
  181. umap/tests/integration/test_slideshow.py +0 -5
  182. umap/tests/integration/test_statics.py +3 -2
  183. umap/tests/integration/test_tableeditor.py +1 -5
  184. umap/tests/integration/test_view_marker.py +64 -0
  185. umap/tests/integration/test_view_polygon.py +59 -0
  186. umap/tests/integration/test_view_polyline.py +51 -0
  187. umap/tests/test_map_views.py +13 -0
  188. {umap_project-2.1.3.dist-info → umap_project-2.2.0b0.dist-info}/METADATA +8 -8
  189. {umap_project-2.1.3.dist-info → umap_project-2.2.0b0.dist-info}/RECORD +194 -178
  190. umap/static/umap/vendors/dompurify/purify.min.js +0 -3
  191. umap/static/umap/vendors/dompurify/purify.min.js.map +0 -1
  192. /umap/tests/integration/{test_polygon.py → test_draw_polygon.py} +0 -0
  193. /umap/tests/integration/{test_polyline.py → test_draw_polyline.py} +0 -0
  194. {umap_project-2.1.3.dist-info → umap_project-2.2.0b0.dist-info}/WHEEL +0 -0
  195. {umap_project-2.1.3.dist-info → umap_project-2.2.0b0.dist-info}/entry_points.txt +0 -0
  196. {umap_project-2.1.3.dist-info → umap_project-2.2.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,463 @@
1
+ describe('U.DataLayer', () => {
2
+ let path = '/map/99/datalayer/update/62/',
3
+ map,
4
+ datalayer
5
+
6
+ before(async () => {
7
+ fetchMock.mock(/\/datalayer\/62\/\?.*/, JSON.stringify(RESPONSES.datalayer62_GET))
8
+ fetchMock.sticky('/map/99/update/settings/', { id: 99 })
9
+ this.options = {
10
+ umap_id: 99,
11
+ }
12
+ MAP = map = initMap({ umap_id: 99 })
13
+ const datalayer_options = defaultDatalayerData()
14
+ await map.initDataLayers([datalayer_options])
15
+ datalayer = map.getDataLayerByUmapId(62)
16
+ enableEdit()
17
+ })
18
+ after(() => {
19
+ fetchMock.restore()
20
+ resetMap()
21
+ })
22
+
23
+ describe('#init()', () => {
24
+ it('should be added in datalayers index', () => {
25
+ assert.notEqual(map.datalayers_index.indexOf(datalayer), -1)
26
+ })
27
+ })
28
+
29
+ describe('#edit()', () => {
30
+ var editButton, form, input, forceButton
31
+
32
+ it('row in control should be active', () => {
33
+ assert.notOk(
34
+ qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer) + '.off')
35
+ )
36
+ })
37
+
38
+ it('should have edit button', () => {
39
+ editButton = qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
40
+ assert.ok(editButton)
41
+ })
42
+
43
+ it('should have toggle visibility element', () => {
44
+ assert.ok(qs('.leaflet-control-browse i.layer-toggle'))
45
+ })
46
+
47
+ it('should exist only one datalayer', () => {
48
+ assert.equal(qsa('.leaflet-control-browse i.layer-toggle').length, 1)
49
+ })
50
+
51
+ it('should build a form on edit button click', () => {
52
+ happen.click(editButton)
53
+ form = qs('form.umap-form')
54
+ input = qs('form.umap-form input[name="name"]')
55
+ assert.ok(form)
56
+ assert.ok(input)
57
+ })
58
+
59
+ it('should update name on input change', () => {
60
+ var new_name = 'This is a new name'
61
+ input.value = new_name
62
+ happen.once(input, { type: 'input' })
63
+ assert.equal(datalayer.options.name, new_name)
64
+ })
65
+
66
+ it('should have made datalayer dirty', () => {
67
+ assert.ok(datalayer.isDirty)
68
+ assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
69
+ })
70
+
71
+ it('should have made Map dirty', () => {
72
+ assert.ok(map.isDirty)
73
+ })
74
+
75
+ it('should call datalayer.save on save button click', (done) => {
76
+ const postDatalayer = fetchMock.post(path, () => {
77
+ return defaultDatalayerData()
78
+ })
79
+ clickSave()
80
+ window.setTimeout(() => {
81
+ assert(fetchMock.called(path))
82
+ done()
83
+ }, 500)
84
+ })
85
+
86
+ it('should show alert if server respond 412', (done) => {
87
+ cleanAlert()
88
+ fetchMock.restore()
89
+ fetchMock.post(path, 412)
90
+ happen.click(editButton)
91
+ input = qs('form.umap-form input[name="name"]')
92
+ input.value = 'a new name'
93
+ happen.once(input, { type: 'input' })
94
+ clickSave()
95
+ window.setTimeout(() => {
96
+ assert(L.DomUtil.hasClass(map._container, 'umap-alert'))
97
+ assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
98
+ const forceButton = qs('#umap-alert-container .umap-action')
99
+ assert.ok(forceButton)
100
+ done()
101
+ }, 500)
102
+ })
103
+
104
+ it('should save anyway on force save button click', (done) => {
105
+ const forceButton = qs('#umap-alert-container .umap-action')
106
+ fetchMock.restore()
107
+ fetchMock.post(path, defaultDatalayerData)
108
+ happen.click(forceButton)
109
+ window.setTimeout(() => {
110
+ assert.notOk(qs('#umap-alert-container .umap-action'))
111
+ assert(fetchMock.called(path))
112
+ assert.equal(map.dirty_datalayers.indexOf(datalayer), -1)
113
+ done()
114
+ }, 500)
115
+ })
116
+ })
117
+
118
+ describe('#save() new', () => {
119
+ let newLayerButton, form, input, newDatalayer, editButton, manageButton
120
+
121
+ it('should have a manage datalayers action', () => {
122
+ enableEdit()
123
+ manageButton = qs('.manage-datalayers')
124
+ assert.ok(manageButton)
125
+ happen.click(manageButton)
126
+ })
127
+
128
+ it('should have a new layer button', () => {
129
+ newLayerButton = qs('.panel.right.on .add-datalayer')
130
+ assert.ok(newLayerButton)
131
+ })
132
+
133
+ it('should build a form on new layer button click', () => {
134
+ happen.click(newLayerButton)
135
+ form = qs('form.umap-form')
136
+ input = qs('form.umap-form input[name="name"]')
137
+ assert.ok(form)
138
+ assert.ok(input)
139
+ })
140
+
141
+ it('should have an empty name', () => {
142
+ assert.notOk(input.value)
143
+ })
144
+
145
+ it('should have created a new datalayer', () => {
146
+ assert.equal(map.datalayers_index.length, 2)
147
+ newDatalayer = map.datalayers_index[1]
148
+ })
149
+
150
+ it('should have made Map dirty', () => {
151
+ assert.ok(map.isDirty)
152
+ })
153
+
154
+ it('should update name on input change', () => {
155
+ var new_name = 'This is a new name'
156
+ input.value = new_name
157
+ happen.once(input, { type: 'input' })
158
+ assert.equal(newDatalayer.options.name, new_name)
159
+ })
160
+
161
+ it('should set umap_id on save callback', async () => {
162
+ assert.notOk(newDatalayer.umap_id)
163
+ fetchMock.post('/map/99/datalayer/create/', defaultDatalayerData({ id: 63 }))
164
+ clickSave()
165
+ return new Promise((resolve) => {
166
+ window.setTimeout(() => {
167
+ assert.equal(newDatalayer.umap_id, 63)
168
+ resolve()
169
+ }, 1000)
170
+ })
171
+ })
172
+
173
+ it('should have unset map dirty', () => {
174
+ assert.notOk(map.isDirty)
175
+ })
176
+
177
+ it('should have edit button', () => {
178
+ editButton = qs('#browse_data_toggle_' + L.stamp(newDatalayer) + ' .layer-edit')
179
+ assert.ok(editButton)
180
+ })
181
+
182
+ it('should call update if we edit again', async () => {
183
+ happen.click(editButton)
184
+ assert.notOk(map.isDirty)
185
+ input = qs('form.umap-form input[name="name"]')
186
+ input.value = "a new name again but we don't care which"
187
+ happen.once(input, { type: 'input' })
188
+ assert.ok(map.isDirty)
189
+ var response = () => {
190
+ return defaultDatalayerData({ pk: 63 })
191
+ }
192
+ var spy = sinon.spy(response)
193
+ fetchMock.post('/map/99/datalayer/update/63/', spy)
194
+ return new Promise((resolve) => {
195
+ clickSave()
196
+ window.setTimeout(() => {
197
+ assert.ok(spy.calledOnce)
198
+ resolve()
199
+ }, 1000)
200
+ })
201
+ })
202
+ })
203
+
204
+ describe('#iconClassChange()', () => {
205
+ it('should change icon class', () => {
206
+ happen.click(qs('[data-id="' + datalayer._leaflet_id + '"] .layer-edit'))
207
+ changeSelectValue(
208
+ qs('form#datalayer-advanced-properties select[name=iconClass]'),
209
+ 'Circle'
210
+ )
211
+ assert.notOk(qs('div.umap-div-icon'))
212
+ assert.ok(qs('div.umap-circle-icon'))
213
+ happen.click(
214
+ qs('form#datalayer-advanced-properties .umap-field-iconClass .undefine')
215
+ )
216
+ assert.notOk(qs('div.umap-circle-icon'))
217
+ assert.ok(qs('div.umap-div-icon'))
218
+ clickCancel()
219
+ })
220
+ })
221
+
222
+ describe('#show/hide', () => {
223
+ it('should hide features on hide', () => {
224
+ assert.ok(qs('div.umap-div-icon'))
225
+ assert.ok(qs('path[fill="none"]'))
226
+ datalayer.hide()
227
+ assert.notOk(qs('div.umap-div-icon'))
228
+ assert.notOk(qs('path[fill="none"]'))
229
+ })
230
+
231
+ it('should show features on show', () => {
232
+ assert.notOk(qs('div.umap-div-icon'))
233
+ assert.notOk(qs('path[fill="none"]'))
234
+ datalayer.show()
235
+ assert.ok(qs('div.umap-div-icon'))
236
+ assert.ok(qs('path[fill="none"]'))
237
+ })
238
+ })
239
+
240
+ describe('#clone()', () => {
241
+ it('should clone everything but the id and the name', () => {
242
+ enableEdit()
243
+ var clone = datalayer.clone()
244
+ assert.notOk(clone.umap_id)
245
+ assert.notEqual(clone.options.name, datalayer.name)
246
+ assert.ok(clone.options.name)
247
+ assert.equal(clone.options.color, datalayer.options.color)
248
+ assert.equal(clone.options.stroke, datalayer.options.stroke)
249
+ clone._delete()
250
+ clickSave()
251
+ })
252
+ })
253
+
254
+ describe('#restore()', () => {
255
+ var oldConfirm,
256
+ newConfirm = () => {
257
+ return true
258
+ }
259
+
260
+ before(() => {
261
+ oldConfirm = window.confirm
262
+ window.confirm = newConfirm
263
+ })
264
+ after(() => {
265
+ window.confirm = oldConfirm
266
+ })
267
+
268
+ it('should restore everything', (done) => {
269
+ enableEdit()
270
+ var geojson = L.Util.CopyJSON(RESPONSES.datalayer62_GET)
271
+ geojson.features.push({
272
+ geometry: {
273
+ type: 'Point',
274
+ coordinates: [-1.274658203125, 50.57634993749885],
275
+ },
276
+ type: 'Feature',
277
+ id: 1807,
278
+ properties: { _umap_options: {}, name: 'new point from restore' },
279
+ })
280
+ geojson._umap_options.color = 'Chocolate'
281
+ fetchMock.get('/datalayer/62/olderversion.geojson', geojson)
282
+ sinon.spy(window, 'confirm')
283
+ datalayer.restore('olderversion.geojson')
284
+ window.setTimeout(() => {
285
+ assert(window.confirm.calledOnce)
286
+ window.confirm.restore()
287
+ assert.equal(datalayer.umap_id, 62)
288
+ assert.ok(datalayer.isDirty)
289
+ assert.equal(datalayer._index.length, 4)
290
+ assert.ok(qs('path[fill="Chocolate"]'))
291
+ done()
292
+ }, 1000)
293
+ })
294
+
295
+ it('should revert anything on cancel click', () => {
296
+ clickCancel()
297
+ assert.equal(datalayer._index.length, 3)
298
+ assert.notOk(qs('path[fill="Chocolate"]'))
299
+ })
300
+ })
301
+
302
+ describe('#smart-options()', () => {
303
+ let poly, marker
304
+ before(() => {
305
+ datalayer.eachLayer(function (layer) {
306
+ if (!poly && layer instanceof L.Polygon) {
307
+ poly = layer
308
+ }
309
+ if (!marker && layer instanceof L.Marker) {
310
+ marker = layer
311
+ }
312
+ })
313
+ })
314
+
315
+ it('should parse color variable', () => {
316
+ let icon = qs('div.umap-div-icon .icon_container')
317
+ poly.properties.mycolor = 'DarkGoldenRod'
318
+ marker.properties.mycolor = 'DarkRed'
319
+ marker.properties._umap_options.color = undefined
320
+ assert.notOk(qs('path[fill="DarkGoldenRod"]'))
321
+ assert.equal(icon.style.backgroundColor, 'olivedrab')
322
+ datalayer.options.color = '{mycolor}'
323
+ datalayer.options.fillColor = '{mycolor}'
324
+ datalayer.indexProperties(poly)
325
+ datalayer.indexProperties(marker)
326
+ datalayer.redraw()
327
+ icon = qs('div.umap-div-icon .icon_container')
328
+ assert.equal(icon.style.backgroundColor, 'darkred')
329
+ assert.ok(qs('path[fill="DarkGoldenRod"]'))
330
+ })
331
+ })
332
+
333
+ describe('#facet-search()', () => {
334
+ before(async () => {
335
+ fetchMock.get(/\/datalayer\/63\/\?.*/, RESPONSES.datalayer63_GET)
336
+ map.options.facetKey = 'name'
337
+ await map.initDataLayers([RESPONSES.datalayer63_GET._umap_options])
338
+ })
339
+ it('should not impact non browsable layer', () => {
340
+ assert.ok(qs('path[fill="SteelBlue"]'))
341
+ })
342
+ it('should allow advanced filter', () => {
343
+ map.openFacet()
344
+ assert.ok(qs('div.umap-facet-search'))
345
+ // This one if from the normal datalayer
346
+ // it's name is "test", so it should be hidden
347
+ // by the filter
348
+ assert.ok(qs('path[fill="none"]'))
349
+ happen.click(qs('input[data-value="name poly"]'))
350
+ assert.notOk(qs('path[fill="none"]'))
351
+ // This one comes from a non browsable layer
352
+ // so it should not be affected by the filter
353
+ assert.ok(qs('path[fill="SteelBlue"]'))
354
+ happen.click(qs('input[data-value="name poly"]')) // Undo
355
+ })
356
+ it('should allow to control facet label', () => {
357
+ map.options.facetKey = 'name|Nom'
358
+ map.openFacet()
359
+ assert.ok(qs('div.umap-facet-search h5'))
360
+ assert.equal(qs('div.umap-facet-search h5').textContent, 'Nom')
361
+ })
362
+ })
363
+ describe('#zoomEnd', () => {
364
+ it('should honour the fromZoom option', () => {
365
+ map.setZoom(6, { animate: false })
366
+ assert.ok(qs('path[fill="none"]'))
367
+ datalayer.options.fromZoom = 6
368
+ map.setZoom(5, { animate: false })
369
+ assert.notOk(qs('path[fill="none"]'))
370
+ map.setZoom(6, { animate: false })
371
+ assert.ok(qs('path[fill="none"]'))
372
+ })
373
+
374
+ it('should honour the toZoom option', () => {
375
+ map.setZoom(6, { animate: false })
376
+ assert.ok(qs('path[fill="none"]'))
377
+ datalayer.options.toZoom = 6
378
+ map.setZoom(7, { animate: false })
379
+ assert.notOk(qs('path[fill="none"]'))
380
+ map.setZoom(6, { animate: false })
381
+ assert.ok(qs('path[fill="none"]'))
382
+ })
383
+ })
384
+
385
+ describe('#displayOnLoad', () => {
386
+ before(() => {
387
+ fetchMock.get(/\/datalayer\/64\/\?.*/, RESPONSES.datalayer64_GET)
388
+ })
389
+
390
+ beforeEach(async () => {
391
+ await map.initDataLayers([RESPONSES.datalayer64_GET._umap_options])
392
+ datalayer = map.getDataLayerByUmapId(64)
393
+ map.setZoom(10, { animate: false })
394
+ })
395
+
396
+ afterEach(() => {
397
+ datalayer._delete()
398
+ })
399
+
400
+ it('should not display layer at load', () => {
401
+ assert.notOk(qs('path[fill="AliceBlue"]'))
402
+ })
403
+
404
+ it('should display on click', (done) => {
405
+ happen.click(qs(`[data-id='${L.stamp(datalayer)}'] .layer-toggle`))
406
+ window.setTimeout(() => {
407
+ assert.ok(qs('path[fill="AliceBlue"]'))
408
+ done()
409
+ }, 500)
410
+ })
411
+
412
+ it('should not display on zoom', (done) => {
413
+ map.setZoom(9, { animate: false })
414
+ window.setTimeout(() => {
415
+ assert.notOk(qs('path[fill="AliceBlue"]'))
416
+ done()
417
+ }, 500)
418
+ })
419
+ })
420
+
421
+ describe('#delete()', () => {
422
+ let deleteLink,
423
+ deletePath = '/map/99/datalayer/delete/62/'
424
+ before(() => {
425
+ datalayer = map.getDataLayerByUmapId(62)
426
+ })
427
+
428
+ it('should have a delete link in update form', () => {
429
+ enableEdit()
430
+ happen.click(qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit'))
431
+ deleteLink = qs('button.delete_datalayer_button')
432
+ assert.ok(deleteLink)
433
+ })
434
+
435
+ it('should delete features on datalayer delete', () => {
436
+ happen.click(deleteLink)
437
+ assert.notOk(qs('div.icon_container'))
438
+ })
439
+
440
+ it('should have set map dirty', () => {
441
+ assert.ok(map.isDirty)
442
+ })
443
+
444
+ it('should delete layer control row on delete', () => {
445
+ assert.notOk(
446
+ qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer))
447
+ )
448
+ })
449
+
450
+ it('should be removed from map.datalayers_index', () => {
451
+ assert.equal(map.datalayers_index.indexOf(datalayer), -1)
452
+ })
453
+
454
+ it('should be removed from map.datalayers', () => {
455
+ assert.notOk(map.datalayers[L.stamp(datalayer)])
456
+ })
457
+
458
+ it('should be visible again on edit cancel', () => {
459
+ clickCancel()
460
+ assert.ok(qs('div.icon_container'))
461
+ })
462
+ })
463
+ })
@@ -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
  })