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.
Files changed (241) hide show
  1. package/actions/display.js +30 -1
  2. package/actions/editing.js +22 -1
  3. package/actions/layerinfo.js +13 -1
  4. package/actions/layers.js +213 -3
  5. package/actions/localConfig.js +58 -1
  6. package/actions/locale.js +21 -1
  7. package/actions/locate.js +26 -1
  8. package/actions/logging.js +10 -1
  9. package/actions/map.js +105 -2
  10. package/actions/measurement.js +12 -1
  11. package/actions/processNotifications.js +37 -1
  12. package/actions/redlining.js +18 -1
  13. package/actions/redliningPick.js +12 -1
  14. package/actions/search.js +12 -1
  15. package/actions/serviceinfo.js +12 -1
  16. package/actions/task.js +55 -3
  17. package/actions/theme.js +339 -19
  18. package/actions/windows.js +164 -5
  19. package/components/AppMenu.js +435 -3
  20. package/components/AttributeForm.js +928 -32
  21. package/components/AttributeTableWidget.js +1105 -13
  22. package/components/AutoEditForm.js +189 -3
  23. package/components/CoordinateDisplayer.js +78 -2
  24. package/components/EditComboField.js +190 -6
  25. package/components/EditUploadField.js +315 -3
  26. package/components/ExportSelection.js +203 -2
  27. package/components/FullscreenSwitcher.js +90 -3
  28. package/components/Icon.js +81 -2
  29. package/components/IdentifyViewer.js +1161 -6
  30. package/components/ImportLayer.js +718 -20
  31. package/components/LayerInfoWindow.js +145 -2
  32. package/components/LinkFeatureForm.js +246 -5
  33. package/components/MapButton.js +88 -2
  34. package/components/MapSelection.js +287 -8
  35. package/components/MessageBar.js +68 -2
  36. package/components/NumericInputWindow.js +359 -2
  37. package/components/PickFeature.js +266 -2
  38. package/components/PluginsContainer.js +227 -8
  39. package/components/PrintSelection.js +620 -49
  40. package/components/ProcessNotifications.js +104 -2
  41. package/components/QtDesignerForm.js +1137 -18
  42. package/components/ResizeableWindow.js +591 -8
  43. package/components/SearchBox.js +1307 -20
  44. package/components/ServiceInfoWindow.js +107 -2
  45. package/components/SideBar.js +204 -4
  46. package/components/StandardApp.js +381 -20
  47. package/components/Swipeable.js +15 -1
  48. package/components/TaskBar.js +85 -2
  49. package/components/ThemeLayersListWindow.js +216 -4
  50. package/components/ThemeList.js +381 -7
  51. package/components/Toolbar.js +106 -2
  52. package/components/WindowManager.js +178 -2
  53. package/components/map/OlLayer.js +257 -6
  54. package/components/map/OlMap.js +405 -5
  55. package/components/map/layers/BingLayer.js +31 -2
  56. package/components/map/layers/GoogleLayer.js +222 -19
  57. package/components/map/layers/GraticuleLayer.js +21 -1
  58. package/components/map/layers/ImageLayer.js +15 -1
  59. package/components/map/layers/MVTLayer.js +52 -2
  60. package/components/map/layers/OSMLayer.js +24 -2
  61. package/components/map/layers/OverlayLayer.js +55 -3
  62. package/components/map/layers/VectorLayer.js +173 -8
  63. package/components/map/layers/WFSLayer.js +220 -6
  64. package/components/map/layers/WMSLayer.js +180 -6
  65. package/components/map/layers/WMTSLayer.js +67 -3
  66. package/components/map/layers/XYZLayer.js +24 -2
  67. package/components/map/layers/index.js +28 -1
  68. package/components/map3d/EditDataset3D.js +190 -3
  69. package/components/map3d/HeightProfile3D.js +402 -3
  70. package/components/map3d/ImportObjects3D.js +162 -2
  71. package/components/map3d/Map3D.js +1304 -38
  72. package/components/map3d/MapControls3D.js +392 -7
  73. package/components/map3d/SearchField3D.js +183 -11
  74. package/components/map3d/View3DSwitcher.js +98 -2
  75. package/components/map3d/drawtool/CreateTool3D.js +174 -4
  76. package/components/map3d/drawtool/EditTool3D.js +590 -6
  77. package/components/map3d/drawtool/NumericInput3D.js +336 -4
  78. package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
  79. package/components/map3d/layers/VectorLayer3D.js +53 -2
  80. package/components/map3d/layers/WFSLayer3D.js +109 -3
  81. package/components/map3d/layers/WMSLayer3D.js +70 -2
  82. package/components/map3d/layers/WMTSLayer3D.js +27 -3
  83. package/components/map3d/layers/index.js +14 -1
  84. package/components/map3d/utils/FirstPersonControls3D.js +423 -16
  85. package/components/map3d/utils/MiscUtils3D.js +221 -13
  86. package/components/map3d/utils/OrbitControls3D.js +176 -5
  87. package/components/map3d/utils/Tiles3DStyle.js +238 -9
  88. package/components/share/ShareLink.js +54 -2
  89. package/components/share/ShareQRCode.js +62 -2
  90. package/components/share/ShareSocials.js +125 -3
  91. package/components/timeline/FixedTimeline.js +236 -5
  92. package/components/timeline/InfiniteTimeline.js +347 -8
  93. package/components/timeline/TimelineFeaturesSlider.js +439 -5
  94. package/components/widgets/AccordeonWidget.js +96 -2
  95. package/components/widgets/ButtonBar.js +124 -2
  96. package/components/widgets/ColorButton.js +201 -3
  97. package/components/widgets/ComboBox.js +166 -2
  98. package/components/widgets/CopyButton.js +110 -2
  99. package/components/widgets/DateTimeInput.js +100 -3
  100. package/components/widgets/EditableSelect.js +230 -3
  101. package/components/widgets/FileSelector.js +128 -4
  102. package/components/widgets/Input.js +124 -2
  103. package/components/widgets/InputContainer.js +96 -2
  104. package/components/widgets/LayerCatalogWidget.js +219 -3
  105. package/components/widgets/MenuButton.js +157 -1
  106. package/components/widgets/ModalDialog.js +64 -2
  107. package/components/widgets/NavBar.js +119 -2
  108. package/components/widgets/NumberInput.js +226 -4
  109. package/components/widgets/PopupMenu.js +72 -1
  110. package/components/widgets/Primitives.js +6 -1
  111. package/components/widgets/ReCaptchaWidget.js +55 -1
  112. package/components/widgets/SearchWidget.js +255 -2
  113. package/components/widgets/Spinner.js +44 -2
  114. package/components/widgets/SuggestionInput.js +77 -2
  115. package/components/widgets/TextInput.js +308 -2
  116. package/components/widgets/ToggleSwitch.js +85 -2
  117. package/components/widgets/VectorLayerPicker.js +85 -3
  118. package/libs/openlayers.js +225 -5
  119. package/package.json +1 -1
  120. package/plugins/API.js +358 -15
  121. package/plugins/AttributeTable.js +109 -3
  122. package/plugins/Authentication.js +130 -5
  123. package/plugins/BackgroundSwitcher.js +218 -4
  124. package/plugins/Bookmark.js +289 -3
  125. package/plugins/BottomBar.js +298 -4
  126. package/plugins/CookiePopup.js +67 -3
  127. package/plugins/Cyclomedia.js +442 -5
  128. package/plugins/Editing.js +497 -9
  129. package/plugins/FeatureForm.js +366 -4
  130. package/plugins/FeatureSearch.js +458 -3
  131. package/plugins/GeometryDigitizer.js +664 -7
  132. package/plugins/HeightProfile.js +763 -15
  133. package/plugins/Help.js +102 -3
  134. package/plugins/HomeButton.js +80 -3
  135. package/plugins/Identify.js +543 -5
  136. package/plugins/LayerCatalog.js +215 -4
  137. package/plugins/LayerTree.js +1194 -6
  138. package/plugins/LocateButton.js +94 -3
  139. package/plugins/Map.js +320 -16
  140. package/plugins/MapCompare.js +94 -3
  141. package/plugins/MapCopyright.js +127 -5
  142. package/plugins/MapExport.js +613 -20
  143. package/plugins/MapFilter.js +868 -12
  144. package/plugins/MapInfoTooltip.js +277 -3
  145. package/plugins/MapLegend.js +253 -4
  146. package/plugins/MapTip.js +290 -4
  147. package/plugins/Measure.js +220 -4
  148. package/plugins/NewsPopup.js +137 -3
  149. package/plugins/OverviewMap.js +167 -7
  150. package/plugins/Panoramax.js +340 -2
  151. package/plugins/Portal.js +199 -4
  152. package/plugins/Print.js +1231 -15
  153. package/plugins/Redlining.js +750 -6
  154. package/plugins/Reports.js +332 -3
  155. package/plugins/Routing.js +1278 -15
  156. package/plugins/ScratchDrawing.js +173 -5
  157. package/plugins/Settings.js +241 -4
  158. package/plugins/Share.js +198 -3
  159. package/plugins/StartupMarker.js +84 -4
  160. package/plugins/TaskButton.js +88 -3
  161. package/plugins/ThemeSwitcher.js +164 -4
  162. package/plugins/TimeManager.js +971 -10
  163. package/plugins/TopBar.js +300 -7
  164. package/plugins/TourGuide.js +213 -2
  165. package/plugins/ValueTool.js +419 -4
  166. package/plugins/View3D.js +519 -14
  167. package/plugins/ZoomButtons.js +165 -3
  168. package/plugins/map/EditingSupport.js +199 -7
  169. package/plugins/map/LocateSupport.js +260 -4
  170. package/plugins/map/MeasurementSupport.js +216 -8
  171. package/plugins/map/RedliningPickSupport.js +201 -7
  172. package/plugins/map/RedliningSupport.js +726 -17
  173. package/plugins/map/SnapInteraction.js +101 -1
  174. package/plugins/map/SnapSupport.js +210 -2
  175. package/plugins/map/SnappingSupport.js +356 -17
  176. package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
  177. package/plugins/map3d/BottomBar3D.js +118 -3
  178. package/plugins/map3d/Compare3D.js +422 -8
  179. package/plugins/map3d/Draw3D.js +353 -6
  180. package/plugins/map3d/ExportObjects3D.js +393 -18
  181. package/plugins/map3d/HideObjects3D.js +313 -12
  182. package/plugins/map3d/Identify3D.js +283 -12
  183. package/plugins/map3d/LayerTree3D.js +323 -3
  184. package/plugins/map3d/MapCopyright3D.js +128 -5
  185. package/plugins/map3d/MapExport3D.js +590 -10
  186. package/plugins/map3d/MapLight3D.js +553 -6
  187. package/plugins/map3d/Measure3D.js +571 -20
  188. package/plugins/map3d/OverviewMap3D.js +169 -3
  189. package/plugins/map3d/Settings3D.js +73 -3
  190. package/plugins/map3d/TopBar3D.js +207 -9
  191. package/plugins/redlining/RedliningBufferSupport.js +206 -3
  192. package/reducers/display.js +34 -2
  193. package/reducers/editing.js +68 -3
  194. package/reducers/index.js +9 -1
  195. package/reducers/layerinfo.js +26 -2
  196. package/reducers/layers.js +456 -9
  197. package/reducers/localConfig.js +122 -2
  198. package/reducers/locale.js +38 -2
  199. package/reducers/locate.js +40 -2
  200. package/reducers/map.js +176 -5
  201. package/reducers/measurement.js +42 -2
  202. package/reducers/processNotifications.js +49 -2
  203. package/reducers/redlining.js +50 -2
  204. package/reducers/redliningPick.js +27 -2
  205. package/reducers/search.js +20 -1
  206. package/reducers/serviceinfo.js +25 -2
  207. package/reducers/task.js +45 -2
  208. package/reducers/theme.js +51 -2
  209. package/reducers/windows.js +203 -2
  210. package/scripts/dist.sh +1 -1
  211. package/scripts/gen-plugin-docs.js +152 -2
  212. package/scripts/makeIconkit.js +85 -6
  213. package/scripts/themesConfig.js +742 -40
  214. package/scripts/updateTranslations.js +251 -10
  215. package/selectors/searchproviders.js +44 -2
  216. package/stores/StandardStore.js +42 -2
  217. package/utils/ConfigUtils.js +84 -3
  218. package/utils/CoordinatesUtils.js +234 -23
  219. package/utils/DxfUtils.js +237 -11
  220. package/utils/EditingInterface.js +421 -87
  221. package/utils/EditingUtils.js +357 -13
  222. package/utils/ElevationInterface.js +83 -22
  223. package/utils/FeatureStyles.js +429 -5
  224. package/utils/IdentifyUtils.js +443 -7
  225. package/utils/ImageEditor.js +79 -9
  226. package/utils/LayerUtils.js +1516 -50
  227. package/utils/LocaleUtils.js +117 -7
  228. package/utils/MapUtils.js +241 -59
  229. package/utils/MeasureUtils.js +323 -2
  230. package/utils/MiscUtils.js +189 -11
  231. package/utils/PermaLinkUtils.js +429 -6
  232. package/utils/PluginStore.js +27 -1
  233. package/utils/ResourceRegistry.js +15 -1
  234. package/utils/RoutingInterface.js +307 -7
  235. package/utils/SearchProviders.js +722 -19
  236. package/utils/ServiceLayerUtils.js +669 -14
  237. package/utils/Signal.js +32 -2
  238. package/utils/ThemeUtils.js +341 -7
  239. package/utils/VectorLayerUtils.js +589 -15
  240. package/utils/expr_grammar/grammar.js +2239 -2
  241. package/utils/expr_grammar/test.js +65 -3
