umap-project 2.4.2__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.
Files changed (177) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/hu/LC_MESSAGES/django.po +100 -50
  6. umap/static/umap/base.css +4 -1
  7. umap/static/umap/css/contextmenu.css +11 -0
  8. umap/static/umap/css/dialog.css +24 -3
  9. umap/static/umap/css/panel.css +4 -2
  10. umap/static/umap/css/slideshow.css +69 -0
  11. umap/static/umap/css/tableeditor.css +69 -0
  12. umap/static/umap/css/tooltip.css +3 -3
  13. umap/static/umap/img/16-white.svg +4 -0
  14. umap/static/umap/img/source/16-white.svg +5 -1
  15. umap/static/umap/js/components/alerts/alert.css +10 -10
  16. umap/static/umap/js/modules/autocomplete.js +23 -1
  17. umap/static/umap/js/modules/browser.js +14 -8
  18. umap/static/umap/js/modules/facets.js +40 -10
  19. umap/static/umap/js/modules/formatter.js +153 -0
  20. umap/static/umap/js/modules/global.js +10 -1
  21. umap/static/umap/js/modules/help.js +25 -25
  22. umap/static/umap/js/modules/importer.js +4 -4
  23. umap/static/umap/js/modules/importers/communesfr.js +3 -1
  24. umap/static/umap/js/modules/importers/datasets.js +8 -6
  25. umap/static/umap/js/modules/importers/geodatamine.js +10 -10
  26. umap/static/umap/js/modules/importers/overpass.js +18 -14
  27. umap/static/umap/js/modules/rules.js +13 -1
  28. umap/static/umap/js/modules/schema.js +16 -12
  29. umap/static/umap/js/{umap.share.js → modules/share.js} +60 -99
  30. umap/static/umap/js/modules/slideshow.js +141 -0
  31. umap/static/umap/js/modules/tableeditor.js +329 -0
  32. umap/static/umap/js/modules/ui/base.js +93 -0
  33. umap/static/umap/js/modules/ui/contextmenu.js +50 -0
  34. umap/static/umap/js/modules/ui/dialog.js +169 -31
  35. umap/static/umap/js/modules/ui/panel.js +6 -4
  36. umap/static/umap/js/modules/ui/tooltip.js +5 -75
  37. umap/static/umap/js/modules/utils.js +20 -0
  38. umap/static/umap/js/umap.controls.js +1 -1
  39. umap/static/umap/js/umap.features.js +22 -14
  40. umap/static/umap/js/umap.forms.js +157 -154
  41. umap/static/umap/js/umap.js +48 -34
  42. umap/static/umap/js/umap.layer.js +232 -164
  43. umap/static/umap/js/umap.permissions.js +1 -1
  44. umap/static/umap/js/umap.popup.js +1 -1
  45. umap/static/umap/locale/am_ET.js +22 -5
  46. umap/static/umap/locale/am_ET.json +19 -5
  47. umap/static/umap/locale/ar.js +22 -5
  48. umap/static/umap/locale/ar.json +19 -5
  49. umap/static/umap/locale/ast.js +22 -5
  50. umap/static/umap/locale/ast.json +19 -5
  51. umap/static/umap/locale/bg.js +22 -5
  52. umap/static/umap/locale/bg.json +19 -5
  53. umap/static/umap/locale/br.js +22 -5
  54. umap/static/umap/locale/br.json +19 -5
  55. umap/static/umap/locale/ca.js +56 -39
  56. umap/static/umap/locale/ca.json +53 -39
  57. umap/static/umap/locale/cs_CZ.js +22 -5
  58. umap/static/umap/locale/cs_CZ.json +19 -5
  59. umap/static/umap/locale/da.js +22 -5
  60. umap/static/umap/locale/da.json +19 -5
  61. umap/static/umap/locale/de.js +22 -5
  62. umap/static/umap/locale/de.json +19 -5
  63. umap/static/umap/locale/el.js +27 -10
  64. umap/static/umap/locale/el.json +19 -5
  65. umap/static/umap/locale/en.js +22 -6
  66. umap/static/umap/locale/en.json +19 -5
  67. umap/static/umap/locale/en_US.json +19 -5
  68. umap/static/umap/locale/es.js +22 -6
  69. umap/static/umap/locale/es.json +19 -5
  70. umap/static/umap/locale/et.js +22 -5
  71. umap/static/umap/locale/et.json +19 -5
  72. umap/static/umap/locale/eu.js +167 -150
  73. umap/static/umap/locale/eu.json +167 -150
  74. umap/static/umap/locale/fa_IR.js +22 -5
  75. umap/static/umap/locale/fa_IR.json +19 -5
  76. umap/static/umap/locale/fi.js +22 -5
  77. umap/static/umap/locale/fi.json +19 -5
  78. umap/static/umap/locale/fr.js +22 -6
  79. umap/static/umap/locale/fr.json +19 -5
  80. umap/static/umap/locale/gl.js +22 -5
  81. umap/static/umap/locale/gl.json +19 -5
  82. umap/static/umap/locale/he.js +22 -5
  83. umap/static/umap/locale/he.json +19 -5
  84. umap/static/umap/locale/hr.js +22 -5
  85. umap/static/umap/locale/hr.json +19 -5
  86. umap/static/umap/locale/hu.js +89 -72
  87. umap/static/umap/locale/hu.json +89 -75
  88. umap/static/umap/locale/id.js +22 -5
  89. umap/static/umap/locale/id.json +19 -5
  90. umap/static/umap/locale/is.js +22 -5
  91. umap/static/umap/locale/is.json +19 -5
  92. umap/static/umap/locale/it.js +22 -5
  93. umap/static/umap/locale/it.json +19 -5
  94. umap/static/umap/locale/ja.js +22 -5
  95. umap/static/umap/locale/ja.json +19 -5
  96. umap/static/umap/locale/ko.js +22 -5
  97. umap/static/umap/locale/ko.json +19 -5
  98. umap/static/umap/locale/lt.js +22 -5
  99. umap/static/umap/locale/lt.json +19 -5
  100. umap/static/umap/locale/ms.js +22 -5
  101. umap/static/umap/locale/ms.json +19 -5
  102. umap/static/umap/locale/nl.js +22 -5
  103. umap/static/umap/locale/nl.json +19 -5
  104. umap/static/umap/locale/no.js +22 -5
  105. umap/static/umap/locale/no.json +19 -5
  106. umap/static/umap/locale/pl.js +22 -5
  107. umap/static/umap/locale/pl.json +19 -5
  108. umap/static/umap/locale/pl_PL.json +19 -5
  109. umap/static/umap/locale/pt.js +22 -6
  110. umap/static/umap/locale/pt.json +21 -7
  111. umap/static/umap/locale/pt_BR.js +22 -5
  112. umap/static/umap/locale/pt_BR.json +19 -5
  113. umap/static/umap/locale/pt_PT.js +22 -5
  114. umap/static/umap/locale/pt_PT.json +19 -5
  115. umap/static/umap/locale/ro.js +22 -5
  116. umap/static/umap/locale/ro.json +19 -5
  117. umap/static/umap/locale/ru.js +22 -5
  118. umap/static/umap/locale/ru.json +19 -5
  119. umap/static/umap/locale/sk_SK.js +22 -5
  120. umap/static/umap/locale/sk_SK.json +19 -5
  121. umap/static/umap/locale/sl.js +22 -5
  122. umap/static/umap/locale/sl.json +19 -5
  123. umap/static/umap/locale/sr.js +22 -5
  124. umap/static/umap/locale/sr.json +19 -5
  125. umap/static/umap/locale/sv.js +22 -5
  126. umap/static/umap/locale/sv.json +19 -5
  127. umap/static/umap/locale/th_TH.js +22 -5
  128. umap/static/umap/locale/th_TH.json +19 -5
  129. umap/static/umap/locale/tr.js +22 -5
  130. umap/static/umap/locale/tr.json +19 -5
  131. umap/static/umap/locale/uk_UA.js +22 -5
  132. umap/static/umap/locale/uk_UA.json +19 -5
  133. umap/static/umap/locale/vi.js +22 -5
  134. umap/static/umap/locale/vi.json +19 -5
  135. umap/static/umap/locale/vi_VN.json +19 -5
  136. umap/static/umap/locale/zh.js +22 -5
  137. umap/static/umap/locale/zh.json +19 -5
  138. umap/static/umap/locale/zh_CN.json +19 -5
  139. umap/static/umap/locale/zh_TW.Big5.json +19 -5
  140. umap/static/umap/locale/zh_TW.js +22 -5
  141. umap/static/umap/locale/zh_TW.json +19 -5
  142. umap/static/umap/map.css +2 -145
  143. umap/static/umap/vars.css +5 -0
  144. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +410 -428
  145. umap/static/umap/vendors/geojson-to-gpx/index.js +155 -0
  146. umap/static/umap/vendors/osmtogeojson/osmtogeojson.js +1 -2
  147. umap/static/umap/vendors/togeojson/togeojson.es.js +1109 -0
  148. umap/static/umap/vendors/togeojson/{togeojson.umd.js.map → togeojson.es.mjs.map} +1 -1
  149. umap/static/umap/vendors/tokml/tokml.es.js +895 -0
  150. umap/static/umap/vendors/tokml/tokml.es.mjs.map +1 -0
  151. umap/storage.py +5 -1
  152. umap/templates/umap/components/alerts/alert.html +3 -3
  153. umap/templates/umap/css.html +3 -0
  154. umap/templates/umap/js.html +0 -6
  155. umap/tests/fixtures/categorized_highway.geojson +1 -0
  156. umap/tests/fixtures/test_import_osm_relation.json +130 -0
  157. umap/tests/integration/conftest.py +8 -1
  158. umap/tests/integration/test_browser.py +3 -2
  159. umap/tests/integration/test_categorized_layer.py +141 -0
  160. umap/tests/integration/test_conditional_rules.py +21 -0
  161. umap/tests/integration/test_datalayer.py +9 -4
  162. umap/tests/integration/test_edit_datalayer.py +1 -0
  163. umap/tests/integration/test_edit_polygon.py +1 -1
  164. umap/tests/integration/test_export_map.py +2 -3
  165. umap/tests/integration/test_import.py +22 -0
  166. umap/tests/integration/test_tableeditor.py +158 -4
  167. umap/tests/integration/test_websocket_sync.py +2 -2
  168. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/METADATA +8 -8
  169. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/RECORD +172 -162
  170. umap/static/umap/js/umap.slideshow.js +0 -163
  171. umap/static/umap/js/umap.tableeditor.js +0 -118
  172. umap/static/umap/vendors/togeojson/togeojson.umd.js +0 -2
  173. umap/static/umap/vendors/togpx/togpx.js +0 -547
  174. umap/static/umap/vendors/tokml/tokml.js +0 -343
  175. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/WHEEL +0 -0
  176. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/entry_points.txt +0 -0
  177. {umap_project-2.4.2.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
- options: {
4
- className: 'leaflet-form'
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
- build: function () {
33
- this.form.innerHTML = '';
34
- for (var idx in this.fields) {
35
- this.buildField(this.fields[idx]);
36
- }
37
- this.on('postsync', this.onPostSync);
38
- return this.form;
39
- },
40
-
41
- buildField: function (field) {
42
- // field can be either a string like "option.name" or a full definition array,
43
- // like ['options.tilelayer.tms', {handler: 'CheckBox', helpText: 'TMS format'}]
44
- var type, helper, options;
45
- if (field instanceof Array) {
46
- options = field[1] || {};
47
- field = field[0];
48
- } else {
49
- options = this.defaultOptions[this.getName(field)] || {};
50
- }
51
- type = options.handler || 'Input';
52
- if (typeof type === 'string' && L.FormBuilder[type]) {
53
- helper = new L.FormBuilder[type](this, field, options);
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
- helper = new type(this, field, options);
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 (var i = 0, l = path.length; i < l; i++) {
65
- value = value[path[i]];
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
- syncAll: function () {
107
- for (var key in this.helpers) {
108
- if (this.helpers.hasOwnProperty(key)) {
109
- this.helpers[key].sync();
110
- }
111
- }
112
- },
89
+ restoreField: function (field) {
90
+ const initial = this.helpers[field].initial
91
+ this.setter(field, initial)
92
+ },
113
93
 
114
- onPostSync: function (e) {
115
- if (e.helper.options.callback) {
116
- e.helper.options.callback.call(e.helper.options.callbackContext || this.obj, e);
117
- }
118
- if (this.options.callback) {
119
- this.options.callback.call(this.options.callbackContext || this.obj, e);
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
- initialize: function (builder, field, options) {
128
- this.builder = builder;
129
- this.obj = this.builder.obj;
130
- this.form = this.builder.form;
131
- this.field = field;
132
- L.setOptions(this, options);
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
- buildHelpText: function () {
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
- fetch: function () {},
200
+ finish: function () {
201
+ this.fireAndForward('finish')
202
+ },
203
+ })
199
204
 
200
- finish: function () {
201
- this.fireAndForward('finish');
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
- L.FormBuilder.Textarea = L.FormBuilder.Element.extend({
207
-
208
- build: function () {
209
- this.input = L.DomUtil.create('textarea', this.options.className || '', this.parentNode);
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
- build: function () {
241
- this.input = L.DomUtil.create('input', this.options.className || '', this.parentNode);
242
- this.input.type = this.type();
243
- this.input.name = this.name;
244
- this.input._helper = this;
245
- if (this.options.placeholder) {
246
- this.input.placeholder = this.options.placeholder;
247
- }
248
- if (this.options.min !== undefined) {
249
- this.input.min = this.options.min;
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
- getSyncEvent: function () {
292
- return 'blur';
293
- },
294
-
295
- finish: function () {
296
- this.sync();
297
- L.FormBuilder.Input.prototype.finish.call(this);
298
- },
299
-
300
- sync: function () {
301
- if (this.backup !== this.value()) {
302
- L.FormBuilder.Input.prototype.sync.call(this);
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
- value: function () {
311
- return !isNaN(this.input.value) && this.input.value !== '' ? parseInt(this.input.value, 10): undefined;
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
- includes: [L.FormBuilder.IntegerMixin]
322
- });
323
-
322
+ includes: [L.FormBuilder.IntegerMixin],
323
+ })
324
324
 
325
325
  L.FormBuilder.BlurIntInput = L.FormBuilder.BlurInput.extend({
326
- includes: [L.FormBuilder.IntegerMixin]
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
- value: function () {
333
- return !isNaN(this.input.value) && this.input.value !== '' ? parseFloat(this.input.value): undefined;
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
- options: {
345
- step: 'any'
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
- options: {
354
- step: 'any'
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
- build: function () {
363
- var container = L.DomUtil.create('div', 'checkbox-wrapper', this.parentNode);
364
- this.input = L.DomUtil.create('input', this.options.className || '', container);
365
- this.input.type = 'checkbox';
366
- this.input.name = this.name;
367
- this.input._helper = this;
368
- this.fetch();
369
- L.DomEvent.on(this.input, 'change', this.sync, this);
370
- },
371
-
372
- fetch: function () {
373
- this.backup = this.toHTML();
374
- this.input.checked = this.backup === true;
375
- },
376
-
377
- value: function () {
378
- return this.input.checked;
379
- },
380
-
381
- toHTML: function () {
382
- return [1, true].indexOf(this.get()) !== -1;
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
- selectOptions: [
390
- ['value', 'label']
391
- ],
392
-
393
- build: function () {
394
- this.select = L.DomUtil.create('select', '', this.parentNode);
395
- this.select.name = this.name;
396
- this.validValues = [];
397
- this.buildOptions();
398
- L.DomEvent.on(this.select, 'change', this.sync, this);
399
- },
400
-
401
- getOptions: function () {
402
- return this.options.selectOptions || this.selectOptions;
403
- },
404
-
405
- fetch: function () {
406
- this.buildOptions();
407
- },
408
-
409
- buildOptions: function () {
410
- this.select.innerHTML = '';
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
- L.FormBuilder.IntSelect = L.FormBuilder.Select.extend({
451
-
452
- value: function () {
453
- return parseInt(L.FormBuilder.Select.prototype.value.apply(this), 10);
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
- selectOptions: [
460
- [undefined, 'inherit'],
461
- [true, 'yes'],
462
- [false, 'no']
463
- ],
464
-
465
- toJS: function () {
466
- var value = this.value();
467
- switch (value) {
468
- case 'true':
469
- case true:
470
- value = true;
471
- break;
472
- case 'false':
473
- case false:
474
- value = false;
475
- break;
476
- default:
477
- value = undefined;
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
+ })