umap-project 2.9.2__py3-none-any.whl → 3.0.0__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.
- umap/__init__.py +1 -1
- umap/context_processors.py +1 -0
- umap/forms.py +1 -2
- umap/locale/de/LC_MESSAGES/django.mo +0 -0
- umap/locale/de/LC_MESSAGES/django.po +218 -96
- umap/locale/en/LC_MESSAGES/django.po +131 -55
- umap/locale/et/LC_MESSAGES/django.mo +0 -0
- umap/locale/et/LC_MESSAGES/django.po +175 -130
- umap/locale/eu/LC_MESSAGES/django.mo +0 -0
- umap/locale/eu/LC_MESSAGES/django.po +117 -72
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +132 -56
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +209 -88
- umap/locale/is/LC_MESSAGES/django.mo +0 -0
- umap/locale/is/LC_MESSAGES/django.po +296 -175
- umap/middleware.py +2 -1
- umap/migrations/0027_map_tags.py +23 -0
- umap/models.py +13 -2
- umap/settings/base.py +23 -5
- umap/static/umap/base.css +41 -8
- umap/static/umap/content.css +72 -37
- umap/static/umap/css/bar.css +43 -21
- umap/static/umap/css/dialog.css +4 -1
- umap/static/umap/css/form.css +40 -27
- umap/static/umap/css/icon.css +11 -1
- umap/static/umap/css/importers.css +7 -0
- umap/static/umap/img/16-white.svg +23 -2
- umap/static/umap/img/16.svg +1 -1
- umap/static/umap/img/24.svg +4 -4
- umap/static/umap/img/home.svg +7 -0
- umap/static/umap/img/importers/banfr.svg +1 -0
- umap/static/umap/img/marker.svg +2 -5
- umap/static/umap/img/source/16-white.svg +24 -3
- umap/static/umap/img/source/16.svg +1 -1
- umap/static/umap/img/source/24.svg +5 -5
- umap/static/umap/img/target.svg +1 -0
- umap/static/umap/js/components/alerts/alert.js +0 -1
- umap/static/umap/js/modules/browser.js +4 -4
- umap/static/umap/js/modules/caption.js +1 -1
- umap/static/umap/js/modules/data/features.js +25 -25
- umap/static/umap/js/modules/data/layer.js +91 -97
- umap/static/umap/js/modules/facets.js +9 -5
- umap/static/umap/js/modules/form/builder.js +21 -29
- umap/static/umap/js/modules/form/fields.js +40 -14
- umap/static/umap/js/modules/formatter.js +1 -1
- umap/static/umap/js/modules/global.js +9 -5
- umap/static/umap/js/modules/help.js +18 -5
- umap/static/umap/js/modules/importer.js +5 -2
- umap/static/umap/js/modules/importers/banfr.js +93 -0
- umap/static/umap/js/modules/importers/cadastrefr.js +2 -2
- umap/static/umap/js/modules/importers/communesfr.js +1 -1
- umap/static/umap/js/modules/permissions.js +20 -10
- umap/static/umap/js/modules/rendering/icon.js +15 -2
- umap/static/umap/js/modules/rendering/layers/classified.js +7 -7
- umap/static/umap/js/modules/rendering/layers/cluster.js +2 -2
- umap/static/umap/js/modules/rendering/layers/heat.js +4 -4
- umap/static/umap/js/modules/rendering/map.js +14 -6
- umap/static/umap/js/modules/rendering/popup.js +2 -2
- umap/static/umap/js/modules/rendering/template.js +3 -3
- umap/static/umap/js/modules/rendering/ui.js +17 -11
- umap/static/umap/js/modules/rules.js +13 -16
- umap/static/umap/js/modules/schema.js +23 -1
- umap/static/umap/js/modules/share.js +1 -1
- umap/static/umap/js/modules/slideshow.js +1 -0
- umap/static/umap/js/modules/sync/engine.js +141 -19
- umap/static/umap/js/modules/sync/undo.js +101 -0
- umap/static/umap/js/modules/sync/updaters.js +51 -28
- umap/static/umap/js/modules/tableeditor.js +1 -1
- umap/static/umap/js/modules/ui/bar.js +61 -21
- umap/static/umap/js/modules/ui/tooltip.js +1 -1
- umap/static/umap/js/modules/umap.js +190 -176
- umap/static/umap/js/modules/utils.js +30 -4
- umap/static/umap/js/umap.controls.js +82 -38
- umap/static/umap/locale/am_ET.js +13 -7
- umap/static/umap/locale/am_ET.json +13 -7
- umap/static/umap/locale/ar.js +13 -7
- umap/static/umap/locale/ar.json +13 -7
- umap/static/umap/locale/ast.js +13 -7
- umap/static/umap/locale/ast.json +13 -7
- umap/static/umap/locale/bg.js +13 -7
- umap/static/umap/locale/bg.json +13 -7
- umap/static/umap/locale/br.js +13 -8
- umap/static/umap/locale/br.json +13 -8
- umap/static/umap/locale/ca.js +13 -7
- umap/static/umap/locale/ca.json +13 -7
- umap/static/umap/locale/cs_CZ.js +26 -20
- umap/static/umap/locale/cs_CZ.json +26 -20
- umap/static/umap/locale/da.js +13 -7
- umap/static/umap/locale/da.json +13 -7
- umap/static/umap/locale/de.js +47 -41
- umap/static/umap/locale/de.json +47 -41
- umap/static/umap/locale/el.js +13 -7
- umap/static/umap/locale/el.json +13 -7
- umap/static/umap/locale/en.js +12 -7
- umap/static/umap/locale/en.json +12 -7
- umap/static/umap/locale/en_US.json +13 -7
- umap/static/umap/locale/es.js +19 -13
- umap/static/umap/locale/es.json +19 -13
- umap/static/umap/locale/et.js +13 -7
- umap/static/umap/locale/et.json +13 -7
- umap/static/umap/locale/eu.js +43 -37
- umap/static/umap/locale/eu.json +43 -37
- umap/static/umap/locale/fa_IR.js +13 -7
- umap/static/umap/locale/fa_IR.json +13 -7
- umap/static/umap/locale/fi.js +13 -7
- umap/static/umap/locale/fi.json +13 -7
- umap/static/umap/locale/fr.js +12 -7
- umap/static/umap/locale/fr.json +12 -7
- umap/static/umap/locale/gl.js +19 -13
- umap/static/umap/locale/gl.json +19 -13
- umap/static/umap/locale/he.js +13 -7
- umap/static/umap/locale/he.json +13 -7
- umap/static/umap/locale/hr.js +13 -7
- umap/static/umap/locale/hr.json +13 -7
- umap/static/umap/locale/hu.js +25 -19
- umap/static/umap/locale/hu.json +25 -19
- umap/static/umap/locale/id.js +13 -7
- umap/static/umap/locale/id.json +13 -7
- umap/static/umap/locale/is.js +151 -145
- umap/static/umap/locale/is.json +151 -145
- umap/static/umap/locale/it.js +13 -7
- umap/static/umap/locale/it.json +13 -7
- umap/static/umap/locale/ja.js +13 -7
- umap/static/umap/locale/ja.json +13 -7
- umap/static/umap/locale/ko.js +13 -7
- umap/static/umap/locale/ko.json +13 -7
- umap/static/umap/locale/lt.js +13 -7
- umap/static/umap/locale/lt.json +13 -7
- umap/static/umap/locale/ms.js +13 -7
- umap/static/umap/locale/ms.json +13 -7
- umap/static/umap/locale/nl.js +12 -7
- umap/static/umap/locale/nl.json +12 -7
- umap/static/umap/locale/no.js +13 -7
- umap/static/umap/locale/no.json +13 -7
- umap/static/umap/locale/pl.js +13 -7
- umap/static/umap/locale/pl.json +13 -7
- umap/static/umap/locale/pl_PL.json +13 -7
- umap/static/umap/locale/pt.js +12 -7
- umap/static/umap/locale/pt.json +12 -7
- umap/static/umap/locale/pt_BR.js +13 -7
- umap/static/umap/locale/pt_BR.json +13 -7
- umap/static/umap/locale/pt_PT.js +13 -7
- umap/static/umap/locale/pt_PT.json +13 -7
- umap/static/umap/locale/ro.js +13 -7
- umap/static/umap/locale/ro.json +13 -7
- umap/static/umap/locale/ru.js +13 -7
- umap/static/umap/locale/ru.json +13 -7
- umap/static/umap/locale/sk_SK.js +13 -7
- umap/static/umap/locale/sk_SK.json +13 -7
- umap/static/umap/locale/sl.js +13 -7
- umap/static/umap/locale/sl.json +13 -7
- umap/static/umap/locale/sr.js +13 -7
- umap/static/umap/locale/sr.json +13 -7
- umap/static/umap/locale/sv.js +13 -7
- umap/static/umap/locale/sv.json +13 -7
- umap/static/umap/locale/th_TH.js +13 -7
- umap/static/umap/locale/th_TH.json +13 -7
- umap/static/umap/locale/tr.js +13 -7
- umap/static/umap/locale/tr.json +13 -7
- umap/static/umap/locale/uk_UA.js +13 -7
- umap/static/umap/locale/uk_UA.json +13 -7
- umap/static/umap/locale/vi.js +13 -7
- umap/static/umap/locale/vi.json +13 -7
- umap/static/umap/locale/vi_VN.json +13 -7
- umap/static/umap/locale/zh.js +13 -7
- umap/static/umap/locale/zh.json +13 -7
- umap/static/umap/locale/zh_CN.json +13 -7
- umap/static/umap/locale/zh_TW.Big5.json +13 -7
- umap/static/umap/locale/zh_TW.js +19 -13
- umap/static/umap/locale/zh_TW.json +19 -13
- umap/static/umap/map.css +58 -28
- umap/static/umap/unittests/sync.js +0 -57
- umap/static/umap/unittests/utils.js +47 -0
- umap/static/umap/vars.css +5 -2
- umap/static/umap/vendors/photon/leaflet.photon.js +3 -0
- umap/sync/payloads.py +3 -2
- umap/templates/auth/user_detail.html +1 -1
- umap/templates/auth/user_stars.html +1 -1
- umap/templates/umap/content.html +17 -12
- umap/templates/umap/home.html +7 -5
- umap/templates/umap/map_fragment.html +1 -1
- umap/templates/umap/map_list.html +20 -13
- umap/templates/umap/search.html +7 -3
- umap/templates/umap/search_bar.html +13 -11
- umap/templates/umap/team_detail.html +1 -1
- umap/tests/base.py +2 -1
- umap/tests/fixtures/remote_data.umap +55 -0
- umap/tests/fixtures/test_upload_data_with_iconurl.umap +122 -0
- umap/tests/integration/test_browser.py +1 -3
- umap/tests/integration/test_conditional_rules.py +3 -0
- umap/tests/integration/test_edit_datalayer.py +2 -7
- umap/tests/integration/test_edit_map.py +15 -0
- umap/tests/integration/test_edit_polygon.py +1 -2
- umap/tests/integration/test_import.py +59 -2
- umap/tests/integration/test_optimistic_merge.py +4 -3
- umap/tests/integration/test_owned_map.py +0 -1
- umap/tests/integration/test_save.py +2 -4
- umap/tests/integration/test_undo_redo.py +267 -0
- umap/tests/integration/test_websocket_sync.py +78 -11
- umap/tests/settings.py +1 -3
- umap/tests/test_datalayer_s3.py +1 -0
- umap/tests/test_map_views.py +1 -0
- umap/tests/test_views.py +34 -0
- umap/utils.py +1 -1
- umap/views.py +23 -2
- {umap_project-2.9.2.dist-info → umap_project-3.0.0.dist-info}/METADATA +13 -12
- {umap_project-2.9.2.dist-info → umap_project-3.0.0.dist-info}/RECORD +211 -213
- umap/static/umap/js/modules/saving.js +0 -52
- umap/static/umap/test/.eslintrc +0 -21
- umap/static/umap/test/DataLayer.js +0 -463
- umap/static/umap/test/Feature.js +0 -131
- umap/static/umap/test/Map.js +0 -37
- umap/static/umap/test/Marker.js +0 -126
- umap/static/umap/test/Polygon.js +0 -111
- umap/static/umap/test/Polyline.js +0 -286
- umap/static/umap/test/Util.js +0 -28
- umap/static/umap/test/_pre.js +0 -455
- umap/static/umap/test/index.html +0 -139
- {umap_project-2.9.2.dist-info → umap_project-3.0.0.dist-info}/WHEEL +0 -0
- {umap_project-2.9.2.dist-info → umap_project-3.0.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.9.2.dist-info → umap_project-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const _queue = new Set()
|
|
2
|
-
|
|
3
|
-
export let isDirty = false
|
|
4
|
-
|
|
5
|
-
export async function save() {
|
|
6
|
-
for (const obj of _queue) {
|
|
7
|
-
const ok = await obj.save()
|
|
8
|
-
if (!ok) break
|
|
9
|
-
remove(obj)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function clear() {
|
|
14
|
-
_queue.clear()
|
|
15
|
-
onUpdate()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function add(obj) {
|
|
19
|
-
_queue.add(obj)
|
|
20
|
-
onUpdate()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function remove(obj) {
|
|
24
|
-
_queue.delete(obj)
|
|
25
|
-
onUpdate()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function has(obj) {
|
|
29
|
-
return _queue.has(obj)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function onUpdate() {
|
|
33
|
-
isDirty = Boolean(_queue.size)
|
|
34
|
-
document.body.classList.toggle('umap-is-dirty', isDirty)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class ServerStored {
|
|
38
|
-
set isDirty(status) {
|
|
39
|
-
if (status) {
|
|
40
|
-
add(this)
|
|
41
|
-
} else {
|
|
42
|
-
remove(this)
|
|
43
|
-
}
|
|
44
|
-
this.onDirty(status)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get isDirty() {
|
|
48
|
-
return has(this)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
onDirty(status) {}
|
|
52
|
-
}
|
umap/static/umap/test/.eslintrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"globals": {
|
|
3
|
-
"describe": true,
|
|
4
|
-
"happen": true,
|
|
5
|
-
"assert": true,
|
|
6
|
-
"before": true,
|
|
7
|
-
"after": true,
|
|
8
|
-
"it": true,
|
|
9
|
-
"sinon": true,
|
|
10
|
-
"enableEdit": true,
|
|
11
|
-
"disableEdit": true,
|
|
12
|
-
"changeInputValue": true,
|
|
13
|
-
"resetMap": true,
|
|
14
|
-
"initMap": true,
|
|
15
|
-
"clickCancel": true,
|
|
16
|
-
"map": true,
|
|
17
|
-
"qs": true,
|
|
18
|
-
"qsa": true,
|
|
19
|
-
"qst": true
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
describe('U.DataLayer', () => {
|
|
2
|
-
let path = '/map/99/datalayer/update/62/',
|
|
3
|
-
map,
|
|
4
|
-
datalayer
|
|
5
|
-
|
|
6
|
-
before(async () => {
|
|
7
|
-
fetchMock.mock(/\/datalayer\/62\/\?.*/, JSON.stringify(RESPONSES.datalayer62_GET))
|
|
8
|
-
fetchMock.sticky('/map/99/update/settings/', { id: 99 })
|
|
9
|
-
this.options = {
|
|
10
|
-
umap_id: 99,
|
|
11
|
-
}
|
|
12
|
-
MAP = map = initMap({ umap_id: 99 })
|
|
13
|
-
const datalayer_options = defaultDatalayerData()
|
|
14
|
-
await map.initDataLayers([datalayer_options])
|
|
15
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
16
|
-
enableEdit()
|
|
17
|
-
})
|
|
18
|
-
after(() => {
|
|
19
|
-
fetchMock.restore()
|
|
20
|
-
resetMap()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe('#init()', () => {
|
|
24
|
-
it('should be added in datalayers index', () => {
|
|
25
|
-
assert.notEqual(map.datalayers_index.indexOf(datalayer), -1)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
describe('#edit()', () => {
|
|
30
|
-
var editButton, form, input, forceButton
|
|
31
|
-
|
|
32
|
-
it('row in control should be active', () => {
|
|
33
|
-
assert.notOk(
|
|
34
|
-
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer) + '.off')
|
|
35
|
-
)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should have edit button', () => {
|
|
39
|
-
editButton = qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
|
|
40
|
-
assert.ok(editButton)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should have toggle visibility element', () => {
|
|
44
|
-
assert.ok(qs('.leaflet-control-browse i.layer-toggle'))
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should exist only one datalayer', () => {
|
|
48
|
-
assert.equal(qsa('.leaflet-control-browse i.layer-toggle').length, 1)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should build a form on edit button click', () => {
|
|
52
|
-
happen.click(editButton)
|
|
53
|
-
form = qs('form.umap-form')
|
|
54
|
-
input = qs('form.umap-form input[name="name"]')
|
|
55
|
-
assert.ok(form)
|
|
56
|
-
assert.ok(input)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should update name on input change', () => {
|
|
60
|
-
var new_name = 'This is a new name'
|
|
61
|
-
input.value = new_name
|
|
62
|
-
happen.once(input, { type: 'input' })
|
|
63
|
-
assert.equal(datalayer.options.name, new_name)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should have made datalayer dirty', () => {
|
|
67
|
-
assert.ok(datalayer.isDirty)
|
|
68
|
-
assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('should have made Map dirty', () => {
|
|
72
|
-
assert.ok(map.isDirty)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should call datalayer.save on save button click', (done) => {
|
|
76
|
-
const postDatalayer = fetchMock.post(path, () => {
|
|
77
|
-
return defaultDatalayerData()
|
|
78
|
-
})
|
|
79
|
-
clickSave()
|
|
80
|
-
window.setTimeout(() => {
|
|
81
|
-
assert(fetchMock.called(path))
|
|
82
|
-
done()
|
|
83
|
-
}, 500)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('should show alert if server respond 412', (done) => {
|
|
87
|
-
cleanAlert()
|
|
88
|
-
fetchMock.restore()
|
|
89
|
-
fetchMock.post(path, 412)
|
|
90
|
-
happen.click(editButton)
|
|
91
|
-
input = qs('form.umap-form input[name="name"]')
|
|
92
|
-
input.value = 'a new name'
|
|
93
|
-
happen.once(input, { type: 'input' })
|
|
94
|
-
clickSave()
|
|
95
|
-
window.setTimeout(() => {
|
|
96
|
-
assert(L.DomUtil.hasClass(map._container, 'umap-alert'))
|
|
97
|
-
assert.notEqual(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
98
|
-
const forceButton = qs('#umap-alert-container .umap-action')
|
|
99
|
-
assert.ok(forceButton)
|
|
100
|
-
done()
|
|
101
|
-
}, 500)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('should save anyway on force save button click', (done) => {
|
|
105
|
-
const forceButton = qs('#umap-alert-container .umap-action')
|
|
106
|
-
fetchMock.restore()
|
|
107
|
-
fetchMock.post(path, defaultDatalayerData)
|
|
108
|
-
happen.click(forceButton)
|
|
109
|
-
window.setTimeout(() => {
|
|
110
|
-
assert.notOk(qs('#umap-alert-container .umap-action'))
|
|
111
|
-
assert(fetchMock.called(path))
|
|
112
|
-
assert.equal(map.dirty_datalayers.indexOf(datalayer), -1)
|
|
113
|
-
done()
|
|
114
|
-
}, 500)
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
describe('#save() new', () => {
|
|
119
|
-
let newLayerButton, form, input, newDatalayer, editButton, manageButton
|
|
120
|
-
|
|
121
|
-
it('should have a manage datalayers action', () => {
|
|
122
|
-
enableEdit()
|
|
123
|
-
manageButton = qs('.manage-datalayers')
|
|
124
|
-
assert.ok(manageButton)
|
|
125
|
-
happen.click(manageButton)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('should have a new layer button', () => {
|
|
129
|
-
newLayerButton = qs('.panel.right.on .add-datalayer')
|
|
130
|
-
assert.ok(newLayerButton)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('should build a form on new layer button click', () => {
|
|
134
|
-
happen.click(newLayerButton)
|
|
135
|
-
form = qs('form.umap-form')
|
|
136
|
-
input = qs('form.umap-form input[name="name"]')
|
|
137
|
-
assert.ok(form)
|
|
138
|
-
assert.ok(input)
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
it('should have an empty name', () => {
|
|
142
|
-
assert.notOk(input.value)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('should have created a new datalayer', () => {
|
|
146
|
-
assert.equal(map.datalayers_index.length, 2)
|
|
147
|
-
newDatalayer = map.datalayers_index[1]
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it('should have made Map dirty', () => {
|
|
151
|
-
assert.ok(map.isDirty)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('should update name on input change', () => {
|
|
155
|
-
var new_name = 'This is a new name'
|
|
156
|
-
input.value = new_name
|
|
157
|
-
happen.once(input, { type: 'input' })
|
|
158
|
-
assert.equal(newDatalayer.options.name, new_name)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
it('should set umap_id on save callback', async () => {
|
|
162
|
-
assert.notOk(newDatalayer.umap_id)
|
|
163
|
-
fetchMock.post('/map/99/datalayer/create/', defaultDatalayerData({ id: 63 }))
|
|
164
|
-
clickSave()
|
|
165
|
-
return new Promise((resolve) => {
|
|
166
|
-
window.setTimeout(() => {
|
|
167
|
-
assert.equal(newDatalayer.umap_id, 63)
|
|
168
|
-
resolve()
|
|
169
|
-
}, 1000)
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('should have unset map dirty', () => {
|
|
174
|
-
assert.notOk(map.isDirty)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('should have edit button', () => {
|
|
178
|
-
editButton = qs('#browse_data_toggle_' + L.stamp(newDatalayer) + ' .layer-edit')
|
|
179
|
-
assert.ok(editButton)
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
it('should call update if we edit again', async () => {
|
|
183
|
-
happen.click(editButton)
|
|
184
|
-
assert.notOk(map.isDirty)
|
|
185
|
-
input = qs('form.umap-form input[name="name"]')
|
|
186
|
-
input.value = "a new name again but we don't care which"
|
|
187
|
-
happen.once(input, { type: 'input' })
|
|
188
|
-
assert.ok(map.isDirty)
|
|
189
|
-
var response = () => {
|
|
190
|
-
return defaultDatalayerData({ pk: 63 })
|
|
191
|
-
}
|
|
192
|
-
var spy = sinon.spy(response)
|
|
193
|
-
fetchMock.post('/map/99/datalayer/update/63/', spy)
|
|
194
|
-
return new Promise((resolve) => {
|
|
195
|
-
clickSave()
|
|
196
|
-
window.setTimeout(() => {
|
|
197
|
-
assert.ok(spy.calledOnce)
|
|
198
|
-
resolve()
|
|
199
|
-
}, 1000)
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
describe('#iconClassChange()', () => {
|
|
205
|
-
it('should change icon class', () => {
|
|
206
|
-
happen.click(qs('[data-id="' + datalayer._leaflet_id + '"] .layer-edit'))
|
|
207
|
-
changeSelectValue(
|
|
208
|
-
qs('form#datalayer-advanced-properties select[name=iconClass]'),
|
|
209
|
-
'Circle'
|
|
210
|
-
)
|
|
211
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
212
|
-
assert.ok(qs('div.umap-circle-icon'))
|
|
213
|
-
happen.click(
|
|
214
|
-
qs('form#datalayer-advanced-properties .umap-field-iconClass .undefine')
|
|
215
|
-
)
|
|
216
|
-
assert.notOk(qs('div.umap-circle-icon'))
|
|
217
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
218
|
-
clickCancel()
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
describe('#show/hide', () => {
|
|
223
|
-
it('should hide features on hide', () => {
|
|
224
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
225
|
-
assert.ok(qs('path[fill="none"]'))
|
|
226
|
-
datalayer.hide()
|
|
227
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
228
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
it('should show features on show', () => {
|
|
232
|
-
assert.notOk(qs('div.umap-div-icon'))
|
|
233
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
234
|
-
datalayer.show()
|
|
235
|
-
assert.ok(qs('div.umap-div-icon'))
|
|
236
|
-
assert.ok(qs('path[fill="none"]'))
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
describe('#clone()', () => {
|
|
241
|
-
it('should clone everything but the id and the name', () => {
|
|
242
|
-
enableEdit()
|
|
243
|
-
var clone = datalayer.clone()
|
|
244
|
-
assert.notOk(clone.umap_id)
|
|
245
|
-
assert.notEqual(clone.options.name, datalayer.name)
|
|
246
|
-
assert.ok(clone.options.name)
|
|
247
|
-
assert.equal(clone.options.color, datalayer.options.color)
|
|
248
|
-
assert.equal(clone.options.stroke, datalayer.options.stroke)
|
|
249
|
-
clone._delete()
|
|
250
|
-
clickSave()
|
|
251
|
-
})
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
describe('#restore()', () => {
|
|
255
|
-
var oldConfirm,
|
|
256
|
-
newConfirm = () => {
|
|
257
|
-
return true
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
before(() => {
|
|
261
|
-
oldConfirm = window.confirm
|
|
262
|
-
window.confirm = newConfirm
|
|
263
|
-
})
|
|
264
|
-
after(() => {
|
|
265
|
-
window.confirm = oldConfirm
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
it('should restore everything', (done) => {
|
|
269
|
-
enableEdit()
|
|
270
|
-
var geojson = L.Util.CopyJSON(RESPONSES.datalayer62_GET)
|
|
271
|
-
geojson.features.push({
|
|
272
|
-
geometry: {
|
|
273
|
-
type: 'Point',
|
|
274
|
-
coordinates: [-1.274658203125, 50.57634993749885],
|
|
275
|
-
},
|
|
276
|
-
type: 'Feature',
|
|
277
|
-
id: 1807,
|
|
278
|
-
properties: { _umap_options: {}, name: 'new point from restore' },
|
|
279
|
-
})
|
|
280
|
-
geojson._umap_options.color = 'Chocolate'
|
|
281
|
-
fetchMock.get('/datalayer/62/olderversion.geojson', geojson)
|
|
282
|
-
sinon.spy(window, 'confirm')
|
|
283
|
-
datalayer.restore('olderversion.geojson')
|
|
284
|
-
window.setTimeout(() => {
|
|
285
|
-
assert(window.confirm.calledOnce)
|
|
286
|
-
window.confirm.restore()
|
|
287
|
-
assert.equal(datalayer.umap_id, 62)
|
|
288
|
-
assert.ok(datalayer.isDirty)
|
|
289
|
-
assert.equal(datalayer._index.length, 4)
|
|
290
|
-
assert.ok(qs('path[fill="Chocolate"]'))
|
|
291
|
-
done()
|
|
292
|
-
}, 1000)
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
it('should revert anything on cancel click', () => {
|
|
296
|
-
clickCancel()
|
|
297
|
-
assert.equal(datalayer._index.length, 3)
|
|
298
|
-
assert.notOk(qs('path[fill="Chocolate"]'))
|
|
299
|
-
})
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
describe('#smart-options()', () => {
|
|
303
|
-
let poly, marker
|
|
304
|
-
before(() => {
|
|
305
|
-
datalayer.eachLayer(function (layer) {
|
|
306
|
-
if (!poly && layer instanceof L.Polygon) {
|
|
307
|
-
poly = layer
|
|
308
|
-
}
|
|
309
|
-
if (!marker && layer instanceof L.Marker) {
|
|
310
|
-
marker = layer
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
it('should parse color variable', () => {
|
|
316
|
-
let icon = qs('div.umap-div-icon .icon_container')
|
|
317
|
-
poly.properties.mycolor = 'DarkGoldenRod'
|
|
318
|
-
marker.properties.mycolor = 'DarkRed'
|
|
319
|
-
marker.properties._umap_options.color = undefined
|
|
320
|
-
assert.notOk(qs('path[fill="DarkGoldenRod"]'))
|
|
321
|
-
assert.equal(icon.style.backgroundColor, 'olivedrab')
|
|
322
|
-
datalayer.options.color = '{mycolor}'
|
|
323
|
-
datalayer.options.fillColor = '{mycolor}'
|
|
324
|
-
datalayer.indexProperties(poly)
|
|
325
|
-
datalayer.indexProperties(marker)
|
|
326
|
-
datalayer.redraw()
|
|
327
|
-
icon = qs('div.umap-div-icon .icon_container')
|
|
328
|
-
assert.equal(icon.style.backgroundColor, 'darkred')
|
|
329
|
-
assert.ok(qs('path[fill="DarkGoldenRod"]'))
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
describe('#facet-search()', () => {
|
|
334
|
-
before(async () => {
|
|
335
|
-
fetchMock.get(/\/datalayer\/63\/\?.*/, RESPONSES.datalayer63_GET)
|
|
336
|
-
map.options.facetKey = 'name'
|
|
337
|
-
await map.initDataLayers([RESPONSES.datalayer63_GET._umap_options])
|
|
338
|
-
})
|
|
339
|
-
it('should not impact non browsable layer', () => {
|
|
340
|
-
assert.ok(qs('path[fill="SteelBlue"]'))
|
|
341
|
-
})
|
|
342
|
-
it('should allow advanced filter', () => {
|
|
343
|
-
map.openFacet()
|
|
344
|
-
assert.ok(qs('div.umap-facet-search'))
|
|
345
|
-
// This one if from the normal datalayer
|
|
346
|
-
// it's name is "test", so it should be hidden
|
|
347
|
-
// by the filter
|
|
348
|
-
assert.ok(qs('path[fill="none"]'))
|
|
349
|
-
happen.click(qs('input[data-value="name poly"]'))
|
|
350
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
351
|
-
// This one comes from a non browsable layer
|
|
352
|
-
// so it should not be affected by the filter
|
|
353
|
-
assert.ok(qs('path[fill="SteelBlue"]'))
|
|
354
|
-
happen.click(qs('input[data-value="name poly"]')) // Undo
|
|
355
|
-
})
|
|
356
|
-
it('should allow to control facet label', () => {
|
|
357
|
-
map.options.facetKey = 'name|Nom'
|
|
358
|
-
map.openFacet()
|
|
359
|
-
assert.ok(qs('div.umap-facet-search h5'))
|
|
360
|
-
assert.equal(qs('div.umap-facet-search h5').textContent, 'Nom')
|
|
361
|
-
})
|
|
362
|
-
})
|
|
363
|
-
describe('#zoomEnd', () => {
|
|
364
|
-
it('should honour the fromZoom option', () => {
|
|
365
|
-
map.setZoom(6, { animate: false })
|
|
366
|
-
assert.ok(qs('path[fill="none"]'))
|
|
367
|
-
datalayer.options.fromZoom = 6
|
|
368
|
-
map.setZoom(5, { animate: false })
|
|
369
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
370
|
-
map.setZoom(6, { animate: false })
|
|
371
|
-
assert.ok(qs('path[fill="none"]'))
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
it('should honour the toZoom option', () => {
|
|
375
|
-
map.setZoom(6, { animate: false })
|
|
376
|
-
assert.ok(qs('path[fill="none"]'))
|
|
377
|
-
datalayer.options.toZoom = 6
|
|
378
|
-
map.setZoom(7, { animate: false })
|
|
379
|
-
assert.notOk(qs('path[fill="none"]'))
|
|
380
|
-
map.setZoom(6, { animate: false })
|
|
381
|
-
assert.ok(qs('path[fill="none"]'))
|
|
382
|
-
})
|
|
383
|
-
})
|
|
384
|
-
|
|
385
|
-
describe('#displayOnLoad', () => {
|
|
386
|
-
before(() => {
|
|
387
|
-
fetchMock.get(/\/datalayer\/64\/\?.*/, RESPONSES.datalayer64_GET)
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
beforeEach(async () => {
|
|
391
|
-
await map.initDataLayers([RESPONSES.datalayer64_GET._umap_options])
|
|
392
|
-
datalayer = map.getDataLayerByUmapId(64)
|
|
393
|
-
map.setZoom(10, { animate: false })
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
afterEach(() => {
|
|
397
|
-
datalayer._delete()
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
it('should not display layer at load', () => {
|
|
401
|
-
assert.notOk(qs('path[fill="AliceBlue"]'))
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
it('should display on click', (done) => {
|
|
405
|
-
happen.click(qs(`[data-id='${L.stamp(datalayer)}'] .layer-toggle`))
|
|
406
|
-
window.setTimeout(() => {
|
|
407
|
-
assert.ok(qs('path[fill="AliceBlue"]'))
|
|
408
|
-
done()
|
|
409
|
-
}, 500)
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
it('should not display on zoom', (done) => {
|
|
413
|
-
map.setZoom(9, { animate: false })
|
|
414
|
-
window.setTimeout(() => {
|
|
415
|
-
assert.notOk(qs('path[fill="AliceBlue"]'))
|
|
416
|
-
done()
|
|
417
|
-
}, 500)
|
|
418
|
-
})
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
describe('#delete()', () => {
|
|
422
|
-
let deleteLink,
|
|
423
|
-
deletePath = '/map/99/datalayer/delete/62/'
|
|
424
|
-
before(() => {
|
|
425
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
it('should have a delete link in update form', () => {
|
|
429
|
-
enableEdit()
|
|
430
|
-
happen.click(qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit'))
|
|
431
|
-
deleteLink = qs('button.delete_datalayer_button')
|
|
432
|
-
assert.ok(deleteLink)
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
it('should delete features on datalayer delete', () => {
|
|
436
|
-
happen.click(deleteLink)
|
|
437
|
-
assert.notOk(qs('div.icon_container'))
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
it('should have set map dirty', () => {
|
|
441
|
-
assert.ok(map.isDirty)
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
it('should delete layer control row on delete', () => {
|
|
445
|
-
assert.notOk(
|
|
446
|
-
qs('.leaflet-control-browse #browse_data_toggle_' + L.stamp(datalayer))
|
|
447
|
-
)
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
it('should be removed from map.datalayers_index', () => {
|
|
451
|
-
assert.equal(map.datalayers_index.indexOf(datalayer), -1)
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
it('should be removed from map.datalayers', () => {
|
|
455
|
-
assert.notOk(map.datalayers[L.stamp(datalayer)])
|
|
456
|
-
})
|
|
457
|
-
|
|
458
|
-
it('should be visible again on edit cancel', () => {
|
|
459
|
-
clickCancel()
|
|
460
|
-
assert.ok(qs('div.icon_container'))
|
|
461
|
-
})
|
|
462
|
-
})
|
|
463
|
-
})
|
umap/static/umap/test/Feature.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
describe('U.FeatureMixin', function () {
|
|
2
|
-
let map, datalayer
|
|
3
|
-
before(async () => {
|
|
4
|
-
await fetchMock.mock(
|
|
5
|
-
/\/datalayer\/62\/\?.*/,
|
|
6
|
-
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
|
-
)
|
|
8
|
-
this.options = {
|
|
9
|
-
umap_id: 99,
|
|
10
|
-
}
|
|
11
|
-
MAP = map = initMap({ umap_id: 99 })
|
|
12
|
-
const datalayer_options = defaultDatalayerData()
|
|
13
|
-
await map.initDataLayers([datalayer_options])
|
|
14
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
15
|
-
})
|
|
16
|
-
after(function () {
|
|
17
|
-
fetchMock.restore()
|
|
18
|
-
resetMap()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('#utils()', function () {
|
|
22
|
-
var poly, marker
|
|
23
|
-
function setFeatures(datalayer) {
|
|
24
|
-
datalayer.eachLayer(function (layer) {
|
|
25
|
-
if (!poly && layer instanceof L.Polygon) {
|
|
26
|
-
poly = layer
|
|
27
|
-
}
|
|
28
|
-
if (!marker && layer instanceof L.Marker) {
|
|
29
|
-
marker = layer
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
it('should generate a valid geojson', function () {
|
|
34
|
-
setFeatures(datalayer)
|
|
35
|
-
assert.ok(poly)
|
|
36
|
-
assert.deepEqual(poly.toGeoJSON().geometry, {
|
|
37
|
-
type: 'Polygon',
|
|
38
|
-
coordinates: [
|
|
39
|
-
[
|
|
40
|
-
[11.25, 53.585984],
|
|
41
|
-
[10.151367, 52.975108],
|
|
42
|
-
[12.689209, 52.167194],
|
|
43
|
-
[14.084473, 53.199452],
|
|
44
|
-
[12.634277, 53.618579],
|
|
45
|
-
[11.25, 53.585984],
|
|
46
|
-
[11.25, 53.585984],
|
|
47
|
-
],
|
|
48
|
-
],
|
|
49
|
-
})
|
|
50
|
-
// Ensure original latlngs has not been modified
|
|
51
|
-
assert.equal(poly.getLatLngs()[0].length, 6)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('should remove empty _umap_options from exported geojson', function () {
|
|
55
|
-
setFeatures(datalayer)
|
|
56
|
-
assert.ok(poly)
|
|
57
|
-
assert.deepEqual(poly.toGeoJSON().properties, { name: 'name poly' })
|
|
58
|
-
assert.ok(marker)
|
|
59
|
-
assert.deepEqual(marker.toGeoJSON().properties, {
|
|
60
|
-
_umap_options: { color: 'OliveDrab' },
|
|
61
|
-
name: 'test',
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
describe('#properties()', function () {
|
|
67
|
-
it('should rename property', function () {
|
|
68
|
-
var poly = datalayer._lineToLayer({}, [
|
|
69
|
-
[0, 0],
|
|
70
|
-
[0, 1],
|
|
71
|
-
[0, 2],
|
|
72
|
-
])
|
|
73
|
-
poly.properties.prop1 = 'xxx'
|
|
74
|
-
poly.renameProperty('prop1', 'prop2')
|
|
75
|
-
assert.equal(poly.properties.prop2, 'xxx')
|
|
76
|
-
assert.ok(typeof poly.properties.prop1 === 'undefined')
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('should not create property when renaming', function () {
|
|
80
|
-
var poly = datalayer._lineToLayer({}, [
|
|
81
|
-
[0, 0],
|
|
82
|
-
[0, 1],
|
|
83
|
-
[0, 2],
|
|
84
|
-
])
|
|
85
|
-
delete poly.properties.prop2 // Make sure it doesn't exist
|
|
86
|
-
poly.renameProperty('prop1', 'prop2')
|
|
87
|
-
assert.ok(typeof poly.properties.prop2 === 'undefined')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('should delete property', function () {
|
|
91
|
-
var poly = datalayer._lineToLayer({}, [
|
|
92
|
-
[0, 0],
|
|
93
|
-
[0, 1],
|
|
94
|
-
[0, 2],
|
|
95
|
-
])
|
|
96
|
-
poly.properties.prop = 'xxx'
|
|
97
|
-
assert.equal(poly.properties.prop, 'xxx')
|
|
98
|
-
poly.deleteProperty('prop')
|
|
99
|
-
assert.ok(typeof poly.properties.prop === 'undefined')
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
describe('#matchFilter()', function () {
|
|
104
|
-
var poly
|
|
105
|
-
|
|
106
|
-
it('should filter on properties', function () {
|
|
107
|
-
poly = datalayer._lineToLayer({}, [
|
|
108
|
-
[0, 0],
|
|
109
|
-
[0, 1],
|
|
110
|
-
[0, 2],
|
|
111
|
-
])
|
|
112
|
-
poly.properties.name = 'mooring'
|
|
113
|
-
assert.ok(poly.matchFilter('moo', ['name']))
|
|
114
|
-
assert.notOk(poly.matchFilter('foo', ['name']))
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('should be case unsensitive', function () {
|
|
118
|
-
assert.ok(poly.matchFilter('Moo', ['name']))
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('should match also in the middle of a string', function () {
|
|
122
|
-
assert.ok(poly.matchFilter('oor', ['name']))
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('should handle multiproperties', function () {
|
|
126
|
-
poly.properties.city = 'Teulada'
|
|
127
|
-
assert.ok(poly.matchFilter('eul', ['name', 'city', 'foo']))
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
})
|
umap/static/umap/test/Map.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
describe('U.Map', () => {
|
|
2
|
-
let map, datalayer
|
|
3
|
-
before(async () => {
|
|
4
|
-
await fetchMock.mock(
|
|
5
|
-
/\/datalayer\/62\/\?.*/,
|
|
6
|
-
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
|
-
)
|
|
8
|
-
this.options = {
|
|
9
|
-
umap_id: 99,
|
|
10
|
-
}
|
|
11
|
-
map = initMap({ umap_id: 99 })
|
|
12
|
-
const datalayer_options = defaultDatalayerData()
|
|
13
|
-
await map.initDataLayers([datalayer_options])
|
|
14
|
-
datalayer = map.getDataLayerByUmapId(62)
|
|
15
|
-
})
|
|
16
|
-
after(() => {
|
|
17
|
-
fetchMock.restore()
|
|
18
|
-
clickCancel()
|
|
19
|
-
resetMap()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
describe('#localizeUrl()', function () {
|
|
23
|
-
it('should replace known variables', function () {
|
|
24
|
-
assert.equal(
|
|
25
|
-
map.localizeUrl('http://example.org/{zoom}'),
|
|
26
|
-
'http://example.org/' + map.getZoom()
|
|
27
|
-
)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('should keep unknown variables', function () {
|
|
31
|
-
assert.equal(
|
|
32
|
-
map.localizeUrl('http://example.org/{unkown}'),
|
|
33
|
-
'http://example.org/{unkown}'
|
|
34
|
-
)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
})
|