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,148 +0,0 @@
1
- L.U.Browser = L.Class.extend({
2
- options: {
3
- filter: '',
4
- inBbox: false,
5
- },
6
-
7
- initialize: function (map) {
8
- this.map = map
9
- },
10
-
11
- addFeature: function (feature) {
12
- const feature_li = L.DomUtil.create('li', `${feature.getClassName()} feature`),
13
- zoom_to = L.DomUtil.create('i', 'feature-zoom_to', feature_li),
14
- edit = L.DomUtil.create('i', 'show-on-edit feature-edit', feature_li),
15
- del = L.DomUtil.create('i', 'show-on-edit feature-delete', feature_li),
16
- colorBox = L.DomUtil.create('i', 'feature-color', feature_li),
17
- title = L.DomUtil.create('span', 'feature-title', feature_li),
18
- symbol = feature._getIconUrl
19
- ? L.U.Icon.prototype.formatUrl(feature._getIconUrl(), feature)
20
- : null
21
- zoom_to.title = L._('Bring feature to center')
22
- edit.title = L._('Edit this feature')
23
- del.title = L._('Delete this feature')
24
- title.textContent = feature.getDisplayName() || '—'
25
- const bgcolor = feature.getOption('color')
26
- colorBox.style.backgroundColor = bgcolor
27
- if (symbol && symbol !== this.map.options.default_iconUrl) {
28
- const icon = L.U.Icon.makeIconElement(symbol, colorBox)
29
- L.U.Icon.setIconContrast(icon, colorBox, symbol, bgcolor)
30
- }
31
- L.DomEvent.on(
32
- zoom_to,
33
- 'click',
34
- function (e) {
35
- e.callback = L.bind(this.view, this)
36
- this.zoomTo(e)
37
- },
38
- feature
39
- )
40
- L.DomEvent.on(
41
- title,
42
- 'click',
43
- function (e) {
44
- e.callback = L.bind(this.view, this)
45
- this.zoomTo(e)
46
- },
47
- feature
48
- )
49
- L.DomEvent.on(edit, 'click', feature.edit, feature)
50
- L.DomEvent.on(del, 'click', feature.confirmDelete, feature)
51
- return feature_li
52
- },
53
-
54
- addDatalayer: function (datalayer, dataContainer) {
55
- const filterKeys = this.map.getFilterKeys()
56
- const container = L.DomUtil.create(
57
- 'div',
58
- datalayer.getHidableClass(),
59
- dataContainer
60
- ),
61
- headline = L.DomUtil.create('h5', '', container)
62
- container.id = `browse_data_datalayer_${datalayer.umap_id}`
63
- datalayer.renderToolbox(headline)
64
- L.DomUtil.add('span', '', headline, datalayer.options.name)
65
- const counter = L.DomUtil.add('span', 'datalayer-counter', headline, datalayer.count())
66
- counter.title = L._('{count} features in this layer', {count: datalayer.count()})
67
- const ul = L.DomUtil.create('ul', '', container)
68
- L.DomUtil.classIf(container, 'off', !datalayer.isVisible())
69
-
70
- const build = () => {
71
- ul.innerHTML = ''
72
- const bounds = this.map.getBounds()
73
- datalayer.eachFeature((feature) => {
74
- if (
75
- this.options.filter &&
76
- !feature.matchFilter(this.options.filter, filterKeys)
77
- )
78
- return
79
- if (this.options.inBbox && !feature.isOnScreen(bounds)) return
80
- ul.appendChild(this.addFeature(feature))
81
- })
82
- }
83
-
84
- build()
85
- datalayer.on('datachanged', build)
86
- datalayer.map.ui.once('panel:closed', () => {
87
- datalayer.off('datachanged', build)
88
- this.map.off('moveend', build)
89
- })
90
- datalayer.map.ui.once('panel:ready', () => {
91
- datalayer.map.ui.once('panel:ready', () => {
92
- datalayer.off('datachanged', build)
93
- })
94
- })
95
- },
96
-
97
- open: function () {
98
- const container = L.DomUtil.create('div', 'umap-browse-data')
99
- // HOTFIX. Remove when this is merged and released:
100
- // https://github.com/Leaflet/Leaflet/pull/9052
101
- L.DomEvent.disableClickPropagation(container)
102
-
103
- const title = L.DomUtil.add(
104
- 'h3',
105
- 'umap-browse-title',
106
- container,
107
- this.map.options.name
108
- )
109
-
110
- const formContainer = L.DomUtil.create('div', '', container)
111
- const dataContainer = L.DomUtil.create('div', 'umap-browse-features', container)
112
-
113
- const appendAll = () => {
114
- dataContainer.innerHTML = ''
115
- this.map.eachBrowsableDataLayer((datalayer) => {
116
- this.addDatalayer(datalayer, dataContainer)
117
- })
118
- }
119
- const resetLayers = () => {
120
- this.map.eachBrowsableDataLayer((datalayer) => {
121
- datalayer.resetLayer(true)
122
- })
123
- }
124
- const fields = [
125
- ['options.filter', { handler: 'Input', placeholder: L._('Filter') }],
126
- ['options.inBbox', { handler: 'Switch', label: L._('Current map view') }],
127
- ]
128
- const builder = new L.U.FormBuilder(this, fields, {
129
- makeDirty: false,
130
- callback: (e) => {
131
- if (e.helper.field === 'options.inBbox') {
132
- if (this.options.inBbox) this.map.on('moveend', appendAll)
133
- else this.map.off('moveend', appendAll)
134
- }
135
- appendAll()
136
- resetLayers()
137
- },
138
- })
139
- formContainer.appendChild(builder.build())
140
-
141
- appendAll()
142
-
143
- this.map.ui.openPanel({
144
- data: { html: container },
145
- actions: [this.map._aboutLink()],
146
- })
147
- },
148
- })
@@ -1,304 +0,0 @@
1
- L.U.Xhr = L.Evented.extend({
2
- initialize: function (ui) {
3
- this.ui = ui
4
- },
5
-
6
- _wrapper: function () {
7
- let wrapper
8
- if (window.XMLHttpRequest === undefined) {
9
- wrapper = () => {
10
- try {
11
- return new window.ActiveXObject('Microsoft.XMLHTTP.6.0')
12
- } catch (e1) {
13
- try {
14
- return new window.ActiveXObject('Microsoft.XMLHTTP.3.0')
15
- } catch (e2) {
16
- throw new Error('XMLHttpRequest is not supported')
17
- }
18
- }
19
- }
20
- } else {
21
- wrapper = window.XMLHttpRequest
22
- }
23
- return new wrapper()
24
- },
25
-
26
- _ajax: function (settings) {
27
- const xhr = this._wrapper(),
28
- id = Math.random(),
29
- self = this
30
- this.fire('dataloading', { id: id })
31
- const loaded = () => {
32
- self.fire('dataload', { id: id })
33
- }
34
-
35
- try {
36
- xhr.open(settings.verb, settings.uri, true)
37
- } catch (err) {
38
- // Unknown protocol?
39
- this.ui.alert({
40
- content: L._('Error while fetching {url}', { url: settings.uri }),
41
- level: 'error',
42
- })
43
- loaded()
44
- return
45
- }
46
-
47
- if (
48
- settings.uri.indexOf('http') !== 0 ||
49
- settings.uri.indexOf(window.location.origin) === 0
50
- ) {
51
- // "X-" mode headers cause the request to be in preflight mode,
52
- // we don"t want that by default for CORS requests
53
- xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
54
- }
55
- if (settings.headers) {
56
- for (const name in settings.headers) {
57
- xhr.setRequestHeader(name, settings.headers[name])
58
- }
59
- }
60
-
61
- xhr.onreadystatechange = () => {
62
- if (xhr.readyState === 4) {
63
- if (xhr.status == 200) {
64
- settings.callback.call(settings.context || xhr, xhr.responseText, xhr)
65
- } else if (xhr.status === 403) {
66
- self.ui.alert({
67
- content: xhr.responseText || L._('Action not allowed :('),
68
- level: 'error',
69
- })
70
- } else if (xhr.status === 412) {
71
- const msg = L._(
72
- 'Woops! Someone else seems to have edited the data. You can save anyway, but this will erase the changes made by others.'
73
- )
74
- const actions = [
75
- {
76
- label: L._('Save anyway'),
77
- callback: function () {
78
- delete settings.headers['If-Match']
79
- self._ajax(settings)
80
- },
81
- callbackContext: self,
82
- },
83
- {
84
- label: L._('Cancel'),
85
- },
86
- ]
87
- self.ui.alert({
88
- content: msg,
89
- level: 'error',
90
- duration: 100000,
91
- actions: actions,
92
- })
93
- } else {
94
- if (xhr.status === 0) {
95
- // 0 === request cut by user or CORS
96
- self.ui.alert({
97
- content: L._(
98
- 'Issue reaching that URL (network problem or CORS protection): {url}',
99
- { url: settings.uri }
100
- ),
101
- level: 'error',
102
- })
103
- } else {
104
- self.ui.alert({ content: L._('Problem in the response'), level: 'error' })
105
- }
106
- }
107
- loaded()
108
- }
109
- }
110
-
111
- try {
112
- xhr.send(settings.data)
113
- } catch (e) {
114
- // Pass
115
- loaded()
116
- console.error('Bad Request', e)
117
- }
118
- },
119
-
120
- // supports only JSON as response data type
121
- _json: function (verb, uri, options) {
122
- const args = arguments,
123
- self = this
124
- const default_options = {
125
- async: true,
126
- callback: null,
127
- responseType: 'text',
128
- data: null,
129
- listen_form: null, // optional form to listen in default callback
130
- }
131
- const settings = L.Util.extend({}, default_options, options)
132
-
133
- if (verb === 'POST') {
134
- // find a way not to make this django specific
135
- const token = document.cookie.replace(
136
- /(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/,
137
- '$1'
138
- )
139
- if (token) {
140
- settings.headers = settings.headers || {}
141
- settings.headers['X-CSRFToken'] = token
142
- }
143
- }
144
-
145
- const callback = function (responseText, response) {
146
- let data
147
- try {
148
- data = JSON.parse(responseText)
149
- } catch (err) {
150
- console.log(err)
151
- self.ui.alert({
152
- content: L._('Problem in the response format'),
153
- level: 'error',
154
- })
155
- return
156
- }
157
- if (data.errors) {
158
- console.log(data.errors)
159
- self.ui.alert({ content: L._('An error occured'), level: 'error' })
160
- } else if (data.login_required) {
161
- // login_required should be an URL for the login form
162
- if (settings.login_callback) settings.login_callback(data)
163
- else self.login(data, args)
164
- } else {
165
- if (settings.callback)
166
- L.bind(settings.callback, settings.context || this)(data, response)
167
- else self.default_callback(data, settings, response)
168
- }
169
- }
170
-
171
- this._ajax({
172
- verb: verb,
173
- uri: uri,
174
- data: settings.data,
175
- callback: callback,
176
- headers: settings.headers,
177
- listener: settings.listener,
178
- })
179
- },
180
-
181
- get: function (uri, options) {
182
- this._json('GET', uri, options)
183
- },
184
-
185
- post: function (uri, options) {
186
- this._json('POST', uri, options)
187
- },
188
-
189
- submit_form: function (form_id, options) {
190
- if (typeof options === 'undefined') options = {}
191
- const form = L.DomUtil.get(form_id)
192
- const formData = new FormData(form)
193
- if (options.extraFormData) formData.append(options.extraFormData)
194
- options.data = formData
195
- this.post(form.action, options)
196
- return false
197
- },
198
-
199
- listen_form: function (form_id, options) {
200
- const form = L.DomUtil.get(form_id),
201
- self = this
202
- if (!form) return
203
- L.DomEvent.on(form, 'submit', L.DomEvent.stopPropagation)
204
- .on(form, 'submit', L.DomEvent.preventDefault)
205
- .on(form, 'submit', () => {
206
- self.submit_form(form_id, options)
207
- })
208
- },
209
-
210
- listen_link: function (link_id, options) {
211
- const link = L.DomUtil.get(link_id),
212
- self = this
213
- if (link) {
214
- L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
215
- if (options.confirm && !confirm(options.confirm)) {
216
- return
217
- }
218
- self.get(link.href, options)
219
- })
220
- }
221
- },
222
-
223
- default_callback: function (data, options) {
224
- // default callback, to avoid boilerplate
225
- if (data.redirect) {
226
- const newPath = data.redirect
227
- if (window.location.pathname == newPath)
228
- window.location.reload() // Keep the hash, so the current view
229
- else window.location = newPath
230
- } else if (data.info) {
231
- this.ui.alert({ content: data.info, level: 'info' })
232
- this.ui.closePanel()
233
- } else if (data.error) {
234
- this.ui.alert({ content: data.error, level: 'error' })
235
- } else if (data.html) {
236
- const ui_options = { data: data }
237
- let listen_options
238
- if (options.className) ui_options.className = options.className
239
- this.ui.openPanel(ui_options)
240
- // To low boilerplate, if there is a form, listen it
241
- if (options.listen_form) {
242
- // Listen form again
243
- listen_options = L.Util.extend({}, options, options.listen_form.options)
244
- this.listen_form(options.listen_form.id, listen_options)
245
- }
246
- if (options.listen_link) {
247
- for (let i = 0, l = options.listen_link.length; i < l; i++) {
248
- // Listen link again
249
- listen_options = L.Util.extend({}, options, options.listen_link[i].options)
250
- this.listen_link(options.listen_link[i].id, listen_options)
251
- }
252
- }
253
- } else if (options.success) {
254
- // Success is called only if data contain no msg and no html
255
- options.success(data)
256
- }
257
- },
258
-
259
- login: function (data, args) {
260
- // data.html: login form
261
- // args: args of the first _json call, to call again at process end
262
- const self = this
263
- const proceed = () => {
264
- self.ui.closePanel()
265
- if (typeof args !== 'undefined') self._json.apply(self, args)
266
- else self.default_callback(data, {})
267
- }
268
- const ask_for_login = (data) => {
269
- self.ui.openPanel({ data: data, className: 'login-panel' })
270
- self.listen_form('login_form', {
271
- callback: function (data) {
272
- if (data.html) ask_for_login(data) // Problem in the login - ask again
273
- else proceed()
274
- },
275
- })
276
- // Auth links
277
- const links = document.getElementsByClassName('umap-login-popup')
278
- Object.keys(links).forEach((el) => {
279
- const link = links[el]
280
- L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', () => {
281
- self.ui.closePanel()
282
- const win = window.open(link.href)
283
- window.umap_proceed = () => {
284
- proceed()
285
- win.close()
286
- }
287
- })
288
- })
289
- }
290
- if (data.login_required) {
291
- this.get(data.login_required, {
292
- callback: function (data) {
293
- ask_for_login(data)
294
- },
295
- })
296
- } else {
297
- ask_for_login(data)
298
- }
299
- },
300
-
301
- logout: function (url) {
302
- this.get(url)
303
- },
304
- })
@@ -1,100 +0,0 @@
1
- describe('L.U.Controls', function () {
2
- before(function () {
3
- this.server = sinon.fakeServer.create()
4
- this.server.respondWith(
5
- /\/datalayer\/62\/\?.*/,
6
- JSON.stringify(RESPONSES.datalayer62_GET)
7
- )
8
- this.map = initMap({ umap_id: 99 })
9
- this.server.respond()
10
- this.datalayer = this.map.getDataLayerByUmapId(62)
11
- })
12
- after(function () {
13
- this.server.restore()
14
- resetMap()
15
- })
16
-
17
- describe('#databrowser()', function () {
18
- let poly, marker, line
19
- before(function () {
20
- this.datalayer.eachLayer(function (layer) {
21
- if (!poly && layer instanceof L.Polygon) {
22
- poly = layer
23
- } else if (!line && layer instanceof L.Polyline) {
24
- line = layer
25
- } else if (!marker && layer instanceof L.Marker) {
26
- marker = layer
27
- }
28
- })
29
- })
30
-
31
- it('should be opened at datalayer button click', function () {
32
- var button = qs('.umap-browse-actions .umap-browse-link')
33
- assert.ok(button)
34
- happen.click(button)
35
- assert.ok(qs('#umap-ui-container .umap-browse-data'))
36
- })
37
-
38
- it('should contain datalayer section', function () {
39
- assert.ok(qs('#browse_data_datalayer_62'))
40
- })
41
-
42
- it("should contain datalayer's features list", function () {
43
- assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
44
- })
45
-
46
- it('should sort feature in natural order', function () {
47
- poly.properties.name = '9. a poly'
48
- marker.properties.name = '1. a marker'
49
- line.properties.name = '100. a line'
50
- this.datalayer.reindex()
51
- this.map.openBrowser()
52
- const els = qsa('.umap-browse-features li')
53
- assert.equal(els.length, 3)
54
- assert.equal(els[0].textContent, '1. a marker')
55
- assert.equal(els[1].textContent, '9. a poly')
56
- assert.equal(els[2].textContent, '100. a line')
57
- })
58
-
59
- it("should redraw datalayer's features list at feature delete", function () {
60
- var oldConfirm = window.confirm
61
- window.confirm = function () {
62
- return true
63
- }
64
- enableEdit()
65
- happen.once(qs('path[fill="DarkBlue"]'), { type: 'contextmenu' })
66
- happen.click(qs('.leaflet-contextmenu .umap-delete'))
67
- assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 2)
68
- window.confirm = oldConfirm
69
- })
70
-
71
- it("should redraw datalayer's features list on edit cancel", function () {
72
- clickCancel()
73
- happen.click(qs('.umap-browse-actions .umap-browse-link'))
74
- assert.equal(qsa('#browse_data_datalayer_62 ul li').length, 3)
75
- })
76
- })
77
-
78
- describe('#exportPanel()', function () {
79
- it('should be opened at datalayer button click', function () {
80
- let button = qs('.leaflet-control-embed button')
81
- assert.ok(button)
82
- happen.click(button)
83
- assert.ok(qs('#umap-ui-container .umap-share'))
84
- })
85
- it('should update iframe link', function () {
86
- let textarea = qs('.umap-share-iframe')
87
- assert.ok(textarea)
88
- console.log(textarea.textContent)
89
- assert.include(textarea.textContent, 'src="')
90
- assert.include(textarea.textContent, 'href="')
91
- // We should ave both, once for iframe link, once for full screen
92
- assert.include(textarea.textContent, 'scrollWheelZoom=true')
93
- assert.include(textarea.textContent, 'scrollWheelZoom=false')
94
- assert.notInclude(textarea.textContent, 'datalayers=62')
95
- let switcher = qs('label[title="Keep current visible layers"]')
96
- happen.click(switcher)
97
- assert.include(textarea.textContent, 'datalayers=62')
98
- })
99
- })
100
- })
@@ -1,46 +0,0 @@
1
- describe('L.U.Map.initialize', function () {
2
- afterEach(function () {
3
- resetMap()
4
- })
5
-
6
- describe('Controls', function () {
7
- it('should not show a minimap by default', function () {
8
- this.map = initMap()
9
- assert.notOk(qs('.leaflet-control-minimap'))
10
- })
11
-
12
- it('should show a minimap', function () {
13
- this.map = initMap({ miniMap: true })
14
- assert.ok(qs('.leaflet-control-minimap'))
15
- })
16
- })
17
-
18
- describe('DefaultView', function () {
19
- it('should set default view in default mode without data', function (done) {
20
- this.map = initMap({ datalayers: [] })
21
- // Did not find a better way to wait for tiles to be actually loaded
22
- window.setTimeout(() => {
23
- assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
24
- done()
25
- }, 1000)
26
- })
27
-
28
- it("should set default view in 'data' mode without data", function (done) {
29
- this.map = initMap({ datalayers: [], defaultView: 'data' })
30
- // Did not find a better way to wait for tiles to be actually loaded
31
- window.setTimeout(() => {
32
- assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
33
- done()
34
- }, 1000)
35
- })
36
-
37
- it("should set default view in 'latest' mode without data", function (done) {
38
- this.map = initMap({ datalayers: [], defaultView: 'latest' })
39
- // Did not find a better way to wait for tiles to be actually loaded
40
- window.setTimeout(() => {
41
- assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
42
- done()
43
- }, 1000)
44
- })
45
- })
46
- })