qwc2 2025.10.13 → 2025.10.15

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 +768 -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,94 +1,428 @@
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 _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 _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 _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 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ 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); }
13
+ /**
2
14
  * Copyright 2017-2024 Sourcepole AG
3
15
  * All rights reserved.
4
16
  *
5
17
  * This source code is licensed under the BSD-style license found in the
6
18
  * LICENSE file in the root directory of this source tree.
7
- *//**
19
+ */
20
+
21
+ /**
8
22
  * NOTE: This sample editing interface is designed to work with the counterpart at
9
23
  * https://github.com/qwc-services/qwc-data-service
10
- */import axios from"axios";import isEmpty from"lodash.isempty";import ConfigUtils from"./ConfigUtils";import{computeExpressionFields}from"./EditingUtils";import LocaleUtils from"./LocaleUtils";var EditingInterface={buildErrMsg:function buildErrMsg(err){var message=LocaleUtils.tr("editing.commitfailed");if(err.response&&err.response.data&&err.response.data.message){message=err.response.data.message;if(!isEmpty(err.response.data.geometry_errors)){message+=":\n";message+=err.response.data.geometry_errors.map(function(entry){var entrymsg=" - "+entry.reason;if(entry.location){entrymsg+=" at "+entry.location}return entrymsg})}if(!isEmpty(err.response.data.data_errors)){message+=":\n - "+err.response.data.data_errors.join("\n - ")}if(!isEmpty(err.response.data.validation_errors)){message+=":\n - "+err.response.data.validation_errors.join("\n - ")}if(!isEmpty(err.response.data.attachment_errors)){message+=":\n - "+err.response.data.attachment_errors.join("\n - ")}}else if(err.response&&err.response.statusText){message+=": "+err.response.statusText}return message},/**
11
- * Gets features at the specified map position.
12
- *
13
- * @param editConfig The edit config of the dataset to query features from
14
- * @param mapPos The [x, y] map position
15
- * @param mapCrs The CRS of the map, as an EPSG code
16
- * @param mapScale The scale denominator, used to compute the pick tolerance
17
- * @param dpi The screen dpi, used to compute the pick tolerance
18
- * @param callback Callback invoked with the picked features, taking `{features: [...]}` on success and `null` on failure
19
- * @param filter An optional feature attribute filter expression
20
- * @param filterGeom An optional filter geometry
21
- */getFeature:function getFeature(editConfig,mapPos,mapCrs,mapScale,dpi,callback){var filter=arguments.length>6&&arguments[6]!==undefined?arguments[6]:null;var filterGeom=arguments.length>7&&arguments[7]!==undefined?arguments[7]:null;var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/";// 10px tolerance
22
- var tol=10/dpi*0.0254*mapScale;var bbox=mapPos[0]-tol+","+(mapPos[1]-tol)+","+(mapPos[0]+tol)+","+(mapPos[1]+tol);var params={bbox:bbox,crs:mapCrs,filter:filter?JSON.stringify(filter):undefined,filter_geom:filterGeom?JSON.stringify(_objectSpread(_objectSpread({},filterGeom),{},{crs:{type:"name",properties:{name:mapCrs}}})):undefined};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(requestUrl,{headers:headers,params:params}).then(function(response){var _response$data;if(!isEmpty(response===null||response===void 0||(_response$data=response.data)===null||_response$data===void 0?void 0:_response$data.features)){var version=+new Date;var promises=response.data.features.map(function(feature){return new Promise(function(resolve){computeExpressionFields(editConfig,feature,EditingInterface,mapCrs,function(newfeature){return resolve(_objectSpread(_objectSpread({},newfeature),{},{__version__:version}))})})});Promise.all(promises).then(function(features){return callback({features:features})})}else{callback(null)}})["catch"](function(){callback(null)})},/**
23
- * Queries a feature by id
24
- *
25
- * @param editConfig The edit config of the dataset to query the feature from
26
- * @param featureId The feature id
27
- * @param mapCrs The CRS of the map, as an EPSG code
28
- * @param callback Callback invoked with the picked feature, taking `{<feature>}` on success and `null` on failure
29
- */getFeatureById:function getFeatureById(editConfig,featureId,mapCrs,callback){var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/"+featureId;var params={crs:mapCrs};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(requestUrl,{headers:headers,params:params}).then(function(response){computeExpressionFields(editConfig,response.data,EditingInterface,mapCrs,function(newfeature){return callback(_objectSpread(_objectSpread({},newfeature),{},{__version__:+new Date}))})})["catch"](function(){callback(null)})},/**
30
- * Gets the dataset features
31
- *
32
- * @param editConfig The edit config of the dataset to query features from
33
- * @param mapCrs The CRS of the map, as an EPSG code
34
- * @param callback Callback invoked with the picked features, taking `{features: [...]}` on success and `null` on failure
35
- * @param filter An optional feature attribute filter expression
36
- * @param filterGeom An optional filter geometry
37
- */getFeatures:function getFeatures(editConfig,mapCrs,callback){var bbox=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var filter=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;var filterGeom=arguments.length>5&&arguments[5]!==undefined?arguments[5]:null;var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/";var params={crs:mapCrs,bbox:bbox?bbox.join(","):undefined,filter:filter?JSON.stringify(filter):undefined,filter_geom:filterGeom?JSON.stringify(_objectSpread(_objectSpread({},filterGeom),{},{crs:{type:"name",properties:{name:mapCrs}}})):undefined};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(requestUrl,{headers:headers,params:params}).then(function(response){var _response$data2;if(Array.isArray(response===null||response===void 0||(_response$data2=response.data)===null||_response$data2===void 0?void 0:_response$data2.features)){var version=+new Date;var promises=response.data.features.map(function(feature){return new Promise(function(resolve){computeExpressionFields(editConfig,feature,EditingInterface,mapCrs,function(newfeature){return resolve(_objectSpread(_objectSpread({},newfeature),{},{__version__:version}))})})});Promise.all(promises).then(function(features){return callback({features:features})})}else{callback(null)}})["catch"](function(){return callback(null)})},/**
38
- * Query the extent of the dataset features
39
- * @param editConfig The edit config of the dataset to query features from
40
- * @param mapCrs The CRS of the map, as an EPSG code
41
- * @param callback Callback invoked with the feature extent, taking `{bbox: [xmin, ymin, xmax, ymax]}` on success and `null` on failure
42
- * @param filter An optional feature attribute filter expression
43
- * @param filterGeom An optional filter geometry
44
- */getExtent:function getExtent(editConfig,mapCrs,callback){var filter=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var filterGeom=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/extent";var params={crs:mapCrs,filter:filter?JSON.stringify(filter):undefined,filter_geom:filterGeom?JSON.stringify(_objectSpread(_objectSpread({},filterGeom),{},{crs:{type:"name",properties:{name:mapCrs}}})):undefined};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(requestUrl,{headers:headers,params:params}).then(function(response){callback(response.data)})["catch"](function(){callback(null)})},/**
45
- * Adds a feature to the dataset
46
- * @param editConfig The edit config of the dataset to add the feature to
47
- * @param mapCrs The CRS of the map, as an EPSG code
48
- * @param featureData A FormData instance, with:
49
- * - A 'feature' entry containing the GeoJSON serialized feature
50
- * - Zero or more 'file:' prefixed file upload entries
51
- * - Zero or more 'relfile:' prefixed file upload entries
52
- * - Optionally a 'g-recaptcha-response' entry with the captcha response
53
- * @param callback Callback invoked with the added feature, taking `(true, {<feature>}` on success and `(false, <Error Message>}` on failure
54
- */addFeatureMultipart:function addFeatureMultipart(editConfig,mapCrs,featureData,callback){var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/multipart";var headers={"Content-Type":"multipart/form-data","Accept-Language":LocaleUtils.lang()};axios.post(requestUrl,featureData,{headers:headers}).then(function(response){computeExpressionFields(editConfig,response.data,EditingInterface,mapCrs,function(newfeature){return callback(true,_objectSpread(_objectSpread({},newfeature),{},{__version__:+new Date}))})})["catch"](function(err){callback(false,EditingInterface.buildErrMsg(err))})},/**
55
- * Edits a feature of the dataset
56
- * @param editConfig The edit config of the edited dataset
57
- * @param mapCrs The CRS of the map, as an EPSG code
58
- * @param featureId The ID of the edited feature
59
- * @param featureData A FormData instance, with:
60
- * - A 'feature' entry containing the GeoJSON serialized feature
61
- * - Zero or more 'file:' prefixed file upload entries
62
- * - Zero or more 'relfile:' prefixed file upload entries
63
- * - Optionally a 'g-recaptcha-response' entry with the captcha response
64
- * @param callback Callback invoked with the edited feature, taking `(true, {<feature>}` on success and `(false, <Error Message>}` on failure
65
- */editFeatureMultipart:function editFeatureMultipart(editConfig,mapCrs,featureId,featureData,callback){var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var requestUrl=editServiceUrl+"/"+editConfig.editDataset+"/multipart/"+featureId;var headers={"Content-Type":"multipart/form-data","Accept-Language":LocaleUtils.lang()};axios.put(requestUrl,featureData,{headers:headers}).then(function(response){computeExpressionFields(editConfig,response.data,EditingInterface,mapCrs,function(newfeature){return callback(true,_objectSpread(_objectSpread({},newfeature),{},{__version__:+new Date}))})})["catch"](function(err){callback(false,EditingInterface.buildErrMsg(err))})},/*
66
- layerId: The edit layer id
67
- featureId: The id of the feature to delete
68
- callback: function(success, result), if success = true, result is null, if success = false, result is an error message
69
- recaptchaResponse: Optional, captcha challenge response
70
- *//**
71
- * Deletes a feature from the dataset
72
- * @param editConfig The edit config of the dataset from which to delete the feature
73
- * @param featureId The ID of the edited feature
74
- * @param callback Callback invoked with the id of the deleted feature, taking `(true, <feature_id>` on success and `(false, <Error Message>}` on failure
75
- * @param recaptchaResponse Optional captcha challenge response
76
- */deleteFeature:function deleteFeature(editConfig,featureId,callback){var recaptchaResponse=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var req=editServiceUrl+"/"+editConfig.editDataset+"/"+featureId;var headers={"Accept-Language":LocaleUtils.lang()};var data={};if(recaptchaResponse){data["g-recaptcha-response"]=recaptchaResponse}axios["delete"](req,{headers:headers,data:data}).then(function(){callback(true,featureId)})["catch"](function(err){callback(false,EditingInterface.buildErrMsg(err))})},/**
77
- * Queries relation values of a feature
78
- * @param editConfig The edit config of the feature dataset
79
- * @param featureId The feature ID
80
- * @param mapCrs The CRS of the map, as an EPSG code
81
- * @param tables Comma separated string of relation table names
82
- * @param editConfigs The theme editConfig block, containing all theme dataset edit configs
83
- * @param callback Callback invoked with the relation values, taking `{<tablename>: {<relation_values>}}` on success and `{}` on failure
84
- */getRelations:function getRelations(editConfig,featureId,mapCrs,tables,editConfigs,callback){var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var req=editServiceUrl+"/"+editConfig.editDataset+"/"+featureId+"/relations";var params={tables:tables,crs:mapCrs};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(req,{headers:headers,params:params}).then(function(response){Promise.all(Object.entries(response.data).map(function(_ref){var _ref2=_slicedToArray(_ref,2),reldataset=_ref2[0],relvalues=_ref2[1];return new Promise(function(resolveTable){Promise.all(relvalues.features.map(function(feature){return new Promise(function(resolveFeature){var relEditConfig=Object.values(editConfigs).find(function(entry){return entry.editDataset===reldataset});computeExpressionFields(relEditConfig,feature,EditingInterface,mapCrs,resolveFeature)})})).then(function(newfeatures){return resolveTable([reldataset,_objectSpread(_objectSpread({},relvalues),{},{features:newfeatures})])})})})).then(function(entries){return callback(Object.fromEntries(entries))})})["catch"](function(){return callback({})})},/**
85
- * Query key-value-pairs of a key-value-relation
86
- * @param keyvalues The keyval string `<keyvaldataset>:<keyfield>:<valuefield>`
87
- * @param callback Callback invoked with the key-value pairs, taking `{keyvalues: {<keyvaldataset>: [{key: <key>, value: <value>}]}}` on success and `{}` on failure
88
- * @param filter An optional filter expression, as `[[["<name>", "<op>", <value>],"and|or",["<name>","<op>",<value>],...]]` (one filter expr per keyvalue entry)
89
- */getKeyValues:function getKeyValues(keyvalues,callback){var filter=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");var req=editServiceUrl+"/"+"keyvals?tables="+keyvalues;var params={filter:filter?JSON.stringify(filter):undefined};var headers={"Accept-Language":LocaleUtils.lang()};axios.get(req,{headers:headers,params:params}).then(function(response){callback(response.data)})["catch"](function(){return callback({})})},/**
90
- * Resolve an attachment value to a full URL
91
- *
92
- * @param dataset The dataset name
93
- * @param fileValue The attachment value
94
- */resolveAttachmentUrl:function resolveAttachmentUrl(dataset,fileValue){var editServiceUrl=ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/,"");return editServiceUrl+"/"+dataset+"/attachment?file="+encodeURIComponent(fileValue)}};export default EditingInterface;
24
+ */
25
+ import axios from 'axios';
26
+ import isEmpty from 'lodash.isempty';
27
+ import ConfigUtils from './ConfigUtils';
28
+ import { computeExpressionFields } from './EditingUtils';
29
+ import LocaleUtils from './LocaleUtils';
30
+ var EditingInterface = {
31
+ buildErrMsg: function buildErrMsg(err) {
32
+ var message = LocaleUtils.tr("editing.commitfailed");
33
+ if (err.response && err.response.data && err.response.data.message) {
34
+ message = err.response.data.message;
35
+ if (!isEmpty(err.response.data.geometry_errors)) {
36
+ message += ":\n";
37
+ message += err.response.data.geometry_errors.map(function (entry) {
38
+ var entrymsg = " - " + entry.reason;
39
+ if (entry.location) {
40
+ entrymsg += " at " + entry.location;
41
+ }
42
+ return entrymsg;
43
+ });
44
+ }
45
+ if (!isEmpty(err.response.data.data_errors)) {
46
+ message += ":\n - " + err.response.data.data_errors.join("\n - ");
47
+ }
48
+ if (!isEmpty(err.response.data.validation_errors)) {
49
+ message += ":\n - " + err.response.data.validation_errors.join("\n - ");
50
+ }
51
+ if (!isEmpty(err.response.data.attachment_errors)) {
52
+ message += ":\n - " + err.response.data.attachment_errors.join("\n - ");
53
+ }
54
+ } else if (err.response && err.response.statusText) {
55
+ message += ": " + err.response.statusText;
56
+ }
57
+ return message;
58
+ },
59
+ /**
60
+ * Gets features at the specified map position.
61
+ *
62
+ * @param editConfig The edit config of the dataset to query features from
63
+ * @param mapPos The [x, y] map position
64
+ * @param mapCrs The CRS of the map, as an EPSG code
65
+ * @param mapScale The scale denominator, used to compute the pick tolerance
66
+ * @param dpi The screen dpi, used to compute the pick tolerance
67
+ * @param callback Callback invoked with the picked features, taking `{features: [...]}` on success and `null` on failure
68
+ * @param filter An optional feature attribute filter expression
69
+ * @param filterGeom An optional filter geometry
70
+ */
71
+ getFeature: function getFeature(editConfig, mapPos, mapCrs, mapScale, dpi, callback) {
72
+ var filter = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
73
+ var filterGeom = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
74
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
75
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + '/';
76
+
77
+ // 10px tolerance
78
+ var tol = 10.0 / dpi * 0.0254 * mapScale;
79
+ var bbox = mapPos[0] - tol + "," + (mapPos[1] - tol) + "," + (mapPos[0] + tol) + "," + (mapPos[1] + tol);
80
+ var params = {
81
+ bbox: bbox,
82
+ crs: mapCrs,
83
+ filter: filter ? JSON.stringify(filter) : undefined,
84
+ filter_geom: filterGeom ? JSON.stringify(_objectSpread(_objectSpread({}, filterGeom), {}, {
85
+ crs: {
86
+ type: "name",
87
+ properties: {
88
+ name: mapCrs
89
+ }
90
+ }
91
+ })) : undefined
92
+ };
93
+ var headers = {
94
+ "Accept-Language": LocaleUtils.lang()
95
+ };
96
+ axios.get(requestUrl, {
97
+ headers: headers,
98
+ params: params
99
+ }).then(function (response) {
100
+ var _response$data;
101
+ if (!isEmpty(response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.features)) {
102
+ var version = +new Date();
103
+ var promises = response.data.features.map(function (feature) {
104
+ return new Promise(function (resolve) {
105
+ computeExpressionFields(editConfig, feature, EditingInterface, mapCrs, function (newfeature) {
106
+ return resolve(_objectSpread(_objectSpread({}, newfeature), {}, {
107
+ __version__: version
108
+ }));
109
+ });
110
+ });
111
+ });
112
+ Promise.all(promises).then(function (features) {
113
+ return callback({
114
+ features: features
115
+ });
116
+ });
117
+ } else {
118
+ callback(null);
119
+ }
120
+ })["catch"](function () {
121
+ callback(null);
122
+ });
123
+ },
124
+ /**
125
+ * Queries a feature by id
126
+ *
127
+ * @param editConfig The edit config of the dataset to query the feature from
128
+ * @param featureId The feature id
129
+ * @param mapCrs The CRS of the map, as an EPSG code
130
+ * @param callback Callback invoked with the picked feature, taking `{<feature>}` on success and `null` on failure
131
+ */
132
+ getFeatureById: function getFeatureById(editConfig, featureId, mapCrs, callback) {
133
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
134
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + '/' + featureId;
135
+ var params = {
136
+ crs: mapCrs
137
+ };
138
+ var headers = {
139
+ "Accept-Language": LocaleUtils.lang()
140
+ };
141
+ axios.get(requestUrl, {
142
+ headers: headers,
143
+ params: params
144
+ }).then(function (response) {
145
+ computeExpressionFields(editConfig, response.data, EditingInterface, mapCrs, function (newfeature) {
146
+ return callback(_objectSpread(_objectSpread({}, newfeature), {}, {
147
+ __version__: +new Date()
148
+ }));
149
+ });
150
+ })["catch"](function () {
151
+ callback(null);
152
+ });
153
+ },
154
+ /**
155
+ * Gets the dataset features
156
+ *
157
+ * @param editConfig The edit config of the dataset to query features from
158
+ * @param mapCrs The CRS of the map, as an EPSG code
159
+ * @param callback Callback invoked with the picked features, taking `{features: [...]}` on success and `null` on failure
160
+ * @param filter An optional feature attribute filter expression
161
+ * @param filterGeom An optional filter geometry
162
+ */
163
+ getFeatures: function getFeatures(editConfig, mapCrs, callback) {
164
+ var bbox = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
165
+ var filter = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
166
+ var filterGeom = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
167
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
168
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + '/';
169
+ var params = {
170
+ crs: mapCrs,
171
+ bbox: bbox ? bbox.join(",") : undefined,
172
+ filter: filter ? JSON.stringify(filter) : undefined,
173
+ filter_geom: filterGeom ? JSON.stringify(_objectSpread(_objectSpread({}, filterGeom), {}, {
174
+ crs: {
175
+ type: "name",
176
+ properties: {
177
+ name: mapCrs
178
+ }
179
+ }
180
+ })) : undefined
181
+ };
182
+ var headers = {
183
+ "Accept-Language": LocaleUtils.lang()
184
+ };
185
+ axios.get(requestUrl, {
186
+ headers: headers,
187
+ params: params
188
+ }).then(function (response) {
189
+ var _response$data2;
190
+ if (Array.isArray(response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.features)) {
191
+ var version = +new Date();
192
+ var promises = response.data.features.map(function (feature) {
193
+ return new Promise(function (resolve) {
194
+ computeExpressionFields(editConfig, feature, EditingInterface, mapCrs, function (newfeature) {
195
+ return resolve(_objectSpread(_objectSpread({}, newfeature), {}, {
196
+ __version__: version
197
+ }));
198
+ });
199
+ });
200
+ });
201
+ Promise.all(promises).then(function (features) {
202
+ return callback({
203
+ features: features
204
+ });
205
+ });
206
+ } else {
207
+ callback(null);
208
+ }
209
+ })["catch"](function () {
210
+ return callback(null);
211
+ });
212
+ },
213
+ /**
214
+ * Query the extent of the dataset features
215
+ * @param editConfig The edit config of the dataset to query features from
216
+ * @param mapCrs The CRS of the map, as an EPSG code
217
+ * @param callback Callback invoked with the feature extent, taking `{bbox: [xmin, ymin, xmax, ymax]}` on success and `null` on failure
218
+ * @param filter An optional feature attribute filter expression
219
+ * @param filterGeom An optional filter geometry
220
+ */
221
+ getExtent: function getExtent(editConfig, mapCrs, callback) {
222
+ var filter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
223
+ var filterGeom = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
224
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
225
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + "/extent";
226
+ var params = {
227
+ crs: mapCrs,
228
+ filter: filter ? JSON.stringify(filter) : undefined,
229
+ filter_geom: filterGeom ? JSON.stringify(_objectSpread(_objectSpread({}, filterGeom), {}, {
230
+ crs: {
231
+ type: "name",
232
+ properties: {
233
+ name: mapCrs
234
+ }
235
+ }
236
+ })) : undefined
237
+ };
238
+ var headers = {
239
+ "Accept-Language": LocaleUtils.lang()
240
+ };
241
+ axios.get(requestUrl, {
242
+ headers: headers,
243
+ params: params
244
+ }).then(function (response) {
245
+ callback(response.data);
246
+ })["catch"](function () {
247
+ callback(null);
248
+ });
249
+ },
250
+ /**
251
+ * Adds a feature to the dataset
252
+ * @param editConfig The edit config of the dataset to add the feature to
253
+ * @param mapCrs The CRS of the map, as an EPSG code
254
+ * @param featureData A FormData instance, with:
255
+ * - A 'feature' entry containing the GeoJSON serialized feature
256
+ * - Zero or more 'file:' prefixed file upload entries
257
+ * - Zero or more 'relfile:' prefixed file upload entries
258
+ * - Optionally a 'g-recaptcha-response' entry with the captcha response
259
+ * @param callback Callback invoked with the added feature, taking `(true, {<feature>}` on success and `(false, <Error Message>}` on failure
260
+ */
261
+ addFeatureMultipart: function addFeatureMultipart(editConfig, mapCrs, featureData, callback) {
262
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
263
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + '/multipart';
264
+ var headers = {
265
+ "Content-Type": "multipart/form-data",
266
+ "Accept-Language": LocaleUtils.lang()
267
+ };
268
+ axios.post(requestUrl, featureData, {
269
+ headers: headers
270
+ }).then(function (response) {
271
+ computeExpressionFields(editConfig, response.data, EditingInterface, mapCrs, function (newfeature) {
272
+ return callback(true, _objectSpread(_objectSpread({}, newfeature), {}, {
273
+ __version__: +new Date()
274
+ }));
275
+ });
276
+ })["catch"](function (err) {
277
+ callback(false, EditingInterface.buildErrMsg(err));
278
+ });
279
+ },
280
+ /**
281
+ * Edits a feature of the dataset
282
+ * @param editConfig The edit config of the edited dataset
283
+ * @param mapCrs The CRS of the map, as an EPSG code
284
+ * @param featureId The ID of the edited feature
285
+ * @param featureData A FormData instance, with:
286
+ * - A 'feature' entry containing the GeoJSON serialized feature
287
+ * - Zero or more 'file:' prefixed file upload entries
288
+ * - Zero or more 'relfile:' prefixed file upload entries
289
+ * - Optionally a 'g-recaptcha-response' entry with the captcha response
290
+ * @param callback Callback invoked with the edited feature, taking `(true, {<feature>}` on success and `(false, <Error Message>}` on failure
291
+ */
292
+ editFeatureMultipart: function editFeatureMultipart(editConfig, mapCrs, featureId, featureData, callback) {
293
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
294
+ var requestUrl = editServiceUrl + '/' + editConfig.editDataset + '/multipart/' + featureId;
295
+ var headers = {
296
+ "Content-Type": "multipart/form-data",
297
+ "Accept-Language": LocaleUtils.lang()
298
+ };
299
+ axios.put(requestUrl, featureData, {
300
+ headers: headers
301
+ }).then(function (response) {
302
+ computeExpressionFields(editConfig, response.data, EditingInterface, mapCrs, function (newfeature) {
303
+ return callback(true, _objectSpread(_objectSpread({}, newfeature), {}, {
304
+ __version__: +new Date()
305
+ }));
306
+ });
307
+ })["catch"](function (err) {
308
+ callback(false, EditingInterface.buildErrMsg(err));
309
+ });
310
+ },
311
+ /*
312
+ layerId: The edit layer id
313
+ featureId: The id of the feature to delete
314
+ callback: function(success, result), if success = true, result is null, if success = false, result is an error message
315
+ recaptchaResponse: Optional, captcha challenge response
316
+ */
317
+ /**
318
+ * Deletes a feature from the dataset
319
+ * @param editConfig The edit config of the dataset from which to delete the feature
320
+ * @param featureId The ID of the edited feature
321
+ * @param callback Callback invoked with the id of the deleted feature, taking `(true, <feature_id>` on success and `(false, <Error Message>}` on failure
322
+ * @param recaptchaResponse Optional captcha challenge response
323
+ */
324
+ deleteFeature: function deleteFeature(editConfig, featureId, callback) {
325
+ var recaptchaResponse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
326
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
327
+ var req = editServiceUrl + '/' + editConfig.editDataset + '/' + featureId;
328
+ var headers = {
329
+ "Accept-Language": LocaleUtils.lang()
330
+ };
331
+ var data = {};
332
+ if (recaptchaResponse) {
333
+ data['g-recaptcha-response'] = recaptchaResponse;
334
+ }
335
+ axios["delete"](req, {
336
+ headers: headers,
337
+ data: data
338
+ }).then(function () {
339
+ callback(true, featureId);
340
+ })["catch"](function (err) {
341
+ callback(false, EditingInterface.buildErrMsg(err));
342
+ });
343
+ },
344
+ /**
345
+ * Queries relation values of a feature
346
+ * @param editConfig The edit config of the feature dataset
347
+ * @param featureId The feature ID
348
+ * @param mapCrs The CRS of the map, as an EPSG code
349
+ * @param tables Comma separated string of relation table names
350
+ * @param editConfigs The theme editConfig block, containing all theme dataset edit configs
351
+ * @param callback Callback invoked with the relation values, taking `{<tablename>: {<relation_values>}}` on success and `{}` on failure
352
+ */
353
+ getRelations: function getRelations(editConfig, featureId, mapCrs, tables, editConfigs, callback) {
354
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
355
+ var req = editServiceUrl + '/' + editConfig.editDataset + '/' + featureId + "/relations";
356
+ var params = {
357
+ tables: tables,
358
+ crs: mapCrs
359
+ };
360
+ var headers = {
361
+ "Accept-Language": LocaleUtils.lang()
362
+ };
363
+ axios.get(req, {
364
+ headers: headers,
365
+ params: params
366
+ }).then(function (response) {
367
+ Promise.all(Object.entries(response.data).map(function (_ref) {
368
+ var _ref2 = _slicedToArray(_ref, 2),
369
+ reldataset = _ref2[0],
370
+ relvalues = _ref2[1];
371
+ return new Promise(function (resolveTable) {
372
+ Promise.all(relvalues.features.map(function (feature) {
373
+ return new Promise(function (resolveFeature) {
374
+ var relEditConfig = Object.values(editConfigs).find(function (entry) {
375
+ return entry.editDataset === reldataset;
376
+ });
377
+ computeExpressionFields(relEditConfig, feature, EditingInterface, mapCrs, resolveFeature);
378
+ });
379
+ })).then(function (newfeatures) {
380
+ return resolveTable([reldataset, _objectSpread(_objectSpread({}, relvalues), {}, {
381
+ features: newfeatures
382
+ })]);
383
+ });
384
+ });
385
+ })).then(function (entries) {
386
+ return callback(Object.fromEntries(entries));
387
+ });
388
+ })["catch"](function () {
389
+ return callback({});
390
+ });
391
+ },
392
+ /**
393
+ * Query key-value-pairs of a key-value-relation
394
+ * @param keyvalues The keyval string `<keyvaldataset>:<keyfield>:<valuefield>`
395
+ * @param callback Callback invoked with the key-value pairs, taking `{keyvalues: {<keyvaldataset>: [{key: <key>, value: <value>}]}}` on success and `{}` on failure
396
+ * @param filter An optional filter expression, as `[[["<name>", "<op>", <value>],"and|or",["<name>","<op>",<value>],...]]` (one filter expr per keyvalue entry)
397
+ */
398
+ getKeyValues: function getKeyValues(keyvalues, callback) {
399
+ var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
400
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
401
+ var req = editServiceUrl + '/' + "keyvals?tables=" + keyvalues;
402
+ var params = {
403
+ filter: filter ? JSON.stringify(filter) : undefined
404
+ };
405
+ var headers = {
406
+ "Accept-Language": LocaleUtils.lang()
407
+ };
408
+ axios.get(req, {
409
+ headers: headers,
410
+ params: params
411
+ }).then(function (response) {
412
+ callback(response.data);
413
+ })["catch"](function () {
414
+ return callback({});
415
+ });
416
+ },
417
+ /**
418
+ * Resolve an attachment value to a full URL
419
+ *
420
+ * @param dataset The dataset name
421
+ * @param fileValue The attachment value
422
+ */
423
+ resolveAttachmentUrl: function resolveAttachmentUrl(dataset, fileValue) {
424
+ var editServiceUrl = ConfigUtils.getConfigProp("editServiceUrl").replace(/\/$/, '');
425
+ return editServiceUrl + '/' + dataset + "/attachment?file=" + encodeURIComponent(fileValue);
426
+ }
427
+ };
428
+ export default EditingInterface;