qwc2 2025.11.5 → 2025.11.12
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.
- package/actions/layers.js +6 -29
- package/components/AttributeForm.js +106 -77
- package/components/AttributeTableWidget.js +89 -88
- package/components/IdentifyViewer.js +4 -2
- package/components/LinkFeatureForm.js +17 -9
- package/components/LocationRecorder.js +1 -1
- package/components/PickFeature.js +45 -33
- package/components/QtDesignerForm.js +20 -18
- package/components/StandardApp.js +4 -0
- package/components/ThemeList.js +9 -10
- package/package.json +2 -1
- package/plugins/Cyclomedia.js +1 -1
- package/plugins/Editing.js +307 -72
- package/plugins/FeatureForm.js +103 -111
- package/plugins/LayerTree.js +4 -1
- package/plugins/NewsPopup.js +2 -2
- package/plugins/Portal.js +3 -1
- package/plugins/Print.js +4 -4
- package/plugins/ThemeSwitcher.js +3 -0
- package/plugins/map/EditingSupport.js +2 -2
- package/plugins/map/RedliningSupport.js +1 -1
- package/plugins/style/Editing.css +34 -0
- package/reducers/editing.js +12 -7
- package/reducers/layers.js +27 -5
- package/static/translations/bg-BG.json +9 -0
- package/static/translations/ca-ES.json +9 -0
- package/static/translations/cs-CZ.json +9 -0
- package/static/translations/de-CH.json +9 -0
- package/static/translations/de-DE.json +9 -0
- package/static/translations/en-US.json +9 -0
- package/static/translations/es-ES.json +9 -0
- package/static/translations/fi-FI.json +9 -0
- package/static/translations/fr-FR.json +9 -0
- package/static/translations/hu-HU.json +9 -0
- package/static/translations/it-IT.json +9 -0
- package/static/translations/ja-JP.json +9 -0
- package/static/translations/nl-NL.json +9 -0
- package/static/translations/no-NO.json +9 -0
- package/static/translations/pl-PL.json +9 -0
- package/static/translations/pt-BR.json +9 -0
- package/static/translations/pt-PT.json +9 -0
- package/static/translations/ro-RO.json +9 -0
- package/static/translations/ru-RU.json +9 -0
- package/static/translations/sv-SE.json +9 -0
- package/static/translations/tr-TR.json +9 -0
- package/static/translations/tsconfig.json +9 -0
- package/static/translations/uk-UA.json +9 -0
- package/utils/EditingUtils.js +11 -9
- package/utils/ElevationInterface.js +1 -2
- package/utils/LayerUtils.js +5 -3
- package/utils/ServiceLayerUtils.js +53 -2
- package/utils/ThemeUtils.js +3 -1
package/actions/layers.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
1
|
/**
|
|
8
2
|
* Copyright 2016-2024 Sourcepole AG
|
|
9
3
|
* All rights reserved.
|
|
@@ -16,8 +10,6 @@ import ReducerIndex from '../reducers/index';
|
|
|
16
10
|
import layersReducer from '../reducers/layers';
|
|
17
11
|
ReducerIndex.register("layers", layersReducer);
|
|
18
12
|
import ConfigUtils from '../utils/ConfigUtils';
|
|
19
|
-
import LayerUtils from '../utils/LayerUtils';
|
|
20
|
-
import LocaleUtils from '../utils/LocaleUtils';
|
|
21
13
|
export var SET_LAYER_LOADING = 'SET_LAYER_LOADING';
|
|
22
14
|
export var ADD_LAYER = 'ADD_LAYER';
|
|
23
15
|
export var ADD_LAYER_SEPARATOR = 'ADD_LAYER_SEPARATOR';
|
|
@@ -45,27 +37,12 @@ export var LayerRole = {
|
|
|
45
37
|
export function addLayer(layer) {
|
|
46
38
|
var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
47
39
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
translations: translations
|
|
55
|
-
}),
|
|
56
|
-
pos: pos,
|
|
57
|
-
options: options
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
} else {
|
|
62
|
-
return {
|
|
63
|
-
type: ADD_LAYER,
|
|
64
|
-
layer: layer,
|
|
65
|
-
pos: pos,
|
|
66
|
-
options: options
|
|
67
|
-
};
|
|
68
|
-
}
|
|
40
|
+
return {
|
|
41
|
+
type: ADD_LAYER,
|
|
42
|
+
layer: layer,
|
|
43
|
+
pos: pos,
|
|
44
|
+
options: options
|
|
45
|
+
};
|
|
69
46
|
}
|
|
70
47
|
export function addLayerSeparator(title, afterLayerId, afterSublayerPath) {
|
|
71
48
|
return {
|
|
@@ -40,7 +40,7 @@ import isEmpty from 'lodash.isempty';
|
|
|
40
40
|
import PropTypes from 'prop-types';
|
|
41
41
|
import { v4 as uuidv4 } from 'uuid';
|
|
42
42
|
import { setEditContext, clearEditContext } from '../actions/editing';
|
|
43
|
-
import {
|
|
43
|
+
import { refreshLayer } from '../actions/layers';
|
|
44
44
|
import { setCurrentTaskBlocked } from '../actions/task';
|
|
45
45
|
import ConfigUtils from '../utils/ConfigUtils';
|
|
46
46
|
import CoordinatesUtils from '../utils/CoordinatesUtils';
|
|
@@ -65,9 +65,6 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
65
65
|
formValid: true,
|
|
66
66
|
captchaResponse: null
|
|
67
67
|
});
|
|
68
|
-
_defineProperty(_this, "editLayerId", function (layerId) {
|
|
69
|
-
return _this.props.editConfig || layerId;
|
|
70
|
-
});
|
|
71
68
|
_defineProperty(_this, "render", function () {
|
|
72
69
|
var captchaRequired = ConfigUtils.getConfigProp("editServiceCaptchaSiteKey") && !ConfigUtils.getConfigProp("username");
|
|
73
70
|
var captchaPending = captchaRequired && !_this.state.captchaResponse;
|
|
@@ -91,8 +88,8 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
91
88
|
onClick: _this.onDiscard
|
|
92
89
|
}); /* submit is handled via onSubmit in the form */
|
|
93
90
|
}
|
|
94
|
-
var
|
|
95
|
-
var editPermissions =
|
|
91
|
+
var editConfig = _this.props.editContext.editConfig;
|
|
92
|
+
var editPermissions = editConfig.permissions || {};
|
|
96
93
|
var readOnly = _this.props.readOnly || editPermissions.updatable === false && _this.props.editContext.action === 'Pick';
|
|
97
94
|
var deleteBar = null;
|
|
98
95
|
if (!_this.props.hideDelete && _this.props.editContext.action === 'Pick' && _this.props.editContext.feature && !_this.props.editContext.changed && editPermissions.deletable !== false && !_this.props.readOnly) {
|
|
@@ -140,8 +137,10 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
140
137
|
}, /*#__PURE__*/React.createElement(LinkFeatureForm, _extends({}, _this.state.childEdit, {
|
|
141
138
|
finished: _this.state.childEdit.finishCallback,
|
|
142
139
|
iface: _this.props.iface,
|
|
140
|
+
mapPrefix: _this.props.editContext.mapPrefix,
|
|
143
141
|
pickFilter: _this.props.childPickFilter,
|
|
144
|
-
readOnly: _this.props.readOnly
|
|
142
|
+
readOnly: _this.props.readOnly,
|
|
143
|
+
translations: _this.props.translations
|
|
145
144
|
})));
|
|
146
145
|
}
|
|
147
146
|
var captchaButton = null;
|
|
@@ -172,15 +171,14 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
172
171
|
},
|
|
173
172
|
onSubmit: _this.onSubmit,
|
|
174
173
|
ref: _this.setupChangedObserver
|
|
175
|
-
},
|
|
174
|
+
}, editConfig.form ? /*#__PURE__*/React.createElement(QtDesignerForm, {
|
|
176
175
|
addRelationRecord: _this.addRelationRecord,
|
|
177
|
-
editConfig:
|
|
178
|
-
editConfigs: _this.props.theme.editConfig,
|
|
176
|
+
editConfig: editConfig,
|
|
179
177
|
editRelationRecord: _this.editRelationRecord,
|
|
180
178
|
feature: _this.props.editContext.feature,
|
|
181
179
|
iface: _this.props.iface,
|
|
182
180
|
mapCrs: _this.props.map.projection,
|
|
183
|
-
mapPrefix: _this.
|
|
181
|
+
mapPrefix: _this.props.editContext.mapPrefix,
|
|
184
182
|
readOnly: readOnly,
|
|
185
183
|
removeRelationRecord: _this.removeRelationRecord,
|
|
186
184
|
reorderRelationRecord: _this.reorderRelationRecord,
|
|
@@ -188,12 +186,12 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
188
186
|
setFormBusy: _this.setFormBusy,
|
|
189
187
|
setRelationTables: _this.setRelationTables,
|
|
190
188
|
switchEditContext: _this.startChildEdit,
|
|
191
|
-
translations: _this.props.
|
|
189
|
+
translations: _this.props.translations,
|
|
192
190
|
updateField: _this.updateField,
|
|
193
191
|
updateRelationField: _this.updateRelationField
|
|
194
192
|
}) : /*#__PURE__*/React.createElement(AutoEditForm, {
|
|
195
|
-
editLayerId:
|
|
196
|
-
fields:
|
|
193
|
+
editLayerId: editConfig.editDataset,
|
|
194
|
+
fields: editConfig.fields,
|
|
197
195
|
iface: _this.props.iface,
|
|
198
196
|
readOnly: readOnly,
|
|
199
197
|
touchFriendly: _this.props.touchFriendly,
|
|
@@ -217,9 +215,6 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
217
215
|
});
|
|
218
216
|
_this.validateFieldConstraints(newFeature);
|
|
219
217
|
});
|
|
220
|
-
_defineProperty(_this, "editMapPrefix", function () {
|
|
221
|
-
return (_this.props.editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
|
|
222
|
-
});
|
|
223
218
|
_defineProperty(_this, "setRelationTables", function (relationTables) {
|
|
224
219
|
_this.setState({
|
|
225
220
|
relationTables: relationTables
|
|
@@ -238,7 +233,8 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
238
233
|
return name + ":" + entry.fk;
|
|
239
234
|
}
|
|
240
235
|
}).join(",");
|
|
241
|
-
|
|
236
|
+
var mapEditConfigs = _this.props.editConfigs[_this.props.editContext.mapPrefix];
|
|
237
|
+
_this.props.iface.getRelations(_this.props.editContext.editConfig, feature.id, _this.props.map.projection, relTables, mapEditConfigs, function (relationValues) {
|
|
242
238
|
var newFeature = _objectSpread(_objectSpread({}, feature), {}, {
|
|
243
239
|
relationValues: relationValues
|
|
244
240
|
});
|
|
@@ -263,12 +259,11 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
263
259
|
});
|
|
264
260
|
_defineProperty(_this, "addRelationRecord", function (table) {
|
|
265
261
|
var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
|
|
266
|
-
var editConfig = _this.props.
|
|
267
|
-
var mapPrefix = (editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
|
|
262
|
+
var editConfig = _this.props.editConfigs[_this.props.editContext.mapPrefix][table.split('.').slice(-1)];
|
|
268
263
|
getFeatureTemplate(editConfig, {
|
|
269
264
|
type: "Feature",
|
|
270
265
|
properties: {}
|
|
271
|
-
}, _this.props.iface, mapPrefix, _this.props.map.projection, function (newRelFeature) {
|
|
266
|
+
}, _this.props.iface, _this.props.editContext.mapPrefix, _this.props.map.projection, function (newRelFeature) {
|
|
272
267
|
newRelFeature.__status__ = "empty";
|
|
273
268
|
if (editConfig.geomType === null) {
|
|
274
269
|
newRelFeature.geometry = null;
|
|
@@ -348,21 +343,22 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
348
343
|
changed: true
|
|
349
344
|
});
|
|
350
345
|
});
|
|
351
|
-
_defineProperty(_this, "editRelationRecord", function (action, layer,
|
|
352
|
-
var editConfig =
|
|
353
|
-
var feature = _this.props.editContext.feature.relationValues[
|
|
346
|
+
_defineProperty(_this, "editRelationRecord", function (action, layer, table, idx, displayField) {
|
|
347
|
+
var editConfig = _this.props.editConfigs[_this.props.editContext.mapPrefix][table.split('.').slice(-1)];
|
|
348
|
+
var feature = _this.props.editContext.feature.relationValues[table].features[idx];
|
|
349
|
+
var childEdit = {
|
|
350
|
+
action: action,
|
|
351
|
+
editConfig: editConfig,
|
|
352
|
+
editContextId: ':' + layer,
|
|
353
|
+
dataset: table,
|
|
354
|
+
idx: idx,
|
|
355
|
+
feature: feature,
|
|
356
|
+
finishCallback: _this.finishEditRelationRecord,
|
|
357
|
+
displayField: displayField,
|
|
358
|
+
hideDelete: true
|
|
359
|
+
};
|
|
354
360
|
_this.setState({
|
|
355
|
-
childEdit:
|
|
356
|
-
action: action,
|
|
357
|
-
editConfig: editConfig,
|
|
358
|
-
editContextId: ':' + layer,
|
|
359
|
-
dataset: dataset,
|
|
360
|
-
idx: idx,
|
|
361
|
-
feature: feature,
|
|
362
|
-
finishCallback: _this.finishEditRelationRecord,
|
|
363
|
-
displayField: displayField,
|
|
364
|
-
hideDelete: true
|
|
365
|
-
}
|
|
361
|
+
childEdit: childEdit
|
|
366
362
|
});
|
|
367
363
|
});
|
|
368
364
|
_defineProperty(_this, "finishEditRelationRecord", function (feature) {
|
|
@@ -405,7 +401,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
405
401
|
_this.setState({
|
|
406
402
|
busy: true
|
|
407
403
|
});
|
|
408
|
-
_this.props.iface.getFeatureById(_this.props.editConfig, _this.props.editContext.feature.id, _this.props.map.projection, function (feature) {
|
|
404
|
+
_this.props.iface.getFeatureById(_this.props.editContext.editConfig, _this.props.editContext.feature.id, _this.props.map.projection, function (feature) {
|
|
409
405
|
_this.setState({
|
|
410
406
|
busy: false
|
|
411
407
|
});
|
|
@@ -431,8 +427,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
431
427
|
type: "Feature",
|
|
432
428
|
properties: {}
|
|
433
429
|
};
|
|
434
|
-
|
|
435
|
-
getFeatureTemplate(_this.props.editConfig, featureSkel, _this.props.iface, mapPrefix, _this.props.map.projection, function (feature) {
|
|
430
|
+
getFeatureTemplate(_this.props.editContext.editConfig, featureSkel, _this.props.iface, _this.props.editContext.mapPrefix, _this.props.map.projection, function (feature) {
|
|
436
431
|
_this.props.setEditContext(_this.props.editContext.id, {
|
|
437
432
|
feature: feature,
|
|
438
433
|
changed: false
|
|
@@ -475,7 +470,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
475
470
|
_defineProperty(_this, "validateFieldConstraints", function (feature) {
|
|
476
471
|
var validCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
477
472
|
var invalidCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
478
|
-
var constraintExpressions = _this.props.editConfig.fields.reduce(function (res, cur) {
|
|
473
|
+
var constraintExpressions = _this.props.editContext.editConfig.fields.reduce(function (res, cur) {
|
|
479
474
|
var _cur$constraints;
|
|
480
475
|
if ((_cur$constraints = cur.constraints) !== null && _cur$constraints !== void 0 && _cur$constraints.expression) {
|
|
481
476
|
return [].concat(_toConsumableArray(res), [{
|
|
@@ -485,7 +480,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
485
480
|
}
|
|
486
481
|
return res;
|
|
487
482
|
}, []);
|
|
488
|
-
parseExpressionsAsync(constraintExpressions, feature, _this.props.editConfig, _this.props.iface, _this.
|
|
483
|
+
parseExpressionsAsync(constraintExpressions, feature, _this.props.editContext.editConfig, _this.props.iface, _this.props.editContext.mapPrefix, _this.props.map.projection, false).then(function (result) {
|
|
489
484
|
var valid = true;
|
|
490
485
|
var reasons = [];
|
|
491
486
|
Object.entries(result).forEach(function (_ref5) {
|
|
@@ -495,11 +490,11 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
495
490
|
var element = _this.form.elements.namedItem(key);
|
|
496
491
|
if (element) {
|
|
497
492
|
if (value === false) {
|
|
498
|
-
var _this$props$
|
|
493
|
+
var _this$props$editConte, _this$props$editConte2;
|
|
499
494
|
valid = false;
|
|
500
|
-
var reason = (_this$props$
|
|
495
|
+
var reason = (_this$props$editConte = (_this$props$editConte2 = _this.props.editContext.editConfig.fields.find(function (field) {
|
|
501
496
|
return field.id === key;
|
|
502
|
-
})) === null || _this$props$
|
|
497
|
+
})) === null || _this$props$editConte2 === void 0 || (_this$props$editConte2 = _this$props$editConte2.constraints) === null || _this$props$editConte2 === void 0 ? void 0 : _this$props$editConte2.placeholder) !== null && _this$props$editConte !== void 0 ? _this$props$editConte : LocaleUtils.tr("editing.contraintviolation");
|
|
503
498
|
reasons.push(reason);
|
|
504
499
|
element.setCustomValidity(reason);
|
|
505
500
|
} else {
|
|
@@ -548,8 +543,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
548
543
|
if (_this.props.editContext.geomReadOnly) {
|
|
549
544
|
delete feature.geometry;
|
|
550
545
|
}
|
|
551
|
-
var
|
|
552
|
-
var mapPrefix = _this.editMapPrefix();
|
|
546
|
+
var editConfig = _this.props.editContext.editConfig;
|
|
553
547
|
var textNullValue = ConfigUtils.getConfigProp("editTextNullValue");
|
|
554
548
|
|
|
555
549
|
// Keep relation values separate
|
|
@@ -572,16 +566,17 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
572
566
|
var nullElements = ["date", "number", "radio"];
|
|
573
567
|
var nullFieldTypes = ["date", "number"];
|
|
574
568
|
if (parts.length >= 3) {
|
|
575
|
-
var
|
|
569
|
+
var _relEditConfig$fields, _relEditConfig$fields2, _relEditConfig$fields3;
|
|
576
570
|
// Relation value
|
|
577
571
|
// Usually <table>__<field>__<index>, but <field> might also contain __ (i.e. upload__user)
|
|
578
572
|
var tablename = parts[0];
|
|
579
|
-
var datasetname = mapPrefix + tablename;
|
|
573
|
+
var datasetname = _this.props.editContext.mapPrefix + "." + tablename;
|
|
580
574
|
var field = parts.slice(1, parts.length - 1).join("__");
|
|
581
575
|
var index = parseInt(parts[parts.length - 1], 10);
|
|
582
|
-
var
|
|
576
|
+
var relEditConfig = _this.props.editConfigs[_this.props.editContext.mapPrefix][tablename];
|
|
577
|
+
var nrelFieldConfig = (_relEditConfig$fields = (_relEditConfig$fields2 = relEditConfig.fields) === null || _relEditConfig$fields2 === void 0 || (_relEditConfig$fields3 = _relEditConfig$fields2.find) === null || _relEditConfig$fields3 === void 0 ? void 0 : _relEditConfig$fields3.call(_relEditConfig$fields2, function (f) {
|
|
583
578
|
return f.id === field;
|
|
584
|
-
})) !== null &&
|
|
579
|
+
})) !== null && _relEditConfig$fields !== void 0 ? _relEditConfig$fields : {};
|
|
585
580
|
var nrelFieldDataType = nrelFieldConfig.type;
|
|
586
581
|
if (nrelFieldConfig.expression) {
|
|
587
582
|
// Skip virtual fields
|
|
@@ -621,7 +616,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
621
616
|
relationValues[datasetname].features[index].properties[field] = "";
|
|
622
617
|
}
|
|
623
618
|
} else {
|
|
624
|
-
var fieldConfig = (
|
|
619
|
+
var fieldConfig = (editConfig.fields || []).find(function (field) {
|
|
625
620
|
return field.id === name;
|
|
626
621
|
}) || {};
|
|
627
622
|
if (fieldConfig.expression) {
|
|
@@ -660,6 +655,37 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
660
655
|
}
|
|
661
656
|
}
|
|
662
657
|
});
|
|
658
|
+
// Remove readonly fields
|
|
659
|
+
Object.keys(feature.properties).forEach(function (key) {
|
|
660
|
+
var _fieldConfig$constrai;
|
|
661
|
+
var fieldConfig = editConfig.fields.find(function (field) {
|
|
662
|
+
return field.id === key;
|
|
663
|
+
}) || {};
|
|
664
|
+
if (fieldConfig !== null && fieldConfig !== void 0 && (_fieldConfig$constrai = fieldConfig.constraints) !== null && _fieldConfig$constrai !== void 0 && _fieldConfig$constrai.readOnly) {
|
|
665
|
+
delete feature.properties[key];
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
Object.entries(relationValues).forEach(function (_ref7) {
|
|
669
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
670
|
+
dataset = _ref8[0],
|
|
671
|
+
entry = _ref8[1];
|
|
672
|
+
var _dataset$split = dataset.split(".", 2),
|
|
673
|
+
_dataset$split2 = _slicedToArray(_dataset$split, 2),
|
|
674
|
+
mapName = _dataset$split2[0],
|
|
675
|
+
layerName = _dataset$split2[1];
|
|
676
|
+
var relEditConfig = _this.props.editConfigs[mapName][layerName];
|
|
677
|
+
entry.features.forEach(function (f) {
|
|
678
|
+
Object.keys(f.properties).forEach(function (key) {
|
|
679
|
+
var _fieldConfig$constrai2;
|
|
680
|
+
var fieldConfig = relEditConfig.fields.find(function (field) {
|
|
681
|
+
return field.id === key;
|
|
682
|
+
}) || {};
|
|
683
|
+
if (fieldConfig !== null && fieldConfig !== void 0 && (_fieldConfig$constrai2 = fieldConfig.constraints) !== null && _fieldConfig$constrai2 !== void 0 && _fieldConfig$constrai2.readOnly) {
|
|
684
|
+
delete f.properties[key];
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
});
|
|
663
689
|
|
|
664
690
|
// Set relation values CRS and sort index if necessary
|
|
665
691
|
Object.keys(relationValues).forEach(function (relTable) {
|
|
@@ -686,38 +712,38 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
686
712
|
feature.relationValues = relationValues;
|
|
687
713
|
var featureData = new FormData();
|
|
688
714
|
featureData.set('feature', JSON.stringify(feature));
|
|
689
|
-
Object.entries(featureUploads).forEach(function (
|
|
690
|
-
var _ref8 = _slicedToArray(_ref7, 2),
|
|
691
|
-
key = _ref8[0],
|
|
692
|
-
value = _ref8[1];
|
|
693
|
-
return featureData.set('file:' + key, value);
|
|
694
|
-
});
|
|
695
|
-
Object.entries(relationUploads).forEach(function (_ref9) {
|
|
715
|
+
Object.entries(featureUploads).forEach(function (_ref9) {
|
|
696
716
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
697
717
|
key = _ref10[0],
|
|
698
718
|
value = _ref10[1];
|
|
699
|
-
return featureData.set('
|
|
719
|
+
return featureData.set('file:' + key, value);
|
|
720
|
+
});
|
|
721
|
+
Object.entries(relationUploads).forEach(function (_ref11) {
|
|
722
|
+
var _ref12 = _slicedToArray(_ref11, 2),
|
|
723
|
+
key = _ref12[0],
|
|
724
|
+
value = _ref12[1];
|
|
725
|
+
return featureData.set('relfile:' + _this.props.editContext.mapPrefix + "." + key, value);
|
|
700
726
|
});
|
|
701
727
|
if (_this.state.captchaResponse) {
|
|
702
728
|
featureData.set('g-recaptcha-response', _this.state.captchaResponse);
|
|
703
729
|
}
|
|
704
730
|
if (_this.props.editContext.action === "Draw") {
|
|
705
731
|
if (_this.props.iface.addFeatureMultipart) {
|
|
706
|
-
_this.props.iface.addFeatureMultipart(
|
|
732
|
+
_this.props.iface.addFeatureMultipart(editConfig, _this.props.map.projection, featureData, function (success, result) {
|
|
707
733
|
return _this.featureCommited(success, result);
|
|
708
734
|
});
|
|
709
735
|
} else {
|
|
710
|
-
_this.props.iface.addFeature(
|
|
736
|
+
_this.props.iface.addFeature(editConfig.editDataset, feature, _this.props.map.projection, function (success, result) {
|
|
711
737
|
return _this.featureCommited(success, result);
|
|
712
738
|
});
|
|
713
739
|
}
|
|
714
740
|
} else if (_this.props.editContext.action === "Pick") {
|
|
715
741
|
if (_this.props.iface.editFeatureMultipart) {
|
|
716
|
-
_this.props.iface.editFeatureMultipart(
|
|
742
|
+
_this.props.iface.editFeatureMultipart(editConfig, _this.props.map.projection, feature.id, featureData, function (success, result) {
|
|
717
743
|
return _this.featureCommited(success, result);
|
|
718
744
|
});
|
|
719
745
|
} else {
|
|
720
|
-
_this.props.iface.editFeature(
|
|
746
|
+
_this.props.iface.editFeature(editConfig.editDataset, feature, _this.props.map.projection, function (success, result) {
|
|
721
747
|
return _this.featureCommited(success, result);
|
|
722
748
|
});
|
|
723
749
|
}
|
|
@@ -761,7 +787,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
761
787
|
if (_this.state.captchaResponse) {
|
|
762
788
|
recaptchaResponse = _this.state.captchaResponse;
|
|
763
789
|
}
|
|
764
|
-
_this.props.iface.deleteFeature(_this.props.editConfig, _this.props.editContext.feature.id, _this.deleteFinished, recaptchaResponse);
|
|
790
|
+
_this.props.iface.deleteFeature(_this.props.editContext.editConfig, _this.props.editContext.feature.id, _this.deleteFinished, recaptchaResponse);
|
|
765
791
|
} else {
|
|
766
792
|
_this.setState({
|
|
767
793
|
deleteClicked: false
|
|
@@ -775,7 +801,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
775
801
|
});
|
|
776
802
|
if (success) {
|
|
777
803
|
_this.props.refreshLayer(function (layer) {
|
|
778
|
-
return layer.
|
|
804
|
+
return layer.wms_name === _this.props.editContext.mapPrefix;
|
|
779
805
|
});
|
|
780
806
|
_this.props.setCurrentTaskBlocked(false);
|
|
781
807
|
if (!_this.props.onCommit || !_this.props.onCommit(result)) {
|
|
@@ -813,7 +839,7 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
813
839
|
});
|
|
814
840
|
_this.props.setCurrentTaskBlocked(false);
|
|
815
841
|
_this.props.refreshLayer(function (layer) {
|
|
816
|
-
return layer.
|
|
842
|
+
return layer.wms_name === _this.props.editContext.mapPrefix;
|
|
817
843
|
});
|
|
818
844
|
if (!_this.props.onDelete || !_this.props.onDelete(result)) {
|
|
819
845
|
_this.props.setEditContext(_this.props.editContext.id, {
|
|
@@ -839,21 +865,22 @@ var AttributeForm = /*#__PURE__*/function (_React$Component) {
|
|
|
839
865
|
});
|
|
840
866
|
});
|
|
841
867
|
_defineProperty(_this, "startChildEdit", function (action, layer, featureId, updateField, displayField) {
|
|
842
|
-
var editConfig =
|
|
868
|
+
var editConfig = _this.props.editConfigs[_this.props.editContext.mapPrefix][layer];
|
|
843
869
|
if (!editConfig) {
|
|
844
870
|
// eslint-disable-next-line
|
|
845
871
|
console.warn("No edit config found for linked edit layer " + layer);
|
|
846
872
|
} else {
|
|
873
|
+
var childEdit = {
|
|
874
|
+
action: action,
|
|
875
|
+
editConfig: editConfig,
|
|
876
|
+
editContextId: ':' + layer,
|
|
877
|
+
displayField: displayField,
|
|
878
|
+
featureId: featureId,
|
|
879
|
+
updateField: updateField,
|
|
880
|
+
finishCallback: _this.finishChildEdit
|
|
881
|
+
};
|
|
847
882
|
_this.setState({
|
|
848
|
-
childEdit:
|
|
849
|
-
action: action,
|
|
850
|
-
editConfig: editConfig,
|
|
851
|
-
editContextId: ':' + layer,
|
|
852
|
-
displayField: displayField,
|
|
853
|
-
featureId: featureId,
|
|
854
|
-
updateField: updateField,
|
|
855
|
-
finishCallback: _this.finishChildEdit
|
|
856
|
-
}
|
|
883
|
+
childEdit: childEdit
|
|
857
884
|
});
|
|
858
885
|
}
|
|
859
886
|
});
|
|
@@ -901,7 +928,7 @@ _defineProperty(AttributeForm, "propTypes", {
|
|
|
901
928
|
childPickFilter: PropTypes.func,
|
|
902
929
|
clearEditContext: PropTypes.func,
|
|
903
930
|
deleteLabel: PropTypes.string,
|
|
904
|
-
|
|
931
|
+
editConfigs: PropTypes.object,
|
|
905
932
|
editContext: PropTypes.object,
|
|
906
933
|
hideDelete: PropTypes.bool,
|
|
907
934
|
iface: PropTypes.object,
|
|
@@ -915,7 +942,8 @@ _defineProperty(AttributeForm, "propTypes", {
|
|
|
915
942
|
setCurrentTaskBlocked: PropTypes.func,
|
|
916
943
|
setEditContext: PropTypes.func,
|
|
917
944
|
theme: PropTypes.object,
|
|
918
|
-
touchFriendly: PropTypes.bool
|
|
945
|
+
touchFriendly: PropTypes.bool,
|
|
946
|
+
translations: PropTypes.object
|
|
919
947
|
});
|
|
920
948
|
_defineProperty(AttributeForm, "defaultProps", {
|
|
921
949
|
touchFriendly: true
|
|
@@ -923,6 +951,7 @@ _defineProperty(AttributeForm, "defaultProps", {
|
|
|
923
951
|
export default connect(function (state) {
|
|
924
952
|
return {
|
|
925
953
|
map: state.map,
|
|
954
|
+
editConfigs: state.layers.editConfigs,
|
|
926
955
|
theme: state.theme.current
|
|
927
956
|
};
|
|
928
957
|
}, {
|