umap-project 1.14.0a5__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 (224) 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 -141
  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 +23 -5
  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_views.py +50 -11
  214. umap/urls.py +6 -12
  215. umap/views.py +170 -47
  216. {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/METADATA +13 -15
  217. {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/RECORD +220 -199
  218. umap/static/umap/js/umap.browser.js +0 -148
  219. umap/static/umap/js/umap.xhr.js +0 -304
  220. umap/static/umap/test/Controls.js +0 -100
  221. umap/static/umap/test/Map.Init.js +0 -46
  222. {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/WHEEL +0 -0
  223. {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/entry_points.txt +0 -0
  224. {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/licenses/LICENSE +0 -0
@@ -34,7 +34,7 @@ L.Map.mergeOptions({
34
34
  // we cannot rely on this because of the y is overriden by Leaflet
35
35
  // See https://github.com/Leaflet/Leaflet/pull/9201
36
36
  // And let's remove this -y when this PR is merged and released.
37
- demoTileInfos: { s: 'a', z: 9, x: 265, y: 181, '-y': 181, r: '' },
37
+ demoTileInfos: { 's': 'a', 'z': 9, 'x': 265, 'y': 181, '-y': 181, 'r': '' },
38
38
  licences: [],
39
39
  licence: '',
40
40
  enableMarkerDraw: true,
@@ -55,19 +55,66 @@ L.Map.mergeOptions({
55
55
  featuresHaveOwner: false,
56
56
  })
57
57
 
58
- L.U.Map.include({
59
- HIDDABLE_CONTROLS: [
60
- 'zoom',
61
- 'search',
62
- 'fullscreen',
63
- 'embed',
64
- 'locate',
65
- 'measure',
66
- 'editinosm',
67
- 'datalayers',
68
- 'star',
69
- 'tilelayers',
70
- ],
58
+ U.Map = L.Map.extend({
59
+ includes: [ControlsMixin],
60
+ editableOptions: {
61
+ 'zoom': undefined,
62
+ 'scrollWheelZoom': Boolean,
63
+ 'scaleControl': Boolean,
64
+ 'moreControl': Boolean,
65
+ 'miniMap': Boolean,
66
+ 'displayPopupFooter': undefined,
67
+ 'onLoadPanel': String,
68
+ 'defaultView': String,
69
+ 'name': String,
70
+ 'description': String,
71
+ 'licence': undefined,
72
+ 'tilelayer': undefined,
73
+ 'overlay': undefined,
74
+ 'limitBounds': undefined,
75
+ 'color': String,
76
+ 'iconClass': String,
77
+ 'iconUrl': String,
78
+ 'smoothFactor': undefined,
79
+ 'iconOpacity': undefined,
80
+ 'opacity': undefined,
81
+ 'weight': undefined,
82
+ 'fill': undefined,
83
+ 'fillColor': undefined,
84
+ 'fillOpacity': undefined,
85
+ 'dashArray': undefined,
86
+ 'popupShape': String,
87
+ 'popupTemplate': String,
88
+ 'popupContentTemplate': String,
89
+ 'zoomTo': undefined,
90
+ 'captionBar': Boolean,
91
+ 'captionMenus': Boolean,
92
+ 'slideshow': undefined,
93
+ 'sortKey': undefined,
94
+ 'labelKey': undefined,
95
+ 'filterKey': undefined,
96
+ 'facetKey': undefined,
97
+ 'slugKey': undefined,
98
+ 'showLabel': undefined,
99
+ 'labelDirection': undefined,
100
+ 'labelInteractive': undefined,
101
+ 'outlinkTarget': undefined,
102
+ 'shortCredit': undefined,
103
+ 'longCredit': undefined,
104
+ 'permanentCredit': undefined,
105
+ 'permanentCreditBackground': undefined,
106
+ 'zoomControl': 'NullableBoolean',
107
+ 'datalayersControl': 'NullableBoolean',
108
+ 'searchControl': 'NullableBoolean',
109
+ 'locateControl': 'NullableBoolean',
110
+ 'fullscreenControl': 'NullableBoolean',
111
+ 'editinosmControl': 'NullableBoolean',
112
+ 'embedControl': 'NullableBoolean',
113
+ 'measureControl': 'NullableBoolean',
114
+ 'tilelayersControl': 'NullableBoolean',
115
+ 'starControl': 'NullableBoolean',
116
+ 'easing': undefined,
117
+ },
71
118
 
72
119
  initialize: function (el, geojson) {
73
120
  // Locale name (pt_PT, en_US…)
@@ -89,18 +136,19 @@ L.U.Map.include({
89
136
  ? geojson.properties.fullscreenControl
90
137
  : true
91
138
  geojson.properties.fullscreenControl = false
92
- L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom')
139
+ this.setOptionsFromQueryString(geojson.properties)
93
140
 
94
141
  L.Map.prototype.initialize.call(this, el, geojson.properties)
95
142
 
96
143
  // After calling parent initialize, as we are doing initCenter our-selves
97
144
  if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
98
- this.urls = new window.umap.URLs(this.options.urls)
145
+ this.urls = new U.URLs(this.options.urls)
99
146
 
100
- this.ui = new L.U.UI(this._container)
101
- this.xhr = new L.U.Xhr(this.ui)
102
- this.xhr.on('dataloading', (e) => this.fire('dataloading', e))
103
- this.xhr.on('dataload', (e) => this.fire('dataload', e))
147
+ this.ui = new U.UI(this._container)
148
+ this.ui.on('dataloading', (e) => this.fire('dataloading', e))
149
+ this.ui.on('dataload', (e) => this.fire('dataload', e))
150
+ this.server = new U.ServerRequest(this.ui)
151
+ this.request = new U.Request(this.ui)
104
152
 
105
153
  this.initLoader()
106
154
  this.name = this.options.name
@@ -108,27 +156,10 @@ L.U.Map.include({
108
156
  this.demoTileInfos = this.options.demoTileInfos
109
157
  this.options.zoomControl = zoomControl
110
158
  this.options.fullscreenControl = fullscreenControl
111
- L.Util.setBooleanFromQueryString(this.options, 'moreControl')
112
- L.Util.setBooleanFromQueryString(this.options, 'scaleControl')
113
- L.Util.setBooleanFromQueryString(this.options, 'miniMap')
114
- L.Util.setFromQueryString(this.options, 'editMode')
115
- L.Util.setBooleanFromQueryString(this.options, 'displayDataBrowserOnLoad')
116
- L.Util.setBooleanFromQueryString(this.options, 'displayCaptionOnLoad')
117
- L.Util.setBooleanFromQueryString(this.options, 'captionBar')
118
- L.Util.setBooleanFromQueryString(this.options, 'captionMenus')
119
- for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
120
- L.Util.setNullableBooleanFromQueryString(
121
- this.options,
122
- `${this.HIDDABLE_CONTROLS[i]}Control`
123
- )
124
- }
125
159
  this.datalayersOnLoad = L.Util.queryString('datalayers')
126
- this.options.onLoadPanel = L.Util.queryString(
127
- 'onLoadPanel',
128
- this.options.onLoadPanel
129
- )
130
- if (this.datalayersOnLoad)
160
+ if (this.datalayersOnLoad) {
131
161
  this.datalayersOnLoad = this.datalayersOnLoad.toString().split(',')
162
+ }
132
163
 
133
164
  if (L.Browser.ielt9) this.options.editMode = 'disabled' // TODO include ie9
134
165
 
@@ -169,7 +200,7 @@ L.U.Map.include({
169
200
  this.facets = {}
170
201
 
171
202
  // Needed for actions labels
172
- this.help = new L.U.Help(this)
203
+ this.help = new U.Help(this)
173
204
 
174
205
  if (this.options.hash) this.addHash()
175
206
  this.initTileLayers()
@@ -178,7 +209,7 @@ L.U.Map.include({
178
209
  // Needs locate control and hash to exist
179
210
  this.initCenter()
180
211
  this.handleLimitBounds()
181
- this.initDatalayers()
212
+ this.initDataLayers()
182
213
 
183
214
  if (this.options.displayCaptionOnLoad) {
184
215
  // Retrocompat
@@ -227,28 +258,33 @@ L.U.Map.include({
227
258
 
228
259
  // Creation mode
229
260
  if (!this.options.umap_id) {
230
- this.isDirty = true
261
+ if (!this.options.preview) {
262
+ this.isDirty = true
263
+ this.enableEdit()
264
+ }
231
265
  this._default_extent = true
232
266
  this.options.name = L._('Untitled map')
233
- this.options.editMode = 'advanced'
234
- const datalayer = this.createDataLayer()
235
- datalayer.connectToMap()
236
- this.enableEdit()
267
+ let data = L.Util.queryString('data', null)
237
268
  let dataUrl = L.Util.queryString('dataUrl', null)
238
269
  const dataFormat = L.Util.queryString('dataFormat', 'geojson')
239
270
  if (dataUrl) {
240
271
  dataUrl = decodeURIComponent(dataUrl)
241
272
  dataUrl = this.localizeUrl(dataUrl)
242
273
  dataUrl = this.proxyUrl(dataUrl)
274
+ const datalayer = this.createDataLayer()
243
275
  datalayer.importFromUrl(dataUrl, dataFormat)
276
+ } else if (data) {
277
+ data = decodeURIComponent(data)
278
+ const datalayer = this.createDataLayer()
279
+ datalayer.importRaw(data, dataFormat)
244
280
  }
245
281
  }
246
282
 
247
- this.slideshow = new L.U.Slideshow(this, this.options.slideshow)
248
- this.permissions = new L.U.MapPermissions(this)
283
+ this.slideshow = new U.Slideshow(this, this.options.slideshow)
284
+ this.permissions = new U.MapPermissions(this)
249
285
  this.initCaptionBar()
250
286
  if (this.hasEditMode()) {
251
- this.editTools = new L.U.Editable(this)
287
+ this.editTools = new U.Editable(this)
252
288
  this.ui.on(
253
289
  'panel:closed panel:open',
254
290
  function () {
@@ -268,8 +304,6 @@ L.U.Map.include({
268
304
  this.options.onLoadPanel === 'datafilters'
269
305
  )
270
306
  this.openFacet()
271
- })
272
- this.onceDataLoaded(function () {
273
307
  const slug = L.Util.queryString('feature')
274
308
  if (slug && this.features_index[slug]) this.features_index[slug].view()
275
309
  if (L.Util.queryString('edit')) {
@@ -288,36 +322,61 @@ L.U.Map.include({
288
322
  }
289
323
  })
290
324
 
291
- window.onbeforeunload = () => this.isDirty || null
325
+ window.onbeforeunload = () => this.editEnabled && this.isDirty || null
292
326
  this.backup()
293
327
  this.initContextMenu()
294
328
  this.on('click contextmenu.show', this.closeInplaceToolbar)
295
329
  },
296
330
 
331
+ setOptionsFromQueryString: function (options) {
332
+ // This is not an editable option
333
+ L.Util.setFromQueryString(options, 'editMode')
334
+ // FIXME retrocompat
335
+ L.Util.setBooleanFromQueryString(options, 'displayDataBrowserOnLoad')
336
+ L.Util.setBooleanFromQueryString(options, 'displayCaptionOnLoad')
337
+ for (const [key, type] of Object.entries(this.editableOptions)) {
338
+ switch (type) {
339
+ case Boolean:
340
+ L.Util.setBooleanFromQueryString(options, key)
341
+ break
342
+ case 'NullableBoolean':
343
+ L.Util.setNullableBooleanFromQueryString(options, key)
344
+ break
345
+ case String:
346
+ L.Util.setFromQueryString(options, key)
347
+ }
348
+ }
349
+ // Specific case for datalayersControl
350
+ // which accepts "expanded" value, on top of true/false/null
351
+ if (L.Util.queryString('datalayersControl') === 'expanded') {
352
+ L.Util.setFromQueryString(options, 'datalayersControl')
353
+ }
354
+ },
355
+
297
356
  initControls: function () {
298
357
  this.helpMenuActions = {}
299
358
  this._controls = {}
300
359
 
301
360
  if (this.hasEditMode() && !this.options.noControl) {
302
- new L.U.EditControl(this).addTo(this)
361
+ new U.EditControl(this).addTo(this)
303
362
 
304
- new L.U.DrawToolbar({ map: this }).addTo(this)
363
+ new U.DrawToolbar({ map: this }).addTo(this)
305
364
 
306
365
  const editActions = [
307
- L.U.ImportAction,
308
- L.U.EditPropertiesAction,
309
- L.U.ManageDatalayersAction,
310
- L.U.ChangeTileLayerAction,
311
- L.U.UpdateExtentAction,
312
- L.U.UpdatePermsAction,
366
+ U.ImportAction,
367
+ U.EditPropertiesAction,
368
+ U.ManageDatalayersAction,
369
+ U.ChangeTileLayerAction,
370
+ U.UpdateExtentAction,
371
+ U.UpdatePermsAction,
313
372
  ]
314
- new L.U.SettingsToolbar({ actions: editActions }).addTo(this)
373
+ new U.SettingsToolbar({ actions: editActions }).addTo(this)
315
374
  }
316
375
  this._controls.zoom = new L.Control.Zoom({
317
376
  zoomInTitle: L._('Zoom in'),
318
377
  zoomOutTitle: L._('Zoom out'),
319
378
  })
320
- this._controls.datalayers = new L.U.DataLayersControl(this)
379
+ this._controls.datalayers = new U.DataLayersControl(this)
321
380
  this._controls.locate = L.control.locate({
322
381
  strings: {
323
382
  title: L._('Center map on your location'),
@@ -334,10 +393,10 @@ L.U.Map.include({
334
393
  this._controls.fullscreen = new L.Control.Fullscreen({
335
394
  title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') },
336
395
  })
337
- this._controls.search = new L.U.SearchControl()
396
+ this._controls.search = new U.SearchControl()
338
397
  this._controls.embed = new L.Control.Embed(this, this.options.embedOptions)
339
- this._controls.tilelayersChooser = new L.U.TileLayerChooser(this)
340
- this._controls.star = new L.U.StarControl(this)
398
+ this._controls.tilelayersChooser = new U.TileLayerChooser(this)
399
+ this._controls.star = new U.StarControl(this)
341
400
  this._controls.editinosm = new L.Control.EditInOSM({
342
401
  position: 'topleft',
343
402
  widgetOptions: {
@@ -347,16 +406,16 @@ L.U.Map.include({
347
406
  },
348
407
  })
349
408
  this._controls.measure = new L.MeasureControl().initHandler(this)
350
- this._controls.more = new L.U.MoreControls()
409
+ this._controls.more = new U.MoreControls()
351
410
  this._controls.scale = L.control.scale()
352
- this._controls.permanentCredit = new L.U.PermanentCreditsControl(this)
411
+ this._controls.permanentCredit = new U.PermanentCreditsControl(this)
353
412
  if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable()
354
413
  else this.scrollWheelZoom.disable()
355
- this.browser = new L.U.Browser(this)
356
- this.importer = new L.U.Importer(this)
357
- this.drop = new L.U.DropControl(this)
358
- this.share = new L.U.Share(this)
359
- this._controls.tilelayers = new L.U.TileLayerControl(this)
414
+ this.browser = new U.Browser(this)
415
+ this.importer = new U.Importer(this)
416
+ this.drop = new U.DropControl(this)
417
+ this.share = new U.Share(this)
418
+ this._controls.tilelayers = new U.TileLayerControl(this)
360
419
  this._controls.tilelayers.setLayers()
361
420
 
362
421
  this.renderControls()
@@ -379,7 +438,7 @@ L.U.Map.include({
379
438
  }
380
439
  if (this.options.noControl) return
381
440
 
382
- this._controls.attribution = new L.U.AttributionControl().addTo(this)
441
+ this._controls.attribution = new U.AttributionControl().addTo(this)
383
442
  if (this.options.miniMap && !this.options.noControl) {
384
443
  this.whenReady(function () {
385
444
  if (this.selected_tilelayer) {
@@ -414,56 +473,22 @@ L.U.Map.include({
414
473
  if (this.options.scaleControl) this._controls.scale.addTo(this)
415
474
  },
416
475
 
417
- initDatalayers: function () {
418
- for (let j = 0; j < this.options.datalayers.length; j++) {
419
- this.createDataLayer(this.options.datalayers[j])
476
+ initDataLayers: async function (datalayers) {
477
+ datalayers = datalayers || this.options.datalayers
478
+ for (const options of datalayers) {
479
+ this.createDataLayer(options)
420
480
  }
421
- this.loadDatalayers()
481
+ await this.loadDataLayers()
422
482
  },
423
483
 
424
- loadDatalayers: function (force) {
425
- const total = this.datalayers_index.length
426
- // toload => datalayer metadata remaining to load (synchronous)
427
- // dataToload => datalayer data remaining to load (asynchronous)
428
- let toload = total,
429
- dataToload = total
430
- let datalayer
431
- const loaded = () => {
432
- this.datalayersLoaded = true
433
- this.fire('datalayersloaded')
434
- }
435
- const decrementToLoad = () => {
436
- toload--
437
- if (toload === 0) loaded()
438
- }
439
- const dataLoaded = () => {
440
- this.dataLoaded = true
441
- this.fire('dataloaded')
442
- }
443
- const decrementDataToLoad = () => {
444
- dataToload--
445
- if (dataToload === 0) dataLoaded()
446
- }
447
- this.eachDataLayer(function (datalayer) {
448
- if (force && !datalayer.hasDataLoaded()) {
449
- datalayer.show()
450
- }
451
- if (datalayer.showAtLoad() || force) {
452
- datalayer.onceLoaded(decrementToLoad)
453
- } else {
454
- decrementToLoad()
455
- }
456
- if (datalayer.showAtLoad() || force) {
457
- datalayer.onceDataLoaded(decrementDataToLoad)
458
- } else {
459
- decrementDataToLoad({ sourceTarget: datalayer })
460
- }
461
- })
462
- if (total === 0) {
463
- // no datalayer
464
- loaded()
465
- dataLoaded()
484
+ loadDataLayers: async function () {
485
+ this.datalayersLoaded = true
486
+ this.fire('datalayersloaded')
487
+ for (const datalayer of Object.values(this.datalayers)) {
488
+ if (datalayer.showAtLoad()) await datalayer.show()
466
489
  }
490
+ this.dataloaded = true
491
+ this.fire('dataloaded')
467
492
  },
468
493
 
469
494
  indexDatalayers: function () {
@@ -496,7 +521,7 @@ L.U.Map.include({
496
521
 
497
522
  onceDataLoaded: function (callback, context) {
498
523
  // Once datalayers **data** have been loaded
499
- if (this.dataLoaded) {
524
+ if (this.dataloaded) {
500
525
  callback.call(context || this, this)
501
526
  } else {
502
527
  this.once('dataloaded', callback, context)
@@ -527,10 +552,10 @@ L.U.Map.include({
527
552
  modifierKey = e.ctrlKey || e.metaKey
528
553
 
529
554
  /* Generic shortcuts */
530
- if (key === L.U.Keys.F && modifierKey) {
555
+ if (key === U.Keys.F && modifierKey) {
531
556
  L.DomEvent.stop(e)
532
557
  this.search()
533
- } else if (e.keyCode === L.U.Keys.ESC) {
558
+ } else if (e.keyCode === U.Keys.ESC) {
534
559
  if (this.help.visible()) this.help.hide()
535
560
  else this.ui.closePanel()
536
561
  }
@@ -538,11 +563,11 @@ L.U.Map.include({
538
563
  if (!this.hasEditMode()) return
539
564
 
540
565
  /* Edit mode only shortcuts */
541
- if (key === L.U.Keys.E && modifierKey && !this.editEnabled) {
566
+ if (key === U.Keys.E && modifierKey && !this.editEnabled) {
542
567
  L.DomEvent.stop(e)
543
568
  this.enableEdit()
544
569
  } else if (
545
- key === L.U.Keys.E &&
570
+ key === U.Keys.E &&
546
571
  modifierKey &&
547
572
  this.editEnabled &&
548
573
  !this.isDirty
@@ -551,41 +576,41 @@ L.U.Map.include({
551
576
  this.disableEdit()
552
577
  this.ui.closePanel()
553
578
  }
554
- if (key === L.U.Keys.S && modifierKey) {
579
+ if (key === U.Keys.S && modifierKey) {
555
580
  L.DomEvent.stop(e)
556
581
  if (this.isDirty) {
557
582
  this.save()
558
583
  }
559
584
  }
560
- if (key === L.U.Keys.Z && modifierKey && this.isDirty) {
585
+ if (key === U.Keys.Z && modifierKey && this.isDirty) {
561
586
  L.DomEvent.stop(e)
562
587
  this.askForReset()
563
588
  }
564
- if (key === L.U.Keys.M && modifierKey && this.editEnabled) {
589
+ if (key === U.Keys.M && modifierKey && this.editEnabled) {
565
590
  L.DomEvent.stop(e)
566
591
  this.editTools.startMarker()
567
592
  }
568
- if (key === L.U.Keys.P && modifierKey && this.editEnabled) {
593
+ if (key === U.Keys.P && modifierKey && this.editEnabled) {
569
594
  L.DomEvent.stop(e)
570
595
  this.editTools.startPolygon()
571
596
  }
572
- if (key === L.U.Keys.L && modifierKey && this.editEnabled) {
597
+ if (key === U.Keys.L && modifierKey && this.editEnabled) {
573
598
  L.DomEvent.stop(e)
574
599
  this.editTools.startPolyline()
575
600
  }
576
- if (key === L.U.Keys.I && modifierKey && this.editEnabled) {
601
+ if (key === U.Keys.I && modifierKey && this.editEnabled) {
577
602
  L.DomEvent.stop(e)
578
603
  this.importer.open()
579
604
  }
580
- if (key === L.U.Keys.O && modifierKey && this.editEnabled) {
605
+ if (key === U.Keys.O && modifierKey && this.editEnabled) {
581
606
  L.DomEvent.stop(e)
582
607
  this.importer.openFiles()
583
608
  }
584
- if (key === L.U.Keys.H && modifierKey && this.editEnabled) {
609
+ if (key === U.Keys.H && modifierKey && this.editEnabled) {
585
610
  L.DomEvent.stop(e)
586
611
  this.help.show('edit')
587
612
  }
588
- if (e.keyCode === L.U.Keys.ESC) {
613
+ if (e.keyCode === U.Keys.ESC) {
589
614
  if (this.editEnabled && this.editTools.drawing()) {
590
615
  this.editTools.stopDrawing()
591
616
  }
@@ -796,7 +821,7 @@ L.U.Map.include({
796
821
  datalayer = datalayer || {
797
822
  name: `${L._('Layer')} ${this.datalayers_index.length + 1}`,
798
823
  }
799
- return new L.U.DataLayer(this, datalayer)
824
+ return new U.DataLayer(this, datalayer)
800
825
  },
801
826
 
802
827
  getDefaultOption: function (option) {
@@ -830,7 +855,10 @@ L.U.Map.include({
830
855
  self.isDirty = true
831
856
  }
832
857
  if (this._controls.tilelayersChooser)
833
- this._controls.tilelayersChooser.openSwitcher({ callback: callback, className: 'dark' })
858
+ this._controls.tilelayersChooser.openSwitcher({
859
+ callback: callback,
860
+ className: 'dark',
861
+ })
834
862
  },
835
863
 
836
864
  manageDatalayers: function () {
@@ -881,8 +909,7 @@ L.U.Map.include({
881
909
 
882
910
  let mustReindex = false
883
911
 
884
- for (let i = 0; i < this.editableOptions.length; i++) {
885
- const option = this.editableOptions[i]
912
+ for (const option of Object.keys(this.editableOptions)) {
886
913
  if (typeof importedData.properties[option] !== 'undefined') {
887
914
  this.options[option] = importedData.properties[option]
888
915
  if (option === 'sortKey') mustReindex = true
@@ -1009,76 +1036,17 @@ L.U.Map.include({
1009
1036
  else this.fire('saved')
1010
1037
  },
1011
1038
 
1012
- editableOptions: [
1013
- 'zoom',
1014
- 'scrollWheelZoom',
1015
- 'scaleControl',
1016
- 'moreControl',
1017
- 'miniMap',
1018
- 'displayPopupFooter',
1019
- 'onLoadPanel',
1020
- 'defaultView',
1021
- 'name',
1022
- 'description',
1023
- 'licence',
1024
- 'tilelayer',
1025
- 'overlay',
1026
- 'limitBounds',
1027
- 'color',
1028
- 'iconClass',
1029
- 'iconUrl',
1030
- 'smoothFactor',
1031
- 'iconOpacity',
1032
- 'opacity',
1033
- 'weight',
1034
- 'fill',
1035
- 'fillColor',
1036
- 'fillOpacity',
1037
- 'dashArray',
1038
- 'popupShape',
1039
- 'popupTemplate',
1040
- 'popupContentTemplate',
1041
- 'zoomTo',
1042
- 'captionBar',
1043
- 'captionMenus',
1044
- 'slideshow',
1045
- 'sortKey',
1046
- 'labelKey',
1047
- 'filterKey',
1048
- 'facetKey',
1049
- 'slugKey',
1050
- 'showLabel',
1051
- 'labelDirection',
1052
- 'labelInteractive',
1053
- 'outlinkTarget',
1054
- 'shortCredit',
1055
- 'longCredit',
1056
- 'permanentCredit',
1057
- 'permanentCreditBackground',
1058
- 'zoomControl',
1059
- 'datalayersControl',
1060
- 'searchControl',
1061
- 'locateControl',
1062
- 'fullscreenControl',
1063
- 'editinosmControl',
1064
- 'embedControl',
1065
- 'measureControl',
1066
- 'tilelayersControl',
1067
- 'starControl',
1068
- 'easing',
1069
- ],
1070
-
1071
1039
  exportOptions: function () {
1072
1040
  const properties = {}
1073
- for (let i = this.editableOptions.length - 1; i >= 0; i--) {
1074
- if (typeof this.options[this.editableOptions[i]] !== 'undefined') {
1075
- properties[this.editableOptions[i]] = this.options[this.editableOptions[i]]
1041
+ for (const option of Object.keys(this.editableOptions)) {
1042
+ if (typeof this.options[option] !== 'undefined') {
1043
+ properties[option] = this.options[option]
1076
1044
  }
1077
1045
  }
1078
1046
  return properties
1079
1047
  },
1080
1048
 
1081
- saveSelf: function () {
1049
+ saveSelf: async function () {
1082
1050
  const geojson = {
1083
1051
  type: 'Feature',
1084
1052
  geometry: this.geometry(),
@@ -1088,64 +1056,62 @@ L.U.Map.include({
1088
1056
  formData.append('name', this.options.name)
1089
1057
  formData.append('center', JSON.stringify(this.geometry()))
1090
1058
  formData.append('settings', JSON.stringify(geojson))
1091
- this.post(this.urls.get('map_save', { map_id: this.options.umap_id }), {
1092
- data: formData,
1093
- context: this,
1094
- callback: function (data) {
1095
- let duration = 3000,
1096
- alert = { content: L._('Map has been saved!'), level: 'info' }
1097
- if (!this.options.umap_id) {
1098
- alert.content = L._('Congratulations, your map has been created!')
1099
- this.options.umap_id = data.id
1100
- this.permissions.setOptions(data.permissions)
1101
- this.permissions.commit()
1102
- if (
1103
- data.permissions &&
1104
- data.permissions.anonymous_edit_url &&
1105
- this.options.urls.map_send_edit_link
1106
- ) {
1107
- alert.duration = Infinity
1108
- alert.content =
1109
- L._(
1110
- 'Your map has been created! As you are not logged in, here is your secret link to edit the map, please keep it safe:'
1111
- ) + `<br>${data.permissions.anonymous_edit_url}`
1112
-
1113
- alert.actions = [
1114
- {
1115
- label: L._('Send me the link'),
1116
- input: L._('Email'),
1117
- callback: this.sendEditLink,
1118
- callbackContext: this,
1119
- },
1120
- {
1121
- label: L._('Copy link'),
1122
- callback: () => {
1123
- L.Util.copyToClipboard(data.permissions.anonymous_edit_url)
1124
- this.ui.alert({
1125
- content: L._('Secret edit link copied to clipboard!'),
1126
- level: 'info',
1127
- })
1128
- },
1129
- callbackContext: this,
1059
+ const uri = this.urls.get('map_save', { map_id: this.options.umap_id })
1060
+ const [data, response, error] = await this.server.post(uri, {}, formData)
1061
+ if (!error) {
1062
+ let duration = 3000,
1063
+ alert = { content: L._('Map has been saved!'), level: 'info' }
1064
+ if (!this.options.umap_id) {
1065
+ alert.content = L._('Congratulations, your map has been created!')
1066
+ this.options.umap_id = data.id
1067
+ this.permissions.setOptions(data.permissions)
1068
+ this.permissions.commit()
1069
+ if (
1070
+ data.permissions &&
1071
+ data.permissions.anonymous_edit_url &&
1072
+ this.options.urls.map_send_edit_link
1073
+ ) {
1074
+ alert.duration = Infinity
1075
+ alert.content =
1076
+ L._(
1077
+ 'Your map has been created! As you are not logged in, here is your secret link to edit the map, please keep it safe:'
1078
+ ) + `<br>${data.permissions.anonymous_edit_url}`
1079
+
1080
+ alert.actions = [
1081
+ {
1082
+ label: L._('Send me the link'),
1083
+ input: L._('Email'),
1084
+ callback: this.sendEditLink,
1085
+ callbackContext: this,
1086
+ },
1087
+ {
1088
+ label: L._('Copy link'),
1089
+ callback: () => {
1090
+ L.Util.copyToClipboard(data.permissions.anonymous_edit_url)
1091
+ this.ui.alert({
1092
+ content: L._('Secret edit link copied to clipboard!'),
1093
+ level: 'info',
1094
+ })
1130
1095
  },
1131
- ]
1132
- }
1133
- } else if (!this.permissions.isDirty) {
1134
- // Do not override local changes to permissions,
1135
- // but update in case some other editors changed them in the meantime.
1136
- this.permissions.setOptions(data.permissions)
1137
- this.permissions.commit()
1096
+ callbackContext: this,
1097
+ },
1098
+ ]
1138
1099
  }
1139
- // Update URL in case the name has changed.
1140
- if (history && history.pushState)
1141
- history.pushState({}, this.options.name, data.url)
1142
- else window.location = data.url
1143
- alert.content = data.info || alert.content
1144
- this.once('saved', () => this.ui.alert(alert))
1145
- this.ui.closePanel()
1146
- this.permissions.save()
1147
- },
1148
- })
1100
+ } else if (!this.permissions.isDirty) {
1101
+ // Do not override local changes to permissions,
1102
+ // but update in case some other editors changed them in the meantime.
1103
+ this.permissions.setOptions(data.permissions)
1104
+ this.permissions.commit()
1105
+ }
1106
+ // Update URL in case the name has changed.
1107
+ if (history && history.pushState)
1108
+ history.pushState({}, this.options.name, data.url)
1109
+ else window.location = data.url
1110
+ alert.content = data.info || alert.content
1111
+ this.once('saved', () => this.ui.alert(alert))
1112
+ this.ui.closePanel()
1113
+ this.permissions.save()
1114
+ }
1149
1115
  },
1150
1116
 
1151
1117
  save: function () {
@@ -1220,13 +1186,13 @@ L.U.Map.include({
1220
1186
  if (
1221
1187
  datalayer &&
1222
1188
  !datalayer.isDataReadOnly() &&
1223
- datalayer.canBrowse() &&
1189
+ datalayer.isBrowsable() &&
1224
1190
  datalayer.isVisible()
1225
1191
  ) {
1226
1192
  return datalayer
1227
1193
  }
1228
1194
  datalayer = this.findDataLayer((datalayer) => {
1229
- if (!datalayer.isDataReadOnly() && datalayer.canBrowse()) {
1195
+ if (!datalayer.isDataReadOnly() && datalayer.isBrowsable()) {
1230
1196
  fallback = datalayer
1231
1197
  if (datalayer.isVisible()) return true
1232
1198
  }
@@ -1234,7 +1200,7 @@ L.U.Map.include({
1234
1200
  if (datalayer) return datalayer
1235
1201
  if (fallback) {
1236
1202
  // No datalayer visible, let's force one
1237
- this.addLayer(fallback.layer)
1203
+ fallback.show()
1238
1204
  return fallback
1239
1205
  }
1240
1206
  return this.createDataLayer()
@@ -1260,7 +1226,7 @@ L.U.Map.include({
1260
1226
  'options.captionBar',
1261
1227
  'options.captionMenus',
1262
1228
  ])
1263
- builder = new L.U.FormBuilder(this, UIFields, {
1229
+ builder = new U.FormBuilder(this, UIFields, {
1264
1230
  callback: function () {
1265
1231
  this.renderControls()
1266
1232
  this.initCaptionBar()
@@ -1289,7 +1255,7 @@ L.U.Map.include({
1289
1255
  'options.dashArray',
1290
1256
  ]
1291
1257
 
1292
- builder = new L.U.FormBuilder(this, shapeOptions, {
1258
+ builder = new U.FormBuilder(this, shapeOptions, {
1293
1259
  callback: function (e) {
1294
1260
  if (this._controls.miniMap) this.renderControls()
1295
1261
  this.eachVisibleDataLayer((datalayer) => {
@@ -1349,7 +1315,7 @@ L.U.Map.include({
1349
1315
  ],
1350
1316
  ]
1351
1317
 
1352
- builder = new L.U.FormBuilder(this, optionsFields, {
1318
+ builder = new U.FormBuilder(this, optionsFields, {
1353
1319
  callback: function (e) {
1354
1320
  this.initCaptionBar()
1355
1321
  if (e.helper.field === 'options.sortKey') {
@@ -1374,7 +1340,7 @@ L.U.Map.include({
1374
1340
  'options.labelInteractive',
1375
1341
  'options.outlinkTarget',
1376
1342
  ]
1377
- builder = new L.U.FormBuilder(this, popupFields, {
1343
+ builder = new U.FormBuilder(this, popupFields, {
1378
1344
  callback: function (e) {
1379
1345
  if (
1380
1346
  e.helper.field === 'options.popupTemplate' ||
@@ -1441,7 +1407,7 @@ L.U.Map.include({
1441
1407
  container,
1442
1408
  L._('Custom background')
1443
1409
  )
1444
- builder = new L.U.FormBuilder(this, tilelayerFields, {
1410
+ builder = new U.FormBuilder(this, tilelayerFields, {
1445
1411
  callback: this.initTileLayers,
1446
1412
  callbackContext: this,
1447
1413
  })
@@ -1492,7 +1458,7 @@ L.U.Map.include({
1492
1458
  ['options.overlay.tms', { handler: 'Switch', label: L._('TMS format') }],
1493
1459
  ]
1494
1460
  const overlay = L.DomUtil.createFieldset(container, L._('Custom overlay'))
1495
- builder = new L.U.FormBuilder(this, overlayFields, {
1461
+ builder = new U.FormBuilder(this, overlayFields, {
1496
1462
  callback: this.initTileLayers,
1497
1463
  callbackContext: this,
1498
1464
  })
@@ -1522,7 +1488,7 @@ L.U.Map.include({
1522
1488
  { handler: 'BlurFloatInput', placeholder: L._('max East') },
1523
1489
  ],
1524
1490
  ]
1525
- const boundsBuilder = new L.U.FormBuilder(this, boundsFields, {
1491
+ const boundsBuilder = new U.FormBuilder(this, boundsFields, {
1526
1492
  callback: this.handleLimitBounds,
1527
1493
  callbackContext: this,
1528
1494
  })
@@ -1588,7 +1554,7 @@ L.U.Map.include({
1588
1554
  this.slideshow.setOptions(this.options.slideshow)
1589
1555
  this.renderControls()
1590
1556
  }
1591
- const slideshowBuilder = new L.U.FormBuilder(this, slideshowFields, {
1557
+ const slideshowBuilder = new U.FormBuilder(this, slideshowFields, {
1592
1558
  callback: slideshowHandler,
1593
1559
  callbackContext: this,
1594
1560
  })
@@ -1628,7 +1594,7 @@ L.U.Map.include({
1628
1594
  { handler: 'Switch', label: L._('Permanent credits background') },
1629
1595
  ],
1630
1596
  ]
1631
- const creditsBuilder = new L.U.FormBuilder(this, creditsFields, {
1597
+ const creditsBuilder = new U.FormBuilder(this, creditsFields, {
1632
1598
  callback: this.renderControls,
1633
1599
  callbackContext: this,
1634
1600
  })
@@ -1684,7 +1650,7 @@ L.U.Map.include({
1684
1650
  metadataFields = ['options.name', 'options.description'],
1685
1651
  title = L.DomUtil.create('h3', '', container)
1686
1652
  title.textContent = L._('Edit map properties')
1687
- const builder = new L.U.FormBuilder(this, metadataFields)
1653
+ const builder = new U.FormBuilder(this, metadataFields)
1688
1654
  const form = builder.build()
1689
1655
  container.appendChild(form)
1690
1656
  this._editControls(container)
@@ -1788,19 +1754,21 @@ L.U.Map.include({
1788
1754
  return this.editTools.startPolygon()
1789
1755
  },
1790
1756
 
1791
- del: function () {
1757
+ del: async function () {
1792
1758
  if (confirm(L._('Are you sure you want to delete this map?'))) {
1793
1759
  const url = this.urls.get('map_delete', { map_id: this.options.umap_id })
1794
- this.post(url)
1760
+ const [data, response, error] = await this.server.post(url)
1761
+ if (data.redirect) window.location = data.redirect
1795
1762
  }
1796
1763
  },
1797
1764
 
1798
- clone: function () {
1765
+ clone: async function () {
1799
1766
  if (
1800
1767
  confirm(L._('Are you sure you want to clone this map and all its datalayers?'))
1801
1768
  ) {
1802
1769
  const url = this.urls.get('map_clone', { map_id: this.options.umap_id })
1803
- this.post(url)
1770
+ const [data, response, error] = await this.server.post(url)
1771
+ if (data.redirect) window.location = data.redirect
1804
1772
  }
1805
1773
  },
1806
1774
 
@@ -1815,25 +1783,8 @@ L.U.Map.include({
1815
1783
  this.loader.onAdd(this)
1816
1784
  },
1817
1785
 
1818
- post: function (url, options) {
1819
- options = options || {}
1820
- options.listener = this
1821
- this.xhr.post(url, options)
1822
- },
1823
-
1824
- get: function (url, options) {
1825
- options = options || {}
1826
- options.listener = this
1827
- this.xhr.get(url, options)
1828
- },
1829
-
1830
- ajax: function (options) {
1831
- options.listener = this
1832
- this.xhr._ajax(options)
1833
- },
1834
-
1835
1786
  initContextMenu: function () {
1836
- this.contextmenu = new L.U.ContextMenu(this)
1787
+ this.contextmenu = new U.ContextMenu(this)
1837
1788
  this.contextmenu.enable()
1838
1789
  },
1839
1790