@@ -1,37 +1,933 @@
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}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.")}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}}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}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}}function _arrayWithHoles(r){if(Array.isArray(r))return r}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}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}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)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}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)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}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)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}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)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7
+ 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."); }
8
+ 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; } }
9
+ 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; }
10
+ 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; } }
11
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
12
+ 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; }
13
+ 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; }
14
+ 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); }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ 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); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
19
+ 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); }
20
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
+ 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); }
24
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
25
+ 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; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
+ 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); }
28
+ /**
2
29
  * Copyright 2017-2024 Sourcepole AG
3
30
  * All rights reserved.
4
31
  *
5
32
  * This source code is licensed under the BSD-style license found in the
6
33
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import clone from"clone";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{setEditContext,clearEditContext}from"../actions/editing";import{LayerRole,refreshLayer}from"../actions/layers";import{setCurrentTaskBlocked}from"../actions/task";import ConfigUtils from"../utils/ConfigUtils";import CoordinatesUtils from"../utils/CoordinatesUtils";import{getFeatureTemplate,parseExpressionsAsync}from"../utils/EditingUtils";import LocaleUtils from"../utils/LocaleUtils";import AutoEditForm from"./AutoEditForm";import LinkFeatureForm from"./LinkFeatureForm";import QtDesignerForm from"./QtDesignerForm";import ButtonBar from"./widgets/ButtonBar";import ReCaptchaWidget from"./widgets/ReCaptchaWidget";import"./style/AttributeForm.css";var AttributeForm=/*#__PURE__*/function(_React$Component){function AttributeForm(props){var _this;_classCallCheck(this,AttributeForm);_this=_callSuper(this,AttributeForm,[props]);_defineProperty(_this,"state",{busy:false,deleteClicked:false,childEdit:null,relationTables:{},formValid:true,captchaResponse:null});_defineProperty(_this,"editLayerId",function(layerId){return _this.props.editConfig||layerId});_defineProperty(_this,"render",function(){var captchaRequired=ConfigUtils.getConfigProp("editServiceCaptchaSiteKey")&&!ConfigUtils.getConfigProp("username");var captchaPending=captchaRequired&&!_this.state.captchaResponse;var commitBar=null;if(_this.props.editContext.changed){var commitButtons=[{key:"Commit",icon:_this.state.formValid?"ok":"warning",label:_this.state.formValid?LocaleUtils.tr("editing.commit"):LocaleUtils.tr("editing.invalidform"),extraClasses:_this.state.formValid?"button-accept":"button-warning",type:"submit",disabled:!_this.state.formValid||captchaPending},{key:"Discard",icon:"remove",label:LocaleUtils.tr("editing.discard"),extraClasses:"button-reject"}];commitBar=/*#__PURE__*/React.createElement(ButtonBar,{buttons:commitButtons,onClick:_this.onDiscard});/* submit is handled via onSubmit in the form */}var curConfig=_this.props.editConfig;var editPermissions=curConfig.permissions||{};var readOnly=_this.props.readOnly||editPermissions.updatable===false&&_this.props.editContext.action==="Pick";var deleteBar=null;if(!_this.props.hideDelete&&_this.props.editContext.action==="Pick"&&_this.props.editContext.feature&&!_this.props.editContext.changed&&editPermissions.deletable!==false&&!_this.props.readOnly){// Delete button bar will appear by default if no permissions are defined in editConfig or when deletable permission is set
8
- if(!_this.state.deleteClicked){var _this$props$deleteLab;var deleteButtons=[{key:"Delete",icon:"trash",label:(_this$props$deleteLab=_this.props.deleteLabel)!==null&&_this$props$deleteLab!==void 0?_this$props$deleteLab:LocaleUtils.tr("editing.delete")}];deleteBar=/*#__PURE__*/React.createElement(ButtonBar,{buttons:deleteButtons,onClick:_this.deleteClicked})}else{var _deleteButtons=[{key:"Yes",icon:"ok",label:LocaleUtils.tr("editing.reallydelete"),extraClasses:"button-accept",disabled:captchaPending},{key:"No",icon:"remove",label:LocaleUtils.tr("editing.canceldelete"),extraClasses:"button-reject"}];deleteBar=/*#__PURE__*/React.createElement(ButtonBar,{buttons:_deleteButtons,onClick:_this.deleteFeature})}}var busyDiv=null;if(_this.state.busy){busyDiv=/*#__PURE__*/React.createElement("div",{className:"attrib-form-busy"})}var childAttributeForm=null;if(_this.state.childEdit){childAttributeForm=/*#__PURE__*/React.createElement("div",{className:"link-feature-form-container"},/*#__PURE__*/React.createElement(LinkFeatureForm,_extends({},_this.state.childEdit,{finished:_this.state.childEdit.finishCallback,iface:_this.props.iface,pickFilter:_this.props.childPickFilter,readOnly:_this.props.readOnly})))}var captchaButton=null;if(captchaRequired&&(_this.props.editContext.changed||_this.state.deleteClicked)){captchaButton=/*#__PURE__*/React.createElement(ReCaptchaWidget,{onChange:function onChange(value){return _this.setState({captchaResponse:value})},sitekey:ConfigUtils.getConfigProp("editServiceCaptchaSiteKey")})}var readOnlyMsg=null;if(!readOnly&&_this.props.editContext.geomReadOnly){readOnlyMsg=LocaleUtils.tr("editing.geomreadonly")}else if(!readOnly&&_this.props.editContext.geomNonZeroZ){readOnlyMsg=LocaleUtils.tr("editing.geomnonzeroz")}return/*#__PURE__*/React.createElement("div",{className:"AttributeForm"},readOnlyMsg?/*#__PURE__*/React.createElement("div",{className:"attrib-form-geom-readonly"},readOnlyMsg):null,/*#__PURE__*/React.createElement("form",{action:"",onChange:function onChange(ev){return _this.formChanged(ev)},onSubmit:_this.onSubmit,ref:_this.setupChangedObserver},_this.props.editConfig.form?/*#__PURE__*/React.createElement(QtDesignerForm,{addRelationRecord:_this.addRelationRecord,editConfig:_this.props.editConfig,editConfigs:_this.props.theme.editConfig,editRelationRecord:_this.editRelationRecord,feature:_this.props.editContext.feature,iface:_this.props.iface,mapCrs:_this.props.map.projection,mapPrefix:_this.editMapPrefix(),readOnly:readOnly,removeRelationRecord:_this.removeRelationRecord,reorderRelationRecord:_this.reorderRelationRecord,report:_this.props.report,setFormBusy:_this.setFormBusy,setRelationTables:_this.setRelationTables,switchEditContext:_this.startChildEdit,translations:_this.props.theme.translations,updateField:_this.updateField,updateRelationField:_this.updateRelationField}):/*#__PURE__*/React.createElement(AutoEditForm,{editLayerId:_this.props.editConfig.editDataset,fields:_this.props.editConfig.fields,iface:_this.props.iface,readOnly:readOnly,touchFriendly:_this.props.touchFriendly,updateField:_this.updateField,values:_this.props.editContext.feature.properties}),captchaButton,commitBar),deleteBar,busyDiv,childAttributeForm)});_defineProperty(_this,"setFormBusy",function(busy){_this.setState({busy:busy})});_defineProperty(_this,"updateField",function(key,value){var newProperties=_objectSpread(_objectSpread({},_this.props.editContext.feature.properties),{},_defineProperty({},key,value));var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{properties:newProperties});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:true});_this.validateFieldConstraints(newFeature)});_defineProperty(_this,"editMapPrefix",function(){return(_this.props.editConfig.editDataset.match(/^[^.]+\./)||[""])[0]});_defineProperty(_this,"setRelationTables",function(relationTables){_this.setState({relationTables:relationTables})});_defineProperty(_this,"loadRelationValues",function(feature,callback){if(!isEmpty(_this.state.relationTables)){if(feature.id){var relTables=Object.entries(_this.state.relationTables).map(function(_ref){var _ref2=_slicedToArray(_ref,2),name=_ref2[0],entry=_ref2[1];if(entry.sortcol){return name+":"+entry.fk+":"+entry.sortcol}else{return name+":"+entry.fk}}).join(",");_this.props.iface.getRelations(_this.props.editConfig,feature.id,_this.props.map.projection,relTables,_this.props.theme.editConfig,function(relationValues){var newFeature=_objectSpread(_objectSpread({},feature),{},{relationValues:relationValues});callback(newFeature)})}else{var relationValues=_objectSpread(_objectSpread({},Object.entries(_this.state.relationTables).reduce(function(res,_ref3){var _ref4=_slicedToArray(_ref3,2),name=_ref4[0],entry=_ref4[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},name,{fk:entry.fk,features:[]}))},{})),feature.relationValues);var newFeature=_objectSpread(_objectSpread({},feature),{},{relationValues:relationValues});callback(newFeature)}}});_defineProperty(_this,"addRelationRecord",function(table){var newRelationValues=_objectSpread({},_this.props.editContext.feature.relationValues);var editConfig=_this.props.theme.editConfig[table.split(".").slice(-1)];var mapPrefix=(editConfig.editDataset.match(/^[^.]+\./)||[""])[0];getFeatureTemplate(editConfig,{type:"Feature",properties:{}},_this.props.iface,mapPrefix,_this.props.map.projection,function(newRelFeature){newRelFeature.__status__="empty";if(editConfig.geomType===null){newRelFeature.geometry=null}// If feature id is known, i.e. not when drawing new feature, set foreign key
9
- if(_this.props.editContext.action!=="Draw"){newRelFeature.properties[_this.state.relationTables[table].fk]=_this.props.editContext.feature.id}newRelationValues[table]=_objectSpread({},newRelationValues[table]);newRelationValues[table].features=newRelationValues[table].features.concat([newRelFeature]);var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{relationValues:newRelationValues});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:true})})});_defineProperty(_this,"reorderRelationRecord",function(table,idx,dir){var nFeatures=_this.props.editContext.feature.relationValues[table].features.length;if(dir<0&&idx===0||dir>0&&idx>=nFeatures-1){return}var newRelationValues=_objectSpread({},_this.props.editContext.feature.relationValues);newRelationValues[table]=_objectSpread({},newRelationValues[table]);var newFeatures=newRelationValues[table].features.slice(0);var offset=dir<0?0:1;newFeatures.splice(idx-1+offset,2,newFeatures[idx+offset],newFeatures[idx-1+offset]);newFeatures[idx-1+offset].properties=_objectSpread({},newFeatures[idx-1+offset].properties);newFeatures[idx+offset].properties=_objectSpread({},newFeatures[idx+offset].properties);newFeatures[idx-1+offset].__status__=["new","empty"].includes(newFeatures[idx-1+offset].__status__)?"new":"changed";newFeatures[idx+offset].__status__=["new","empty"].includes(newFeatures[idx+offset].__status__)?"new":"changed";newRelationValues[table].features=newFeatures;var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{relationValues:newRelationValues});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:true})});_defineProperty(_this,"removeRelationRecord",function(table,idx){var newRelationValues=_objectSpread({},_this.props.editContext.feature.relationValues);newRelationValues[table]=_objectSpread({},newRelationValues[table]);newRelationValues[table].features=newRelationValues[table].features.slice(0);var fieldStatus=newRelationValues[table].features[idx].__status__||"";// If field was new, delete it directly, else mark it as deleted
10
- if(["new","empty"].includes(fieldStatus)){newRelationValues[table].features.splice(idx,1)}else{newRelationValues[table].features[idx]=_objectSpread(_objectSpread({},newRelationValues[table].features[idx]),{},{__status__:fieldStatus.startsWith("deleted")?fieldStatus.substr(8):"deleted:"+fieldStatus})}var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{relationValues:newRelationValues});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:true})});_defineProperty(_this,"updateRelationField",function(table,idx,key,value){var newRelationValues=_objectSpread({},_this.props.editContext.feature.relationValues);newRelationValues[table]=_objectSpread({},newRelationValues[table]);newRelationValues[table].features=newRelationValues[table].features.slice(0);newRelationValues[table].features[idx]=_objectSpread(_objectSpread({},newRelationValues[table].features[idx]),{},{properties:_objectSpread(_objectSpread({},newRelationValues[table].features[idx].properties),{},_defineProperty({},key,value)),__status__:["new","empty"].includes(newRelationValues[table].features[idx].__status__)?"new":"changed"});var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{relationValues:newRelationValues});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:true})});_defineProperty(_this,"editRelationRecord",function(action,layer,dataset,idx,displayField){var editConfig=(_this.props.theme.editConfig||{})[layer];var feature=_this.props.editContext.feature.relationValues[dataset].features[idx];_this.setState({childEdit:{action:action,editConfig:editConfig,editContextId:":"+layer,dataset:dataset,idx:idx,feature:feature,finishCallback:_this.finishEditRelationRecord,displayField:displayField,hideDelete:true}})});_defineProperty(_this,"finishEditRelationRecord",function(feature){_this.props.clearEditContext(_this.state.childEdit.editContextId,_this.props.editContext.id);if(feature){var table=_this.state.childEdit.dataset;var idx=_this.state.childEdit.idx;var newRelationValues=_objectSpread({},_this.props.editContext.feature.relationValues);newRelationValues[table]=_objectSpread({},newRelationValues[table]);newRelationValues[table].features=newRelationValues[table].features.slice(0);newRelationValues[table].features[idx]=_objectSpread(_objectSpread({},feature),{},{properties:_objectSpread({},feature.properties)});// If feature id is known, i.e. not when drawing new feature, set foreign key
11
- var changed=_this.props.editContext.changed;var fk=_this.state.relationTables[table].fk;if(_this.props.editContext.action!=="Draw"&&feature.properties[fk]!==_this.props.editContext.feature.id){newRelationValues[table].features[idx].properties[fk]=_this.props.editContext.feature.id;newRelationValues[table].features[idx].__status__="changed";changed=true}var newFeature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{relationValues:newRelationValues});_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:changed})}_this.setState({childEdit:null})});_defineProperty(_this,"onDiscard",function(action){if(action==="Discard"){_this.props.setCurrentTaskBlocked(false);if(!_this.props.onDiscard||!_this.props.onDiscard()){if(_this.props.editContext.action==="Pick"){// Re-query the original feature
12
- _this.setState({busy:true});_this.props.iface.getFeatureById(_this.props.editConfig,_this.props.editContext.feature.id,_this.props.map.projection,function(feature){_this.setState({busy:false});if(!isEmpty(_this.state.relationTables)){// Re-load relation values
13
- _this.loadRelationValues(feature,function(newFeature){_this.props.setEditContext(_this.props.editContext.id,{feature:newFeature,changed:false})});// Re-validate feature field constraints
14
- _this.validateFieldConstraints(feature)}else{_this.props.setEditContext(_this.props.editContext.id,{feature:feature,changed:false})}})}else{var featureSkel={type:"Feature",properties:{}};var mapPrefix=(_this.props.editConfig.editDataset.match(/^[^.]+\./)||[""])[0];getFeatureTemplate(_this.props.editConfig,featureSkel,_this.props.iface,mapPrefix,_this.props.map.projection,function(feature){_this.props.setEditContext(_this.props.editContext.id,{feature:feature,changed:false})})}}}});_defineProperty(_this,"setupChangedObserver",function(form){_this.form=form;if(form){form.observer=new MutationObserver(function(){_this.setState({formValid:form.checkValidity()})});form.observer.observe(form,{subtree:true,childList:true,attributes:true})}});_defineProperty(_this,"formChanged",function(ev){var _ev$target;var form=ev.currentTarget;if((_ev$target=ev.target)!==null&&_ev$target!==void 0&&_ev$target.setCustomValidity){ev.target.setCustomValidity("")}if(form){_this.setState({formValid:form.checkValidity()});_this.props.setEditContext(_this.props.editContext.id,{changed:true})}});_defineProperty(_this,"validateFieldConstraints",function(feature){var validCallback=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var invalidCallback=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var constraintExpressions=_this.props.editConfig.fields.reduce(function(res,cur){var _cur$constraints;if((_cur$constraints=cur.constraints)!==null&&_cur$constraints!==void 0&&_cur$constraints.expression){return[].concat(_toConsumableArray(res),[{field:cur.id,expression:cur.constraints.expression}])}return res},[]);parseExpressionsAsync(constraintExpressions,feature,_this.props.editConfig,_this.props.iface,_this.editMapPrefix(),_this.props.map.projection,false).then(function(result){var valid=true;var reasons=[];Object.entries(result).forEach(function(_ref5){var _ref6=_slicedToArray(_ref5,2),key=_ref6[0],value=_ref6[1];var element=_this.form.elements.namedItem(key);if(element){if(value===false){var _this$props$editConfi,_this$props$editConfi2;valid=false;var reason=(_this$props$editConfi=(_this$props$editConfi2=_this.props.editConfig.fields.find(function(field){return field.id===key}))===null||_this$props$editConfi2===void 0||(_this$props$editConfi2=_this$props$editConfi2.constraints)===null||_this$props$editConfi2===void 0?void 0:_this$props$editConfi2.placeholder)!==null&&_this$props$editConfi!==void 0?_this$props$editConfi:LocaleUtils.tr("editing.contraintviolation");reasons.push(reason);element.setCustomValidity(reason)}else{element.setCustomValidity("")}}});if(!valid){_this.setState({formValid:false});if(invalidCallback){invalidCallback(reasons)}}else{if(validCallback){validCallback()}}})});_defineProperty(_this,"onSubmit",function(ev){ev.preventDefault();_this.validateFieldConstraints(_this.props.editContext.feature,_this.doSubmit,function(reasons){/* eslint-disable-next-line */alert(LocaleUtils.tr("editing.contraintviolation")+":\n"+reasons.join("\n"))})});_defineProperty(_this,"doSubmit",function(){_this.setState({busy:true});var feature=_this.props.editContext.feature;// Ensure properties is not null
15
- feature=_objectSpread(_objectSpread({},feature),{},{type:"Feature",properties:_objectSpread({},feature.properties||{}),crs:{type:"name",properties:{name:CoordinatesUtils.toOgcUrnCrs(_this.props.map.projection)}}});// Omit geometry if it is read-only
16
- if(_this.props.editContext.geomReadOnly){delete feature.geometry}var curConfig=_this.props.editConfig;var mapPrefix=_this.editMapPrefix();var textNullValue=ConfigUtils.getConfigProp("editTextNullValue");// Keep relation values separate
17
- var relationValues=clone(feature.relationValues||{});delete feature.relationValues;var relationUploads={};var featureUploads={};// Collect all values from form fields
18
- var fieldnames=Array.from(_this.form.elements).map(function(element){return element.name}).filter(function(x){return x&&x!=="g-recaptcha-response"});fieldnames.forEach(function(name){var element=_this.form.elements.namedItem(name);if(element){var parts=name.split("__");var value=element.type==="radio"||element.type==="checkbox"?element.checked:element.value;var nullElements=["date","number","radio"];var nullFieldTypes=["date","number"];if(parts.length>=3){var _this$props$theme$edi,_this$props$theme$edi2,_this$props$theme$edi3;// Relation value
19
- // Usually <table>__<field>__<index>, but <field> might also contain __ (i.e. upload__user)
20
- var tablename=parts[0];var datasetname=mapPrefix+tablename;var field=parts.slice(1,parts.length-1).join("__");var index=parseInt(parts[parts.length-1],10);var nrelFieldConfig=(_this$props$theme$edi=(_this$props$theme$edi2=_this.props.theme.editConfig[tablename].fields)===null||_this$props$theme$edi2===void 0||(_this$props$theme$edi3=_this$props$theme$edi2.find)===null||_this$props$theme$edi3===void 0?void 0:_this$props$theme$edi3.call(_this$props$theme$edi2,function(f){return f.id===field}))!==null&&_this$props$theme$edi!==void 0?_this$props$theme$edi:{};var nrelFieldDataType=nrelFieldConfig.type;if(nrelFieldConfig.expression){// Skip virtual fields
21
- delete relationValues[datasetname].features[index][field];return}if((element instanceof RadioNodeList||nullElements.includes(element.type)||nullFieldTypes.includes(nrelFieldDataType))&&element.value===""){// Set empty value to null instead of empty string
22
- value=null}if(nrelFieldDataType==="text"&&textNullValue!==undefined&&element.value===textNullValue){// Convert text NULL to null
23
- value=null}// relationValues for table must exist as rows are either pre-existing or were added
24
- if(!(field in relationValues[datasetname].features[index].properties)){relationValues[datasetname].features[index].defaultedProperties=[].concat(_toConsumableArray(relationValues[datasetname].features[index].defaultedProperties||[]),[field])}relationValues[datasetname].features[index].properties[field]=value;if(relationValues[datasetname].features[index].__status__==="empty"){relationValues[datasetname].features[index].__status__="new"}if(element.type==="file"&&element.files.length>0){relationUploads[name]=element.files[0];relationValues[datasetname].features[index].properties[field]=""}else if(element.type==="hidden"&&element.value.startsWith("data:")){var filename=element.dataset.filename;var type=element.value.match(/image\/\w+/)[0];if(!filename){var ext=type.split("/")[1];filename=uuidv4()+"."+ext}relationUploads[name]=new File([_this.dataUriToBlob(element.value)],filename,{type:type});relationValues[datasetname].features[index].properties[field]=""}}else{var fieldConfig=(curConfig.fields||[]).find(function(field){return field.id===name})||{};if(fieldConfig.expression){// Skip virtual fields
25
- delete feature.properties[name];return}var dataType=fieldConfig.type;if((element instanceof RadioNodeList||nullElements.includes(element.type)||nullFieldTypes.includes(dataType))&&element.value===""){// Set empty value to null instead of empty string
26
- value=null}if(dataType==="text"&&textNullValue!==undefined&&element.value===textNullValue){// Convert text NULL to null
27
- value=null}if(!(name in feature.properties)){feature.defaultedProperties=[].concat(_toConsumableArray(feature.defaultedProperties||[]),[name])}feature.properties[name]=value;if(element.type==="file"&&element.files.length>0){featureUploads[name]=element.files[0];feature.properties[name]=""}else if(element.type==="hidden"&&element.value.startsWith("data:")){var _filename=element.dataset.filename;var _type=element.value.match(/image\/\w+/)[0];if(!_filename){var _ext=_type.split("/")[1];_filename=uuidv4()+"."+_ext}featureUploads[name]=new File([_this.dataUriToBlob(element.value)],_filename,{type:_type});feature.properties[name]=""}}}});// Set relation values CRS and sort index if necessary
28
- Object.keys(relationValues).forEach(function(relTable){relationValues[relTable].features=relationValues[relTable].features.filter(function(relFeature){return relFeature.__status__!=="empty"}).map(function(relFeature,idx){var newRelFeature=_objectSpread(_objectSpread({},relFeature),{},{crs:{type:"name",properties:{name:CoordinatesUtils.toOgcUrnCrs(_this.props.map.projection)}}});var sortcol=_this.state.relationTables[relTable].sortcol;var noreorder=_this.state.relationTables[relTable].noreorder;if(sortcol&&!noreorder){newRelFeature.__status__=feature.__status__||(newRelFeature.properties[sortcol]!==idx?"changed":"");newRelFeature.properties[sortcol]=idx}return newRelFeature})});feature.relationValues=relationValues;var featureData=new FormData;featureData.set("feature",JSON.stringify(feature));Object.entries(featureUploads).forEach(function(_ref7){var _ref8=_slicedToArray(_ref7,2),key=_ref8[0],value=_ref8[1];return featureData.set("file:"+key,value)});Object.entries(relationUploads).forEach(function(_ref9){var _ref10=_slicedToArray(_ref9,2),key=_ref10[0],value=_ref10[1];return featureData.set("relfile:"+mapPrefix+key,value)});if(_this.state.captchaResponse){featureData.set("g-recaptcha-response",_this.state.captchaResponse)}if(_this.props.editContext.action==="Draw"){if(_this.props.iface.addFeatureMultipart){_this.props.iface.addFeatureMultipart(_this.props.editConfig,_this.props.map.projection,featureData,function(success,result){return _this.featureCommited(success,result)})}else{_this.props.iface.addFeature(_this.props.editConfig.editDataset,feature,_this.props.map.projection,function(success,result){return _this.featureCommited(success,result)})}}else if(_this.props.editContext.action==="Pick"){if(_this.props.iface.editFeatureMultipart){_this.props.iface.editFeatureMultipart(_this.props.editConfig,_this.props.map.projection,feature.id,featureData,function(success,result){return _this.featureCommited(success,result)})}else{_this.props.iface.editFeature(_this.props.editConfig.editDataset,feature,_this.props.map.projection,function(success,result){return _this.featureCommited(success,result)})}}});_defineProperty(_this,"featureCommited",function(success,result){if(!success){_this.commitFinished(false,result);return}// Check for relation records which failed to commit
29
- var relationValueErrors=Object.values(result.relationValues||[]).find(function(entry){return(entry.features||[]).find(function(f){return f.error})})!==undefined;if(relationValueErrors){// Relation values commit failed, switch to pick to avoid adding feature again on next attempt
30
- _this.commitFinished(false,LocaleUtils.tr("editing.relationcommitfailed"));_this.props.setEditContext(_this.props.editContext.id,{action:"Pick",feature:result,changed:true})}else{_this.commitFinished(true,result)}});_defineProperty(_this,"deleteClicked",function(){_this.setState({deleteClicked:true});_this.props.setCurrentTaskBlocked(true,LocaleUtils.tr("editing.unsavedchanged"))});_defineProperty(_this,"deleteFeature",function(action){if(action==="Yes"){_this.setState({busy:true});var recaptchaResponse=null;if(_this.state.captchaResponse){recaptchaResponse=_this.state.captchaResponse}_this.props.iface.deleteFeature(_this.props.editConfig,_this.props.editContext.feature.id,_this.deleteFinished,recaptchaResponse)}else{_this.setState({deleteClicked:false});_this.props.setCurrentTaskBlocked(false)}});_defineProperty(_this,"commitFinished",function(success,result){_this.setState({busy:false});if(success){_this.props.refreshLayer(function(layer){return layer.role===LayerRole.THEME});_this.props.setCurrentTaskBlocked(false);if(!_this.props.onCommit||!_this.props.onCommit(result)){if(!isEmpty(_this.state.relationTables)){// Re-load relation values
31
- _this.loadRelationValues(result,function(newFeature){_this.props.setEditContext(_this.props.editContext.id,{action:"Pick",feature:newFeature,changed:false})});// Re-validate feature field constraints
32
- _this.validateFieldConstraints(result)}else{_this.props.setEditContext(_this.props.editContext.id,{action:"Pick",feature:result,changed:false})}}}else{// eslint-disable-next-line
33
- alert(result)}});_defineProperty(_this,"deleteFinished",function(success,result){_this.setState({busy:false});if(success){_this.setState({deleteClicked:false});_this.props.setCurrentTaskBlocked(false);_this.props.refreshLayer(function(layer){return layer.role===LayerRole.THEME});if(!_this.props.onDelete||!_this.props.onDelete(result)){_this.props.setEditContext(_this.props.editContext.id,{feature:null,changed:false})}}else{// eslint-disable-next-line
34
- alert(result)}});_defineProperty(_this,"dataUriToBlob",function(dataUri){var parts=dataUri.split(",");var byteString=parts[0].indexOf("base64")>=0?atob(parts[1]):decodeURI(parts[1]);var mimeString=parts[0].split(":")[1].split(";")[0];var ia=new Uint8Array(byteString.length);for(var i=0;i<byteString.length;i++){ia[i]=byteString.charCodeAt(i)}return new Blob([ia],{type:mimeString})});_defineProperty(_this,"startChildEdit",function(action,layer,featureId,updateField,displayField){var editConfig=(_this.props.theme.editConfig||{})[layer];if(!editConfig){// eslint-disable-next-line
35
- console.warn("No edit config found for linked edit layer "+layer)}else{_this.setState({childEdit:{action:action,editConfig:editConfig,editContextId:":"+layer,displayField:displayField,featureId:featureId,updateField:updateField,finishCallback:_this.finishChildEdit}})}});_defineProperty(_this,"finishChildEdit",function(feature){_this.props.clearEditContext(_this.state.childEdit.editContextId,_this.props.editContext.id);if(feature&&feature.id!==_this.state.childEdit.featureId){_this.state.childEdit.updateField(feature.id)}_this.setState({childEdit:null})});_this.form=null;return _this}_inherits(AttributeForm,_React$Component);return _createClass(AttributeForm,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;if(prevProps.editContext.changed!==this.props.editContext.changed){this.props.setCurrentTaskBlocked(this.props.editContext.changed===true,LocaleUtils.tr("editing.unsavedchanged"))}if((!this.props.editContext.feature||this.props.editContext.changed)&&this.state.deleteClicked){this.setState({deleteClicked:false})}// Reload relation values if necessary
36
- var feature=this.props.editContext.feature;var prevFeature=prevProps.editContext.feature;if((!this.props.editContext.changed||!feature.relationValues)&&(this.state.relationTables!==prevState.relationTables||feature.id!==(prevFeature||{}).id)){this.loadRelationValues(this.props.editContext.feature,function(newFeature){_this2.props.setEditContext(_this2.props.editContext.id,{feature:newFeature})});// Re-validate feature field constraints
37
- this.validateFieldConstraints(this.props.editContext.feature)}}}])}(React.Component);_defineProperty(AttributeForm,"propTypes",{childPickFilter:PropTypes.func,clearEditContext:PropTypes.func,deleteLabel:PropTypes.string,editConfig:PropTypes.object,editContext:PropTypes.object,hideDelete:PropTypes.bool,iface:PropTypes.object,map:PropTypes.object,onCommit:PropTypes.func,onDelete:PropTypes.func,onDiscard:PropTypes.func,readOnly:PropTypes.bool,refreshLayer:PropTypes.func,report:PropTypes.bool,setCurrentTaskBlocked:PropTypes.func,setEditContext:PropTypes.func,theme:PropTypes.object,touchFriendly:PropTypes.bool});_defineProperty(AttributeForm,"defaultProps",{touchFriendly:true});export default connect(function(state){return{map:state.map,theme:state.theme.current}},{clearEditContext:clearEditContext,setEditContext:setEditContext,setCurrentTaskBlocked:setCurrentTaskBlocked,refreshLayer:refreshLayer})(AttributeForm);
34
+ */
35
+
36
+ import React from 'react';
37
+ import { connect } from 'react-redux';
38
+ import clone from 'clone';
39
+ import isEmpty from 'lodash.isempty';
40
+ import PropTypes from 'prop-types';
41
+ import { v4 as uuidv4 } from 'uuid';
42
+ import { setEditContext, clearEditContext } from '../actions/editing';
43
+ import { LayerRole, refreshLayer } from '../actions/layers';
44
+ import { setCurrentTaskBlocked } from '../actions/task';
45
+ import ConfigUtils from '../utils/ConfigUtils';
46
+ import CoordinatesUtils from '../utils/CoordinatesUtils';
47
+ import { getFeatureTemplate, parseExpressionsAsync } from '../utils/EditingUtils';
48
+ import LocaleUtils from '../utils/LocaleUtils';
49
+ import AutoEditForm from './AutoEditForm';
50
+ import LinkFeatureForm from './LinkFeatureForm';
51
+ import QtDesignerForm from './QtDesignerForm';
52
+ import ButtonBar from './widgets/ButtonBar';
53
+ import ReCaptchaWidget from './widgets/ReCaptchaWidget';
54
+ import './style/AttributeForm.css';
55
+ var AttributeForm = /*#__PURE__*/function (_React$Component) {
56
+ function AttributeForm(props) {
57
+ var _this;
58
+ _classCallCheck(this, AttributeForm);
59
+ _this = _callSuper(this, AttributeForm, [props]);
60
+ _defineProperty(_this, "state", {
61
+ busy: false,
62
+ deleteClicked: false,
63
+ childEdit: null,
64
+ relationTables: {},
65
+ formValid: true,
66
+ captchaResponse: null
67
+ });
68
+ _defineProperty(_this, "editLayerId", function (layerId) {
69
+ return _this.props.editConfig || layerId;
70
+ });
71
+ _defineProperty(_this, "render", function () {
72
+ var captchaRequired = ConfigUtils.getConfigProp("editServiceCaptchaSiteKey") && !ConfigUtils.getConfigProp("username");
73
+ var captchaPending = captchaRequired && !_this.state.captchaResponse;
74
+ var commitBar = null;
75
+ if (_this.props.editContext.changed) {
76
+ var commitButtons = [{
77
+ key: 'Commit',
78
+ icon: _this.state.formValid ? 'ok' : 'warning',
79
+ label: _this.state.formValid ? LocaleUtils.tr("editing.commit") : LocaleUtils.tr("editing.invalidform"),
80
+ extraClasses: _this.state.formValid ? "button-accept" : "button-warning",
81
+ type: "submit",
82
+ disabled: !_this.state.formValid || captchaPending
83
+ }, {
84
+ key: 'Discard',
85
+ icon: 'remove',
86
+ label: LocaleUtils.tr("editing.discard"),
87
+ extraClasses: "button-reject"
88
+ }];
89
+ commitBar = /*#__PURE__*/React.createElement(ButtonBar, {
90
+ buttons: commitButtons,
91
+ onClick: _this.onDiscard
92
+ }); /* submit is handled via onSubmit in the form */
93
+ }
94
+ var curConfig = _this.props.editConfig;
95
+ var editPermissions = curConfig.permissions || {};
96
+ var readOnly = _this.props.readOnly || editPermissions.updatable === false && _this.props.editContext.action === 'Pick';
97
+ var deleteBar = null;
98
+ if (!_this.props.hideDelete && _this.props.editContext.action === 'Pick' && _this.props.editContext.feature && !_this.props.editContext.changed && editPermissions.deletable !== false && !_this.props.readOnly) {
99
+ // Delete button bar will appear by default if no permissions are defined in editConfig or when deletable permission is set
100
+ if (!_this.state.deleteClicked) {
101
+ var _this$props$deleteLab;
102
+ var deleteButtons = [{
103
+ key: 'Delete',
104
+ icon: 'trash',
105
+ label: (_this$props$deleteLab = _this.props.deleteLabel) !== null && _this$props$deleteLab !== void 0 ? _this$props$deleteLab : LocaleUtils.tr("editing.delete")
106
+ }];
107
+ deleteBar = /*#__PURE__*/React.createElement(ButtonBar, {
108
+ buttons: deleteButtons,
109
+ onClick: _this.deleteClicked
110
+ });
111
+ } else {
112
+ var _deleteButtons = [{
113
+ key: 'Yes',
114
+ icon: 'ok',
115
+ label: LocaleUtils.tr("editing.reallydelete"),
116
+ extraClasses: "button-accept",
117
+ disabled: captchaPending
118
+ }, {
119
+ key: 'No',
120
+ icon: 'remove',
121
+ label: LocaleUtils.tr("editing.canceldelete"),
122
+ extraClasses: "button-reject"
123
+ }];
124
+ deleteBar = /*#__PURE__*/React.createElement(ButtonBar, {
125
+ buttons: _deleteButtons,
126
+ onClick: _this.deleteFeature
127
+ });
128
+ }
129
+ }
130
+ var busyDiv = null;
131
+ if (_this.state.busy) {
132
+ busyDiv = /*#__PURE__*/React.createElement("div", {
133
+ className: "attrib-form-busy"
134
+ });
135
+ }
136
+ var childAttributeForm = null;
137
+ if (_this.state.childEdit) {
138
+ childAttributeForm = /*#__PURE__*/React.createElement("div", {
139
+ className: "link-feature-form-container"
140
+ }, /*#__PURE__*/React.createElement(LinkFeatureForm, _extends({}, _this.state.childEdit, {
141
+ finished: _this.state.childEdit.finishCallback,
142
+ iface: _this.props.iface,
143
+ pickFilter: _this.props.childPickFilter,
144
+ readOnly: _this.props.readOnly
145
+ })));
146
+ }
147
+ var captchaButton = null;
148
+ if (captchaRequired && (_this.props.editContext.changed || _this.state.deleteClicked)) {
149
+ captchaButton = /*#__PURE__*/React.createElement(ReCaptchaWidget, {
150
+ onChange: function onChange(value) {
151
+ return _this.setState({
152
+ captchaResponse: value
153
+ });
154
+ },
155
+ sitekey: ConfigUtils.getConfigProp("editServiceCaptchaSiteKey")
156
+ });
157
+ }
158
+ var readOnlyMsg = null;
159
+ if (!readOnly && _this.props.editContext.geomReadOnly) {
160
+ readOnlyMsg = LocaleUtils.tr("editing.geomreadonly");
161
+ } else if (!readOnly && _this.props.editContext.geomNonZeroZ) {
162
+ readOnlyMsg = LocaleUtils.tr("editing.geomnonzeroz");
163
+ }
164
+ return /*#__PURE__*/React.createElement("div", {
165
+ className: "AttributeForm"
166
+ }, readOnlyMsg ? /*#__PURE__*/React.createElement("div", {
167
+ className: "attrib-form-geom-readonly"
168
+ }, readOnlyMsg) : null, /*#__PURE__*/React.createElement("form", {
169
+ action: "",
170
+ onChange: function onChange(ev) {
171
+ return _this.formChanged(ev);
172
+ },
173
+ onSubmit: _this.onSubmit,
174
+ ref: _this.setupChangedObserver
175
+ }, _this.props.editConfig.form ? /*#__PURE__*/React.createElement(QtDesignerForm, {
176
+ addRelationRecord: _this.addRelationRecord,
177
+ editConfig: _this.props.editConfig,
178
+ editConfigs: _this.props.theme.editConfig,
179
+ editRelationRecord: _this.editRelationRecord,
180
+ feature: _this.props.editContext.feature,
181
+ iface: _this.props.iface,
182
+ mapCrs: _this.props.map.projection,
183
+ mapPrefix: _this.editMapPrefix(),
184
+ readOnly: readOnly,
185
+ removeRelationRecord: _this.removeRelationRecord,
186
+ reorderRelationRecord: _this.reorderRelationRecord,
187
+ report: _this.props.report,
188
+ setFormBusy: _this.setFormBusy,
189
+ setRelationTables: _this.setRelationTables,
190
+ switchEditContext: _this.startChildEdit,
191
+ translations: _this.props.theme.translations,
192
+ updateField: _this.updateField,
193
+ updateRelationField: _this.updateRelationField
194
+ }) : /*#__PURE__*/React.createElement(AutoEditForm, {
195
+ editLayerId: _this.props.editConfig.editDataset,
196
+ fields: _this.props.editConfig.fields,
197
+ iface: _this.props.iface,
198
+ readOnly: readOnly,
199
+ touchFriendly: _this.props.touchFriendly,
200
+ updateField: _this.updateField,
201
+ values: _this.props.editContext.feature.properties
202
+ }), captchaButton, commitBar), deleteBar, busyDiv, childAttributeForm);
203
+ });
204
+ _defineProperty(_this, "setFormBusy", function (busy) {
205
+ _this.setState({
206
+ busy: busy
207
+ });
208
+ });
209
+ _defineProperty(_this, "updateField", function (key, value) {
210
+ var newProperties = _objectSpread(_objectSpread({}, _this.props.editContext.feature.properties), {}, _defineProperty({}, key, value));
211
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
212
+ properties: newProperties
213
+ });
214
+ _this.props.setEditContext(_this.props.editContext.id, {
215
+ feature: newFeature,
216
+ changed: true
217
+ });
218
+ _this.validateFieldConstraints(newFeature);
219
+ });
220
+ _defineProperty(_this, "editMapPrefix", function () {
221
+ return (_this.props.editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
222
+ });
223
+ _defineProperty(_this, "setRelationTables", function (relationTables) {
224
+ _this.setState({
225
+ relationTables: relationTables
226
+ });
227
+ });
228
+ _defineProperty(_this, "loadRelationValues", function (feature, callback) {
229
+ if (!isEmpty(_this.state.relationTables)) {
230
+ if (feature.id) {
231
+ var relTables = Object.entries(_this.state.relationTables).map(function (_ref) {
232
+ var _ref2 = _slicedToArray(_ref, 2),
233
+ name = _ref2[0],
234
+ entry = _ref2[1];
235
+ if (entry.sortcol) {
236
+ return name + ":" + entry.fk + ":" + entry.sortcol;
237
+ } else {
238
+ return name + ":" + entry.fk;
239
+ }
240
+ }).join(",");
241
+ _this.props.iface.getRelations(_this.props.editConfig, feature.id, _this.props.map.projection, relTables, _this.props.theme.editConfig, function (relationValues) {
242
+ var newFeature = _objectSpread(_objectSpread({}, feature), {}, {
243
+ relationValues: relationValues
244
+ });
245
+ callback(newFeature);
246
+ });
247
+ } else {
248
+ var relationValues = _objectSpread(_objectSpread({}, Object.entries(_this.state.relationTables).reduce(function (res, _ref3) {
249
+ var _ref4 = _slicedToArray(_ref3, 2),
250
+ name = _ref4[0],
251
+ entry = _ref4[1];
252
+ return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, name, {
253
+ fk: entry.fk,
254
+ features: []
255
+ }));
256
+ }, {})), feature.relationValues);
257
+ var newFeature = _objectSpread(_objectSpread({}, feature), {}, {
258
+ relationValues: relationValues
259
+ });
260
+ callback(newFeature);
261
+ }
262
+ }
263
+ });
264
+ _defineProperty(_this, "addRelationRecord", function (table) {
265
+ var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
266
+ var editConfig = _this.props.theme.editConfig[table.split('.').slice(-1)];
267
+ var mapPrefix = (editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
268
+ getFeatureTemplate(editConfig, {
269
+ type: "Feature",
270
+ properties: {}
271
+ }, _this.props.iface, mapPrefix, _this.props.map.projection, function (newRelFeature) {
272
+ newRelFeature.__status__ = "empty";
273
+ if (editConfig.geomType === null) {
274
+ newRelFeature.geometry = null;
275
+ }
276
+ // If feature id is known, i.e. not when drawing new feature, set foreign key
277
+ if (_this.props.editContext.action !== "Draw") {
278
+ newRelFeature.properties[_this.state.relationTables[table].fk] = _this.props.editContext.feature.id;
279
+ }
280
+ newRelationValues[table] = _objectSpread({}, newRelationValues[table]);
281
+ newRelationValues[table].features = newRelationValues[table].features.concat([newRelFeature]);
282
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
283
+ relationValues: newRelationValues
284
+ });
285
+ _this.props.setEditContext(_this.props.editContext.id, {
286
+ feature: newFeature,
287
+ changed: true
288
+ });
289
+ });
290
+ });
291
+ _defineProperty(_this, "reorderRelationRecord", function (table, idx, dir) {
292
+ var nFeatures = _this.props.editContext.feature.relationValues[table].features.length;
293
+ if (dir < 0 && idx === 0 || dir > 0 && idx >= nFeatures - 1) {
294
+ return;
295
+ }
296
+ var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
297
+ newRelationValues[table] = _objectSpread({}, newRelationValues[table]);
298
+ var newFeatures = newRelationValues[table].features.slice(0);
299
+ var offset = dir < 0 ? 0 : 1;
300
+ newFeatures.splice(idx - 1 + offset, 2, newFeatures[idx + offset], newFeatures[idx - 1 + offset]);
301
+ newFeatures[idx - 1 + offset].properties = _objectSpread({}, newFeatures[idx - 1 + offset].properties);
302
+ newFeatures[idx + offset].properties = _objectSpread({}, newFeatures[idx + offset].properties);
303
+ newFeatures[idx - 1 + offset].__status__ = ["new", "empty"].includes(newFeatures[idx - 1 + offset].__status__) ? "new" : "changed";
304
+ newFeatures[idx + offset].__status__ = ["new", "empty"].includes(newFeatures[idx + offset].__status__) ? "new" : "changed";
305
+ newRelationValues[table].features = newFeatures;
306
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
307
+ relationValues: newRelationValues
308
+ });
309
+ _this.props.setEditContext(_this.props.editContext.id, {
310
+ feature: newFeature,
311
+ changed: true
312
+ });
313
+ });
314
+ _defineProperty(_this, "removeRelationRecord", function (table, idx) {
315
+ var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
316
+ newRelationValues[table] = _objectSpread({}, newRelationValues[table]);
317
+ newRelationValues[table].features = newRelationValues[table].features.slice(0);
318
+ var fieldStatus = newRelationValues[table].features[idx].__status__ || "";
319
+ // If field was new, delete it directly, else mark it as deleted
320
+ if (["new", "empty"].includes(fieldStatus)) {
321
+ newRelationValues[table].features.splice(idx, 1);
322
+ } else {
323
+ newRelationValues[table].features[idx] = _objectSpread(_objectSpread({}, newRelationValues[table].features[idx]), {}, {
324
+ __status__: fieldStatus.startsWith("deleted") ? fieldStatus.substr(8) : "deleted:" + fieldStatus
325
+ });
326
+ }
327
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
328
+ relationValues: newRelationValues
329
+ });
330
+ _this.props.setEditContext(_this.props.editContext.id, {
331
+ feature: newFeature,
332
+ changed: true
333
+ });
334
+ });
335
+ _defineProperty(_this, "updateRelationField", function (table, idx, key, value) {
336
+ var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
337
+ newRelationValues[table] = _objectSpread({}, newRelationValues[table]);
338
+ newRelationValues[table].features = newRelationValues[table].features.slice(0);
339
+ newRelationValues[table].features[idx] = _objectSpread(_objectSpread({}, newRelationValues[table].features[idx]), {}, {
340
+ properties: _objectSpread(_objectSpread({}, newRelationValues[table].features[idx].properties), {}, _defineProperty({}, key, value)),
341
+ __status__: ["new", "empty"].includes(newRelationValues[table].features[idx].__status__) ? "new" : "changed"
342
+ });
343
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
344
+ relationValues: newRelationValues
345
+ });
346
+ _this.props.setEditContext(_this.props.editContext.id, {
347
+ feature: newFeature,
348
+ changed: true
349
+ });
350
+ });
351
+ _defineProperty(_this, "editRelationRecord", function (action, layer, dataset, idx, displayField) {
352
+ var editConfig = (_this.props.theme.editConfig || {})[layer];
353
+ var feature = _this.props.editContext.feature.relationValues[dataset].features[idx];
354
+ _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
+ }
366
+ });
367
+ });
368
+ _defineProperty(_this, "finishEditRelationRecord", function (feature) {
369
+ _this.props.clearEditContext(_this.state.childEdit.editContextId, _this.props.editContext.id);
370
+ if (feature) {
371
+ var table = _this.state.childEdit.dataset;
372
+ var idx = _this.state.childEdit.idx;
373
+ var newRelationValues = _objectSpread({}, _this.props.editContext.feature.relationValues);
374
+ newRelationValues[table] = _objectSpread({}, newRelationValues[table]);
375
+ newRelationValues[table].features = newRelationValues[table].features.slice(0);
376
+ newRelationValues[table].features[idx] = _objectSpread(_objectSpread({}, feature), {}, {
377
+ properties: _objectSpread({}, feature.properties)
378
+ });
379
+ // If feature id is known, i.e. not when drawing new feature, set foreign key
380
+ var changed = _this.props.editContext.changed;
381
+ var fk = _this.state.relationTables[table].fk;
382
+ if (_this.props.editContext.action !== "Draw" && feature.properties[fk] !== _this.props.editContext.feature.id) {
383
+ newRelationValues[table].features[idx].properties[fk] = _this.props.editContext.feature.id;
384
+ newRelationValues[table].features[idx].__status__ = "changed";
385
+ changed = true;
386
+ }
387
+ var newFeature = _objectSpread(_objectSpread({}, _this.props.editContext.feature), {}, {
388
+ relationValues: newRelationValues
389
+ });
390
+ _this.props.setEditContext(_this.props.editContext.id, {
391
+ feature: newFeature,
392
+ changed: changed
393
+ });
394
+ }
395
+ _this.setState({
396
+ childEdit: null
397
+ });
398
+ });
399
+ _defineProperty(_this, "onDiscard", function (action) {
400
+ if (action === "Discard") {
401
+ _this.props.setCurrentTaskBlocked(false);
402
+ if (!_this.props.onDiscard || !_this.props.onDiscard()) {
403
+ if (_this.props.editContext.action === 'Pick') {
404
+ // Re-query the original feature
405
+ _this.setState({
406
+ busy: true
407
+ });
408
+ _this.props.iface.getFeatureById(_this.props.editConfig, _this.props.editContext.feature.id, _this.props.map.projection, function (feature) {
409
+ _this.setState({
410
+ busy: false
411
+ });
412
+ if (!isEmpty(_this.state.relationTables)) {
413
+ // Re-load relation values
414
+ _this.loadRelationValues(feature, function (newFeature) {
415
+ _this.props.setEditContext(_this.props.editContext.id, {
416
+ feature: newFeature,
417
+ changed: false
418
+ });
419
+ });
420
+ // Re-validate feature field constraints
421
+ _this.validateFieldConstraints(feature);
422
+ } else {
423
+ _this.props.setEditContext(_this.props.editContext.id, {
424
+ feature: feature,
425
+ changed: false
426
+ });
427
+ }
428
+ });
429
+ } else {
430
+ var featureSkel = {
431
+ type: "Feature",
432
+ properties: {}
433
+ };
434
+ var mapPrefix = (_this.props.editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
435
+ getFeatureTemplate(_this.props.editConfig, featureSkel, _this.props.iface, mapPrefix, _this.props.map.projection, function (feature) {
436
+ _this.props.setEditContext(_this.props.editContext.id, {
437
+ feature: feature,
438
+ changed: false
439
+ });
440
+ });
441
+ }
442
+ }
443
+ }
444
+ });
445
+ _defineProperty(_this, "setupChangedObserver", function (form) {
446
+ _this.form = form;
447
+ if (form) {
448
+ form.observer = new MutationObserver(function () {
449
+ _this.setState({
450
+ formValid: form.checkValidity()
451
+ });
452
+ });
453
+ form.observer.observe(form, {
454
+ subtree: true,
455
+ childList: true,
456
+ attributes: true
457
+ });
458
+ }
459
+ });
460
+ _defineProperty(_this, "formChanged", function (ev) {
461
+ var _ev$target;
462
+ var form = ev.currentTarget;
463
+ if ((_ev$target = ev.target) !== null && _ev$target !== void 0 && _ev$target.setCustomValidity) {
464
+ ev.target.setCustomValidity("");
465
+ }
466
+ if (form) {
467
+ _this.setState({
468
+ formValid: form.checkValidity()
469
+ });
470
+ _this.props.setEditContext(_this.props.editContext.id, {
471
+ changed: true
472
+ });
473
+ }
474
+ });
475
+ _defineProperty(_this, "validateFieldConstraints", function (feature) {
476
+ var validCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
477
+ var invalidCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
478
+ var constraintExpressions = _this.props.editConfig.fields.reduce(function (res, cur) {
479
+ var _cur$constraints;
480
+ if ((_cur$constraints = cur.constraints) !== null && _cur$constraints !== void 0 && _cur$constraints.expression) {
481
+ return [].concat(_toConsumableArray(res), [{
482
+ field: cur.id,
483
+ expression: cur.constraints.expression
484
+ }]);
485
+ }
486
+ return res;
487
+ }, []);
488
+ parseExpressionsAsync(constraintExpressions, feature, _this.props.editConfig, _this.props.iface, _this.editMapPrefix(), _this.props.map.projection, false).then(function (result) {
489
+ var valid = true;
490
+ var reasons = [];
491
+ Object.entries(result).forEach(function (_ref5) {
492
+ var _ref6 = _slicedToArray(_ref5, 2),
493
+ key = _ref6[0],
494
+ value = _ref6[1];
495
+ var element = _this.form.elements.namedItem(key);
496
+ if (element) {
497
+ if (value === false) {
498
+ var _this$props$editConfi, _this$props$editConfi2;
499
+ valid = false;
500
+ var reason = (_this$props$editConfi = (_this$props$editConfi2 = _this.props.editConfig.fields.find(function (field) {
501
+ return field.id === key;
502
+ })) === null || _this$props$editConfi2 === void 0 || (_this$props$editConfi2 = _this$props$editConfi2.constraints) === null || _this$props$editConfi2 === void 0 ? void 0 : _this$props$editConfi2.placeholder) !== null && _this$props$editConfi !== void 0 ? _this$props$editConfi : LocaleUtils.tr("editing.contraintviolation");
503
+ reasons.push(reason);
504
+ element.setCustomValidity(reason);
505
+ } else {
506
+ element.setCustomValidity("");
507
+ }
508
+ }
509
+ });
510
+ if (!valid) {
511
+ _this.setState({
512
+ formValid: false
513
+ });
514
+ if (invalidCallback) {
515
+ invalidCallback(reasons);
516
+ }
517
+ } else {
518
+ if (validCallback) {
519
+ validCallback();
520
+ }
521
+ }
522
+ });
523
+ });
524
+ _defineProperty(_this, "onSubmit", function (ev) {
525
+ ev.preventDefault();
526
+ _this.validateFieldConstraints(_this.props.editContext.feature, _this.doSubmit, function (reasons) {
527
+ /* eslint-disable-next-line */
528
+ alert(LocaleUtils.tr("editing.contraintviolation") + ":\n" + reasons.join("\n"));
529
+ });
530
+ });
531
+ _defineProperty(_this, "doSubmit", function () {
532
+ _this.setState({
533
+ busy: true
534
+ });
535
+ var feature = _this.props.editContext.feature;
536
+ // Ensure properties is not null
537
+ feature = _objectSpread(_objectSpread({}, feature), {}, {
538
+ type: "Feature",
539
+ properties: _objectSpread({}, feature.properties || {}),
540
+ crs: {
541
+ type: "name",
542
+ properties: {
543
+ name: CoordinatesUtils.toOgcUrnCrs(_this.props.map.projection)
544
+ }
545
+ }
546
+ });
547
+ // Omit geometry if it is read-only
548
+ if (_this.props.editContext.geomReadOnly) {
549
+ delete feature.geometry;
550
+ }
551
+ var curConfig = _this.props.editConfig;
552
+ var mapPrefix = _this.editMapPrefix();
553
+ var textNullValue = ConfigUtils.getConfigProp("editTextNullValue");
554
+
555
+ // Keep relation values separate
556
+ var relationValues = clone(feature.relationValues || {});
557
+ delete feature.relationValues;
558
+ var relationUploads = {};
559
+ var featureUploads = {};
560
+
561
+ // Collect all values from form fields
562
+ var fieldnames = Array.from(_this.form.elements).map(function (element) {
563
+ return element.name;
564
+ }).filter(function (x) {
565
+ return x && x !== "g-recaptcha-response";
566
+ });
567
+ fieldnames.forEach(function (name) {
568
+ var element = _this.form.elements.namedItem(name);
569
+ if (element) {
570
+ var parts = name.split("__");
571
+ var value = element.type === "radio" || element.type === "checkbox" ? element.checked : element.value;
572
+ var nullElements = ["date", "number", "radio"];
573
+ var nullFieldTypes = ["date", "number"];
574
+ if (parts.length >= 3) {
575
+ var _this$props$theme$edi, _this$props$theme$edi2, _this$props$theme$edi3;
576
+ // Relation value
577
+ // Usually <table>__<field>__<index>, but <field> might also contain __ (i.e. upload__user)
578
+ var tablename = parts[0];
579
+ var datasetname = mapPrefix + tablename;
580
+ var field = parts.slice(1, parts.length - 1).join("__");
581
+ var index = parseInt(parts[parts.length - 1], 10);
582
+ var nrelFieldConfig = (_this$props$theme$edi = (_this$props$theme$edi2 = _this.props.theme.editConfig[tablename].fields) === null || _this$props$theme$edi2 === void 0 || (_this$props$theme$edi3 = _this$props$theme$edi2.find) === null || _this$props$theme$edi3 === void 0 ? void 0 : _this$props$theme$edi3.call(_this$props$theme$edi2, function (f) {
583
+ return f.id === field;
584
+ })) !== null && _this$props$theme$edi !== void 0 ? _this$props$theme$edi : {};
585
+ var nrelFieldDataType = nrelFieldConfig.type;
586
+ if (nrelFieldConfig.expression) {
587
+ // Skip virtual fields
588
+ delete relationValues[datasetname].features[index][field];
589
+ return;
590
+ }
591
+ if ((element instanceof RadioNodeList || nullElements.includes(element.type) || nullFieldTypes.includes(nrelFieldDataType)) && element.value === "") {
592
+ // Set empty value to null instead of empty string
593
+ value = null;
594
+ }
595
+ if (nrelFieldDataType === "text" && textNullValue !== undefined && element.value === textNullValue) {
596
+ // Convert text NULL to null
597
+ value = null;
598
+ }
599
+
600
+ // relationValues for table must exist as rows are either pre-existing or were added
601
+ if (!(field in relationValues[datasetname].features[index].properties)) {
602
+ relationValues[datasetname].features[index].defaultedProperties = [].concat(_toConsumableArray(relationValues[datasetname].features[index].defaultedProperties || []), [field]);
603
+ }
604
+ relationValues[datasetname].features[index].properties[field] = value;
605
+ if (relationValues[datasetname].features[index].__status__ === "empty") {
606
+ relationValues[datasetname].features[index].__status__ = "new";
607
+ }
608
+ if (element.type === "file" && element.files.length > 0) {
609
+ relationUploads[name] = element.files[0];
610
+ relationValues[datasetname].features[index].properties[field] = "";
611
+ } else if (element.type === "hidden" && element.value.startsWith("data:")) {
612
+ var filename = element.dataset.filename;
613
+ var type = element.value.match(/image\/\w+/)[0];
614
+ if (!filename) {
615
+ var ext = type.split("/")[1];
616
+ filename = uuidv4() + "." + ext;
617
+ }
618
+ relationUploads[name] = new File([_this.dataUriToBlob(element.value)], filename, {
619
+ type: type
620
+ });
621
+ relationValues[datasetname].features[index].properties[field] = "";
622
+ }
623
+ } else {
624
+ var fieldConfig = (curConfig.fields || []).find(function (field) {
625
+ return field.id === name;
626
+ }) || {};
627
+ if (fieldConfig.expression) {
628
+ // Skip virtual fields
629
+ delete feature.properties[name];
630
+ return;
631
+ }
632
+ var dataType = fieldConfig.type;
633
+ if ((element instanceof RadioNodeList || nullElements.includes(element.type) || nullFieldTypes.includes(dataType)) && element.value === "") {
634
+ // Set empty value to null instead of empty string
635
+ value = null;
636
+ }
637
+ if (dataType === "text" && textNullValue !== undefined && element.value === textNullValue) {
638
+ // Convert text NULL to null
639
+ value = null;
640
+ }
641
+ if (!(name in feature.properties)) {
642
+ feature.defaultedProperties = [].concat(_toConsumableArray(feature.defaultedProperties || []), [name]);
643
+ }
644
+ feature.properties[name] = value;
645
+ if (element.type === "file" && element.files.length > 0) {
646
+ featureUploads[name] = element.files[0];
647
+ feature.properties[name] = "";
648
+ } else if (element.type === "hidden" && element.value.startsWith("data:")) {
649
+ var _filename = element.dataset.filename;
650
+ var _type = element.value.match(/image\/\w+/)[0];
651
+ if (!_filename) {
652
+ var _ext = _type.split("/")[1];
653
+ _filename = uuidv4() + "." + _ext;
654
+ }
655
+ featureUploads[name] = new File([_this.dataUriToBlob(element.value)], _filename, {
656
+ type: _type
657
+ });
658
+ feature.properties[name] = "";
659
+ }
660
+ }
661
+ }
662
+ });
663
+
664
+ // Set relation values CRS and sort index if necessary
665
+ Object.keys(relationValues).forEach(function (relTable) {
666
+ relationValues[relTable].features = relationValues[relTable].features.filter(function (relFeature) {
667
+ return relFeature.__status__ !== "empty";
668
+ }).map(function (relFeature, idx) {
669
+ var newRelFeature = _objectSpread(_objectSpread({}, relFeature), {}, {
670
+ crs: {
671
+ type: "name",
672
+ properties: {
673
+ name: CoordinatesUtils.toOgcUrnCrs(_this.props.map.projection)
674
+ }
675
+ }
676
+ });
677
+ var sortcol = _this.state.relationTables[relTable].sortcol;
678
+ var noreorder = _this.state.relationTables[relTable].noreorder;
679
+ if (sortcol && !noreorder) {
680
+ newRelFeature.__status__ = feature.__status__ || (newRelFeature.properties[sortcol] !== idx ? "changed" : "");
681
+ newRelFeature.properties[sortcol] = idx;
682
+ }
683
+ return newRelFeature;
684
+ });
685
+ });
686
+ feature.relationValues = relationValues;
687
+ var featureData = new FormData();
688
+ featureData.set('feature', JSON.stringify(feature));
689
+ Object.entries(featureUploads).forEach(function (_ref7) {
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) {
696
+ var _ref10 = _slicedToArray(_ref9, 2),
697
+ key = _ref10[0],
698
+ value = _ref10[1];
699
+ return featureData.set('relfile:' + mapPrefix + key, value);
700
+ });
701
+ if (_this.state.captchaResponse) {
702
+ featureData.set('g-recaptcha-response', _this.state.captchaResponse);
703
+ }
704
+ if (_this.props.editContext.action === "Draw") {
705
+ if (_this.props.iface.addFeatureMultipart) {
706
+ _this.props.iface.addFeatureMultipart(_this.props.editConfig, _this.props.map.projection, featureData, function (success, result) {
707
+ return _this.featureCommited(success, result);
708
+ });
709
+ } else {
710
+ _this.props.iface.addFeature(_this.props.editConfig.editDataset, feature, _this.props.map.projection, function (success, result) {
711
+ return _this.featureCommited(success, result);
712
+ });
713
+ }
714
+ } else if (_this.props.editContext.action === "Pick") {
715
+ if (_this.props.iface.editFeatureMultipart) {
716
+ _this.props.iface.editFeatureMultipart(_this.props.editConfig, _this.props.map.projection, feature.id, featureData, function (success, result) {
717
+ return _this.featureCommited(success, result);
718
+ });
719
+ } else {
720
+ _this.props.iface.editFeature(_this.props.editConfig.editDataset, feature, _this.props.map.projection, function (success, result) {
721
+ return _this.featureCommited(success, result);
722
+ });
723
+ }
724
+ }
725
+ });
726
+ _defineProperty(_this, "featureCommited", function (success, result) {
727
+ if (!success) {
728
+ _this.commitFinished(false, result);
729
+ return;
730
+ }
731
+ // Check for relation records which failed to commit
732
+ var relationValueErrors = Object.values(result.relationValues || []).find(function (entry) {
733
+ return (entry.features || []).find(function (f) {
734
+ return f.error;
735
+ });
736
+ }) !== undefined;
737
+ if (relationValueErrors) {
738
+ // Relation values commit failed, switch to pick to avoid adding feature again on next attempt
739
+ _this.commitFinished(false, LocaleUtils.tr("editing.relationcommitfailed"));
740
+ _this.props.setEditContext(_this.props.editContext.id, {
741
+ action: "Pick",
742
+ feature: result,
743
+ changed: true
744
+ });
745
+ } else {
746
+ _this.commitFinished(true, result);
747
+ }
748
+ });
749
+ _defineProperty(_this, "deleteClicked", function () {
750
+ _this.setState({
751
+ deleteClicked: true
752
+ });
753
+ _this.props.setCurrentTaskBlocked(true, LocaleUtils.tr("editing.unsavedchanged"));
754
+ });
755
+ _defineProperty(_this, "deleteFeature", function (action) {
756
+ if (action === 'Yes') {
757
+ _this.setState({
758
+ busy: true
759
+ });
760
+ var recaptchaResponse = null;
761
+ if (_this.state.captchaResponse) {
762
+ recaptchaResponse = _this.state.captchaResponse;
763
+ }
764
+ _this.props.iface.deleteFeature(_this.props.editConfig, _this.props.editContext.feature.id, _this.deleteFinished, recaptchaResponse);
765
+ } else {
766
+ _this.setState({
767
+ deleteClicked: false
768
+ });
769
+ _this.props.setCurrentTaskBlocked(false);
770
+ }
771
+ });
772
+ _defineProperty(_this, "commitFinished", function (success, result) {
773
+ _this.setState({
774
+ busy: false
775
+ });
776
+ if (success) {
777
+ _this.props.refreshLayer(function (layer) {
778
+ return layer.role === LayerRole.THEME;
779
+ });
780
+ _this.props.setCurrentTaskBlocked(false);
781
+ if (!_this.props.onCommit || !_this.props.onCommit(result)) {
782
+ if (!isEmpty(_this.state.relationTables)) {
783
+ // Re-load relation values
784
+ _this.loadRelationValues(result, function (newFeature) {
785
+ _this.props.setEditContext(_this.props.editContext.id, {
786
+ action: 'Pick',
787
+ feature: newFeature,
788
+ changed: false
789
+ });
790
+ });
791
+ // Re-validate feature field constraints
792
+ _this.validateFieldConstraints(result);
793
+ } else {
794
+ _this.props.setEditContext(_this.props.editContext.id, {
795
+ action: 'Pick',
796
+ feature: result,
797
+ changed: false
798
+ });
799
+ }
800
+ }
801
+ } else {
802
+ // eslint-disable-next-line
803
+ alert(result);
804
+ }
805
+ });
806
+ _defineProperty(_this, "deleteFinished", function (success, result) {
807
+ _this.setState({
808
+ busy: false
809
+ });
810
+ if (success) {
811
+ _this.setState({
812
+ deleteClicked: false
813
+ });
814
+ _this.props.setCurrentTaskBlocked(false);
815
+ _this.props.refreshLayer(function (layer) {
816
+ return layer.role === LayerRole.THEME;
817
+ });
818
+ if (!_this.props.onDelete || !_this.props.onDelete(result)) {
819
+ _this.props.setEditContext(_this.props.editContext.id, {
820
+ feature: null,
821
+ changed: false
822
+ });
823
+ }
824
+ } else {
825
+ // eslint-disable-next-line
826
+ alert(result);
827
+ }
828
+ });
829
+ _defineProperty(_this, "dataUriToBlob", function (dataUri) {
830
+ var parts = dataUri.split(',');
831
+ var byteString = parts[0].indexOf('base64') >= 0 ? atob(parts[1]) : decodeURI(parts[1]);
832
+ var mimeString = parts[0].split(':')[1].split(';')[0];
833
+ var ia = new Uint8Array(byteString.length);
834
+ for (var i = 0; i < byteString.length; i++) {
835
+ ia[i] = byteString.charCodeAt(i);
836
+ }
837
+ return new Blob([ia], {
838
+ type: mimeString
839
+ });
840
+ });
841
+ _defineProperty(_this, "startChildEdit", function (action, layer, featureId, updateField, displayField) {
842
+ var editConfig = (_this.props.theme.editConfig || {})[layer];
843
+ if (!editConfig) {
844
+ // eslint-disable-next-line
845
+ console.warn("No edit config found for linked edit layer " + layer);
846
+ } else {
847
+ _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
+ }
857
+ });
858
+ }
859
+ });
860
+ _defineProperty(_this, "finishChildEdit", function (feature) {
861
+ _this.props.clearEditContext(_this.state.childEdit.editContextId, _this.props.editContext.id);
862
+ if (feature && feature.id !== _this.state.childEdit.featureId) {
863
+ _this.state.childEdit.updateField(feature.id);
864
+ }
865
+ _this.setState({
866
+ childEdit: null
867
+ });
868
+ });
869
+ _this.form = null;
870
+ return _this;
871
+ }
872
+ _inherits(AttributeForm, _React$Component);
873
+ return _createClass(AttributeForm, [{
874
+ key: "componentDidUpdate",
875
+ value: function componentDidUpdate(prevProps, prevState) {
876
+ var _this2 = this;
877
+ if (prevProps.editContext.changed !== this.props.editContext.changed) {
878
+ this.props.setCurrentTaskBlocked(this.props.editContext.changed === true, LocaleUtils.tr("editing.unsavedchanged"));
879
+ }
880
+ if ((!this.props.editContext.feature || this.props.editContext.changed) && this.state.deleteClicked) {
881
+ this.setState({
882
+ deleteClicked: false
883
+ });
884
+ }
885
+ // Reload relation values if necessary
886
+ var feature = this.props.editContext.feature;
887
+ var prevFeature = prevProps.editContext.feature;
888
+ if ((!this.props.editContext.changed || !feature.relationValues) && (this.state.relationTables !== prevState.relationTables || feature.id !== (prevFeature || {}).id)) {
889
+ this.loadRelationValues(this.props.editContext.feature, function (newFeature) {
890
+ _this2.props.setEditContext(_this2.props.editContext.id, {
891
+ feature: newFeature
892
+ });
893
+ });
894
+ // Re-validate feature field constraints
895
+ this.validateFieldConstraints(this.props.editContext.feature);
896
+ }
897
+ }
898
+ }]);
899
+ }(React.Component);
900
+ _defineProperty(AttributeForm, "propTypes", {
901
+ childPickFilter: PropTypes.func,
902
+ clearEditContext: PropTypes.func,
903
+ deleteLabel: PropTypes.string,
904
+ editConfig: PropTypes.object,
905
+ editContext: PropTypes.object,
906
+ hideDelete: PropTypes.bool,
907
+ iface: PropTypes.object,
908
+ map: PropTypes.object,
909
+ onCommit: PropTypes.func,
910
+ onDelete: PropTypes.func,
911
+ onDiscard: PropTypes.func,
912
+ readOnly: PropTypes.bool,
913
+ refreshLayer: PropTypes.func,
914
+ report: PropTypes.bool,
915
+ setCurrentTaskBlocked: PropTypes.func,
916
+ setEditContext: PropTypes.func,
917
+ theme: PropTypes.object,
918
+ touchFriendly: PropTypes.bool
919
+ });
920
+ _defineProperty(AttributeForm, "defaultProps", {
921
+ touchFriendly: true
922
+ });
923
+ export default connect(function (state) {
924
+ return {
925
+ map: state.map,
926
+ theme: state.theme.current
927
+ };
928
+ }, {
929
+ clearEditContext: clearEditContext,
930
+ setEditContext: setEditContext,
931
+ setCurrentTaskBlocked: setCurrentTaskBlocked,
932
+ refreshLayer: refreshLayer
933
+ })(AttributeForm);