qwc2 2025.10.9 → 2025.10.14
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/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
|
@@ -1,10 +1,57 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==
|
|
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 _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
13
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
15
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
16
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
17
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
19
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
20
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
21
|
+
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; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
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); }
|
|
24
|
+
/**
|
|
2
25
|
* Copyright 2016-2024 Sourcepole AG
|
|
3
26
|
* All rights reserved.
|
|
4
27
|
*
|
|
5
28
|
* This source code is licensed under the BSD-style license found in the
|
|
6
29
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import React from 'react';
|
|
33
|
+
import { connect } from 'react-redux';
|
|
34
|
+
import axios from 'axios';
|
|
35
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
36
|
+
import isEmpty from 'lodash.isempty';
|
|
37
|
+
import PropTypes from 'prop-types';
|
|
38
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
39
|
+
import ConfigUtils from '../utils/ConfigUtils';
|
|
40
|
+
import { parseExpression, FeatureCache, KeyValCache } from '../utils/EditingUtils';
|
|
41
|
+
import LocaleUtils from '../utils/LocaleUtils';
|
|
42
|
+
import MiscUtils from '../utils/MiscUtils';
|
|
43
|
+
import EditComboField from './EditComboField';
|
|
44
|
+
import EditUploadField from './EditUploadField';
|
|
45
|
+
import Icon from './Icon';
|
|
46
|
+
import ButtonBar from './widgets/ButtonBar';
|
|
47
|
+
import DateTimeInput from './widgets/DateTimeInput';
|
|
48
|
+
import NumberInput from './widgets/NumberInput';
|
|
49
|
+
import Spinner from './widgets/Spinner';
|
|
50
|
+
import TextInput from './widgets/TextInput';
|
|
51
|
+
import './style/QtDesignerForm.css';
|
|
52
|
+
var FormPreprocessors = {};
|
|
53
|
+
|
|
54
|
+
/* editDataset: <mapname>.<layername>
|
|
8
55
|
preprocessor: function(formData, feature, callback)
|
|
9
56
|
formData: {
|
|
10
57
|
fields: { dict of fields },
|
|
@@ -13,19 +60,1091 @@ preprocessor: function(formData, feature, callback)
|
|
|
13
60
|
}
|
|
14
61
|
feature: The feature for which the form is being displayed
|
|
15
62
|
callback: function(formData), return the updated formData
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
63
|
+
*/
|
|
64
|
+
export function registerFormPreprocessor(editDataset, preprocessor) {
|
|
65
|
+
FormPreprocessors[editDataset] = preprocessor;
|
|
66
|
+
}
|
|
67
|
+
export function removeFormPreprocessor(editDataset) {
|
|
68
|
+
delete FormPreprocessors[editDataset];
|
|
69
|
+
}
|
|
70
|
+
var hFitWidgets = ["QLabel", "QCheckBox", "QRadioButton", "Line", "QDateTimeEdit", "QDateEdit", "QTimeEdit"];
|
|
71
|
+
var vFitWidgets = ["QLabel", "QCheckBox", "QRadioButton", "Line", "QDateTimeEdit", "QDateEdit", "QTimeEdit", "QPushButton", "QComboBox", "QLineEdit", "QSpinBox", "QDoubleSpinBox", "QSlider"];
|
|
72
|
+
var QtDesignerForm = /*#__PURE__*/function (_React$Component) {
|
|
73
|
+
function QtDesignerForm(props) {
|
|
74
|
+
var _this;
|
|
75
|
+
_classCallCheck(this, QtDesignerForm);
|
|
76
|
+
_this = _callSuper(this, QtDesignerForm, [props]);
|
|
77
|
+
_defineProperty(_this, "state", {
|
|
78
|
+
reevaluate: 0
|
|
79
|
+
});
|
|
80
|
+
_defineProperty(_this, "renderLayout", function (layout, feature, editConfig, updateField) {
|
|
81
|
+
var _this$props$editConfi;
|
|
82
|
+
var nametransform = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (name) {
|
|
83
|
+
return name;
|
|
84
|
+
};
|
|
85
|
+
var visible = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
86
|
+
var containerClass = "";
|
|
87
|
+
var itemStyle = function itemStyle() {
|
|
88
|
+
return {};
|
|
89
|
+
};
|
|
90
|
+
var sortKey = function sortKey(item, idx) {
|
|
91
|
+
return idx;
|
|
92
|
+
};
|
|
93
|
+
var containerStyle = {};
|
|
94
|
+
if (!layout) {
|
|
95
|
+
return null;
|
|
96
|
+
} else if (layout["class"] === "QGridLayout" || layout["class"] === "QFormLayout") {
|
|
97
|
+
containerClass = "qt-designer-layout-grid";
|
|
98
|
+
containerStyle = {
|
|
99
|
+
gridTemplateColumns: _this.computeLayoutColumns(layout.item).join(" "),
|
|
100
|
+
gridTemplateRows: _this.computeLayoutRows(layout.item).join(" ")
|
|
101
|
+
};
|
|
102
|
+
itemStyle = function itemStyle(item) {
|
|
103
|
+
return {
|
|
104
|
+
gridArea: 1 + parseInt(item.row, 10) + "/" + (1 + parseInt(item.column, 10)) + "/ span " + parseInt(item.rowspan || 1, 10) + "/ span " + parseInt(item.colspan || 1, 10)
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
sortKey = function sortKey(item) {
|
|
108
|
+
return item.row;
|
|
109
|
+
};
|
|
110
|
+
} else if (layout["class"] === "QVBoxLayout") {
|
|
111
|
+
containerClass = "qt-designer-layout-grid";
|
|
112
|
+
itemStyle = function itemStyle(item, idx) {
|
|
113
|
+
return {
|
|
114
|
+
gridArea: 1 + idx + "/1/ span 1/ span 1"
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
sortKey = function sortKey(item, idx) {
|
|
118
|
+
return idx;
|
|
119
|
+
};
|
|
120
|
+
} else if (layout["class"] === "QHBoxLayout") {
|
|
121
|
+
containerClass = "qt-designer-layout-grid";
|
|
122
|
+
containerStyle = {
|
|
123
|
+
gridTemplateColumns: _this.computeLayoutColumns(layout.item, true).join(" ")
|
|
124
|
+
};
|
|
125
|
+
itemStyle = function itemStyle(item, idx) {
|
|
126
|
+
return {
|
|
127
|
+
gridArea: "1/" + (1 + idx) + "/ span 1/ span 1"
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
sortKey = function sortKey(item, idx) {
|
|
131
|
+
return idx;
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
if (!visible) {
|
|
137
|
+
containerStyle.display = 'none';
|
|
138
|
+
}
|
|
139
|
+
if (layout.item.find(function (item) {
|
|
140
|
+
return item.spacer && (item.spacer.property || {}).orientation === "Qt::Vertical";
|
|
141
|
+
})) {
|
|
142
|
+
containerStyle.height = '100%';
|
|
143
|
+
}
|
|
144
|
+
var fields = ((_this$props$editConfi = _this.props.editConfig.fields) !== null && _this$props$editConfi !== void 0 ? _this$props$editConfi : []).reduce(function (res, field) {
|
|
145
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, field.id, field));
|
|
146
|
+
}, {});
|
|
147
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
className: containerClass,
|
|
149
|
+
key: layout.name,
|
|
150
|
+
style: containerStyle
|
|
151
|
+
}, layout.item.sort(function (a, b) {
|
|
152
|
+
return sortKey(a) - sortKey(b);
|
|
153
|
+
}).map(function (item, idx) {
|
|
154
|
+
var child = null;
|
|
155
|
+
if (item.widget) {
|
|
156
|
+
child = _this.renderWidget(item.widget, feature, editConfig, fields, updateField, nametransform, false);
|
|
157
|
+
} else if (item.layout) {
|
|
158
|
+
child = _this.renderLayout(item.layout, feature, editConfig, updateField, nametransform);
|
|
159
|
+
} else if (item.spacer) {
|
|
160
|
+
child = /*#__PURE__*/React.createElement("div", null);
|
|
161
|
+
} else {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
165
|
+
key: "i" + idx,
|
|
166
|
+
style: itemStyle(item, idx)
|
|
167
|
+
}, child);
|
|
168
|
+
}));
|
|
169
|
+
});
|
|
170
|
+
_defineProperty(_this, "computeLayoutColumns", function (items) {
|
|
171
|
+
var useIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
172
|
+
var columns = [];
|
|
173
|
+
var hasAuto = false;
|
|
174
|
+
var hasSpacer = items.find(function (item) {
|
|
175
|
+
var _item$spacer;
|
|
176
|
+
return ((_item$spacer = item.spacer) === null || _item$spacer === void 0 || (_item$spacer = _item$spacer.property) === null || _item$spacer === void 0 ? void 0 : _item$spacer.orientation) === "Qt::Horizontal";
|
|
177
|
+
});
|
|
178
|
+
items.forEach(function (item, index) {
|
|
179
|
+
var _item$spacer2, _item$widget;
|
|
180
|
+
var col = useIndex ? index : parseInt(item.column, 10) || 0;
|
|
181
|
+
var colSpan = useIndex ? 1 : parseInt(item.colspan, 10) || 1;
|
|
182
|
+
if (((_item$spacer2 = item.spacer) === null || _item$spacer2 === void 0 || (_item$spacer2 = _item$spacer2.property) === null || _item$spacer2 === void 0 ? void 0 : _item$spacer2.orientation) === "Qt::Horizontal") {
|
|
183
|
+
columns[col] = 'auto';
|
|
184
|
+
hasAuto = true;
|
|
185
|
+
} else if (!hasSpacer && !hFitWidgets.includes((_item$widget = item.widget) === null || _item$widget === void 0 ? void 0 : _item$widget["class"]) && colSpan === 1) {
|
|
186
|
+
columns[col] = 'auto';
|
|
187
|
+
hasAuto = true;
|
|
188
|
+
} else {
|
|
189
|
+
var _columns$col;
|
|
190
|
+
columns[col] = (_columns$col = columns[col]) !== null && _columns$col !== void 0 ? _columns$col : null; // Placeholder replaced by fit-content below
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
var fit = 'fit-content(' + Math.round(1 / columns.length * 100) + '%)';
|
|
194
|
+
for (var col = 0; col < columns.length; ++col) {
|
|
195
|
+
columns[col] = hasAuto ? columns[col] || fit : 'auto';
|
|
196
|
+
}
|
|
197
|
+
return columns;
|
|
198
|
+
});
|
|
199
|
+
_defineProperty(_this, "computeLayoutRows", function (items) {
|
|
200
|
+
var useIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
201
|
+
var rows = [];
|
|
202
|
+
var hasSpacer = items.find(function (item) {
|
|
203
|
+
var _item$spacer3;
|
|
204
|
+
return ((_item$spacer3 = item.spacer) === null || _item$spacer3 === void 0 || (_item$spacer3 = _item$spacer3.property) === null || _item$spacer3 === void 0 ? void 0 : _item$spacer3.orientation) === "Qt::Vertical";
|
|
205
|
+
});
|
|
206
|
+
items.forEach(function (item, index) {
|
|
207
|
+
var _item$spacer4, _item$widget2, _item$widget2$startsW, _item$widget$layout, _item$widget3, _item$widget5;
|
|
208
|
+
var row = useIndex ? index : parseInt(item.row, 10) || 0;
|
|
209
|
+
var rowSpan = useIndex ? 1 : parseInt(item.rowspan, 10) || 1;
|
|
210
|
+
if (((_item$spacer4 = item.spacer) === null || _item$spacer4 === void 0 || (_item$spacer4 = _item$spacer4.property) === null || _item$spacer4 === void 0 ? void 0 : _item$spacer4.orientation) === "Qt::Vertical" || (_item$widget2 = item.widget) !== null && _item$widget2 !== void 0 && (_item$widget2 = _item$widget2.name) !== null && _item$widget2 !== void 0 && (_item$widget2$startsW = _item$widget2.startsWith) !== null && _item$widget2$startsW !== void 0 && _item$widget2$startsW.call(_item$widget2, "nrel_")) {
|
|
211
|
+
rows[row] = 'auto';
|
|
212
|
+
} else if ((_item$widget$layout = (_item$widget3 = item.widget) === null || _item$widget3 === void 0 ? void 0 : _item$widget3.layout) !== null && _item$widget$layout !== void 0 ? _item$widget$layout : item.layout) {
|
|
213
|
+
var _item$widget4, _item$layout;
|
|
214
|
+
rows[row] = (_item$widget4 = item.widget) !== null && _item$widget4 !== void 0 && (_item$widget4 = _item$widget4.layout) !== null && _item$widget4 !== void 0 && _item$widget4.verticalFill || (_item$layout = item.layout) !== null && _item$layout !== void 0 && _item$layout.verticalFill ? 'auto' : null; // Placeholder replaced by fit-content below
|
|
215
|
+
} else if (!hasSpacer && !vFitWidgets.includes((_item$widget5 = item.widget) === null || _item$widget5 === void 0 ? void 0 : _item$widget5["class"]) && rowSpan === 1) {
|
|
216
|
+
rows[row] = 'auto';
|
|
217
|
+
} else {
|
|
218
|
+
var _rows$row;
|
|
219
|
+
rows[row] = (_rows$row = rows[row]) !== null && _rows$row !== void 0 ? _rows$row : null; // Placeholder replaced by fit-content below
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
var fit = 'fit-content(' + Math.round(1 / rows.length * 100) + '%)';
|
|
223
|
+
for (var row = 0; row < rows.length; ++row) {
|
|
224
|
+
rows[row] = rows[row] || fit;
|
|
225
|
+
}
|
|
226
|
+
return rows;
|
|
227
|
+
});
|
|
228
|
+
_defineProperty(_this, "renderWidget", function (widget, feature, editConfig, fields, updateField) {
|
|
229
|
+
var _widget$name;
|
|
230
|
+
var nametransform = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : function (name) {
|
|
231
|
+
return name;
|
|
232
|
+
};
|
|
233
|
+
var isRelWidget = arguments.length > 6 ? arguments[6] : undefined;
|
|
234
|
+
var disabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
235
|
+
var value = (_widget$name = (feature.properties || {})[widget.name]) !== null && _widget$name !== void 0 ? _widget$name : "";
|
|
236
|
+
var prop = widget.property || {};
|
|
237
|
+
if (String(prop.visible) === "false") {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
var attr = widget.attribute || {};
|
|
241
|
+
var fieldname = widget.name.replace(/kvrel__/, '').split("__")[isRelWidget ? 1 : 0];
|
|
242
|
+
var field = fields[fieldname];
|
|
243
|
+
var fieldConstraints = (field === null || field === void 0 ? void 0 : field.constraints) || {};
|
|
244
|
+
var inputConstraints = {};
|
|
245
|
+
inputConstraints.readOnly = _this.props.readOnly || String(prop.readOnly) === "true" || String(prop.enabled) === "false" || fieldConstraints.readOnly === true || disabled;
|
|
246
|
+
inputConstraints.required = !inputConstraints.readOnly && (String(prop.required) === "true" || String(fieldConstraints.required) === "true");
|
|
247
|
+
inputConstraints.placeholder = prop.placeholderText || fieldConstraints.placeholder || "";
|
|
248
|
+
var fontProps = prop.font || {};
|
|
249
|
+
var fontStyle = {
|
|
250
|
+
fontWeight: String(fontProps.bold) === "true" ? "bold" : "normal",
|
|
251
|
+
fontStyle: String(fontProps.italic) === "true" ? "italic" : "normal",
|
|
252
|
+
textDecoration: [String(fontProps.underline) === "true" ? "underline" : "", String(fontProps.strikeout) === "true" ? "line-through" : ""].join(" "),
|
|
253
|
+
fontSize: Math.round((fontProps.pointsize || 9) / 9 * 100) + "%",
|
|
254
|
+
textAlign: 'left'
|
|
255
|
+
};
|
|
256
|
+
if (prop.alignment) {
|
|
257
|
+
if (prop.alignment.includes("Qt::AlignRight")) {
|
|
258
|
+
fontStyle.textAlign = 'right';
|
|
259
|
+
} else if (prop.alignment.includes("Qt::AlignCenter")) {
|
|
260
|
+
fontStyle.textAlign = 'center';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
var elname = undefined;
|
|
264
|
+
if (widget.name.startsWith("ext__")) {
|
|
265
|
+
updateField = null;
|
|
266
|
+
value = _this.state.formData.externalFields[widget.name.slice(5)];
|
|
267
|
+
inputConstraints.readOnly = true;
|
|
268
|
+
} else {
|
|
269
|
+
elname = nametransform(widget.name);
|
|
270
|
+
}
|
|
271
|
+
if (widget["class"] === "QLabel") {
|
|
272
|
+
if (widget.name.startsWith("img__")) {
|
|
273
|
+
var _widget$name$split$;
|
|
274
|
+
value = (_widget$name$split$ = (feature.properties || [])[widget.name.split("__")[1]]) !== null && _widget$name$split$ !== void 0 ? _widget$name$split$ : widget.property.text;
|
|
275
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
276
|
+
className: "qt-designer-form-image"
|
|
277
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
278
|
+
href: value,
|
|
279
|
+
rel: "noreferrer",
|
|
280
|
+
target: "_blank"
|
|
281
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
282
|
+
src: value
|
|
283
|
+
})));
|
|
284
|
+
} else if (widget.name.startsWith("ext__")) {
|
|
285
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
286
|
+
style: fontStyle
|
|
287
|
+
}, value);
|
|
288
|
+
} else {
|
|
289
|
+
var text = widget.property.fieldLabel ? _this.translateFieldName(widget.property.text, editConfig.layerName) : widget.property.text;
|
|
290
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
291
|
+
style: fontStyle
|
|
292
|
+
}, text);
|
|
293
|
+
}
|
|
294
|
+
} else if (widget["class"] === "Line") {
|
|
295
|
+
var _widget$property;
|
|
296
|
+
var linetype = ((_widget$property = widget.property) === null || _widget$property === void 0 ? void 0 : _widget$property.orientation) === "Qt::Vertical" ? "vline" : "hline";
|
|
297
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
298
|
+
className: "qt-designer-form-" + linetype
|
|
299
|
+
});
|
|
300
|
+
} else if (widget["class"] === "QFrame") {
|
|
301
|
+
if (widget.property.visibilityExpression) {
|
|
302
|
+
var exprResult = parseExpression(widget.property.visibilityExpression, feature, editConfig, _this.props.iface, _this.props.mapPrefix, _this.props.mapCrs, function () {
|
|
303
|
+
return _this.setState({
|
|
304
|
+
reevaluate: +new Date()
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
if (exprResult === false || exprResult === 0) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
312
|
+
className: "qt-designer-form-container"
|
|
313
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
className: "qt-designer-form-frame"
|
|
315
|
+
}, widget.name.startsWith("nrel__") ? _this.renderNRelation(widget) : _this.renderLayout(widget.layout, feature, editConfig, updateField, nametransform)));
|
|
316
|
+
} else if (widget["class"] === "QGroupBox") {
|
|
317
|
+
if (widget.property.visibilityExpression) {
|
|
318
|
+
var _exprResult = parseExpression(widget.property.visibilityExpression, feature, editConfig, _this.props.iface, _this.props.mapPrefix, _this.props.mapCrs, function () {
|
|
319
|
+
return _this.setState({
|
|
320
|
+
reevaluate: +new Date()
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
if (_exprResult === false || _exprResult === 0) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
328
|
+
className: "qt-designer-form-container"
|
|
329
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
330
|
+
className: "qt-designer-form-frame-title",
|
|
331
|
+
style: fontStyle
|
|
332
|
+
}, _this.translateFormString(prop.title, editConfig.layerName)), /*#__PURE__*/React.createElement("div", {
|
|
333
|
+
className: "qt-designer-form-frame"
|
|
334
|
+
}, widget.name.startsWith("nrel__") ? _this.renderNRelation(widget) : _this.renderLayout(widget.layout, feature, editConfig, updateField, nametransform)));
|
|
335
|
+
} else if (widget["class"] === "QTabWidget") {
|
|
336
|
+
var tabwidgets = (widget.widget || []).filter(function (child) {
|
|
337
|
+
var exprResult = parseExpression(child.property.visibilityExpression, feature, editConfig, _this.props.iface, _this.props.mapPrefix, _this.props.mapCrs, function () {
|
|
338
|
+
return _this.setState({
|
|
339
|
+
reevaluate: +new Date()
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
return exprResult !== false && exprResult !== 0;
|
|
343
|
+
});
|
|
344
|
+
if (isEmpty(tabwidgets)) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
var activetab = _this.state.activetabs[widget.name] || tabwidgets[0].name;
|
|
348
|
+
var tabs = tabwidgets.map(function (tab) {
|
|
349
|
+
return {
|
|
350
|
+
key: tab.name,
|
|
351
|
+
label: _this.translateFormString(tab.attribute.title, editConfig.layerName)
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
355
|
+
className: "qt-designer-form-container"
|
|
356
|
+
}, /*#__PURE__*/React.createElement(ButtonBar, {
|
|
357
|
+
active: activetab,
|
|
358
|
+
buttons: tabs,
|
|
359
|
+
className: "qt-designer-form-tabbar",
|
|
360
|
+
onClick: function onClick(key) {
|
|
361
|
+
return _this.setState(function (state) {
|
|
362
|
+
return {
|
|
363
|
+
activetabs: _objectSpread(_objectSpread({}, state.activetabs), {}, _defineProperty({}, widget.name, key))
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
368
|
+
className: "qt-designer-form-frame"
|
|
369
|
+
}, tabwidgets.filter(function (child) {
|
|
370
|
+
return child.layout;
|
|
371
|
+
}).map(function (child) {
|
|
372
|
+
return _this.renderLayout(child.layout, feature, editConfig, updateField, nametransform, child.name === activetab);
|
|
373
|
+
})));
|
|
374
|
+
} else if (widget["class"] === "QTextEdit" || widget["class"] === "QTextBrowser" || widget["class"] === "QPlainTextEdit") {
|
|
375
|
+
var _feature$properties$w, _feature$properties;
|
|
376
|
+
if (((_feature$properties$w = (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties[widget.name]) !== null && _feature$properties$w !== void 0 ? _feature$properties$w : null) === null) {
|
|
377
|
+
var _ConfigUtils$getConfi;
|
|
378
|
+
value = (_ConfigUtils$getConfi = ConfigUtils.getConfigProp("editTextNullValue")) !== null && _ConfigUtils$getConfi !== void 0 ? _ConfigUtils$getConfi : "";
|
|
379
|
+
}
|
|
380
|
+
if (_this.props.report) {
|
|
381
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
382
|
+
className: "qt-designer-form-textarea"
|
|
383
|
+
}, value);
|
|
384
|
+
} else {
|
|
385
|
+
var addLinkAnchors = ConfigUtils.getConfigProp("editingAddLinkAnchors") !== false;
|
|
386
|
+
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
387
|
+
addLinkAnchors: addLinkAnchors,
|
|
388
|
+
multiline: true,
|
|
389
|
+
name: elname,
|
|
390
|
+
onChange: function onChange(val) {
|
|
391
|
+
return updateField(widget.name, val);
|
|
392
|
+
}
|
|
393
|
+
}, inputConstraints, {
|
|
394
|
+
style: fontStyle,
|
|
395
|
+
value: String(value)
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
} else if (widget["class"] === "QLineEdit") {
|
|
399
|
+
if (widget.name.endsWith("__upload")) {
|
|
400
|
+
var _feature$properties2;
|
|
401
|
+
var fieldId = widget.name.replace(/__upload/, '');
|
|
402
|
+
var uploadValue = ((_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2[fieldId]) || "";
|
|
403
|
+
var uploadElName = elname.replace(/__upload/, '');
|
|
404
|
+
var constraints = {
|
|
405
|
+
accept: prop.text || "",
|
|
406
|
+
required: inputConstraints.required
|
|
407
|
+
};
|
|
408
|
+
return /*#__PURE__*/React.createElement(EditUploadField, {
|
|
409
|
+
constraints: constraints,
|
|
410
|
+
dataset: editConfig.editDataset,
|
|
411
|
+
disabled: inputConstraints.readOnly,
|
|
412
|
+
fieldId: fieldId,
|
|
413
|
+
iface: _this.props.iface,
|
|
414
|
+
name: uploadElName,
|
|
415
|
+
report: _this.props.report,
|
|
416
|
+
updateField: updateField,
|
|
417
|
+
value: uploadValue
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
var _feature$properties$w2, _feature$properties3;
|
|
421
|
+
if (fieldConstraints.prec !== undefined && typeof value === 'number') {
|
|
422
|
+
value = value.toFixed(fieldConstraints.prec);
|
|
423
|
+
} else if (((_feature$properties$w2 = (_feature$properties3 = feature.properties) === null || _feature$properties3 === void 0 ? void 0 : _feature$properties3[widget.name]) !== null && _feature$properties$w2 !== void 0 ? _feature$properties$w2 : null) === null) {
|
|
424
|
+
var _ConfigUtils$getConfi2;
|
|
425
|
+
value = (_ConfigUtils$getConfi2 = ConfigUtils.getConfigProp("editTextNullValue")) !== null && _ConfigUtils$getConfi2 !== void 0 ? _ConfigUtils$getConfi2 : "";
|
|
426
|
+
}
|
|
427
|
+
if (_this.props.report) {
|
|
428
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
429
|
+
style: fontStyle
|
|
430
|
+
}, value || inputConstraints.placeholder);
|
|
431
|
+
} else {
|
|
432
|
+
var _addLinkAnchors = ConfigUtils.getConfigProp("editingAddLinkAnchors") !== false;
|
|
433
|
+
var editTextNullValue = ConfigUtils.getConfigProp("editTextNullValue");
|
|
434
|
+
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
435
|
+
addLinkAnchors: _addLinkAnchors,
|
|
436
|
+
clearValue: editTextNullValue,
|
|
437
|
+
name: elname,
|
|
438
|
+
onChange: function onChange(val) {
|
|
439
|
+
return updateField(widget.name, val);
|
|
440
|
+
}
|
|
441
|
+
}, inputConstraints, {
|
|
442
|
+
style: fontStyle,
|
|
443
|
+
value: String(value)
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
} else if (widget["class"] === "QCheckBox" || widget["class"] === "QRadioButton") {
|
|
448
|
+
var _this$props$feature$p;
|
|
449
|
+
var type = widget["class"] === "QCheckBox" ? "checkbox" : "radio";
|
|
450
|
+
var inGroup = attr.buttonGroup;
|
|
451
|
+
var checked = inGroup ? ((_this$props$feature$p = _this.props.feature.properties) === null || _this$props$feature$p === void 0 ? void 0 : _this$props$feature$p[_this.groupOrName(widget)]) === widget.name : value;
|
|
452
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
453
|
+
style: fontStyle
|
|
454
|
+
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
455
|
+
checked: checked,
|
|
456
|
+
disabled: inputConstraints.readOnly,
|
|
457
|
+
name: nametransform(_this.groupOrName(widget)),
|
|
458
|
+
onChange: function onChange(ev) {
|
|
459
|
+
return updateField(_this.groupOrName(widget), inGroup ? widget.name : ev.target.checked);
|
|
460
|
+
}
|
|
461
|
+
}, inputConstraints, {
|
|
462
|
+
type: type,
|
|
463
|
+
value: widget.name
|
|
464
|
+
})), widget.property.text);
|
|
465
|
+
} else if (widget["class"] === "QComboBox") {
|
|
466
|
+
var parts = widget.name.split("__");
|
|
467
|
+
if ((parts.length === 5 || parts.length === 6) && parts[0] === "kvrel") {
|
|
468
|
+
var _fieldId2;
|
|
469
|
+
// kvrel__attrname__datatable__keyfield__valuefield
|
|
470
|
+
// kvrel__reltablename__attrname__datatable__keyfield__valuefield
|
|
471
|
+
var count = parts.length;
|
|
472
|
+
var _fieldId = parts.slice(1, count - 3).join("__");
|
|
473
|
+
value = (_fieldId2 = (feature.properties || [])[_fieldId]) !== null && _fieldId2 !== void 0 ? _fieldId2 : "";
|
|
474
|
+
var keyvalrel = _this.props.mapPrefix + parts[count - 3] + ":" + parts[count - 2] + ":" + parts[count - 1];
|
|
475
|
+
var filterExpr = null;
|
|
476
|
+
if (field !== null && field !== void 0 && field.filterExpression) {
|
|
477
|
+
filterExpr = parseExpression(field.filterExpression, feature, editConfig, _this.props.iface, _this.props.mapPrefix, _this.props.mapCrs, function () {
|
|
478
|
+
return _this.setState({
|
|
479
|
+
reevaluate: +new Date()
|
|
480
|
+
});
|
|
481
|
+
}, true);
|
|
482
|
+
}
|
|
483
|
+
return /*#__PURE__*/React.createElement(EditComboField, {
|
|
484
|
+
editIface: _this.props.iface,
|
|
485
|
+
fieldId: _fieldId,
|
|
486
|
+
filterExpr: filterExpr,
|
|
487
|
+
key: _fieldId,
|
|
488
|
+
keyvalrel: keyvalrel,
|
|
489
|
+
multiSelect: widget.property.allowMulti === true || widget.allowMulti === "true",
|
|
490
|
+
name: nametransform(_fieldId),
|
|
491
|
+
placeholder: inputConstraints.placeholder,
|
|
492
|
+
readOnly: inputConstraints.readOnly || fieldConstraints.readOnly,
|
|
493
|
+
required: inputConstraints.required || fieldConstraints.required,
|
|
494
|
+
style: fontStyle,
|
|
495
|
+
updateField: updateField,
|
|
496
|
+
value: value
|
|
497
|
+
});
|
|
498
|
+
} else {
|
|
499
|
+
var values = MiscUtils.ensureArray(widget.item || []).map(function (item) {
|
|
500
|
+
var _item$property$value;
|
|
501
|
+
return {
|
|
502
|
+
label: item.property.text,
|
|
503
|
+
value: (_item$property$value = item.property.value) !== null && _item$property$value !== void 0 ? _item$property$value : item.property.text
|
|
504
|
+
};
|
|
505
|
+
});
|
|
506
|
+
return /*#__PURE__*/React.createElement(EditComboField, {
|
|
507
|
+
editIface: _this.props.iface,
|
|
508
|
+
fieldId: widget.name,
|
|
509
|
+
key: widget.name,
|
|
510
|
+
name: elname,
|
|
511
|
+
placeholder: inputConstraints.placeholder,
|
|
512
|
+
readOnly: inputConstraints.readOnly || inputConstraints.readOnly,
|
|
513
|
+
required: inputConstraints.required || inputConstraints.required,
|
|
514
|
+
style: fontStyle,
|
|
515
|
+
updateField: updateField,
|
|
516
|
+
value: value,
|
|
517
|
+
values: values
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
} else if (widget["class"] === "QSpinBox" || widget["class"] === "QDoubleSpinBox" || widget["class"] === "QSlider") {
|
|
521
|
+
var _prop$minimum, _prop$maximum, _ref, _prop$singleStep, _prop$decimals;
|
|
522
|
+
var floatConstraint = function floatConstraint(x) {
|
|
523
|
+
var f = parseFloat(x);
|
|
524
|
+
return isNaN(f) ? undefined : f;
|
|
525
|
+
};
|
|
526
|
+
var min = floatConstraint((_prop$minimum = prop.minimum) !== null && _prop$minimum !== void 0 ? _prop$minimum : fieldConstraints.min);
|
|
527
|
+
var max = floatConstraint((_prop$maximum = prop.maximum) !== null && _prop$maximum !== void 0 ? _prop$maximum : fieldConstraints.max);
|
|
528
|
+
var step = (_ref = (_prop$singleStep = prop.singleStep) !== null && _prop$singleStep !== void 0 ? _prop$singleStep : fieldConstraints.step) !== null && _ref !== void 0 ? _ref : 1;
|
|
529
|
+
var precision = (_prop$decimals = prop.decimals) !== null && _prop$decimals !== void 0 ? _prop$decimals : 0;
|
|
530
|
+
if (widget["class"] === "QSlider") {
|
|
531
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
532
|
+
max: max,
|
|
533
|
+
min: min,
|
|
534
|
+
name: elname,
|
|
535
|
+
onChange: function onChange(ev) {
|
|
536
|
+
return updateField(widget.name, ev.target.value);
|
|
537
|
+
}
|
|
538
|
+
}, inputConstraints, {
|
|
539
|
+
size: 5,
|
|
540
|
+
step: step,
|
|
541
|
+
style: fontStyle,
|
|
542
|
+
type: "range",
|
|
543
|
+
value: value
|
|
544
|
+
}));
|
|
545
|
+
} else {
|
|
546
|
+
return /*#__PURE__*/React.createElement(NumberInput, _extends({
|
|
547
|
+
decimals: precision,
|
|
548
|
+
max: max,
|
|
549
|
+
min: min,
|
|
550
|
+
name: elname,
|
|
551
|
+
onChange: function onChange(val) {
|
|
552
|
+
return updateField(widget.name, val);
|
|
553
|
+
}
|
|
554
|
+
}, inputConstraints, {
|
|
555
|
+
step: step,
|
|
556
|
+
style: fontStyle,
|
|
557
|
+
value: value
|
|
558
|
+
}));
|
|
559
|
+
}
|
|
560
|
+
} else if (widget["class"] === "QDateEdit") {
|
|
561
|
+
var _min = prop.minimumDate ? _this.dateConstraint(prop.minimumDate) : "1600-01-01";
|
|
562
|
+
var _max = prop.maximumDate ? _this.dateConstraint(prop.maximumDate) : "9999-12-31";
|
|
563
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
564
|
+
max: _max,
|
|
565
|
+
min: _min,
|
|
566
|
+
name: elname,
|
|
567
|
+
onChange: function onChange(ev) {
|
|
568
|
+
return updateField(widget.name, ev.target.value);
|
|
569
|
+
}
|
|
570
|
+
}, inputConstraints, {
|
|
571
|
+
style: fontStyle,
|
|
572
|
+
type: "date",
|
|
573
|
+
value: value
|
|
574
|
+
}));
|
|
575
|
+
} else if (widget["class"] === "QTimeEdit") {
|
|
576
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
577
|
+
name: elname,
|
|
578
|
+
onChange: function onChange(ev) {
|
|
579
|
+
return updateField(widget.name, ev.target.value);
|
|
580
|
+
}
|
|
581
|
+
}, inputConstraints, {
|
|
582
|
+
style: fontStyle,
|
|
583
|
+
type: "time",
|
|
584
|
+
value: value
|
|
585
|
+
}));
|
|
586
|
+
} else if (widget["class"] === "QDateTimeEdit") {
|
|
587
|
+
var _min2 = prop.minimumDate ? _this.dateConstraint(prop.minimumDate) : "1600-01-01";
|
|
588
|
+
var _max2 = prop.maximumDate ? _this.dateConstraint(prop.maximumDate) : "9999-12-31";
|
|
589
|
+
return /*#__PURE__*/React.createElement(DateTimeInput, {
|
|
590
|
+
maxDate: _max2,
|
|
591
|
+
minDate: _min2,
|
|
592
|
+
name: elname,
|
|
593
|
+
onChange: function onChange(val) {
|
|
594
|
+
return updateField(widget.name, val);
|
|
595
|
+
},
|
|
596
|
+
readOnly: inputConstraints.readOnly,
|
|
597
|
+
required: inputConstraints.required,
|
|
598
|
+
style: fontStyle,
|
|
599
|
+
value: value
|
|
600
|
+
});
|
|
601
|
+
} else if (widget["class"] === "QWidget") {
|
|
602
|
+
if (widget.name.startsWith("nrel__")) {
|
|
603
|
+
return _this.renderNRelation(widget);
|
|
604
|
+
} else if (widget.name.startsWith("ext__")) {
|
|
605
|
+
return value;
|
|
606
|
+
} else {
|
|
607
|
+
return _this.renderLayout(widget.layout, feature, editConfig, updateField, nametransform);
|
|
608
|
+
}
|
|
609
|
+
} else if (widget["class"] === "QPushButton") {
|
|
610
|
+
if (widget.name.startsWith("btn__") && widget.onClick) {
|
|
611
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
612
|
+
className: "button",
|
|
613
|
+
disabled: inputConstraints.readOnly,
|
|
614
|
+
onClick: function onClick() {
|
|
615
|
+
return widget.onClick(_this.props.setFormBusy);
|
|
616
|
+
},
|
|
617
|
+
type: "button"
|
|
618
|
+
}, widget.property.text);
|
|
619
|
+
} else if (widget.name.startsWith("featurelink__")) {
|
|
620
|
+
var _parts = widget.name.split("__");
|
|
621
|
+
// featurelink__layer__attrname
|
|
622
|
+
// featurelink__layer__reltable__attrname
|
|
623
|
+
if (_parts.length === 3 || _parts.length === 4) {
|
|
624
|
+
var _feature$properties4;
|
|
625
|
+
var layer = _parts[1];
|
|
626
|
+
var reltable = _parts.length === 4 ? _parts[2] : "";
|
|
627
|
+
var attrname = _parts.slice(2).join("__");
|
|
628
|
+
value = (_feature$properties4 = feature.properties) === null || _feature$properties4 === void 0 ? void 0 : _feature$properties4[attrname];
|
|
629
|
+
if (layer === reltable) {
|
|
630
|
+
var index = parseInt(nametransform("").split("__")[1], 10); // Ugh..
|
|
631
|
+
var reldataset = _this.props.mapPrefix + reltable;
|
|
632
|
+
var displayField = attrname.split("__")[1];
|
|
633
|
+
if (feature.__status__ !== "empty") {
|
|
634
|
+
var featurebuttons = [{
|
|
635
|
+
key: 'Edit',
|
|
636
|
+
icon: 'editing',
|
|
637
|
+
label: String(value !== null && value !== void 0 ? value : "")
|
|
638
|
+
}];
|
|
639
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
640
|
+
className: "qt-designer-form-featurelink-buttons"
|
|
641
|
+
}, /*#__PURE__*/React.createElement(ButtonBar, {
|
|
642
|
+
buttons: featurebuttons,
|
|
643
|
+
forceLabel: true,
|
|
644
|
+
onClick: function onClick() {
|
|
645
|
+
return _this.props.editRelationRecord('Edit', reltable, reldataset, index, displayField);
|
|
646
|
+
}
|
|
647
|
+
}));
|
|
648
|
+
} else {
|
|
649
|
+
var _featurebuttons = [];
|
|
650
|
+
if (feature.geometry !== null) {
|
|
651
|
+
_featurebuttons.push({
|
|
652
|
+
key: 'Pick',
|
|
653
|
+
icon: 'pick',
|
|
654
|
+
label: LocaleUtils.tr("editing.pick")
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
_featurebuttons.push({
|
|
658
|
+
key: 'Create',
|
|
659
|
+
icon: 'editdraw',
|
|
660
|
+
label: LocaleUtils.tr("editing.create")
|
|
661
|
+
});
|
|
662
|
+
return /*#__PURE__*/React.createElement(ButtonBar, {
|
|
663
|
+
buttons: _featurebuttons,
|
|
664
|
+
forceLabel: true,
|
|
665
|
+
onClick: function onClick(action) {
|
|
666
|
+
return _this.props.editRelationRecord(action, reltable, reldataset, index, displayField);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
} else {
|
|
671
|
+
if (value !== null) {
|
|
672
|
+
var _featurebuttons2 = [{
|
|
673
|
+
key: 'Edit',
|
|
674
|
+
icon: 'editing',
|
|
675
|
+
label: String(value !== null && value !== void 0 ? value : "")
|
|
676
|
+
}];
|
|
677
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
678
|
+
className: "qt-designer-form-featurelink-buttons"
|
|
679
|
+
}, /*#__PURE__*/React.createElement(ButtonBar, {
|
|
680
|
+
buttons: _featurebuttons2,
|
|
681
|
+
onClick: function onClick() {
|
|
682
|
+
return _this.props.switchEditContext('Edit', layer, value, function (v) {
|
|
683
|
+
return updateField(attrname, v);
|
|
684
|
+
}, attrname);
|
|
685
|
+
}
|
|
686
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
687
|
+
className: "button",
|
|
688
|
+
onClick: function onClick() {
|
|
689
|
+
return updateField(attrname, null);
|
|
690
|
+
},
|
|
691
|
+
type: "button"
|
|
692
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
693
|
+
icon: "clear"
|
|
694
|
+
})));
|
|
695
|
+
} else {
|
|
696
|
+
var _featurebuttons3 = [{
|
|
697
|
+
key: 'Pick',
|
|
698
|
+
icon: 'pick',
|
|
699
|
+
label: LocaleUtils.tr("editing.pick")
|
|
700
|
+
}, {
|
|
701
|
+
key: 'Create',
|
|
702
|
+
icon: 'editdraw',
|
|
703
|
+
label: LocaleUtils.tr("editing.create")
|
|
704
|
+
}];
|
|
705
|
+
return /*#__PURE__*/React.createElement(ButtonBar, {
|
|
706
|
+
buttons: _featurebuttons3,
|
|
707
|
+
onClick: function onClick(action) {
|
|
708
|
+
return _this.props.switchEditContext(action, layer, null, function (v) {
|
|
709
|
+
return updateField(attrname, v);
|
|
710
|
+
}, attrname);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
} else if (widget["class"] === "QStackedWidget") {
|
|
718
|
+
return _this.renderLayout(widget.widget[parseInt(widget.property.currentIndex, 10)].layout, feature, editConfig, updateField, nametransform);
|
|
719
|
+
}
|
|
720
|
+
return null;
|
|
721
|
+
});
|
|
722
|
+
_defineProperty(_this, "renderNRelation", function (widget) {
|
|
723
|
+
var _widget$property2, _editConfig$fields, _this$props$feature$r;
|
|
724
|
+
var parts = widget.name.split("__");
|
|
725
|
+
if (parts.length < 3) {
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
var disabled = String((_widget$property2 = widget.property) === null || _widget$property2 === void 0 ? void 0 : _widget$property2.enabled) === "false";
|
|
729
|
+
var tablename = parts[1];
|
|
730
|
+
var sortcol = parts[3] || null;
|
|
731
|
+
var noreorder = parts[4] || false;
|
|
732
|
+
var headerItems = widget.layout.item.filter(function (item) {
|
|
733
|
+
return item.widget && item.widget.name.startsWith("header__");
|
|
734
|
+
}).sort(function (a, b) {
|
|
735
|
+
return a.column - b.column;
|
|
736
|
+
});
|
|
737
|
+
var widgetItems = widget.layout.item.filter(function (item) {
|
|
738
|
+
return !item.widget || !item.widget.name.startsWith("header__");
|
|
739
|
+
}).sort(function (a, b) {
|
|
740
|
+
return a.column - b.column;
|
|
741
|
+
});
|
|
742
|
+
var tableFitWidgets = ["QLabel", "QCheckBox", "QRadioButton", "QDateTimeEdit", "QDateEdit", "QTimeEdit"];
|
|
743
|
+
var columnStyles = widgetItems.map(function (item) {
|
|
744
|
+
return item.widget && tableFitWidgets.includes(item.widget["class"]) ? {
|
|
745
|
+
width: '1px'
|
|
746
|
+
} : {};
|
|
747
|
+
});
|
|
748
|
+
var editConfig = _this.props.editConfigs[tablename];
|
|
749
|
+
if (!editConfig) {
|
|
750
|
+
// Relation dataset not permitted / no edit config available
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
var relDataset = editConfig.editDataset;
|
|
754
|
+
var fields = ((_editConfig$fields = editConfig.fields) !== null && _editConfig$fields !== void 0 ? _editConfig$fields : []).reduce(function (res, field) {
|
|
755
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, field.id, field));
|
|
756
|
+
}, {});
|
|
757
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
758
|
+
className: "qt-designer-widget-relation"
|
|
759
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
760
|
+
className: "qt-designer-widget-relation-table-container"
|
|
761
|
+
}, !_this.props.feature.relationValues ? /*#__PURE__*/React.createElement("div", {
|
|
762
|
+
className: "qt-designer-widget-relation-table-loading"
|
|
763
|
+
}, /*#__PURE__*/React.createElement(Spinner, null)) : null, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, !isEmpty(headerItems) ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null), headerItems.map(function (item) {
|
|
764
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
765
|
+
key: item.widget.name
|
|
766
|
+
}, item.widget.property.text);
|
|
767
|
+
}), /*#__PURE__*/React.createElement("th", null)) : null, (((_this$props$feature$r = _this.props.feature.relationValues) === null || _this$props$feature$r === void 0 || (_this$props$feature$r = _this$props$feature$r[relDataset]) === null || _this$props$feature$r === void 0 ? void 0 : _this$props$feature$r.features) || []).map(function (feature, idx) {
|
|
768
|
+
var updateField = function updateField(name, value) {
|
|
769
|
+
var fieldname = name.slice(tablename.length + 2); // Strip <tablename>__ prefix
|
|
770
|
+
_this.props.updateRelationField(relDataset, idx, fieldname, value);
|
|
771
|
+
};
|
|
772
|
+
var nametransform = function nametransform(name) {
|
|
773
|
+
return name + "__" + idx;
|
|
774
|
+
};
|
|
775
|
+
var status = feature.__status__ || "";
|
|
776
|
+
var relFeature = _objectSpread(_objectSpread({}, feature), {}, {
|
|
777
|
+
properties: Object.entries(feature.properties).reduce(function (res, _ref2) {
|
|
778
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
779
|
+
key = _ref3[0],
|
|
780
|
+
value = _ref3[1];
|
|
781
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, tablename + "__" + key, value));
|
|
782
|
+
}, {})
|
|
783
|
+
});
|
|
784
|
+
var statusIcon = null;
|
|
785
|
+
if (status === "empty") {
|
|
786
|
+
// Pass
|
|
787
|
+
} else if (status === "new") {
|
|
788
|
+
statusIcon = "new";
|
|
789
|
+
} else if (status) {
|
|
790
|
+
statusIcon = "edited";
|
|
791
|
+
}
|
|
792
|
+
var statusText = "";
|
|
793
|
+
if (feature.error) {
|
|
794
|
+
statusIcon = "warning";
|
|
795
|
+
statusText = _this.buildErrMsg(feature);
|
|
796
|
+
}
|
|
797
|
+
var extraClass = status.startsWith("deleted") ? "qt-designer-widget-relation-record-deleted" : "";
|
|
798
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
799
|
+
className: "qt-designer-widget-relation-record " + extraClass,
|
|
800
|
+
key: relDataset + idx
|
|
801
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
802
|
+
className: "qt-designer-widget-relation-record-icon"
|
|
803
|
+
}, statusIcon ? /*#__PURE__*/React.createElement(Icon, {
|
|
804
|
+
icon: statusIcon,
|
|
805
|
+
title: statusText
|
|
806
|
+
}) : null), widgetItems.map(function (item, widx) {
|
|
807
|
+
if (item.widget) {
|
|
808
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
809
|
+
className: "qt-designer-widget-relation-row-widget",
|
|
810
|
+
key: item.widget.name,
|
|
811
|
+
style: columnStyles[widx]
|
|
812
|
+
}, _this.renderWidget(item.widget, relFeature, editConfig, fields, updateField, nametransform, true, disabled));
|
|
813
|
+
} else if (item.spacer) {
|
|
814
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
815
|
+
key: "spacer_" + widx
|
|
816
|
+
});
|
|
817
|
+
} else {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
}), !_this.props.readOnly && !disabled && sortcol && !noreorder ? /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(Icon, {
|
|
821
|
+
icon: "chevron-up",
|
|
822
|
+
onClick: function onClick() {
|
|
823
|
+
return _this.props.reorderRelationRecord(relDataset, idx, -1);
|
|
824
|
+
}
|
|
825
|
+
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Icon, {
|
|
826
|
+
icon: "chevron-down",
|
|
827
|
+
onClick: function onClick() {
|
|
828
|
+
return _this.props.reorderRelationRecord(relDataset, idx, 1);
|
|
829
|
+
}
|
|
830
|
+
})) : null, !_this.props.readOnly && !disabled ? /*#__PURE__*/React.createElement("td", {
|
|
831
|
+
className: "qt-designer-widget-relation-record-icon"
|
|
832
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
833
|
+
icon: "trash",
|
|
834
|
+
onClick: function onClick() {
|
|
835
|
+
return _this.props.removeRelationRecord(relDataset, idx);
|
|
836
|
+
}
|
|
837
|
+
})) : null);
|
|
838
|
+
})))), !_this.props.readOnly ? /*#__PURE__*/React.createElement("div", {
|
|
839
|
+
className: "qt-designer-widget-relation-buttons"
|
|
840
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
841
|
+
className: "button qt-designer-widget-relation-add",
|
|
842
|
+
disabled: !_this.props.feature.relationValues,
|
|
843
|
+
onClick: function onClick(ev) {
|
|
844
|
+
return _this.addRelationRecord(ev, relDataset);
|
|
845
|
+
},
|
|
846
|
+
type: "button"
|
|
847
|
+
}, LocaleUtils.tr("editing.add"))) : null, /*#__PURE__*/React.createElement("div", {
|
|
848
|
+
className: "qt-designer-widget-relation-resize-handle",
|
|
849
|
+
onPointerDown: _this.startRelationTableResize
|
|
850
|
+
}));
|
|
851
|
+
});
|
|
852
|
+
_defineProperty(_this, "addRelationRecord", function (ev, datasetname) {
|
|
853
|
+
_this.setState({
|
|
854
|
+
relationAddPressed: ev.target
|
|
855
|
+
});
|
|
856
|
+
_this.props.addRelationRecord(datasetname);
|
|
857
|
+
});
|
|
858
|
+
_defineProperty(_this, "startRelationTableResize", function (ev) {
|
|
859
|
+
var container = ev.target.parentElement.parentElement;
|
|
860
|
+
if (!container) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
var startHeight = container.offsetHeight;
|
|
864
|
+
var startMouseY = ev.clientY;
|
|
865
|
+
var resizeInput = function resizeInput(event) {
|
|
866
|
+
container.style.height = Math.max(30, startHeight + (event.clientY - startMouseY)) + 'px';
|
|
867
|
+
};
|
|
868
|
+
ev.view.document.body.style.userSelect = 'none';
|
|
869
|
+
ev.view.addEventListener("pointermove", resizeInput);
|
|
870
|
+
ev.view.addEventListener("pointerup", function () {
|
|
871
|
+
ev.view.document.body.style.userSelect = '';
|
|
872
|
+
ev.view.removeEventListener("pointermove", resizeInput);
|
|
873
|
+
}, {
|
|
874
|
+
once: true
|
|
875
|
+
});
|
|
876
|
+
});
|
|
877
|
+
_defineProperty(_this, "groupOrName", function (widget) {
|
|
878
|
+
return widget.attribute && widget.attribute.buttonGroup ? widget.attribute.buttonGroup._ : widget.name;
|
|
879
|
+
});
|
|
880
|
+
_defineProperty(_this, "dateConstraint", function (constr) {
|
|
881
|
+
return constr.year + "-" + ("0" + constr.month).slice(-2) + "-" + ("0" + constr.day).slice(-2);
|
|
882
|
+
});
|
|
883
|
+
_defineProperty(_this, "parseForm", function (data) {
|
|
884
|
+
var loadingReqId = uuidv4();
|
|
885
|
+
_this.setState({
|
|
886
|
+
loading: true,
|
|
887
|
+
loadingReqId: loadingReqId
|
|
888
|
+
}, function () {
|
|
889
|
+
var parserOpts = {
|
|
890
|
+
isArray: function isArray() {
|
|
891
|
+
return false;
|
|
892
|
+
},
|
|
893
|
+
ignoreAttributes: false,
|
|
894
|
+
attributeNamePrefix: ""
|
|
895
|
+
};
|
|
896
|
+
var json = new XMLParser(parserOpts).parse(data);
|
|
897
|
+
var relationTables = {};
|
|
898
|
+
var externalFields = {};
|
|
899
|
+
var widgets = {};
|
|
900
|
+
var fields = {};
|
|
901
|
+
var buttons = {};
|
|
902
|
+
var nrels = {};
|
|
903
|
+
var counters = {
|
|
904
|
+
widget: 0,
|
|
905
|
+
layout: 0
|
|
906
|
+
};
|
|
907
|
+
_this.reformatWidget(json.ui.widget, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
908
|
+
// console.log(json);
|
|
909
|
+
json.externalFields = externalFields;
|
|
910
|
+
json.widgets = widgets;
|
|
911
|
+
json.fields = fields;
|
|
912
|
+
json.buttons = buttons;
|
|
913
|
+
json.nrels = nrels;
|
|
914
|
+
if (FormPreprocessors[_this.props.editConfig.editDataset]) {
|
|
915
|
+
FormPreprocessors[_this.props.editConfig.editDataset](json, _this.props.feature, function (formData) {
|
|
916
|
+
if (_this.state.loadingReqId === loadingReqId) {
|
|
917
|
+
_this.setState({
|
|
918
|
+
formData: formData,
|
|
919
|
+
loading: false,
|
|
920
|
+
loadingReqId: null
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
} else {
|
|
925
|
+
_this.setState({
|
|
926
|
+
formData: json,
|
|
927
|
+
loading: false,
|
|
928
|
+
loadingReqId: null
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
_this.props.setRelationTables(relationTables);
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
_defineProperty(_this, "reformatWidget", function (widget, relationTables, fields, buttons, nrels, externalFields, widgets, counters) {
|
|
935
|
+
if (widget.property) {
|
|
936
|
+
widget.property = MiscUtils.ensureArray(widget.property).reduce(function (res, prop) {
|
|
937
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, prop.name, prop[Object.keys(prop).find(function (key) {
|
|
938
|
+
return key !== "name";
|
|
939
|
+
})]));
|
|
940
|
+
}, {});
|
|
941
|
+
} else {
|
|
942
|
+
widget.property = {};
|
|
943
|
+
}
|
|
944
|
+
if (widget.attribute) {
|
|
945
|
+
widget.attribute = MiscUtils.ensureArray(widget.attribute).reduce(function (res, prop) {
|
|
946
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, prop.name, prop[Object.keys(prop).find(function (key) {
|
|
947
|
+
return key !== "name";
|
|
948
|
+
})]));
|
|
949
|
+
}, {});
|
|
950
|
+
} else {
|
|
951
|
+
widget.attribute = {};
|
|
952
|
+
}
|
|
953
|
+
var verticalFill = false;
|
|
954
|
+
if (widget.item) {
|
|
955
|
+
MiscUtils.ensureArray(widget.item).forEach(function (item) {
|
|
956
|
+
verticalFill |= _this.reformatWidget(item, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
widget.name = widget.name || ":widget_" + counters.widget++;
|
|
960
|
+
var fieldNames = _this.props.editConfig.fields.map(function (field) {
|
|
961
|
+
return field.id;
|
|
962
|
+
});
|
|
963
|
+
if (fieldNames.includes(widget.name)) {
|
|
964
|
+
fields[widget.name] = widget;
|
|
965
|
+
} else if (widget.name.startsWith("kvrel__") || widget.name.startsWith("img__")) {
|
|
966
|
+
var _parts2 = widget.name.split("__");
|
|
967
|
+
if (fieldNames.includes(_parts2[1])) {
|
|
968
|
+
fields[_parts2[1]] = widget;
|
|
969
|
+
}
|
|
970
|
+
} else if (widget.name.startsWith("btn__")) {
|
|
971
|
+
buttons[widget.name.split("__")[1]] = widget;
|
|
972
|
+
} else if (widget.name.startsWith("nrel__")) {
|
|
973
|
+
nrels[widget.name.split("__")[1]] = widget;
|
|
974
|
+
}
|
|
975
|
+
if (widget.name.startsWith("ext__")) {
|
|
976
|
+
externalFields[widget.name.slice(5)] = "";
|
|
977
|
+
}
|
|
978
|
+
widgets[widget.name] = widget;
|
|
979
|
+
if (widget.layout) {
|
|
980
|
+
verticalFill |= _this.reformatLayout(widget.layout, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
981
|
+
}
|
|
982
|
+
if (widget.widget) {
|
|
983
|
+
widget.widget = Array.isArray(widget.widget) ? widget.widget : [widget.widget];
|
|
984
|
+
widget.widget.forEach(function (child) {
|
|
985
|
+
child.name = ":widget_" + counters.widget++;
|
|
986
|
+
verticalFill |= _this.reformatWidget(child, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
if (widget.name.startsWith("nrel__") || !widget.layout && !vFitWidgets.includes(widget["class"])) {
|
|
990
|
+
verticalFill = true;
|
|
991
|
+
}
|
|
992
|
+
var parts = widget.name.split("__");
|
|
993
|
+
if (parts.length >= 3 && parts[0] === "nrel") {
|
|
994
|
+
relationTables[_this.props.mapPrefix + parts[1]] = {
|
|
995
|
+
fk: parts[2],
|
|
996
|
+
sortcol: parts[3] || null,
|
|
997
|
+
noreorder: parts[4] || false
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
return verticalFill;
|
|
1001
|
+
});
|
|
1002
|
+
_defineProperty(_this, "reformatLayout", function (layout, relationTables, fields, buttons, nrels, externalFields, widgets, counters) {
|
|
1003
|
+
layout.item = MiscUtils.ensureArray(layout.item);
|
|
1004
|
+
layout.name = layout.name || ":layout_" + counters.layout++;
|
|
1005
|
+
var verticalFill = false;
|
|
1006
|
+
layout.item.forEach(function (item) {
|
|
1007
|
+
if (!item) {
|
|
1008
|
+
return;
|
|
1009
|
+
} else if (item.widget) {
|
|
1010
|
+
verticalFill |= _this.reformatWidget(item.widget, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
1011
|
+
} else if (item.spacer) {
|
|
1012
|
+
item.spacer.property = MiscUtils.ensureArray(item.spacer.property).reduce(function (res, prop) {
|
|
1013
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, prop.name, prop[Object.keys(prop).find(function (key) {
|
|
1014
|
+
return key !== "name";
|
|
1015
|
+
})]));
|
|
1016
|
+
}, {});
|
|
1017
|
+
if (item.spacer.property.orientation === "Qt::Vertical") {
|
|
1018
|
+
verticalFill = true;
|
|
1019
|
+
}
|
|
1020
|
+
} else if (item.layout) {
|
|
1021
|
+
verticalFill |= _this.reformatLayout(item.layout, relationTables, fields, buttons, nrels, externalFields, widgets, counters);
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
layout.verticalFill = verticalFill;
|
|
1025
|
+
return verticalFill;
|
|
1026
|
+
});
|
|
1027
|
+
_defineProperty(_this, "buildErrMsg", function (record) {
|
|
1028
|
+
var message = record.error;
|
|
1029
|
+
var errorDetails = record.error_details || {};
|
|
1030
|
+
if (!isEmpty(errorDetails.geometry_errors)) {
|
|
1031
|
+
message += ":\n";
|
|
1032
|
+
message += errorDetails.geometry_errors.map(function (entry) {
|
|
1033
|
+
return " - " + entry.reason + " at " + entry.location;
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
if (!isEmpty(errorDetails.data_errors)) {
|
|
1037
|
+
message += ":\n - " + errorDetails.data_errors.join("\n - ");
|
|
1038
|
+
}
|
|
1039
|
+
if (!isEmpty(errorDetails.validation_errors)) {
|
|
1040
|
+
message += ":\n - " + errorDetails.validation_errors.join("\n - ");
|
|
1041
|
+
}
|
|
1042
|
+
return message;
|
|
1043
|
+
});
|
|
1044
|
+
_defineProperty(_this, "translateFormString", function (label, layerName) {
|
|
1045
|
+
var _this$props$translati, _this$props$translati2;
|
|
1046
|
+
return (_this$props$translati = (_this$props$translati2 = _this.props.translations) === null || _this$props$translati2 === void 0 || (_this$props$translati2 = _this$props$translati2.layers) === null || _this$props$translati2 === void 0 || (_this$props$translati2 = _this$props$translati2[layerName]) === null || _this$props$translati2 === void 0 || (_this$props$translati2 = _this$props$translati2.form) === null || _this$props$translati2 === void 0 ? void 0 : _this$props$translati2[label]) !== null && _this$props$translati !== void 0 ? _this$props$translati : label;
|
|
1047
|
+
});
|
|
1048
|
+
_defineProperty(_this, "translateFieldName", function (fieldName, layerName) {
|
|
1049
|
+
var _this$props$translati3, _this$props$translati4;
|
|
1050
|
+
return (_this$props$translati3 = (_this$props$translati4 = _this.props.translations) === null || _this$props$translati4 === void 0 || (_this$props$translati4 = _this$props$translati4.layers) === null || _this$props$translati4 === void 0 || (_this$props$translati4 = _this$props$translati4[layerName]) === null || _this$props$translati4 === void 0 || (_this$props$translati4 = _this$props$translati4.fields) === null || _this$props$translati4 === void 0 ? void 0 : _this$props$translati4[fieldName]) !== null && _this$props$translati3 !== void 0 ? _this$props$translati3 : fieldName;
|
|
1051
|
+
});
|
|
1052
|
+
_this.state = QtDesignerForm.defaultState;
|
|
1053
|
+
return _this;
|
|
1054
|
+
}
|
|
1055
|
+
_inherits(QtDesignerForm, _React$Component);
|
|
1056
|
+
return _createClass(QtDesignerForm, [{
|
|
1057
|
+
key: "componentDidMount",
|
|
1058
|
+
value: function componentDidMount() {
|
|
1059
|
+
this.componentDidUpdate({});
|
|
1060
|
+
}
|
|
1061
|
+
}, {
|
|
1062
|
+
key: "componentDidUpdate",
|
|
1063
|
+
value: function componentDidUpdate(prevProps) {
|
|
1064
|
+
var _prevProps$editConfig,
|
|
1065
|
+
_prevProps$feature,
|
|
1066
|
+
_this2 = this;
|
|
1067
|
+
// Query form
|
|
1068
|
+
if (this.props.editConfig.form !== ((_prevProps$editConfig = prevProps.editConfig) === null || _prevProps$editConfig === void 0 ? void 0 : _prevProps$editConfig.form) || this.props.feature.__version__ !== ((_prevProps$feature = prevProps.feature) === null || _prevProps$feature === void 0 ? void 0 : _prevProps$feature.__version__)) {
|
|
1069
|
+
this.setState(function (state) {
|
|
1070
|
+
var _prevProps$editConfig2;
|
|
1071
|
+
return _objectSpread(_objectSpread({}, QtDesignerForm.defaultState), {}, {
|
|
1072
|
+
activetabs: _this2.props.editConfig.form === ((_prevProps$editConfig2 = prevProps.editConfig) === null || _prevProps$editConfig2 === void 0 ? void 0 : _prevProps$editConfig2.form) ? state.activetabs : {}
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
var url = MiscUtils.resolveAssetsPath(this.props.editConfig.form);
|
|
1076
|
+
url += (url.includes('?') ? '&' : '?') + "lang=" + this.props.locale;
|
|
1077
|
+
axios.get(url).then(function (response) {
|
|
1078
|
+
_this2.parseForm(response.data);
|
|
1079
|
+
})["catch"](function (e) {
|
|
1080
|
+
// eslint-disable-next-line
|
|
1081
|
+
console.log(e);
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
// As soon as relation value is added, scroll to bottom of list
|
|
1085
|
+
if (this.state.relationAddPressed && this.props.feature.relationValues !== prevProps.feature.relationValues) {
|
|
1086
|
+
var relationWidget = this.state.relationAddPressed.parentNode.previousSibling;
|
|
1087
|
+
relationWidget.scrollTo(0, relationWidget.scrollHeight);
|
|
1088
|
+
this.setState({
|
|
1089
|
+
relationAddPressed: null
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}, {
|
|
1094
|
+
key: "componentWillUnmount",
|
|
1095
|
+
value: function componentWillUnmount() {
|
|
1096
|
+
KeyValCache.clear();
|
|
1097
|
+
FeatureCache.clear();
|
|
1098
|
+
}
|
|
1099
|
+
}, {
|
|
1100
|
+
key: "render",
|
|
1101
|
+
value: function render() {
|
|
1102
|
+
if (this.state.loading) {
|
|
1103
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1104
|
+
className: "qt-designer-form-loading"
|
|
1105
|
+
}, /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement("span", null, LocaleUtils.tr("qtdesignerform.loading")));
|
|
1106
|
+
} else if (this.state.formData) {
|
|
1107
|
+
var root = this.state.formData.ui.widget;
|
|
1108
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1109
|
+
className: this.props.report ? "qt-designer-report" : "qt-designer-form"
|
|
1110
|
+
}, this.renderLayout(root.layout, this.props.feature, this.props.editConfig, this.props.updateField));
|
|
1111
|
+
} else {
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}]);
|
|
1116
|
+
}(React.Component);
|
|
1117
|
+
_defineProperty(QtDesignerForm, "propTypes", {
|
|
1118
|
+
addRelationRecord: PropTypes.func,
|
|
1119
|
+
editConfig: PropTypes.object,
|
|
1120
|
+
editConfigs: PropTypes.object,
|
|
1121
|
+
editLayerId: PropTypes.string,
|
|
1122
|
+
editRelationRecord: PropTypes.func,
|
|
1123
|
+
feature: PropTypes.object,
|
|
1124
|
+
iface: PropTypes.object,
|
|
1125
|
+
locale: PropTypes.string,
|
|
1126
|
+
mapCrs: PropTypes.string,
|
|
1127
|
+
mapPrefix: PropTypes.string,
|
|
1128
|
+
readOnly: PropTypes.bool,
|
|
1129
|
+
removeRelationRecord: PropTypes.func,
|
|
1130
|
+
reorderRelationRecord: PropTypes.func,
|
|
1131
|
+
report: PropTypes.bool,
|
|
1132
|
+
setFormBusy: PropTypes.func,
|
|
1133
|
+
setRelationTables: PropTypes.func,
|
|
1134
|
+
switchEditContext: PropTypes.func,
|
|
1135
|
+
translations: PropTypes.object,
|
|
1136
|
+
updateField: PropTypes.func,
|
|
1137
|
+
updateRelationField: PropTypes.func
|
|
1138
|
+
});
|
|
1139
|
+
_defineProperty(QtDesignerForm, "defaultState", {
|
|
1140
|
+
activetabs: {},
|
|
1141
|
+
formdata: null,
|
|
1142
|
+
loading: false,
|
|
1143
|
+
loadingReqId: null,
|
|
1144
|
+
relationAddPressed: null
|
|
1145
|
+
});
|
|
1146
|
+
export default connect(function (state) {
|
|
1147
|
+
return {
|
|
1148
|
+
locale: state.locale.current
|
|
1149
|
+
};
|
|
1150
|
+
}, {})(QtDesignerForm);
|