umap-project 2.7.0b2__py3-none-any.whl → 2.7.1__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 (71) hide show
  1. umap/__init__.py +1 -1
  2. umap/asgi.py +15 -0
  3. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/es/LC_MESSAGES/django.po +134 -128
  5. umap/models.py +2 -1
  6. umap/settings/base.py +1 -1
  7. umap/static/umap/css/importers.css +4 -0
  8. umap/static/umap/img/16.svg +1 -184
  9. umap/static/umap/img/24-white.svg +1 -0
  10. umap/static/umap/img/24.svg +1 -0
  11. umap/static/umap/img/importers/cadastrefr.svg +23 -0
  12. umap/static/umap/img/source/16.svg +753 -200
  13. umap/static/umap/img/source/24-white.svg +3 -2
  14. umap/static/umap/img/source/24.svg +3 -2
  15. umap/static/umap/js/modules/browser.js +47 -0
  16. umap/static/umap/js/modules/caption.js +10 -4
  17. umap/static/umap/js/modules/data/layer.js +26 -14
  18. umap/static/umap/js/modules/importer.js +3 -0
  19. umap/static/umap/js/modules/importers/cadastrefr.js +62 -0
  20. umap/static/umap/js/modules/importers/communesfr.js +2 -2
  21. umap/static/umap/js/modules/rendering/layers/classified.js +2 -0
  22. umap/static/umap/js/modules/rendering/ui.js +30 -3
  23. umap/static/umap/js/modules/share.js +1 -3
  24. umap/static/umap/js/modules/slideshow.js +1 -1
  25. umap/static/umap/js/modules/sync/engine.js +14 -8
  26. umap/static/umap/js/modules/sync/hlc.js +3 -3
  27. umap/static/umap/js/modules/sync/updaters.js +14 -2
  28. umap/static/umap/js/modules/ui/contextmenu.js +5 -0
  29. umap/static/umap/js/modules/ui/panel.js +12 -1
  30. umap/static/umap/js/modules/utils.js +24 -4
  31. umap/static/umap/js/umap.controls.js +46 -21
  32. umap/static/umap/js/umap.core.js +1 -1
  33. umap/static/umap/js/umap.js +29 -20
  34. umap/static/umap/locale/ca.js +8 -4
  35. umap/static/umap/locale/ca.json +8 -4
  36. umap/static/umap/locale/en.js +5 -1
  37. umap/static/umap/locale/en.json +5 -1
  38. umap/static/umap/locale/es.js +330 -319
  39. umap/static/umap/locale/es.json +330 -319
  40. umap/static/umap/locale/fr.js +5 -1
  41. umap/static/umap/locale/fr.json +5 -1
  42. umap/static/umap/map.css +37 -7
  43. umap/static/umap/unittests/hlc.js +10 -3
  44. umap/static/umap/unittests/utils.js +24 -0
  45. umap/static/umap/vars.css +2 -1
  46. umap/static/umap/vendors/colorbrewer/colorbrewer.js +309 -317
  47. umap/static/umap/vendors/dompurify/purify.es.js +15 -16
  48. umap/static/umap/vendors/dompurify/purify.es.mjs.map +1 -1
  49. umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js +2 -2
  50. umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map +1 -1
  51. umap/static/umap/vendors/simple-statistics/simple-statistics.min.js +1 -1
  52. umap/static/umap/vendors/simple-statistics/simple-statistics.min.js.map +1 -1
  53. umap/templates/umap/js.html +0 -1
  54. umap/templates/umap/map_detail.html +2 -2
  55. umap/tests/fixtures/test_upload_data.csv +2 -2
  56. umap/tests/integration/test_browser.py +69 -7
  57. umap/tests/integration/test_caption.py +3 -3
  58. umap/tests/integration/test_datalayer.py +1 -5
  59. umap/tests/integration/test_edit_datalayer.py +1 -2
  60. umap/tests/integration/test_edit_map.py +1 -1
  61. umap/tests/integration/test_edit_marker.py +1 -1
  62. umap/tests/integration/test_facets_browser.py +3 -3
  63. umap/tests/integration/test_import.py +0 -4
  64. umap/tests/integration/test_map.py +0 -4
  65. umap/tests/integration/test_view_marker.py +63 -0
  66. umap/tests/test_map_views.py +19 -0
  67. {umap_project-2.7.0b2.dist-info → umap_project-2.7.1.dist-info}/METADATA +14 -10
  68. {umap_project-2.7.0b2.dist-info → umap_project-2.7.1.dist-info}/RECORD +71 -68
  69. {umap_project-2.7.0b2.dist-info → umap_project-2.7.1.dist-info}/WHEEL +0 -0
  70. {umap_project-2.7.0b2.dist-info → umap_project-2.7.1.dist-info}/entry_points.txt +0 -0
  71. {umap_project-2.7.0b2.dist-info → umap_project-2.7.1.dist-info}/licenses/LICENSE +0 -0
