@opengeoweb/warnings 6.1.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useContext, useRef, useCallback, useDebugValue, Fragment, useState, useEffect } from 'react';
3
3
  import 'react-dom';
4
- import { Polygons, Edit, Delete } from '@opengeoweb/theme';
5
- import { uiTypes, uiSelectors, uiActions, layerSelectors, drawSelectors, mapStoreActions, drawActions, snackbarActions } from '@opengeoweb/store';
6
- import { MapControlButton, useSetupDialog } from '@opengeoweb/core';
7
- import { dateUtils, ToggleMenu, ToolContainerDraggable, AlertBanner, calculateDialogSizeAndPosition } from '@opengeoweb/shared';
8
- import { List, Typography, ListItem, MenuItem, ListItemText, Paper, ListItemButton, Box, Stack } from '@mui/material';
4
+ import { Polygons } from '@opengeoweb/theme';
5
+ import { uiTypes, uiSelectors, layerSelectors, drawSelectors, uiActions, drawActions, mapStoreActions, snackbarActions } from '@opengeoweb/store';
6
+ import { MapControlButton } from '@opengeoweb/webmap-react';
7
+ import { useAreaDrawDialogAction, useSetupDialog } from '@opengeoweb/core';
8
+ import { dateUtils, ToolContainerDraggable, AlertBanner, calculateDialogSizeAndPosition } from '@opengeoweb/shared';
9
+ import { Typography, List, ListItem, Paper, ListItemButton, Box, Stack, LinearProgress } from '@mui/material';
9
10
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
10
11
 
11
12
  var shim = {exports: {}};
@@ -1198,32 +1199,46 @@ initializeUseSelector(withSelector.exports.useSyncExternalStoreWithSelector);
1198
1199
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1199
1200
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1200
1201
  * */
