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