@@ -35,7 +35,7 @@ export function checkId(string) {
35
35
  * @returns Array[string]
36
36
  */
37
37
  export function getImpactsFromSchema(fields, schema) {
38
- schema = schema || U.SCHEMA
38
+ const current_schema = schema || U.SCHEMA
39
39
  const impacted = fields
40
40
  .map((field) => {
41
41
  // remove the option prefix for fields
@@ -46,14 +46,30 @@ export function getImpactsFromSchema(fields, schema) {
46
46
  .reduce((acc, field) => {
47
47
  // retrieve the "impacts" field from the schema
48
48
  // and merge them together using sets
49
- const impacts = schema[field]?.impacts || []
50
- impacts.forEach((impact) => acc.add(impact))
49
+ const impacts = current_schema[field]?.impacts || []
50
+ for (const impact of impacts) {
51
+ acc.add(impact)
52
+ }
51
53
  return acc
52
54
  }, new Set())
53
55
 
54
56
  return Array.from(impacted)
55
57
  }
56
58
 
59
+ /**
60
+ * Check if a field exists in the schema.
61
+ *
62
+ * @param {string} field
63
+ * @param {object} schema
64
+ * @returns {boolean}
65
+ */
66
+ export function fieldInSchema(field, schema) {
67
+ const current_schema = schema || U.SCHEMA
68
+ if (typeof field !== 'string') return false
69
+ const field_name = field.replace('options.', '').split('.')[0]
70
+ return current_schema[field_name] !== undefined
71
+ }
72
+
57
73
  /**
58
74
  * Import DOM purify, and initialize it.
59
75
  *
@@ -407,6 +423,10 @@ export class WithTemplate {
407
423
  }
408
424
  }
409
425
 
410
- export function deepEqual(object1, object2){
426
+ export function deepEqual(object1, object2) {
411
427
  return JSON.stringify(object1) === JSON.stringify(object2)
412
428
  }
429
+
430
+ export function slugify(str) {
431
+ return (str || 'data').replace(/[^a-z0-9]/gi, '_').toLowerCase()
432
+ }
@@ -453,17 +453,13 @@ U.PermanentCreditsControl = L.Control.extend({
453
453
  },
454
454
 
455
455
  onAdd: function () {
456
- const paragraphContainer = L.DomUtil.create(
456
+ this.paragraphContainer = L.DomUtil.create(
457
457
  'div',
458
- 'umap-permanent-credits-container'
458
+ 'umap-permanent-credits-container text'
459
459
  )
460
- const creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
461
-
462
- this.paragraphContainer = paragraphContainer
463
460
  this.setCredits()
464
461
  this.setBackground()
465
-
466
- return paragraphContainer
462
+ return this.paragraphContainer
467
463
  },
468
464
 
469
465
  setCredits: function () {
@@ -661,11 +657,36 @@ const ControlsMixin = {
661
657
  })
662
658
  }
663
659
  button.addEventListener('click', () => {
664
- const x = button.offsetLeft
665
- const y = button.offsetTop + button.offsetHeight
666
- menu.openAt([x, y], actions)
660
+ menu.openBelow(button, actions)
661
+ })
662
+ }
663
+
664
+ const connectedPeers = this.sync.getNumberOfConnectedPeers()
665
+ if (connectedPeers !== 0) {
666
+ const connectedPeersCount = L.DomUtil.createButton(
667
+ 'leaflet-control-connected-peers',
668
+ rightContainer,
669
+ ''
670
+ )
671
+ L.DomEvent.on(connectedPeersCount, 'mouseover', () => {
672
+ this.tooltip.open({
673
+ content: L._('{connectedPeers} peer(s) currently connected to this map', {
674
+ connectedPeers: connectedPeers,
675
+ }),
676
+ anchor: connectedPeersCount,
677
+ position: 'bottom',
678
+ delay: 500,
679
+ duration: 5000,
680
+ })
667
681
  })
682
+
683
+ const updateConnectedPeersCount = () => {
684
+ connectedPeersCount.innerHTML =
685
+ '<span>' + this.sync.getNumberOfConnectedPeers() + '</span>'
686
+ }
687
+ updateConnectedPeersCount()
668
688
  }
689
+
669
690
  this.help.getStartedLink(rightContainer)
670
691
  const controlEditCancel = L.DomUtil.createButton(
671
692
  'leaflet-control-edit-cancel',
@@ -1161,17 +1182,6 @@ U.Editable = L.Editable.extend({
1161
1182
  initialize: function (map, options) {
1162
1183
  L.Editable.prototype.initialize.call(this, map, options)
1163
1184
  this.on('editable:drawing:click editable:drawing:move', this.drawingTooltip)
1164
- this.on('editable:drawing:end', (event) => {
1165
- this.map.tooltip.close()
1166
- // Leaflet.Editable will delete the drawn shape if invalid
1167
- // (eg. line has only one drawn point)
1168
- // So let's check if the layer has no more shape
1169
- if (!event.layer.feature.hasGeom()) {
1170
- event.layer.feature.del()
1171
- } else {
1172
- event.layer.feature.edit()
1173
- }
1174
- })
1175
1185
  // Layer for items added by users
1176
1186
  this.on('editable:drawing:cancel', (event) => {
1177
1187
  if (event.layer instanceof U.LeafletMarker) event.layer.feature.del()
@@ -1301,4 +1311,19 @@ U.Editable = L.Editable.extend({
1301
1311
  L.DomEvent.stop(e)
1302
1312
  e.cancel()
1303
1313
  },
1314
+
1315
+ onEscape: function () {
1316
+ this.once('editable:drawing:end', (event) => {
1317
+ this.map.tooltip.close()
1318
+ // Leaflet.Editable will delete the drawn shape if invalid
1319
+ // (eg. line has only one drawn point)
1320
+ // So let's check if the layer has no more shape
1321
+ if (!event.layer.feature.hasGeom()) {
1322
+ event.layer.feature.del()
1323
+ } else {
1324
+ event.layer.feature.edit()
1325
+ }
1326
+ })
1327
+ this.stopDrawing()
1328
+ },
1304
1329
  })
@@ -143,7 +143,7 @@ L.DomUtil.createButtonIcon = (parent, className, title, callback, size = 16) =>
143
143
 
144
144
  L.DomUtil.createTitle = (parent, text, iconClassName, className = '', tag = 'h3') => {
145
145
  const title = L.DomUtil.create(tag, '', parent)
146
- if (className) L.DomUtil.createIcon(title, iconClassName)
146
+ if (iconClassName) L.DomUtil.createIcon(title, iconClassName)
147
147
  L.DomUtil.add('span', className, title, text)
148
148
  return title
149
149
  }
@@ -191,15 +191,17 @@ U.Map = L.Map.extend({
191
191
  this.renderEditToolbar()
192
192
  }
193
193
 
194
- this.initShortcuts()
195
- if (!this.options.noControl) this.initCaptionBar()
196
- this.onceDataLoaded(this.setViewFromQueryString)
194
+ if (!this.options.noControl) {
195
+ this.initShortcuts()
196
+ this.initCaptionBar()
197
+ this.on('contextmenu', this.onContextMenu)
198
+ this.onceDataLoaded(this.setViewFromQueryString)
199
+ this.on('click', this.closeInplaceToolbar)
200
+ this.propagate()
201
+ }
197
202
 
198
203
  window.onbeforeunload = () => (this.editEnabled && this.isDirty) || null
199
204
  this.backup()
200
- this.on('click', this.closeInplaceToolbar)
201
- this.on('contextmenu', this.onContextMenu)
202
- this.propagate()
203
205
  },
204
206
 
205
207
  initSyncEngine: async function () {
@@ -222,8 +224,12 @@ U.Map = L.Map.extend({
222
224
  },
223
225
 
224
226
  render: function (fields) {
225
- const impacts = U.Utils.getImpactsFromSchema(fields)
227
+ if (fields.includes('numberOfConnectedPeers')) {
228
+ this.renderEditToolbar()
229
+ this.propagate()
230
+ }
226
231
 
232
+ const impacts = U.Utils.getImpactsFromSchema(fields)
227
233
  for (const impact of impacts) {
228
234
  switch (impact) {
229
235
  case 'ui':
@@ -557,7 +563,7 @@ U.Map = L.Map.extend({
557
563
  if (this.importer.dialog.visible) {
558
564
  this.importer.dialog.close()
559
565
  } else if (this.editEnabled && this.editTools.drawing()) {
560
- this.editTools.stopDrawing()
566
+ this.editTools.onEscape()
561
567
  } else if (this.measureTools.enabled()) {
562
568
  this.measureTools.stopDrawing()
563
569
  } else if (this.fullPanel?.isOpen()) {
@@ -1047,7 +1053,6 @@ U.Map = L.Map.extend({
1047
1053
  return
1048
1054
  }
1049
1055
  this.options.user = data.user
1050
- this.renderEditToolbar()
1051
1056
  if (!this.options.umap_id) {
1052
1057
  this.options.umap_id = data.id
1053
1058
  this.permissions.setOptions(data.permissions)
@@ -1085,7 +1090,6 @@ U.Map = L.Map.extend({
1085
1090
  } else {
1086
1091
  window.location = data.url
1087
1092
  }
1088
- this.propagate()
1089
1093
  return true
1090
1094
  },
1091
1095
 
@@ -1104,7 +1108,10 @@ U.Map = L.Map.extend({
1104
1108
  if (datalayer.isDirty) await datalayer.save()
1105
1109
  }
1106
1110
  this.isDirty = false
1107
- this.renderEditToolbar()
1111
+ // Do a blind render for now, as we are not sure what could
1112
+ // have changed, we'll be more subtil when we'll remove the
1113
+ // save action
1114
+ this.render(['name', 'user', 'permissions'])
1108
1115
  this.fire('saved')
1109
1116
  },
1110
1117
 
@@ -1592,7 +1599,7 @@ U.Map = L.Map.extend({
1592
1599
  'umap-caption-bar',
1593
1600
  this._controlContainer
1594
1601
  )
1595
- const name = L.DomUtil.create('h3', '', container)
1602
+ const name = L.DomUtil.create('h3', 'map-name', container)
1596
1603
  L.DomEvent.disableClickPropagation(container)
1597
1604
  this.addAuthorLink('span', container)
1598
1605
  if (this.getOption('captionMenus')) {
@@ -1618,11 +1625,6 @@ U.Map = L.Map.extend({
1618
1625
  )
1619
1626
  }
1620
1627
  }
1621
- const setName = function () {
1622
- name.textContent = this.getDisplayName()
1623
- }
1624
- L.bind(setName, this)()
1625
- this.on('postsync', L.bind(setName, this))
1626
1628
  this.onceDatalayersLoaded(function () {
1627
1629
  this.slideshow.renderToolbox(container)
1628
1630
  })
@@ -1686,7 +1688,7 @@ U.Map = L.Map.extend({
1686
1688
  this.loader.onAdd(this)
1687
1689
  },
1688
1690
 
1689
- getContextMenuItems: function (event) {
1691
+ getOwnContextMenuItems: function (event) {
1690
1692
  const items = []
1691
1693
  if (this.hasEditMode()) {
1692
1694
  if (this.editEnabled) {
@@ -1752,9 +1754,14 @@ U.Map = L.Map.extend({
1752
1754
  },
1753
1755
  {
1754
1756
  label: this.help.displayLabel('SEARCH'),
1755
- action: () => this.search(event),
1757
+ action: () => this.search(),
1756
1758
  }
1757
1759
  )
1760
+ return items
1761
+ },
1762
+
1763
+ getContextMenuItems: function (event) {
1764
+ const items = []
1758
1765
  if (this.options.urls.routing) {
1759
1766
  items.push('-', {
1760
1767
  label: L._('Directions from here'),
@@ -1771,7 +1778,9 @@ U.Map = L.Map.extend({
1771
1778
  },
1772
1779
 
1773
1780
  onContextMenu: function (event) {
1774
- const items = this.getContextMenuItems(event)
1781
+ const items = this.getOwnContextMenuItems(event).concat(
1782
+ this.getContextMenuItems(event)
1783
+ )
1775
1784
  this.contextmenu.open(event.originalEvent, items)
1776
1785
  },
1777
1786
 
@@ -102,7 +102,7 @@ const locale = {
102
102
  "Define link to open in a new window on polygon click.": "Define link to open in a new window on polygon click.",
103
103
  "define": "definir",
104
104
  "Delay between two transitions when in play mode": "Delay between two transitions when in play mode",
105
- "Delete layer": "Delete layer",
105
+ "Delete layer": "Suprimeix la capa",
106
106
  "Delete this feature": "Suprimeix aquesta característica",
107
107
  "Delete this shape": "Delete this shape",
108
108
  "Delete this vertex (Alt+Click)": "Delete this vertex (Alt+Click)",
@@ -456,8 +456,8 @@ const locale = {
456
456
  "key=value or key!=value": "key=value or key!=value",
457
457
  "Are you sure you want to delete this rule?": "Are you sure you want to delete this rule?",
458
458
  "empty rule": "empty rule",
459
- "Conditional style rules": "Conditional style rules",
460
- "Add rule": "Add rule",
459
+ "Conditional style rules": "Regles d'estil condicional",
460
+ "Add rule": "Afegeix una regla",
461
461
  "Browser: data": "Navegador: dades",
462
462
  "Browser: layers": "Navegador: capes",
463
463
  "Browser: filters": "Navegador: filtres",
@@ -513,7 +513,11 @@ const locale = {
513
513
  "Type new owner's username": "Type new owner's username",
514
514
  "Type editor's username": "Type editor's username",
515
515
  "Map": "Map",
516
- "Manage collaborators": "Manage collaborators"
516
+ "Manage collaborators": "Manage collaborators",
517
+ "show/hide all layers": "show/hide all layers",
518
+ "zoom to data extent": "zoom to data extent",
519
+ "download visible data": "download visible data",
520
+ "{connectedPeers} peer(s) currently connected to this map": "{connectedPeers} peer(s) currently connected to this map"
517
521
  }
518
522
  L.registerLocale("ca", locale)
519
523
  L.setLocale("ca")
@@ -102,7 +102,7 @@
102
102
  "Define link to open in a new window on polygon click.": "Define link to open in a new window on polygon click.",
103
103
  "define": "definir",
104
104
  "Delay between two transitions when in play mode": "Delay between two transitions when in play mode",
105
- "Delete layer": "Delete layer",
105
+ "Delete layer": "Suprimeix la capa",
106
106
  "Delete this feature": "Suprimeix aquesta característica",
107
107
  "Delete this shape": "Delete this shape",
108
108
  "Delete this vertex (Alt+Click)": "Delete this vertex (Alt+Click)",
@@ -456,8 +456,8 @@
456
456
  "key=value or key!=value": "key=value or key!=value",
457
457
  "Are you sure you want to delete this rule?": "Are you sure you want to delete this rule?",
458
458
  "empty rule": "empty rule",
459
- "Conditional style rules": "Conditional style rules",
460
- "Add rule": "Add rule",
459
+ "Conditional style rules": "Regles d'estil condicional",
460
+ "Add rule": "Afegeix una regla",
461
461
  "Browser: data": "Navegador: dades",
462
462
  "Browser: layers": "Navegador: capes",
463
463
  "Browser: filters": "Navegador: filtres",
@@ -513,5 +513,9 @@
513
513
  "Type new owner's username": "Type new owner's username",
514
514
  "Type editor's username": "Type editor's username",
515
515
  "Map": "Map",
516
- "Manage collaborators": "Manage collaborators"
516
+ "Manage collaborators": "Manage collaborators",
517
+ "show/hide all layers": "show/hide all layers",
518
+ "zoom to data extent": "zoom to data extent",
519
+ "download visible data": "download visible data",
520
+ "{connectedPeers} peer(s) currently connected to this map": "{connectedPeers} peer(s) currently connected to this map"
517
521
  }
@@ -513,7 +513,11 @@ const locale = {
513
513
  "Type new owner's username": "Type new owner's username",
514
514
  "Type editor's username": "Type editor's username",
515
515
  "Map": "Map",
516
- "Manage collaborators": "Manage collaborators"
516
+ "Manage collaborators": "Manage collaborators",
517
+ "show/hide all layers": "show/hide all layers",
518
+ "zoom to data extent": "zoom to data extent",
519
+ "download visible data": "download visible data",
520
+ "{connectedPeers} peer(s) currently connected to this map": "{connectedPeers} peer(s) currently connected to this map"
517
521
  }
518
522
  L.registerLocale("en", locale)
519
523
  L.setLocale("en")
@@ -513,5 +513,9 @@
513
513
  "Type new owner's username": "Type new owner's username",
514
514
  "Type editor's username": "Type editor's username",
515
515
  "Map": "Map",
516
- "Manage collaborators": "Manage collaborators"
516
+ "Manage collaborators": "Manage collaborators",
517
+ "show/hide all layers": "show/hide all layers",
518
+ "zoom to data extent": "zoom to data extent",
519
+ "download visible data": "download visible data",
520
+ "{connectedPeers} peer(s) currently connected to this map": "{connectedPeers} peer(s) currently connected to this map"
517
521
  }