1201
- var dialogType$1 = uiTypes.DialogTypes.AreaManager;
1202
+ var areaDialogType = uiTypes.DialogTypes.AreaManager;
1202
1203
  var AreaManagerMapButtonConnect = function AreaManagerMapButtonConnect(_ref) {
1203
1204
  var mapId = _ref.mapId,
1204
1205
  _ref$source = _ref.source,
1205
1206
  source = _ref$source === void 0 ? 'app' : _ref$source;
1206
- var dispatch = useDispatch();
1207
+ var _useAreaDrawDialogAct = useAreaDrawDialogAction({
1208
+ mapId: mapId,
1209
+ source: source
1210
+ }),
1211
+ closeDrawDialog = _useAreaDrawDialogAct.closeDrawDialog,
1212
+ openAreaDialog = _useAreaDrawDialogAct.openAreaDialog,
1213
+ closeAreaDialog = _useAreaDrawDialogAct.closeAreaDialog;
1207
1214
  var mapIdForCurrentlyOpenDialog = useSelector(function (store) {
1208
- return uiSelectors.getDialogMapId(store, dialogType$1);
1215
+ return uiSelectors.getDialogMapId(store, areaDialogType);
1209
1216
  });
1210
- var dialogIsOpen = useSelector(function (store) {
1211
- return uiSelectors.getisDialogOpen(store, dialogType$1);
1217
+ var isAreaDialogOpen = useSelector(function (store) {
1218
+ return uiSelectors.getisDialogOpen(store, areaDialogType);
1212
1219
  });
1220
+ var drawingDialogType = "".concat(uiTypes.DialogTypes.DockedDrawingTool, "-").concat(mapId);
1221
+ var isDrawDialogOpen = useSelector(function (store) {
1222
+ return uiSelectors.getisDialogOpen(store, drawingDialogType);
1223
+ });
1224
+ var openAreasDialog = function openAreasDialog() {
1225
+ // close drawing dialog if open
1226
+ if (isDrawDialogOpen) {
1227
+ closeDrawDialog();
1228
+ }
1229
+ // open area manager dialog
1230
+ openAreaDialog();
1231
+ };
1232
+ var onClick = function onClick() {
1233
+ var openDialogForAnotherMap = mapIdForCurrentlyOpenDialog !== mapId;
1234
+ var shouldOpen = openDialogForAnotherMap || !isAreaDialogOpen;
1235
+ shouldOpen ? openAreasDialog() : closeAreaDialog();
1236
+ };
1213
1237
  return /*#__PURE__*/React__default.createElement(MapControlButton, {
1214
1238
  "aria-label": "Area Manager Button for ".concat(mapId),
1215
1239
  title: "Area Manager",
1216
- onClick: function onClick() {
1217
- var openDialogForAnotherMap = mapIdForCurrentlyOpenDialog !== mapId;
1218
- var shouldOpen = openDialogForAnotherMap || !dialogIsOpen;
1219
- dispatch(uiActions.setActiveMapIdForDialog({
1220
- type: dialogType$1,
1221
- mapId: mapId,
1222
- setOpen: shouldOpen,
1223
- source: source
1224
- }));
1225
- },
1226
- isActive: mapIdForCurrentlyOpenDialog === mapId && dialogIsOpen
1240
+ onClick: onClick,
1241
+ isActive: mapIdForCurrentlyOpenDialog === mapId && isAreaDialogOpen
1227
1242
  }, /*#__PURE__*/React__default.createElement(Polygons, null));
1228
1243
  };
1229
1244
 
@@ -1636,12 +1651,21 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1636
1651
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1637
1652
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1638
1653
  * */
1654
+ var NO_AREAS_FOUND = 'No areas found';
1639
1655
  var Drawings = function Drawings(_ref) {
1640
1656
  var drawings = _ref.drawings,
1641
1657
  onClickDrawing = _ref.onClickDrawing,
1642
- onClickEdit = _ref.onClickEdit,
1643
1658
  activeDrawing = _ref.activeDrawing;
1644
1659
  var lastHeaderRef = React__default.useRef('');
1660
+ if (drawings.length === 0) {
1661
+ return /*#__PURE__*/React__default.createElement(Typography, {
1662
+ sx: {
1663
+ paddingLeft: '16px',
1664
+ paddingTop: '8px'
1665
+ },
1666
+ variant: "body1"
1667
+ }, NO_AREAS_FOUND);
1668
+ }
1645
1669
  return /*#__PURE__*/React__default.createElement(List, null, drawings.map(function (drawing) {
1646
1670
  var drawingDate = dateUtils.isoStringToDate(drawing.lastUpdatedTime);
1647
1671
  var header = dateUtils.dateToString(drawingDate, 'EEEE, MMMM dd', true);
@@ -1655,17 +1679,7 @@ var Drawings = function Drawings(_ref) {
1655
1679
  },
1656
1680
  variant: "caption"
1657
1681
  }, header), /*#__PURE__*/React__default.createElement(ListItem, {
1658
- disablePadding: true,
1659
- secondaryAction: /*#__PURE__*/React__default.createElement(ToggleMenu, {
1660
- menuTitle: "Area options",
1661
- tooltipTitle: "Area options",
1662
- menuPosition: "bottom",
1663
- "aria-label": "Options"
1664
- }, /*#__PURE__*/React__default.createElement(MenuItem, {
1665
- onClick: function onClick() {
1666
- return onClickEdit(drawing.id);
1667
- }
1668
- }, /*#__PURE__*/React__default.createElement(ListItemText, null, "Edit"), /*#__PURE__*/React__default.createElement(Edit, null)), /*#__PURE__*/React__default.createElement(MenuItem, null, /*#__PURE__*/React__default.createElement(ListItemText, null, "Delete"), " ", /*#__PURE__*/React__default.createElement(Delete, null)))
1682
+ disablePadding: true
1669
1683
  }, /*#__PURE__*/React__default.createElement(Paper, {
1670
1684
  elevation: 1,
1671
1685
  sx: {
@@ -1738,25 +1752,17 @@ var AreaManager = function AreaManager(_ref) {
1738
1752
  drawingListItems = _ref.drawingListItems,
1739
1753
  _ref$onClickDrawing = _ref.onClickDrawing,
1740
1754
  onClickDrawing = _ref$onClickDrawing === void 0 ? function () {} : _ref$onClickDrawing,
1741
- _ref$onUnMount = _ref.onUnMount,
1742
- onUnMount = _ref$onUnMount === void 0 ? function () {} : _ref$onUnMount,
1743
- _ref$onEditDrawing = _ref.onEditDrawing,
1744
- onEditDrawing = _ref$onEditDrawing === void 0 ? function () {} : _ref$onEditDrawing,
1745
1755
  _ref$activeDrawingId = _ref.activeDrawingId,
1746
1756
  activeDrawingId = _ref$activeDrawingId === void 0 ? '' : _ref$activeDrawingId,
1747
- error = _ref.error;
1757
+ error = _ref.error,
1758
+ _ref$isLoading = _ref.isLoading,
1759
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
1748
1760
  var minSize = DEFAULT_AREA_MANAGER_MIN_SIZE;
1749
1761
  var startSizeCalc = calculateStartSize(minSize, size, startPosition);
1750
1762
  var _React$useState = React.useState(startSizeCalc),
1751
1763
  _React$useState2 = _slicedToArray(_React$useState, 2),
1752
1764
  sizeInState = _React$useState2[0],
1753
1765
  setSizeInState = _React$useState2[1];
1754
- React.useEffect(function () {
1755
- return function () {
1756
- onUnMount();
1757
- };
1758
- // eslint-disable-next-line react-hooks/exhaustive-deps
1759
- }, []);
1760
1766
  return /*#__PURE__*/React.createElement(ToolContainerDraggable, {
1761
1767
  title: title,
1762
1768
  startSize: sizeInState,
@@ -1789,13 +1795,16 @@ var AreaManager = function AreaManager(_ref) {
1789
1795
  setSizeInState(dragSize);
1790
1796
  }
1791
1797
  }
1792
- }, error && /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AlertBanner, {
1798
+ }, isLoading && /*#__PURE__*/React.createElement(LinearProgress, {
1799
+ "data-testid": "loading-bar",
1800
+ color: "secondary"
1801
+ }), error && /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AlertBanner, {
1793
1802
  title: error,
1794
1803
  shouldClose: true
1795
- })), /*#__PURE__*/React.createElement(Drawings, {
1804
+ })), !isLoading && !error && /*#__PURE__*/React.createElement(Drawings, {
1796
1805
  drawings: drawingListItems,
1797
1806
  onClickDrawing: onClickDrawing,
1798
- onClickEdit: onEditDrawing,
1807
+ // onClickEdit={onEditDrawing}
1799
1808
  activeDrawing: activeDrawingId
1800
1809
  }));
1801
1810
  };
@@ -1817,6 +1826,10 @@ var AreaManager = function AreaManager(_ref) {
1817
1826
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1818
1827
  * */
1819
1828
  var API_NAME = 'warnings';
1829
+ var getIdFromUrl = function getIdFromUrl(url) {
1830
+ var splitString = url && url.split('/');
1831
+ return url && splitString[splitString.length - 2];
1832
+ };
1820
1833
  var getApiRoutes$1 = function getApiRoutes(axiosInstance) {
1821
1834
  return {
1822
1835
  getDrawings: function getDrawings() {
@@ -1829,7 +1842,10 @@ var getApiRoutes$1 = function getApiRoutes(axiosInstance) {
1829
1842
  return axiosInstance.post("/drawings/".concat(drawingId, "/"), data);
1830
1843
  },
1831
1844
  saveDrawingAs: function saveDrawingAs(data) {
1832
- return axiosInstance.post("/drawings/", data);
1845
+ return axiosInstance.post("/drawings/", data).then(function (response) {
1846
+ var headerLocation = response === null || response === void 0 ? void 0 : response.request.getResponseHeader('Location');
1847
+ return getIdFromUrl(headerLocation);
1848
+ });
1833
1849
  },
1834
1850
  deleteDrawing: function deleteDrawing(drawingId) {
1835
1851
  return axiosInstance.post("/drawings/".concat(drawingId, "?delete=true"));
@@ -1853,7 +1869,6 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
1853
1869
  var _useSetupDialog = useSetupDialog(dialogType, source),
1854
1870
  dialogOrder = _useSetupDialog.dialogOrder,
1855
1871
  setDialogOrder = _useSetupDialog.setDialogOrder,
1856
- onCloseDialog = _useSetupDialog.onCloseDialog,
1857
1872
  isDialogOpen = _useSetupDialog.isDialogOpen,
1858
1873
  uiSource = _useSetupDialog.uiSource,
1859
1874
  setFocused = _useSetupDialog.setFocused,
@@ -1863,6 +1878,11 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
1863
1878
  var mapId = useSelector(function (store) {
1864
1879
  return uiSelectors.getDialogMapId(store, dialogType);
1865
1880
  });
1881
+ var _useAreaDrawDialogAct = useAreaDrawDialogAction({
1882
+ mapId: mapId,
1883
+ source: source
1884
+ }),
1885
+ closeAreaDialog = _useAreaDrawDialogAct.closeAreaDialog;
1866
1886
  var geoJSONLayerId = "".concat(mapId, "-geosjon");
1867
1887
  var currentLayer = useSelector(function (store) {
1868
1888
  return layerSelectors.getLayerById(store, geoJSONLayerId);
@@ -1875,14 +1895,21 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
1875
1895
  _useState2 = _slicedToArray(_useState, 2),
1876
1896
  drawings = _useState2[0],
1877
1897
  setDrawings = _useState2[1];
1898
+ var _useState3 = useState(false),
1899
+ _useState4 = _slicedToArray(_useState3, 2),
1900
+ loading = _useState4[0],
1901
+ setLoading = _useState4[1];
1878
1902
  var fetchDrawings = function fetchDrawings() {
1879
1903
  uiActions.setErrorDialog({
1880
1904
  error: 'error.message',
1881
1905
  type: dialogType
1882
1906
  });
1907
+ setLoading(true);
1883
1908
  warningsApi.getDrawings().then(function (response) {
1909
+ setLoading(false);
1884
1910
  setDrawings(response.data);
1885
1911
  })["catch"](function (error) {
1912
+ setLoading(false);
1886
1913
  dispatch(uiActions.setErrorDialog({
1887
1914
  error: error.message,
1888
1915
  type: dialogType
@@ -1890,9 +1917,11 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
1890
1917
  });
1891
1918
  };
1892
1919
  useEffect(function () {
1893
- fetchDrawings();
1920
+ if (isDialogOpen) {
1921
+ fetchDrawings();
1922
+ }
1894
1923
  // eslint-disable-next-line react-hooks/exhaustive-deps
1895
- }, []);
1924
+ }, [isDialogOpen]);
1896
1925
  var deleteGeoJSONLayer = function deleteGeoJSONLayer() {
1897
1926
  dispatch(mapStoreActions.layerDelete({
1898
1927
  layerId: geoJSONLayerId,
@@ -1952,55 +1981,38 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
1952
1981
  }, _callee2);
1953
1982
  }));
1954
1983
  };
1955
- var openDrawTools = function openDrawTools(drawingId) {
1956
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1957
- var _yield$warningsApi$ge, data;
1958
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1959
- while (1) switch (_context3.prev = _context3.next) {
1960
- case 0:
1961
- _context3.prev = 0;
1962
- _context3.next = 3;
1963
- return warningsApi.getDrawingDetails(drawingId);
1964
- case 3:
1965
- _yield$warningsApi$ge = _context3.sent;
1966
- data = _yield$warningsApi$ge.data;
1967
- // update draw tool values
1968
- dispatch(drawActions.setDrawValues({
1969
- area: data.area,
1970
- areaName: data.name,
1971
- mapId: mapId,
1972
- id: drawingId
1973
- }));
1974
- // open draw dialog
1975
- dispatch(uiActions.setActiveMapIdForDialog({
1976
- type: "".concat(uiTypes.DialogTypes.DockedDrawingTool, "-").concat(mapId),
1977
- mapId: mapId,
1978
- setOpen: true,
1979
- source: source
1980
- }));
1981
- _context3.next = 11;
1982
- break;
1983
- case 9:
1984
- _context3.prev = 9;
1985
- _context3.t0 = _context3["catch"](0);
1986
- case 11:
1987
- case "end":
1988
- return _context3.stop();
1989
- }
1990
- }, _callee3, null, [[0, 9]]);
1991
- }));
1992
- };
1993
- var onEditDrawing = function onEditDrawing(drawingId) {
1994
- // delete current redux layers
1995
- deleteGeoJSONLayer();
1996
- onCloseDialog();
1997
- openDrawTools(drawingId);
1998
- };
1984
+ // TODO: re-enable for: https://gitlab.com/opengeoweb/opengeoweb/-/issues/4080
1985
+ // const openDrawTools = async (drawingId: string): Promise<void> => {
1986
+ // try {
1987
+ // const { data } = await warningsApi.getDrawingDetails(drawingId);
1988
+ // // update draw tool values
1989
+ // dispatch(
1990
+ // drawActions.setDrawValues({
1991
+ // area: data.area,
1992
+ // areaName: data.name,
1993
+ // mapId,
1994
+ // id: drawingId,
1995
+ // }),
1996
+ // );
1997
+ // // open draw dialog
1998
+ // dispatch(
1999
+ // uiActions.setActiveMapIdForDialog({
2000
+ // type: `${uiTypes.DialogTypes.DockedDrawingTool}-${mapId}`,
2001
+ // mapId,
2002
+ // setOpen: true,
2003
+ // source,
2004
+ // }),
2005
+ // );
2006
+ // } catch (error) {
2007
+ // // TODO: handle error. Might need to move this to redux
2008
+ // }
2009
+ // };
2010
+ // const onEditDrawing = (drawingId: string): void => {
2011
+ // closeAreaDialog();
2012
+ // openDrawTools(drawingId);
2013
+ // };
1999
2014
  var onClose = function onClose() {
2000
- onCloseDialog();
2001
- };
2002
- var onHideAreaManager = function onHideAreaManager() {
2003
- deleteGeoJSONLayer();
2015
+ closeAreaDialog();
2004
2016
  };
2005
2017
  if (!isDialogOpen) {
2006
2018
  return null;
@@ -2021,10 +2033,10 @@ var AreaManagerConnect = function AreaManagerConnect(_ref) {
2021
2033
  },
2022
2034
  drawingListItems: drawings,
2023
2035
  onClickDrawing: onClickDrawing,
2024
- onUnMount: onHideAreaManager,
2025
- onEditDrawing: onEditDrawing,
2036
+ // onEditDrawing={onEditDrawing}
2026
2037
  activeDrawingId: activeDrawingId,
2027
- error: uiError
2038
+ error: uiError,
2039
+ isLoading: loading
2028
2040
  });
2029
2041
  };
2030
2042
 
@@ -3011,9 +3023,6 @@ function delayP(ms, val) {
3011
3023
  }
3012
3024
 
3013
3025
  if (process.env.NODE_ENV !== 'production' && typeof Proxy !== 'undefined') ;
3014
- var identity = function identity(v) {
3015
- return v;
3016
- };
3017
3026
  function check(value, predicate, error) {
3018
3027
  if (!predicate(value)) {
3019
3028
  throw new Error(error);
@@ -3064,7 +3073,6 @@ var PUT = 'PUT';
3064
3073
  var CALL = 'CALL';
3065
3074
  var FORK = 'FORK';
3066
3075
  var CANCEL = 'CANCEL';
3067
- var SELECT = 'SELECT';
3068
3076
 
3069
3077
  var TEST_HINT = '\n(HINT: if you are getting these errors in tests, consider using createMockTask from @redux-saga/testing-utils)';
3070
3078
 
@@ -3248,25 +3256,6 @@ function cancel(taskOrTasks) {
3248
3256
 
3249
3257
  return makeEffect(CANCEL, taskOrTasks);
3250
3258
  }
3251
- function select(selector) {
3252
- if (selector === void 0) {
3253
- selector = identity;
3254
- }
3255
-
3256
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
3257
- args[_key5 - 1] = arguments[_key5];
3258
- }
3259
-
3260
- if (process.env.NODE_ENV !== 'production' && arguments.length) {
3261
- check(arguments[0], notUndef, 'select(selector, [...]): argument selector is undefined');
3262
- check(selector, func, "select(selector, [...]): argument " + selector + " is not a function");
3263
- }
3264
-
3265
- return makeEffect(SELECT, {
3266
- selector: selector,
3267
- args: args
3268
- });
3269
- }
3270
3259
  var delay =
3271
3260
  /*#__PURE__*/
3272
3261
  call.bind(null, delayP);
@@ -3407,144 +3396,91 @@ var SUBMIT_ERROR = 'Something went wrong saving a drawing';
3407
3396
  var getSnackbarMessage = function getSnackbarMessage(areaName, id) {
3408
3397
  return "Drawing ".concat(areaName, " has been ").concat(id ? 'updated' : 'saved', "!");
3409
3398
  };
3410
- function onOpenUiDialogSaga(_ref) {
3399
+ function submitDrawValuesSaga(_ref) {
3411
3400
  var payload = _ref.payload;
3412
3401
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3413
- var type, mapId, drawUiType, areaManagerUiType, isDrawingOpen, isAreaManagerOpen;
3402
+ var mapId, id, formValues, dialogType, warningsApi, newID;
3414
3403
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3415
3404
  while (1) switch (_context.prev = _context.next) {
3416
- case 0:
3417
- type = payload.type, mapId = payload.mapId;
3418
- drawUiType = "".concat(uiTypes.DialogTypes.DockedDrawingTool, "-").concat(mapId);
3419
- areaManagerUiType = uiTypes.DialogTypes.AreaManager;
3420
- if (!(type === areaManagerUiType)) {
3421
- _context.next = 10;
3422
- break;
3423
- }
3424
- _context.next = 6;
3425
- return select(uiSelectors.getisDialogOpen, drawUiType);
3426
- case 6:
3427
- isDrawingOpen = _context.sent;
3428
- if (!isDrawingOpen) {
3429
- _context.next = 10;
3430
- break;
3431
- }
3432
- _context.next = 10;
3433
- return put(uiActions.setToggleOpenDialog(Object.assign(Object.assign({}, payload), {
3434
- type: drawUiType,
3435
- setOpen: false
3436
- })));
3437
- case 10:
3438
- if (!(type === drawUiType)) {
3439
- _context.next = 17;
3440
- break;
3441
- }
3442
- _context.next = 13;
3443
- return select(uiSelectors.getisDialogOpen, areaManagerUiType);
3444
- case 13:
3445
- isAreaManagerOpen = _context.sent;
3446
- if (!isAreaManagerOpen) {
3447
- _context.next = 17;
3448
- break;
3449
- }
3450
- _context.next = 17;
3451
- return put(uiActions.setToggleOpenDialog(Object.assign(Object.assign({}, payload), {
3452
- type: areaManagerUiType,
3453
- setOpen: false
3454
- })));
3455
- case 17:
3456
- case "end":
3457
- return _context.stop();
3458
- }
3459
- }, _callee);
3460
- })();
3461
- }
3462
- function submitDrawValuesSaga(_ref2) {
3463
- var payload = _ref2.payload;
3464
- return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3465
- var mapId, id, formValues, dialogType, warningsApi, newID;
3466
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3467
- while (1) switch (_context2.prev = _context2.next) {
3468
3405
  case 0:
3469
3406
  mapId = payload.mapId, id = payload.id, formValues = __rest(payload, ["mapId", "id"]);
3470
3407
  dialogType = "".concat(uiTypes.DialogTypes.DockedDrawingTool, "-").concat(mapId);
3471
- _context2.prev = 2;
3472
- _context2.next = 5;
3408
+ _context.prev = 2;
3409
+ _context.next = 5;
3473
3410
  return put(uiActions.toggleIsLoadingDialog({
3474
3411
  isLoading: true,
3475
3412
  type: dialogType
3476
3413
  }));
3477
3414
  case 5:
3478
- _context2.next = 7;
3415
+ _context.next = 7;
3479
3416
  return call(getWarningsApi);
3480
3417
  case 7:
3481
- warningsApi = _context2.sent;
3418
+ warningsApi = _context.sent;
3482
3419
  if (id) {
3483
- _context2.next = 16;
3420
+ _context.next = 16;
3484
3421
  break;
3485
3422
  }
3486
- _context2.next = 11;
3423
+ _context.next = 11;
3487
3424
  return call(warningsApi.saveDrawingAs, formValues);
3488
3425
  case 11:
3489
- newID = _context2.sent;
3490
- _context2.next = 14;
3491
- return put(drawActions.setDrawValues(Object.assign({
3426
+ newID = _context.sent;
3427
+ _context.next = 14;
3428
+ return put(drawActions.setDrawValues({
3492
3429
  mapId: mapId,
3493
- id: newID
3494
- }, formValues)));
3430
+ id: newID,
3431
+ areaName: formValues.name,
3432
+ area: formValues.area
3433
+ }));
3495
3434
  case 14:
3496
- _context2.next = 18;
3435
+ _context.next = 18;
3497
3436
  break;
3498
3437
  case 16:
3499
- _context2.next = 18;
3438
+ _context.next = 18;
3500
3439
  return call(warningsApi.updateDrawing, id, formValues);
3501
3440
  case 18:
3502
- _context2.next = 20;
3441
+ _context.next = 20;
3503
3442
  return put(snackbarActions.openSnackbar({
3504
- message: getSnackbarMessage(formValues.areaName, id)
3443
+ message: getSnackbarMessage(formValues.name, id)
3505
3444
  }));
3506
3445
  case 20:
3507
- _context2.next = 22;
3446
+ _context.next = 22;
3508
3447
  return put(uiActions.toggleIsLoadingDialog({
3509
3448
  isLoading: false,
3510
3449
  type: dialogType
3511
3450
  }));
3512
3451
  case 22:
3513
- _context2.next = 30;
3452
+ _context.next = 30;
3514
3453
  break;
3515
3454
  case 24:
3516
- _context2.prev = 24;
3517
- _context2.t0 = _context2["catch"](2);
3518
- _context2.next = 28;
3455
+ _context.prev = 24;
3456
+ _context.t0 = _context["catch"](2);
3457
+ _context.next = 28;
3519
3458
  return put(uiActions.toggleIsLoadingDialog({
3520
3459
  isLoading: false,
3521
3460
  type: dialogType
3522
3461
  }));
3523
3462
  case 28:
3524
- _context2.next = 30;
3463
+ _context.next = 30;
3525
3464
  return put(uiActions.setErrorDialog({
3526
3465
  type: dialogType,
3527
3466
  error: SUBMIT_ERROR
3528
3467
  }));
3529
3468
  case 30:
3530
3469
  case "end":
3531
- return _context2.stop();
3470
+ return _context.stop();
3532
3471
  }
3533
- }, _callee2, null, [[2, 24]]);
3472
+ }, _callee, null, [[2, 24]]);
3534
3473
  })();
