umap-project 2.4.1__py3-none-any.whl → 2.5.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.
- umap/__init__.py +1 -1
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +145 -90
- umap/locale/en/LC_MESSAGES/django.po +13 -13
- umap/locale/eu/LC_MESSAGES/django.mo +0 -0
- umap/locale/eu/LC_MESSAGES/django.po +145 -89
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +100 -50
- umap/static/umap/base.css +5 -2
- umap/static/umap/content.css +2 -2
- umap/static/umap/css/contextmenu.css +11 -0
- umap/static/umap/css/dialog.css +25 -4
- umap/static/umap/css/importers.css +2 -0
- umap/static/umap/css/panel.css +6 -4
- umap/static/umap/css/slideshow.css +69 -0
- umap/static/umap/css/tableeditor.css +69 -0
- umap/static/umap/css/tooltip.css +3 -3
- umap/static/umap/img/16-white.svg +4 -0
- umap/static/umap/img/source/16-white.svg +5 -1
- umap/static/umap/js/components/alerts/alert.css +11 -11
- umap/static/umap/js/components/alerts/alert.js +1 -1
- umap/static/umap/js/modules/autocomplete.js +27 -5
- umap/static/umap/js/modules/browser.js +20 -14
- umap/static/umap/js/modules/caption.js +4 -4
- umap/static/umap/js/modules/dompurify.js +2 -3
- umap/static/umap/js/modules/facets.js +53 -17
- umap/static/umap/js/modules/formatter.js +153 -0
- umap/static/umap/js/modules/global.js +25 -16
- umap/static/umap/js/modules/help.js +26 -26
- umap/static/umap/js/modules/importer.js +10 -10
- umap/static/umap/js/modules/importers/communesfr.js +3 -1
- umap/static/umap/js/modules/importers/datasets.js +8 -6
- umap/static/umap/js/modules/importers/geodatamine.js +14 -14
- umap/static/umap/js/modules/importers/overpass.js +19 -15
- umap/static/umap/js/modules/orderable.js +2 -2
- umap/static/umap/js/modules/request.js +1 -1
- umap/static/umap/js/modules/rules.js +26 -11
- umap/static/umap/js/modules/schema.js +16 -12
- umap/static/umap/js/{umap.share.js → modules/share.js} +58 -103
- umap/static/umap/js/modules/slideshow.js +141 -0
- umap/static/umap/js/modules/sync/engine.js +3 -3
- umap/static/umap/js/modules/sync/updaters.js +10 -11
- umap/static/umap/js/modules/sync/websocket.js +1 -1
- umap/static/umap/js/modules/tableeditor.js +329 -0
- umap/static/umap/js/modules/ui/base.js +93 -0
- umap/static/umap/js/modules/ui/contextmenu.js +50 -0
- umap/static/umap/js/modules/ui/dialog.js +169 -31
- umap/static/umap/js/modules/ui/panel.js +7 -5
- umap/static/umap/js/modules/ui/tooltip.js +7 -77
- umap/static/umap/js/modules/urls.js +1 -2
- umap/static/umap/js/modules/utils.js +36 -16
- umap/static/umap/js/umap.controls.js +27 -29
- umap/static/umap/js/umap.core.js +19 -15
- umap/static/umap/js/umap.datalayer.permissions.js +15 -18
- umap/static/umap/js/umap.features.js +113 -131
- umap/static/umap/js/umap.forms.js +203 -228
- umap/static/umap/js/umap.icon.js +17 -22
- umap/static/umap/js/umap.js +117 -107
- umap/static/umap/js/umap.layer.js +374 -324
- umap/static/umap/js/umap.permissions.js +7 -10
- umap/static/umap/js/umap.popup.js +20 -20
- umap/static/umap/locale/am_ET.js +22 -5
- umap/static/umap/locale/am_ET.json +22 -5
- umap/static/umap/locale/ar.js +22 -5
- umap/static/umap/locale/ar.json +22 -5
- umap/static/umap/locale/ast.js +22 -5
- umap/static/umap/locale/ast.json +22 -5
- umap/static/umap/locale/bg.js +22 -5
- umap/static/umap/locale/bg.json +22 -5
- umap/static/umap/locale/br.js +22 -5
- umap/static/umap/locale/br.json +22 -5
- umap/static/umap/locale/ca.js +56 -39
- umap/static/umap/locale/ca.json +56 -39
- umap/static/umap/locale/cs_CZ.js +22 -5
- umap/static/umap/locale/cs_CZ.json +22 -5
- umap/static/umap/locale/da.js +22 -5
- umap/static/umap/locale/da.json +22 -5
- umap/static/umap/locale/de.js +22 -5
- umap/static/umap/locale/de.json +22 -5
- umap/static/umap/locale/el.js +27 -10
- umap/static/umap/locale/el.json +27 -10
- umap/static/umap/locale/en.js +22 -6
- umap/static/umap/locale/en.json +22 -6
- umap/static/umap/locale/en_US.json +22 -5
- umap/static/umap/locale/es.js +22 -6
- umap/static/umap/locale/es.json +22 -6
- umap/static/umap/locale/et.js +22 -5
- umap/static/umap/locale/et.json +22 -5
- umap/static/umap/locale/eu.js +167 -150
- umap/static/umap/locale/eu.json +167 -150
- umap/static/umap/locale/fa_IR.js +22 -5
- umap/static/umap/locale/fa_IR.json +22 -5
- umap/static/umap/locale/fi.js +22 -5
- umap/static/umap/locale/fi.json +22 -5
- umap/static/umap/locale/fr.js +22 -6
- umap/static/umap/locale/fr.json +22 -6
- umap/static/umap/locale/gl.js +22 -5
- umap/static/umap/locale/gl.json +22 -5
- umap/static/umap/locale/he.js +22 -5
- umap/static/umap/locale/he.json +22 -5
- umap/static/umap/locale/hr.js +22 -5
- umap/static/umap/locale/hr.json +22 -5
- umap/static/umap/locale/hu.js +89 -72
- umap/static/umap/locale/hu.json +89 -72
- umap/static/umap/locale/id.js +22 -5
- umap/static/umap/locale/id.json +22 -5
- umap/static/umap/locale/is.js +22 -5
- umap/static/umap/locale/is.json +22 -5
- umap/static/umap/locale/it.js +22 -5
- umap/static/umap/locale/it.json +22 -5
- umap/static/umap/locale/ja.js +22 -5
- umap/static/umap/locale/ja.json +22 -5
- umap/static/umap/locale/ko.js +22 -5
- umap/static/umap/locale/ko.json +22 -5
- umap/static/umap/locale/lt.js +22 -5
- umap/static/umap/locale/lt.json +22 -5
- umap/static/umap/locale/ms.js +22 -5
- umap/static/umap/locale/ms.json +22 -5
- umap/static/umap/locale/nl.js +22 -5
- umap/static/umap/locale/nl.json +22 -5
- umap/static/umap/locale/no.js +22 -5
- umap/static/umap/locale/no.json +22 -5
- umap/static/umap/locale/pl.js +22 -5
- umap/static/umap/locale/pl.json +22 -5
- umap/static/umap/locale/pl_PL.json +22 -5
- umap/static/umap/locale/pt.js +22 -6
- umap/static/umap/locale/pt.json +22 -6
- umap/static/umap/locale/pt_BR.js +22 -5
- umap/static/umap/locale/pt_BR.json +22 -5
- umap/static/umap/locale/pt_PT.js +22 -5
- umap/static/umap/locale/pt_PT.json +22 -5
- umap/static/umap/locale/ro.js +22 -5
- umap/static/umap/locale/ro.json +22 -5
- umap/static/umap/locale/ru.js +22 -5
- umap/static/umap/locale/ru.json +22 -5
- umap/static/umap/locale/sk_SK.js +22 -5
- umap/static/umap/locale/sk_SK.json +22 -5
- umap/static/umap/locale/sl.js +22 -5
- umap/static/umap/locale/sl.json +22 -5
- umap/static/umap/locale/sr.js +22 -5
- umap/static/umap/locale/sr.json +22 -5
- umap/static/umap/locale/sv.js +22 -5
- umap/static/umap/locale/sv.json +22 -5
- umap/static/umap/locale/th_TH.js +22 -5
- umap/static/umap/locale/th_TH.json +22 -5
- umap/static/umap/locale/tr.js +22 -5
- umap/static/umap/locale/tr.json +22 -5
- umap/static/umap/locale/uk_UA.js +22 -5
- umap/static/umap/locale/uk_UA.json +22 -5
- umap/static/umap/locale/vi.js +22 -5
- umap/static/umap/locale/vi.json +22 -5
- umap/static/umap/locale/vi_VN.json +22 -5
- umap/static/umap/locale/zh.js +22 -5
- umap/static/umap/locale/zh.json +22 -5
- umap/static/umap/locale/zh_CN.json +22 -5
- umap/static/umap/locale/zh_TW.Big5.json +22 -5
- umap/static/umap/locale/zh_TW.js +22 -5
- umap/static/umap/locale/zh_TW.json +22 -5
- umap/static/umap/map.css +9 -153
- umap/static/umap/vars.css +15 -0
- umap/static/umap/vendors/dompurify/purify.es.js +5 -59
- umap/static/umap/vendors/dompurify/purify.es.mjs.map +1 -1
- umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +410 -428
- umap/static/umap/vendors/geojson-to-gpx/index.js +155 -0
- umap/static/umap/vendors/osmtogeojson/osmtogeojson.js +1 -2
- umap/static/umap/vendors/togeojson/togeojson.es.js +1109 -0
- umap/static/umap/vendors/togeojson/{togeojson.umd.js.map → togeojson.es.mjs.map} +1 -1
- umap/static/umap/vendors/tokml/tokml.es.js +895 -0
- umap/static/umap/vendors/tokml/tokml.es.mjs.map +1 -0
- umap/storage.py +6 -2
- umap/templates/umap/components/alerts/alert.html +3 -3
- umap/templates/umap/css.html +3 -0
- umap/templates/umap/js.html +0 -6
- umap/tests/fixtures/categorized_highway.geojson +1 -0
- umap/tests/fixtures/test_import_osm_relation.json +130 -0
- umap/tests/integration/conftest.py +8 -1
- umap/tests/integration/test_browser.py +3 -2
- umap/tests/integration/test_categorized_layer.py +141 -0
- umap/tests/integration/test_conditional_rules.py +21 -0
- umap/tests/integration/test_datalayer.py +9 -4
- umap/tests/integration/test_edit_datalayer.py +1 -0
- umap/tests/integration/test_edit_polygon.py +1 -1
- umap/tests/integration/test_export_map.py +2 -3
- umap/tests/integration/test_import.py +22 -0
- umap/tests/integration/test_map_preview.py +36 -2
- umap/tests/integration/test_tableeditor.py +158 -4
- umap/tests/integration/test_websocket_sync.py +2 -2
- umap/tests/test_views.py +2 -2
- umap/views.py +3 -2
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/METADATA +8 -8
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/RECORD +194 -184
- umap/static/umap/js/umap.slideshow.js +0 -165
- umap/static/umap/js/umap.tableeditor.js +0 -118
- umap/static/umap/vendors/togeojson/togeojson.umd.js +0 -2
- umap/static/umap/vendors/togpx/togpx.js +0 -547
- umap/static/umap/vendors/tokml/tokml.js +0 -343
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/WHEEL +0 -0
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,482 +1,464 @@
|
|
|
1
1
|
L.FormBuilder = L.Evented.extend({
|
|
2
|
+
options: {
|
|
3
|
+
className: 'leaflet-form',
|
|
4
|
+
},
|
|
5
|
+
|
|
6
|
+
defaultOptions: {
|
|
7
|
+
// Eg.:
|
|
8
|
+
// name: {label: L._('name')},
|
|
9
|
+
// description: {label: L._('description'), handler: 'Textarea'},
|
|
10
|
+
// opacity: {label: L._('opacity'), helpText: L._('Opacity, from 0.1 to 1.0 (opaque).')},
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
initialize: function (obj, fields, options) {
|
|
14
|
+
L.setOptions(this, options)
|
|
15
|
+
this.obj = obj
|
|
16
|
+
this.form = L.DomUtil.create('form', this.options.className)
|
|
17
|
+
this.setFields(fields)
|
|
18
|
+
if (this.options.id) {
|
|
19
|
+
this.form.id = this.options.id
|
|
20
|
+
}
|
|
21
|
+
if (this.options.className) {
|
|
22
|
+
L.DomUtil.addClass(this.form, this.options.className)
|
|
23
|
+
}
|
|
24
|
+
},
|
|
2
25
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
defaultOptions: {
|
|
8
|
-
// Eg.:
|
|
9
|
-
// name: {label: L._('name')},
|
|
10
|
-
// description: {label: L._('description'), handler: 'Textarea'},
|
|
11
|
-
// opacity: {label: L._('opacity'), helpText: L._('Opacity, from 0.1 to 1.0 (opaque).')},
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
initialize: function (obj, fields, options) {
|
|
15
|
-
L.setOptions(this, options);
|
|
16
|
-
this.obj = obj;
|
|
17
|
-
this.form = L.DomUtil.create('form', this.options.className);
|
|
18
|
-
this.setFields(fields);
|
|
19
|
-
if (this.options.id) {
|
|
20
|
-
this.form.id = this.options.id;
|
|
21
|
-
}
|
|
22
|
-
if (this.options.className) {
|
|
23
|
-
L.DomUtil.addClass(this.form, this.options.className);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
setFields: function (fields) {
|
|
28
|
-
this.fields = fields || [];
|
|
29
|
-
this.helpers = {};
|
|
30
|
-
},
|
|
26
|
+
setFields: function (fields) {
|
|
27
|
+
this.fields = fields || []
|
|
28
|
+
this.helpers = {}
|
|
29
|
+
},
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
31
|
+
build: function () {
|
|
32
|
+
this.form.innerHTML = ''
|
|
33
|
+
for (const idx in this.fields) {
|
|
34
|
+
this.buildField(this.fields[idx])
|
|
35
|
+
}
|
|
36
|
+
this.on('postsync', this.onPostSync)
|
|
37
|
+
return this.form
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
buildField: function (field) {
|
|
41
|
+
// field can be either a string like "option.name" or a full definition array,
|
|
42
|
+
// like ['options.tilelayer.tms', {handler: 'CheckBox', helpText: 'TMS format'}]
|
|
43
|
+
let type
|
|
44
|
+
let helper
|
|
45
|
+
let options
|
|
46
|
+
if (Array.isArray(field)) {
|
|
47
|
+
options = field[1] || {}
|
|
48
|
+
field = field[0]
|
|
49
|
+
} else {
|
|
50
|
+
options = this.defaultOptions[this.getName(field)] || {}
|
|
51
|
+
}
|
|
52
|
+
type = options.handler || 'Input'
|
|
53
|
+
if (typeof type === 'string' && L.FormBuilder[type]) {
|
|
54
|
+
helper = new L.FormBuilder[type](this, field, options)
|
|
55
|
+
} else {
|
|
56
|
+
helper = new type(this, field, options)
|
|
57
|
+
}
|
|
58
|
+
this.helpers[field] = helper
|
|
59
|
+
return helper
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
getter: function (field) {
|
|
63
|
+
const path = field.split('.')
|
|
64
|
+
let value = this.obj
|
|
65
|
+
for (const sub of path) {
|
|
66
|
+
value = value[sub]
|
|
67
|
+
}
|
|
68
|
+
return value
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
setter: function (field, value) {
|
|
72
|
+
const path = field.split('.')
|
|
73
|
+
let obj = this.obj
|
|
74
|
+
let what
|
|
75
|
+
for (let i = 0, l = path.length; i < l; i++) {
|
|
76
|
+
what = path[i]
|
|
77
|
+
if (what === path[l - 1]) {
|
|
78
|
+
if (typeof value === 'undefined') {
|
|
79
|
+
delete obj[what]
|
|
54
80
|
} else {
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
this.helpers[field] = helper;
|
|
58
|
-
return helper;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
getter: function (field) {
|
|
62
|
-
var path = field.split('.'),
|
|
63
|
-
value = this.obj;
|
|
64
|
-
for (const prop of path) {
|
|
65
|
-
value = value[prop];
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
setter: function (field, value) {
|
|
71
|
-
var path = field.split('.'),
|
|
72
|
-
obj = this.obj,
|
|
73
|
-
what;
|
|
74
|
-
for (var i = 0, l = path.length; i < l; i++) {
|
|
75
|
-
what = path[i];
|
|
76
|
-
if (what === path[l - 1]) {
|
|
77
|
-
if (typeof value === 'undefined') {
|
|
78
|
-
delete obj[what];
|
|
79
|
-
} else {
|
|
80
|
-
obj[what] = value;
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
obj = obj[what];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
resetField: function (field) {
|
|
89
|
-
var backup = this.helpers[field].backup;
|
|
90
|
-
this.setter(field, backup);
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
getName: function (field) {
|
|
94
|
-
var fieldEls = field.split('.');
|
|
95
|
-
return fieldEls[fieldEls.length - 1];
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
fetchAll: function () {
|
|
99
|
-
for (var key in this.helpers) {
|
|
100
|
-
if (this.helpers.hasOwnProperty(key)) {
|
|
101
|
-
this.helpers[key].fetch();
|
|
102
|
-
}
|
|
81
|
+
obj[what] = value
|
|
103
82
|
}
|
|
104
|
-
|
|
83
|
+
} else {
|
|
84
|
+
obj = obj[what]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
105
88
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
},
|
|
89
|
+
restoreField: function (field) {
|
|
90
|
+
const initial = this.helpers[field].initial
|
|
91
|
+
this.setter(field, initial)
|
|
92
|
+
},
|
|
113
93
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
94
|
+
getName: (field) => {
|
|
95
|
+
const fieldEls = field.split('.')
|
|
96
|
+
return fieldEls[fieldEls.length - 1]
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
fetchAll: function () {
|
|
100
|
+
for (const helper of Object.values(this.helpers)) {
|
|
101
|
+
helper.fetch()
|
|
121
102
|
}
|
|
103
|
+
},
|
|
122
104
|
|
|
123
|
-
|
|
105
|
+
syncAll: function () {
|
|
106
|
+
for (const helper of Object.values(this.helpers)) {
|
|
107
|
+
helper.sync()
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
onPostSync: function (e) {
|
|
112
|
+
if (e.helper.options.callback) {
|
|
113
|
+
e.helper.options.callback.call(e.helper.options.callbackContext || this.obj, e)
|
|
114
|
+
}
|
|
115
|
+
if (this.options.callback) {
|
|
116
|
+
this.options.callback.call(this.options.callbackContext || this.obj, e)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
})
|
|
124
120
|
|
|
125
121
|
L.FormBuilder.Element = L.Evented.extend({
|
|
122
|
+
initialize: function (builder, field, options) {
|
|
123
|
+
this.builder = builder
|
|
124
|
+
this.obj = this.builder.obj
|
|
125
|
+
this.form = this.builder.form
|
|
126
|
+
this.field = field
|
|
127
|
+
L.setOptions(this, options)
|
|
128
|
+
this.fieldEls = this.field.split('.')
|
|
129
|
+
this.name = this.builder.getName(field)
|
|
130
|
+
this.parentNode = this.getParentNode()
|
|
131
|
+
this.buildLabel()
|
|
132
|
+
this.build()
|
|
133
|
+
this.buildHelpText()
|
|
134
|
+
this.fireAndForward('helper:init')
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
fireAndForward: function (type, e = {}) {
|
|
138
|
+
e.helper = this
|
|
139
|
+
this.fire(type, e)
|
|
140
|
+
this.builder.fire(type, e)
|
|
141
|
+
if (this.obj.fire) this.obj.fire(type, e)
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
getParentNode: function () {
|
|
145
|
+
return this.options.wrapper
|
|
146
|
+
? L.DomUtil.create(
|
|
147
|
+
this.options.wrapper,
|
|
148
|
+
this.options.wrapperClass || '',
|
|
149
|
+
this.form
|
|
150
|
+
)
|
|
151
|
+
: this.form
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
get: function () {
|
|
155
|
+
return this.builder.getter(this.field)
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
toHTML: function () {
|
|
159
|
+
return this.get()
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
toJS: function () {
|
|
163
|
+
return this.value()
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
sync: function () {
|
|
167
|
+
this.fireAndForward('presync')
|
|
168
|
+
this.set()
|
|
169
|
+
this.fireAndForward('postsync')
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
set: function () {
|
|
173
|
+
this.builder.setter(this.field, this.toJS())
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
getLabelParent: function () {
|
|
177
|
+
return this.parentNode
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
getHelpTextParent: function () {
|
|
181
|
+
return this.parentNode
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
buildLabel: function () {
|
|
185
|
+
if (this.options.label) {
|
|
186
|
+
this.label = L.DomUtil.create('label', '', this.getLabelParent())
|
|
187
|
+
this.label.innerHTML = this.options.label
|
|
188
|
+
}
|
|
189
|
+
},
|
|
126
190
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.fieldEls = this.field.split('.');
|
|
134
|
-
this.name = this.builder.getName(field);
|
|
135
|
-
this.parentNode = this.getParentNode();
|
|
136
|
-
this.buildLabel();
|
|
137
|
-
this.build();
|
|
138
|
-
this.buildHelpText();
|
|
139
|
-
this.fireAndForward('helper:init');
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
fireAndForward: function (type, e) {
|
|
143
|
-
e = e || {};
|
|
144
|
-
e.helper = this;
|
|
145
|
-
this.fire(type, e);
|
|
146
|
-
this.builder.fire(type, e);
|
|
147
|
-
if (this.obj.fire) this.obj.fire(type, e);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
getParentNode: function () {
|
|
151
|
-
return this.options.wrapper ? L.DomUtil.create(this.options.wrapper, this.options.wrapperClass || '', this.form) : this.form;
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
get: function () {
|
|
155
|
-
return this.builder.getter(this.field);
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
toHTML: function () {
|
|
159
|
-
return this.get();
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
toJS: function () {
|
|
163
|
-
return this.value();
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
sync: function () {
|
|
167
|
-
this.fireAndForward('presync');
|
|
168
|
-
this.set();
|
|
169
|
-
this.fireAndForward('postsync');
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
set: function () {
|
|
173
|
-
this.builder.setter(this.field, this.toJS());
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
getLabelParent: function () {
|
|
177
|
-
return this.parentNode;
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
getHelpTextParent: function () {
|
|
181
|
-
return this.parentNode;
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
buildLabel: function () {
|
|
185
|
-
if (this.options.label) {
|
|
186
|
-
this.label = L.DomUtil.create('label', '', this.getLabelParent());
|
|
187
|
-
this.label.innerHTML = this.options.label;
|
|
188
|
-
}
|
|
189
|
-
},
|
|
191
|
+
buildHelpText: function () {
|
|
192
|
+
if (this.options.helpText) {
|
|
193
|
+
const container = L.DomUtil.create('small', 'help-text', this.getHelpTextParent())
|
|
194
|
+
container.innerHTML = this.options.helpText
|
|
195
|
+
}
|
|
196
|
+
},
|
|
190
197
|
|
|
191
|
-
|
|
192
|
-
if (this.options.helpText) {
|
|
193
|
-
var container = L.DomUtil.create('small', 'help-text', this.getHelpTextParent());
|
|
194
|
-
container.innerHTML = this.options.helpText;
|
|
195
|
-
}
|
|
196
|
-
},
|
|
198
|
+
fetch: () => {},
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
finish: function () {
|
|
201
|
+
this.fireAndForward('finish')
|
|
202
|
+
},
|
|
203
|
+
})
|
|
199
204
|
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
L.FormBuilder.Textarea = L.FormBuilder.Element.extend({
|
|
206
|
+
build: function () {
|
|
207
|
+
this.input = L.DomUtil.create(
|
|
208
|
+
'textarea',
|
|
209
|
+
this.options.className || '',
|
|
210
|
+
this.parentNode
|
|
211
|
+
)
|
|
212
|
+
if (this.options.placeholder) this.input.placeholder = this.options.placeholder
|
|
213
|
+
this.fetch()
|
|
214
|
+
L.DomEvent.on(this.input, 'input', this.sync, this)
|
|
215
|
+
L.DomEvent.on(this.input, 'keypress', this.onKeyPress, this)
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
fetch: function () {
|
|
219
|
+
const value = this.toHTML()
|
|
220
|
+
this.initial = value
|
|
221
|
+
if (value) {
|
|
222
|
+
this.input.value = value
|
|
202
223
|
}
|
|
224
|
+
},
|
|
203
225
|
|
|
204
|
-
|
|
226
|
+
value: function () {
|
|
227
|
+
return this.input.value
|
|
228
|
+
},
|
|
205
229
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (this.options.placeholder) this.input.placeholder = this.options.placeholder;
|
|
211
|
-
this.fetch();
|
|
212
|
-
L.DomEvent.on(this.input, 'input', this.sync, this);
|
|
213
|
-
L.DomEvent.on(this.input, 'keypress', this.onKeyPress, this);
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
fetch: function () {
|
|
217
|
-
var value = this.backup = this.toHTML();
|
|
218
|
-
if (value) {
|
|
219
|
-
this.input.value = value;
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
value: function () {
|
|
224
|
-
return this.input.value;
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
onKeyPress: function (e) {
|
|
228
|
-
var key = e.keyCode,
|
|
229
|
-
ENTER = 13;
|
|
230
|
-
if (key === ENTER && (e.shiftKey || e.ctrlKey)) {
|
|
231
|
-
L.DomEvent.stop(e);
|
|
232
|
-
this.finish();
|
|
233
|
-
}
|
|
230
|
+
onKeyPress: function (e) {
|
|
231
|
+
if (e.key === 'Enter' && (e.shiftKey || e.ctrlKey)) {
|
|
232
|
+
L.DomEvent.stop(e)
|
|
233
|
+
this.finish()
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
})
|
|
235
|
+
},
|
|
236
|
+
})
|
|
237
237
|
|
|
238
238
|
L.FormBuilder.Input = L.FormBuilder.Element.extend({
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
if (this.options.max !== undefined) {
|
|
252
|
-
this.input.max = this.options.max;
|
|
253
|
-
}
|
|
254
|
-
if (this.options.step) {
|
|
255
|
-
this.input.step = this.options.step;
|
|
256
|
-
}
|
|
257
|
-
this.fetch();
|
|
258
|
-
L.DomEvent.on(this.input, this.getSyncEvent(), this.sync, this);
|
|
259
|
-
L.DomEvent.on(this.input, 'keydown', this.onKeyDown, this);
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
fetch: function () {
|
|
263
|
-
this.input.value = this.backup = (typeof this.toHTML() !== 'undefined' ? this.toHTML() : null);
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
getSyncEvent: function () {
|
|
267
|
-
return 'input';
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
type: function () {
|
|
271
|
-
return this.options.type || 'text';
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
value: function () {
|
|
275
|
-
return this.input.value || undefined;
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
onKeyDown: function (e) {
|
|
279
|
-
var key = e.keyCode,
|
|
280
|
-
ENTER = 13;
|
|
281
|
-
if (key === ENTER) {
|
|
282
|
-
L.DomEvent.stop(e);
|
|
283
|
-
this.finish();
|
|
284
|
-
}
|
|
239
|
+
build: function () {
|
|
240
|
+
this.input = L.DomUtil.create(
|
|
241
|
+
'input',
|
|
242
|
+
this.options.className || '',
|
|
243
|
+
this.parentNode
|
|
244
|
+
)
|
|
245
|
+
this.input.type = this.type()
|
|
246
|
+
this.input.name = this.name
|
|
247
|
+
this.input._helper = this
|
|
248
|
+
if (this.options.placeholder) {
|
|
249
|
+
this.input.placeholder = this.options.placeholder
|
|
285
250
|
}
|
|
286
|
-
|
|
287
|
-
|
|
251
|
+
if (this.options.min !== undefined) {
|
|
252
|
+
this.input.min = this.options.min
|
|
253
|
+
}
|
|
254
|
+
if (this.options.max !== undefined) {
|
|
255
|
+
this.input.max = this.options.max
|
|
256
|
+
}
|
|
257
|
+
if (this.options.step) {
|
|
258
|
+
this.input.step = this.options.step
|
|
259
|
+
}
|
|
260
|
+
this.fetch()
|
|
261
|
+
L.DomEvent.on(this.input, this.getSyncEvent(), this.sync, this)
|
|
262
|
+
L.DomEvent.on(this.input, 'keydown', this.onKeyDown, this)
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
fetch: function () {
|
|
266
|
+
const value = this.toHTML() !== undefined ? this.toHTML() : null
|
|
267
|
+
this.initial = value
|
|
268
|
+
this.input.value = value
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
getSyncEvent: () => 'input',
|
|
272
|
+
|
|
273
|
+
type: function () {
|
|
274
|
+
return this.options.type || 'text'
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
value: function () {
|
|
278
|
+
return this.input.value || undefined
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
onKeyDown: function (e) {
|
|
282
|
+
if (e.key === 'Enter') {
|
|
283
|
+
L.DomEvent.stop(e)
|
|
284
|
+
this.finish()
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
})
|
|
288
288
|
|
|
289
289
|
L.FormBuilder.BlurInput = L.FormBuilder.Input.extend({
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
290
|
+
getSyncEvent: () => 'blur',
|
|
291
|
+
|
|
292
|
+
build: function () {
|
|
293
|
+
L.FormBuilder.Input.prototype.build.call(this)
|
|
294
|
+
L.DomEvent.on(this.input, 'focus', this.fetch, this)
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
finish: function () {
|
|
298
|
+
this.sync()
|
|
299
|
+
L.FormBuilder.Input.prototype.finish.call(this)
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
sync: function () {
|
|
303
|
+
// Do not commit any change if user only clicked
|
|
304
|
+
// on the field than clicked outside
|
|
305
|
+
if (this.initial !== this.value()) {
|
|
306
|
+
L.FormBuilder.Input.prototype.sync.call(this)
|
|
304
307
|
}
|
|
305
|
-
|
|
306
|
-
})
|
|
308
|
+
},
|
|
309
|
+
})
|
|
307
310
|
|
|
308
311
|
L.FormBuilder.IntegerMixin = {
|
|
312
|
+
value: function () {
|
|
313
|
+
return !isNaN(this.input.value) && this.input.value !== ''
|
|
314
|
+
? parseInt(this.input.value, 10)
|
|
315
|
+
: undefined
|
|
316
|
+
},
|
|
309
317
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
type: function () {
|
|
315
|
-
return 'number';
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
};
|
|
318
|
+
type: () => 'number',
|
|
319
|
+
}
|
|
319
320
|
|
|
320
321
|
L.FormBuilder.IntInput = L.FormBuilder.Input.extend({
|
|
321
|
-
|
|
322
|
-
})
|
|
323
|
-
|
|
322
|
+
includes: [L.FormBuilder.IntegerMixin],
|
|
323
|
+
})
|
|
324
324
|
|
|
325
325
|
L.FormBuilder.BlurIntInput = L.FormBuilder.BlurInput.extend({
|
|
326
|
-
|
|
327
|
-
})
|
|
328
|
-
|
|
326
|
+
includes: [L.FormBuilder.IntegerMixin],
|
|
327
|
+
})
|
|
329
328
|
|
|
330
329
|
L.FormBuilder.FloatMixin = {
|
|
330
|
+
value: function () {
|
|
331
|
+
return !isNaN(this.input.value) && this.input.value !== ''
|
|
332
|
+
? parseFloat(this.input.value)
|
|
333
|
+
: undefined
|
|
334
|
+
},
|
|
331
335
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
type: function () {
|
|
337
|
-
return 'number';
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
};
|
|
336
|
+
type: () => 'number',
|
|
337
|
+
}
|
|
341
338
|
|
|
342
339
|
L.FormBuilder.FloatInput = L.FormBuilder.Input.extend({
|
|
340
|
+
options: {
|
|
341
|
+
step: 'any',
|
|
342
|
+
},
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
includes: [L.FormBuilder.FloatMixin]
|
|
349
|
-
});
|
|
344
|
+
includes: [L.FormBuilder.FloatMixin],
|
|
345
|
+
})
|
|
350
346
|
|
|
351
347
|
L.FormBuilder.BlurFloatInput = L.FormBuilder.BlurInput.extend({
|
|
348
|
+
options: {
|
|
349
|
+
step: 'any',
|
|
350
|
+
},
|
|
352
351
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
|
|
357
|
-
includes: [L.FormBuilder.FloatMixin]
|
|
358
|
-
});
|
|
352
|
+
includes: [L.FormBuilder.FloatMixin],
|
|
353
|
+
})
|
|
359
354
|
|
|
360
355
|
L.FormBuilder.CheckBox = L.FormBuilder.Element.extend({
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
});
|
|
356
|
+
build: function () {
|
|
357
|
+
const container = L.DomUtil.create('div', 'checkbox-wrapper', this.parentNode)
|
|
358
|
+
this.input = L.DomUtil.create('input', this.options.className || '', container)
|
|
359
|
+
this.input.type = 'checkbox'
|
|
360
|
+
this.input.name = this.name
|
|
361
|
+
this.input._helper = this
|
|
362
|
+
this.fetch()
|
|
363
|
+
L.DomEvent.on(this.input, 'change', this.sync, this)
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
fetch: function () {
|
|
367
|
+
this.initial = this.toHTML()
|
|
368
|
+
this.input.checked = this.initial === true
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
value: function () {
|
|
372
|
+
return this.input.checked
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
toHTML: function () {
|
|
376
|
+
return [1, true].indexOf(this.get()) !== -1
|
|
377
|
+
},
|
|
378
|
+
})
|
|
386
379
|
|
|
387
380
|
L.FormBuilder.Select = L.FormBuilder.Element.extend({
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
var options = this.getOptions(),
|
|
412
|
-
option;
|
|
413
|
-
for (var i = 0, l = options.length; i < l; i++) {
|
|
414
|
-
option = options[i];
|
|
415
|
-
if (typeof option === 'string') this.buildOption(option, option);
|
|
416
|
-
else this.buildOption(option[0], option[1]);
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
buildOption: function (value, label) {
|
|
421
|
-
this.validValues.push(value);
|
|
422
|
-
var option = L.DomUtil.create('option', '', this.select);
|
|
423
|
-
option.value = value;
|
|
424
|
-
option.innerHTML = label;
|
|
425
|
-
if (this.toHTML() === value) {
|
|
426
|
-
option.selected = 'selected';
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
value: function () {
|
|
431
|
-
if (this.select[this.select.selectedIndex]) return this.select[this.select.selectedIndex].value;
|
|
432
|
-
},
|
|
433
|
-
|
|
434
|
-
getDefault: function () {
|
|
435
|
-
return this.getOptions()[0][0];
|
|
436
|
-
},
|
|
437
|
-
|
|
438
|
-
toJS: function () {
|
|
439
|
-
var value = this.value();
|
|
440
|
-
if (this.validValues.indexOf(value) !== -1) {
|
|
441
|
-
return value;
|
|
442
|
-
} else {
|
|
443
|
-
return this.getDefault();
|
|
444
|
-
}
|
|
381
|
+
selectOptions: [['value', 'label']],
|
|
382
|
+
|
|
383
|
+
build: function () {
|
|
384
|
+
this.select = L.DomUtil.create('select', '', this.parentNode)
|
|
385
|
+
this.select.name = this.name
|
|
386
|
+
this.validValues = []
|
|
387
|
+
this.buildOptions()
|
|
388
|
+
L.DomEvent.on(this.select, 'change', this.sync, this)
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
getOptions: function () {
|
|
392
|
+
return this.options.selectOptions || this.selectOptions
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
fetch: function () {
|
|
396
|
+
this.buildOptions()
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
buildOptions: function () {
|
|
400
|
+
this.select.innerHTML = ''
|
|
401
|
+
for (const option of this.getOptions()) {
|
|
402
|
+
if (typeof option === 'string') this.buildOption(option, option)
|
|
403
|
+
else this.buildOption(option[0], option[1])
|
|
445
404
|
}
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
buildOption: function (value, label) {
|
|
408
|
+
this.validValues.push(value)
|
|
409
|
+
const option = L.DomUtil.create('option', '', this.select)
|
|
410
|
+
option.value = value
|
|
411
|
+
option.innerHTML = label
|
|
412
|
+
if (this.toHTML() === value) {
|
|
413
|
+
option.selected = 'selected'
|
|
414
|
+
}
|
|
415
|
+
},
|
|
446
416
|
|
|
417
|
+
value: function () {
|
|
418
|
+
if (this.select[this.select.selectedIndex])
|
|
419
|
+
return this.select[this.select.selectedIndex].value
|
|
420
|
+
},
|
|
447
421
|
|
|
448
|
-
|
|
422
|
+
getDefault: function () {
|
|
423
|
+
return this.getOptions()[0][0]
|
|
424
|
+
},
|
|
449
425
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
value
|
|
453
|
-
|
|
426
|
+
toJS: function () {
|
|
427
|
+
const value = this.value()
|
|
428
|
+
if (this.validValues.indexOf(value) !== -1) {
|
|
429
|
+
return value
|
|
454
430
|
}
|
|
431
|
+
return this.getDefault()
|
|
432
|
+
},
|
|
433
|
+
})
|
|
455
434
|
|
|
456
|
-
|
|
435
|
+
L.FormBuilder.IntSelect = L.FormBuilder.Select.extend({
|
|
436
|
+
value: function () {
|
|
437
|
+
return parseInt(L.FormBuilder.Select.prototype.value.apply(this), 10)
|
|
438
|
+
},
|
|
439
|
+
})
|
|
457
440
|
|
|
458
441
|
L.FormBuilder.NullableBoolean = L.FormBuilder.Select.extend({
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
return value;
|
|
442
|
+
selectOptions: [
|
|
443
|
+
[undefined, 'inherit'],
|
|
444
|
+
[true, 'yes'],
|
|
445
|
+
[false, 'no'],
|
|
446
|
+
],
|
|
447
|
+
|
|
448
|
+
toJS: function () {
|
|
449
|
+
let value = this.value()
|
|
450
|
+
switch (value) {
|
|
451
|
+
case 'true':
|
|
452
|
+
case true:
|
|
453
|
+
value = true
|
|
454
|
+
break
|
|
455
|
+
case 'false':
|
|
456
|
+
case false:
|
|
457
|
+
value = false
|
|
458
|
+
break
|
|
459
|
+
default:
|
|
460
|
+
value = undefined
|
|
480
461
|
}
|
|
481
|
-
|
|
482
|
-
}
|
|
462
|
+
return value
|
|
463
|
+
},
|
|
464
|
+
})
|