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