3535
3474
  }
3536
3475
  function drawingSaga() {
3537
- return _regeneratorRuntime().wrap(function drawingSaga$(_context3) {
3538
- while (1) switch (_context3.prev = _context3.next) {
3476
+ return _regeneratorRuntime().wrap(function drawingSaga$(_context2) {
3477
+ while (1) switch (_context2.prev = _context2.next) {
3539
3478
  case 0:
3540
- _context3.next = 2;
3541
- return takeLatest$1(uiActions.setActiveMapIdForDialog, onOpenUiDialogSaga);
3542
- case 2:
3543
- _context3.next = 4;
3479
+ _context2.next = 2;
3544
3480
  return takeLatest$1(drawActions.submitDrawValues, submitDrawValuesSaga);
3545
- case 4:
3481
+ case 2:
3546
3482
  case "end":
3547
- return _context3.stop();
3483
+ return _context2.stop();
3548
3484
  }
3549
3485
  }, _marked);
3550
3486
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "6.1.1",
3
+ "version": "7.0.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,12 +9,12 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@mui/material": "5.12.0",
12
- "@opengeoweb/api": "6.1.1",
13
- "@opengeoweb/core": "6.1.1",
14
- "@opengeoweb/shared": "6.1.1",
15
- "@opengeoweb/store": "6.1.1",
16
- "@opengeoweb/theme": "6.1.1",
17
- "@opengeoweb/webmap-react": "6.1.1",
12
+ "@opengeoweb/api": "7.0.0",
13
+ "@opengeoweb/core": "7.0.0",
14
+ "@opengeoweb/shared": "7.0.0",
15
+ "@opengeoweb/store": "7.0.0",
16
+ "@opengeoweb/theme": "7.0.0",
17
+ "@opengeoweb/webmap-react": "7.0.0",
18
18
  "@reduxjs/toolkit": "1.9.5",
19
19
  "axios": "1.5.0",
20
20
  "react": "18.2.0",
@@ -26,8 +26,7 @@ export declare const AreaManager: React.FC<{
26
26
  headerSize?: HeaderSize;
27
27
  drawingListItems: DrawingListItem[];
28
28
  onClickDrawing?: (drawing: DrawingListItem) => void;
29
- onUnMount?: () => void;
30
- onEditDrawing?: (drawingId: string) => void;
31
29
  activeDrawingId?: string;
32
30
  error?: string;
31
+ isLoading?: boolean;
33
32
  }>;
@@ -23,3 +23,11 @@ export declare const AreaManagerDark: {
23
23
  };
24
24
  storyName: string;
25
25
  };
26
+ export declare const AreaManagerLightNoResults: {
27
+ (): React.ReactElement;
28
+ storyName: string;
29
+ };
30
+ export declare const AreaManagerDarkNoResults: {
31
+ (): React.ReactElement;
32
+ storyName: string;
33
+ };
@@ -1,8 +1,8 @@
1
1
  import { FC } from 'react';
2
2
  import { DrawingListItem } from '../../store/drawings/types';
3
+ export declare const NO_AREAS_FOUND = "No areas found";
3
4
  export declare const Drawings: FC<{
4
5
  drawings: DrawingListItem[];
5
6
  onClickDrawing: (drawing: DrawingListItem) => void;
6
- onClickEdit: (drawingId: string) => void;
7
7
  activeDrawing: string;
8
8
  }>;
@@ -1,9 +1,6 @@
1
1
  import { SagaIterator } from 'redux-saga';
2
2
  export declare const SUBMIT_ERROR = "Something went wrong saving a drawing";
3
3
  export declare const getSnackbarMessage: (areaName: string, id: string) => string;
4
- export declare function onOpenUiDialogSaga({ payload }: {
5
- payload: any;
6
- }): SagaIterator;
7
4
  export declare function submitDrawValuesSaga({ payload }: {
8
5
  payload: any;
9
6
  }): SagaIterator;
@@ -1,9 +1,9 @@
1
- export type DrawingScope = 'user';
1
+ import { drawTypes } from '@opengeoweb/store';
2
2
  export interface DrawingListItem {
3
3
  id: string;
4
4
  name: string;
5
5
  lastUpdatedTime: string;
6
- scope: DrawingScope;
6
+ scope: drawTypes.DrawingScope;
7
7
  area: GeoJSON.FeatureCollection;
8
8
  }
9
9
  export interface DrawingFromBE extends DrawingListItem {
@@ -2,6 +2,7 @@ import { CreateApiProps } from '@opengeoweb/api';
2
2
  import { AxiosInstance } from 'axios';
3
3
  import { DrawingDetails, DrawingFromBE, DrawingListItem } from '../store/drawings/types';
4
4
  export declare const API_NAME = "warnings";
5
+ export declare const getIdFromUrl: (url: string) => string;
5
6
  export type WarningsApi = {
6
7
  getDrawings: () => Promise<{
7
8
  data: DrawingListItem[];