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