@opengeoweb/warnings 10.0.0 → 10.1.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,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
3
  import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Options, Close, ChevronDown, ChevronUp, Copy, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
- import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData } from '@opengeoweb/store';
4
+ import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, MapView, MapViewLayer, getFeatureExtent } from '@opengeoweb/webmap-react';
6
6
  import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
@@ -19,7 +19,7 @@ import { VariableSizeList } from 'react-window';
19
19
  import AutoSizer from 'react-virtualized-auto-sizer';
20
20
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, getHeaders, useAuthQuery, useAuthenticationContext, ProductStatus } from '@opengeoweb/api';
21
21
  import { useFormContext } from 'react-hook-form';
22
- import { isEqual, cloneDeep, clamp, groupBy, pick, assign } from 'lodash';
22
+ import { isEqual, cloneDeep, clamp, groupBy, assign, pick } from 'lodash';
23
23
  import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
24
24
  import { useQueryClient } from '@tanstack/react-query';
25
25
  import { isAxiosError } from 'axios';
@@ -1186,7 +1186,7 @@ var useCloseDrawDialog = function useCloseDrawDialog(_ref) {
1186
1186
  drawMode: ''
1187
1187
  }));
1188
1188
  // reset active draw tool
1189
- dispatch(drawtoolActions.changeDrawToolMode({
1189
+ dispatch(drawingToolActions.changeDrawToolMode({
1190
1190
  drawToolId: drawingDialogType,
1191
1191
  drawModeId: drawDialogActiveDrawModeId
1192
1192
  }));
@@ -1213,7 +1213,7 @@ var useCloseDrawDialog = function useCloseDrawDialog(_ref) {
1213
1213
  }
1214
1214
  // clear existing geoJSON
1215
1215
  if (featureLayerContainsGeoJSON) {
1216
- dispatch(mapStoreActions.layerChangeGeojson({
1216
+ dispatch(layerActions.layerChangeGeojson({
1217
1217
  layerId: drawLayerId,
1218
1218
  geojson: emptyGeoJSON
1219
1219
  }));
@@ -1260,7 +1260,7 @@ var useCloseObjectDialog = function useCloseObjectDialog(_ref3) {
1260
1260
  source: source
1261
1261
  }));
1262
1262
  if (featureLayerContainsGeoJSON && shouldReset) {
1263
- dispatch(mapStoreActions.layerChangeGeojson({
1263
+ dispatch(layerActions.layerChangeGeojson({
1264
1264
  layerId: drawLayerId,
1265
1265
  geojson: emptyGeoJSON
1266
1266
  }));
@@ -1318,7 +1318,7 @@ var useObjectDrawDialogAction = function useObjectDrawDialogAction(_ref5) {
1318
1318
  objectDialogLayerHasGeoJSON = _useDialogOptions2.hasGeoJSON,
1319
1319
  objectDialogLayerId = _useDialogOptions2.dialogLayerId;
1320
1320
  var clearGeoJSON = function clearGeoJSON(layerId) {
1321
- dispatch(mapStoreActions.layerChangeGeojson({
1321
+ dispatch(layerActions.layerChangeGeojson({
1322
1322
  layerId: layerId,
1323
1323
  geojson: emptyGeoJSON
1324
1324
  }));
@@ -1366,7 +1366,7 @@ var useObjectDrawDialogAction = function useObjectDrawDialogAction(_ref5) {
1366
1366
  // move shape to screen
1367
1367
  if (isObjectDialogOpen && objectDialogLayerHasGeoJSON) {
1368
1368
  // update new shape
1369
- dispatch(mapStoreActions.layerSetGeojsonFromLayer({
1369
+ dispatch(layerActions.layerSetGeojsonFromLayer({
1370
1370
  layerId: currentDrawLayerId,
1371
1371
  sourceLayerId: objectDialogLayerId
1372
1372
  }));
@@ -1399,13 +1399,13 @@ var useObjectDrawDialogAction = function useObjectDrawDialogAction(_ref5) {
1399
1399
  source: source
1400
1400
  }));
1401
1401
  // activate draw tool
1402
- dispatch(drawtoolActions.updateGeoJSONLayerId({
1402
+ dispatch(drawingToolActions.updateGeoJSONLayerId({
1403
1403
  drawToolId: drawingDialogType,
1404
1404
  geoJSONLayerId: currentDrawLayerId
1405
1405
  }));
1406
1406
  // activate default draw mode
1407
1407
  if (!drawDialogActiveDrawModeId && !isDrawDialogOpen) {
1408
- dispatch(drawtoolActions.changeDrawToolMode({
1408
+ dispatch(drawingToolActions.changeDrawToolMode({
1409
1409
  drawToolId: drawingDialogType,
1410
1410
  drawModeId: defaultPolygon.drawModeId
1411
1411
  }));
@@ -1413,7 +1413,7 @@ var useObjectDrawDialogAction = function useObjectDrawDialogAction(_ref5) {
1413
1413
  // move shape to screen
1414
1414
  if (isDrawDialogOpen && drawDialogLayerHasGeoJSON) {
1415
1415
  // update new shape
1416
- dispatch(mapStoreActions.layerSetGeojsonFromLayer({
1416
+ dispatch(layerActions.layerSetGeojsonFromLayer({
1417
1417
  layerId: currentDrawLayerId,
1418
1418
  sourceLayerId: drawDialogLayerId
1419
1419
  }));
@@ -1435,7 +1435,7 @@ var useObjectDrawDialogAction = function useObjectDrawDialogAction(_ref5) {
1435
1435
  }));
1436
1436
  }
1437
1437
  if (newGeoJSON) {
1438
- dispatch(mapStoreActions.layerChangeGeojson({
1438
+ dispatch(layerActions.layerChangeGeojson({
1439
1439
  layerId: currentDrawLayerId,
1440
1440
  geojson: newGeoJSON
1441
1441
  }));
@@ -1589,7 +1589,7 @@ var Objects = function Objects(_ref2) {
1589
1589
  var _useWarningsTranslati = useWarningsTranslation(),
1590
1590
  t = _useWarningsTranslati.t;
1591
1591
  var listRef = React__default.useRef(null);
1592
- var _getListInclHeaders = getListInclHeaders$1(objects),
1592
+ var _getListInclHeaders = getListInclHeaders$1(objects || []),
1593
1593
  listInclHeaders = _getListInclHeaders.listInclHeaders,
1594
1594
  headerList = _getListInclHeaders.headerList;
1595
1595
  var getItemSize = function getItemSize(width, index) {
@@ -2187,7 +2187,8 @@ var slice = createSlice({
2187
2187
  var area = action.payload.area;
2188
2188
  // only support 1 area (for now)
2189
2189
  if (draft.publicWarning) {
2190
- draft.publicWarning.warningDetail.areas = [area];
2190
+ var areaWithPreservedUUID = Object.assign({}, draft.publicWarning.warningDetail.areas.at(0), area);
2191
+ draft.publicWarning.warningDetail.areas = [areaWithPreservedUUID];
2191
2192
  } else {
2192
2193
  var newWarning = {
2193
2194
  warningDetail: {
@@ -2206,6 +2207,11 @@ var slice = createSlice({
2206
2207
  draft.publicWarning.warningDetail.areas = removeAreas;
2207
2208
  }
2208
2209
  },
2210
+ removeAllAreas: function removeAllAreas(draft) {
2211
+ if (draft.publicWarning) {
2212
+ draft.publicWarning.warningDetail.areas = [];
2213
+ }
2214
+ },
2209
2215
  openPublicWarningFormDialog: function openPublicWarningFormDialog(draft, action) {
2210
2216
  var _action$payload2 = action.payload,
2211
2217
  object = _action$payload2.object,
@@ -2396,7 +2402,7 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
2396
2402
  };
2397
2403
  var showGeoJSONLayer = function showGeoJSONLayer(drawing) {
2398
2404
  if (!currentLayer) {
2399
- dispatch(mapStoreActions.addLayer({
2405
+ dispatch(layerActions.addLayer({
2400
2406
  mapId: mapId,
2401
2407
  layer: {
2402
2408
  geojson: drawing.geoJSON
@@ -2405,7 +2411,7 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
2405
2411
  origin: 'warnings-lib'
2406
2412
  }));
2407
2413
  } else {
2408
- dispatch(mapStoreActions.layerChangeGeojson({
2414
+ dispatch(layerActions.layerChangeGeojson({
2409
2415
  layerId: geoJSONLayerId,
2410
2416
  geojson: drawing.geoJSON
2411
2417
  }));
@@ -2477,10 +2483,12 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
2477
2483
  _context2.prev = 13;
2478
2484
  _context2.t0 = _context2["catch"](2);
2479
2485
  setLoading(false);
2480
- dispatch(uiActions.setErrorDialog({
2481
- error: _context2.t0.message,
2482
- type: objectDialogType
2483
- }));
2486
+ if (_context2.t0 instanceof Error) {
2487
+ dispatch(uiActions.setErrorDialog({
2488
+ error: _context2.t0.message,
2489
+ type: objectDialogType
2490
+ }));
2491
+ }
2484
2492
  case 17:
2485
2493
  case "end":
2486
2494
  return _context2.stop();
@@ -7533,7 +7541,8 @@ var DrawingToolForm = function DrawingToolForm(_ref) {
7533
7541
  }));
7534
7542
  }, [geoJSONProperties, drawModes]);
7535
7543
  var onChangeOpacity = React.useCallback(function (event) {
7536
- var value = event.target.value;
7544
+ var target = event.target;
7545
+ var value = target.value;
7537
7546
  var newOpacity = parseInt(value, 10) / 100;
7538
7547
  var additionalStrokeOpacity = 0.8;
7539
7548
  onChangeProperties({
@@ -7620,7 +7629,7 @@ var DrawingToolFormConnect = function DrawingToolFormConnect() {
7620
7629
  }));
7621
7630
  }, [dispatch, drawTool == null ? void 0 : drawTool.geoJSONLayerId]);
7622
7631
  var onChangeDrawMode = React.useCallback(function (tool) {
7623
- dispatch(drawtoolActions.changeDrawToolMode({
7632
+ dispatch(drawingToolActions.changeDrawToolMode({
7624
7633
  drawToolId: drawToolId,
7625
7634
  drawModeId: tool.drawModeId
7626
7635
  }));
@@ -7632,7 +7641,7 @@ var DrawingToolFormConnect = function DrawingToolFormConnect() {
7632
7641
  drawMode: ''
7633
7642
  }));
7634
7643
  if (drawTool != null && drawTool.activeDrawModeId) {
7635
- dispatch(drawtoolActions.changeDrawToolMode({
7644
+ dispatch(drawingToolActions.changeDrawToolMode({
7636
7645
  drawToolId: drawToolId,
7637
7646
  drawModeId: drawTool == null ? void 0 : drawTool.activeDrawModeId
7638
7647
  }));
@@ -7724,12 +7733,12 @@ var DrawingToolConnect = function DrawingToolConnect(_ref) {
7724
7733
  var dispatch = useDispatch();
7725
7734
  React.useEffect(function () {
7726
7735
  var defaultDrawModes = translateDrawModes(currentlySupportedDrawModes, t);
7727
- dispatch(drawtoolActions.registerDrawTool({
7736
+ dispatch(drawingToolActions.registerDrawTool({
7728
7737
  drawToolId: drawingDialogType,
7729
7738
  defaultDrawModes: defaultDrawModes
7730
7739
  }));
7731
7740
  return function () {
7732
- dispatch(drawtoolActions.unregisterDrawTool({
7741
+ dispatch(drawingToolActions.unregisterDrawTool({
7733
7742
  drawToolId: drawingDialogType
7734
7743
  }));
7735
7744
  };
@@ -8195,7 +8204,7 @@ var AreaField = function AreaField(_ref) {
8195
8204
  });
8196
8205
  };
8197
8206
 
8198
- var _defaultLevelFilter, _defaultEmptyFilter, _defaultPhenomenonFil;
8207
+ var _defaultLevelFilter, _defaultEmptyFilter;
8199
8208
  /* *
8200
8209
  * Licensed under the Apache License, Version 2.0 (the "License");
8201
8210
  * you may not use this file except in compliance with the License.
@@ -8251,12 +8260,19 @@ var domainLevels = {
8251
8260
  };
8252
8261
  var defaultLevelFilter = (_defaultLevelFilter = {}, _defaultLevelFilter[emptyFilterId] = true, _defaultLevelFilter.extreme = true, _defaultLevelFilter.moderate = true, _defaultLevelFilter.severe = true, _defaultLevelFilter.AIR = true, _defaultLevelFilter.SIG = true, _defaultLevelFilter);
8253
8262
  var defaultEmptyFilter = (_defaultEmptyFilter = {}, _defaultEmptyFilter[emptyFilterId] = true, _defaultEmptyFilter);
8254
- (_defaultPhenomenonFil = {}, _defaultPhenomenonFil[emptyFilterId] = true, _defaultPhenomenonFil.coastalEvent = true, _defaultPhenomenonFil.fog = true, _defaultPhenomenonFil.highTemp = true, _defaultPhenomenonFil.lowTemp = true, _defaultPhenomenonFil.rain = true, _defaultPhenomenonFil.snowIce = true, _defaultPhenomenonFil.thunderstorm = true, _defaultPhenomenonFil.wind = true, _defaultPhenomenonFil);
8263
+ var makeFilterFromList = function makeFilterFromList(options) {
8264
+ var _options$reduce;
8265
+ return options.reduce(function (acc, p) {
8266
+ var _Object$assign;
8267
+ return p ? Object.assign({}, acc, (_Object$assign = {}, _Object$assign[p] = true, _Object$assign)) : acc;
8268
+ }, (_options$reduce = {}, _options$reduce[emptyFilterId] = true, _options$reduce));
8269
+ };
8270
+ var defaultPhenomenonFilter = makeFilterFromList(Object.values(Phenomenon$1));
8255
8271
  var initialFilters = {
8256
8272
  incident: defaultEmptyFilter,
8257
8273
  source: defaultEmptyFilter,
8258
8274
  domain: defaultDomainFilter,
8259
- phenomenon: defaultEmptyFilter,
8275
+ phenomenon: defaultPhenomenonFilter,
8260
8276
  level: defaultLevelFilter
8261
8277
  };
8262
8278
  var getSelectedOptions = function getSelectedOptions(options) {
@@ -8270,11 +8286,11 @@ var getSelectedOptions = function getSelectedOptions(options) {
8270
8286
  };
8271
8287
  };
8272
8288
  var updateState = function updateState(state, optionKey, value, only) {
8273
- var _Object$assign3;
8289
+ var _Object$assign4;
8274
8290
  if (only) {
8275
8291
  return Object.keys(state).reduce(function (acc, k) {
8276
- var _Object$assign;
8277
- return Object.assign({}, acc, (_Object$assign = {}, _Object$assign[k] = k === optionKey, _Object$assign));
8292
+ var _Object$assign2;
8293
+ return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[k] = k === optionKey, _Object$assign2));
8278
8294
  }, {});
8279
8295
  }
8280
8296
  if (optionKey === 'ALL') {
@@ -8282,11 +8298,11 @@ var updateState = function updateState(state, optionKey, value, only) {
8282
8298
  return state;
8283
8299
  }
8284
8300
  return Object.keys(state).reduce(function (acc, k) {
8285
- var _Object$assign2;
8286
- return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[k] = value, _Object$assign2));
8301
+ var _Object$assign3;
8302
+ return Object.assign({}, acc, (_Object$assign3 = {}, _Object$assign3[k] = value, _Object$assign3));
8287
8303
  }, {});
8288
8304
  }
8289
- return Object.assign({}, state, (_Object$assign3 = {}, _Object$assign3[optionKey] = value, _Object$assign3));
8305
+ return Object.assign({}, state, (_Object$assign4 = {}, _Object$assign4[optionKey] = value, _Object$assign4));
8290
8306
  };
8291
8307
  /** Make sure our value is in the filter */
8292
8308
  var getValue = function getValue(values, value) {
@@ -9205,7 +9221,8 @@ var prepareFormValues = function prepareFormValues(data) {
9205
9221
  var productToPost = _objectWithoutPropertiesLoose(data, _excluded$6);
9206
9222
  // remove empty fields
9207
9223
  return Object.keys(productToPost).reduce(function (warningDetail, fieldName) {
9208
- var fieldValue = productToPost[fieldName];
9224
+ var key = fieldName;
9225
+ var fieldValue = productToPost[key];
9209
9226
  if (Array.isArray(fieldValue)) {
9210
9227
  if (!fieldValue.length || fieldValue[0].geoJSON === null) {
9211
9228
  return warningDetail;
@@ -9213,7 +9230,7 @@ var prepareFormValues = function prepareFormValues(data) {
9213
9230
  }
9214
9231
  if (fieldValue) {
9215
9232
  var _Object$assign;
9216
- return Object.assign({}, warningDetail, (_Object$assign = {}, _Object$assign[fieldName] = fieldValue, _Object$assign));
9233
+ return Object.assign({}, warningDetail, (_Object$assign = {}, _Object$assign[key] = fieldValue, _Object$assign));
9217
9234
  }
9218
9235
  return warningDetail;
9219
9236
  }, {});
@@ -9301,6 +9318,8 @@ var Form = function Form(_ref5) {
9301
9318
  onSaveForm = _ref5$onSaveForm === void 0 ? function () {} : _ref5$onSaveForm,
9302
9319
  _ref5$onPublishForm = _ref5.onPublishForm,
9303
9320
  onPublishForm = _ref5$onPublishForm === void 0 ? function () {} : _ref5$onPublishForm,
9321
+ _ref5$onClearForm = _ref5.onClearForm,
9322
+ onClearForm = _ref5$onClearForm === void 0 ? function () {} : _ref5$onClearForm,
9304
9323
  object = _ref5.object,
9305
9324
  _ref5$formAction = _ref5.formAction,
9306
9325
  formAction = _ref5$formAction === void 0 ? '' : _ref5$formAction,
@@ -9398,6 +9417,7 @@ var Form = function Form(_ref5) {
9398
9417
  var onPressClear = function onPressClear() {
9399
9418
  reset(getEmptyPublicWarning());
9400
9419
  setWarningGeoJSONFeature(undefined);
9420
+ onClearForm();
9401
9421
  };
9402
9422
  var publicWarningId = publicWarningDetails == null ? void 0 : publicWarningDetails.id;
9403
9423
  React.useEffect(function () {
@@ -9807,6 +9827,9 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9807
9827
  }
9808
9828
  }));
9809
9829
  };
9830
+ var clearForm = function clearForm() {
9831
+ dispatch(publicWarningFormActions.removeAllAreas());
9832
+ };
9810
9833
  var saveForm = function saveForm(newFormValues) {
9811
9834
  var status = newFormValues.linked_to_id ? PublicWarningStatus.DRAFT_PUBLISHED : PublicWarningStatus.DRAFT;
9812
9835
  dispatch(publicWarningFormActions.saveWarning({
@@ -9855,6 +9878,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9855
9878
  publicWarningDetails: publicWarning == null ? void 0 : publicWarning.warningDetail,
9856
9879
  onPublishForm: publishForm,
9857
9880
  onSaveForm: saveForm,
9881
+ onClearForm: clearForm,
9858
9882
  formAction: publicWarningFormAction,
9859
9883
  isReadOnly: isReadOnly,
9860
9884
  error: publicWarningFormError,
@@ -10371,6 +10395,9 @@ var AreaObjectLoaderConnect = function AreaObjectLoaderConnect(_ref) {
10371
10395
  var warningId = useSelector(function (store) {
10372
10396
  return getPublicWarningId(store);
10373
10397
  });
10398
+ var warningStatus = useSelector(function (store) {
10399
+ return getPublicWarningStatus(store);
10400
+ });
10374
10401
  var fetchItems = function fetchItems() {
10375
10402
  dispatch(uiActions.setErrorDialog({
10376
10403
  error: '',
@@ -10451,7 +10478,7 @@ var AreaObjectLoaderConnect = function AreaObjectLoaderConnect(_ref) {
10451
10478
  }
10452
10479
  // eslint-disable-next-line react-hooks/exhaustive-deps
10453
10480
  }, [areas, searchQuery]);
10454
- var isChangeAreaDisabled = warningId !== undefined && typeof warningId === 'string' && warningId.length > 0;
10481
+ var isChangeAreaDisabled = warningId !== undefined && typeof warningId === 'string' && warningId.length > 0 && warningStatus !== PublicWarningStatus.DRAFT && warningStatus !== PublicWarningStatus.DRAFT_PUBLISHED;
10455
10482
  var drawingError = uiError ? {
10456
10483
  type: areaObjectLoaderType,
10457
10484
  error: uiError
@@ -11037,9 +11064,10 @@ var warningColors = Object.assign({}, LevelColors);
11037
11064
 
11038
11065
  var _excluded$5 = ["id", "warningDetail", "status", "editor"],
11039
11066
  _excluded2 = ["id", "linked_to_id", "proposal_id", "warning_handle_uuid"],
11040
- _excluded3 = ["id"],
11041
- _excluded4 = ["id", "warningDetail"],
11042
- _excluded5 = ["id"];
11067
+ _excluded3 = ["published_warning_uuid"],
11068
+ _excluded4 = ["id"],
11069
+ _excluded5 = ["id", "warningDetail"],
11070
+ _excluded6 = ["id"];
11043
11071
  var getSortedStatus = function getSortedStatus(status) {
11044
11072
  switch (status) {
11045
11073
  case 'DRAFT_PUBLISHED':
@@ -11063,15 +11091,22 @@ var getWarningWithoutIdStatusEditor = function getWarningWithoutIdStatusEditor(w
11063
11091
  warningDetail.proposal_id;
11064
11092
  warningDetail.warning_handle_uuid;
11065
11093
  var cleanWarningDetail = _objectWithoutPropertiesLoose(warningDetail, _excluded2);
11094
+ var areas = warningDetail.areas.map(function (_ref) {
11095
+ _ref.published_warning_uuid;
11096
+ var area = _objectWithoutPropertiesLoose(_ref, _excluded3);
11097
+ return area;
11098
+ });
11066
11099
  return Object.assign({}, fullWarning, {
11067
- warningDetail: cleanWarningDetail
11100
+ warningDetail: Object.assign({}, cleanWarningDetail, {
11101
+ areas: areas
11102
+ })
11068
11103
  });
11069
11104
  };
11070
11105
  var getWarningWithLinkedToId = function getWarningWithLinkedToId(warning) {
11071
11106
  var id = warning.id,
11072
11107
  warningDetail = warning.warningDetail;
11073
11108
  warningDetail.id;
11074
- var cleanWarningDetail = _objectWithoutPropertiesLoose(warningDetail, _excluded3);
11109
+ var cleanWarningDetail = _objectWithoutPropertiesLoose(warningDetail, _excluded4);
11075
11110
  return Object.assign({}, warning, {
11076
11111
  warningDetail: Object.assign({}, cleanWarningDetail, {
11077
11112
  linked_to_id: id
@@ -11082,9 +11117,9 @@ var getWarningWithLinkedToId = function getWarningWithLinkedToId(warning) {
11082
11117
  var getWarningWithProposalId = function getWarningWithProposalId(warning) {
11083
11118
  var id = warning.id,
11084
11119
  warningDetail = warning.warningDetail,
11085
- fullWarning = _objectWithoutPropertiesLoose(warning, _excluded4);
11120
+ fullWarning = _objectWithoutPropertiesLoose(warning, _excluded5);
11086
11121
  warningDetail.id;
11087
- var cleanWarningDetail = _objectWithoutPropertiesLoose(warningDetail, _excluded5);
11122
+ var cleanWarningDetail = _objectWithoutPropertiesLoose(warningDetail, _excluded6);
11088
11123
  return Object.assign({}, fullWarning, {
11089
11124
  warningDetail: Object.assign({}, cleanWarningDetail, {
11090
11125
  proposal_id: id
@@ -11253,7 +11288,8 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11253
11288
  label: jsx(Fragment, {
11254
11289
  children: t(getTranslationKey(emptyFilterId, id))
11255
11290
  })
11256
- }, id + "-" + emptyFilterId), Object.keys(options).map(function (optionId) {
11291
+ }, id + "-" + emptyFilterId), Object.keys(options).map(function (_optionId) {
11292
+ var optionId = _optionId;
11257
11293
  if (optionId === emptyFilterId) {
11258
11294
  return null;
11259
11295
  }
@@ -12026,7 +12062,6 @@ var PublicWarningList = function PublicWarningList(_ref) {
12026
12062
  var _ref$warnings = _ref.warnings,
12027
12063
  warnings = _ref$warnings === void 0 ? [] : _ref$warnings,
12028
12064
  filterHookState = _ref.filterHookState,
12029
- filterState = _ref.filterState,
12030
12065
  _ref$isLoading = _ref.isLoading,
12031
12066
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
12032
12067
  error = _ref.error,
@@ -12185,7 +12220,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
12185
12220
  children: jsx(FilterList, {
12186
12221
  isAllSelected: allSelected,
12187
12222
  onClickAll: onClickAll,
12188
- filterState: filterState,
12223
+ filterState: filterHookState.filterState,
12189
12224
  updateFilter: updateFilter
12190
12225
  })
12191
12226
  }), jsxs(Grid2, {
@@ -12528,7 +12563,7 @@ var getFilterOptions = function getFilterOptions(defaultFilter, allOptions, save
12528
12563
  allSelected = _getSelectedOptions.allSelected;
12529
12564
  return [updatedOptions, allSelected];
12530
12565
  };
12531
- var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, savedFilterState, presetFilterState, isLoading) {
12566
+ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, savedFilterState, presetFilterState) {
12532
12567
  var pickedDomainFilter = savedFilterState.domain,
12533
12568
  pickedPhenomenonFilter = savedFilterState.phenomenon,
12534
12569
  pickedLevelFilter = savedFilterState.level,
@@ -12583,28 +12618,18 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
12583
12618
  var _getFilterOptions4 = getFilterOptions(defaultIncidentFilter, relevantIncidents, pickedIncidentFilter),
12584
12619
  updatedPickedIncidents = _getFilterOptions4[0],
12585
12620
  allIncidentsSelected = _getFilterOptions4[1];
12586
- useEffect(function () {
12587
- if (isLoading) {
12588
- return;
12589
- }
12590
- // when the warnings change, update the filters
12591
- onUpdateFilters({
12592
- incident: updatedPickedIncidents,
12593
- source: updatedPickedSources,
12594
- domain: pickedDomainFilter,
12595
- phenomenon: updatedPickedPhenomena,
12596
- level: updatedPickedLevels
12597
- }, 'system');
12598
- // eslint-disable-next-line react-hooks/exhaustive-deps
12599
- }, [warnings]);
12600
12621
  useEffect(function () {
12601
12622
  // when the preset changes, update the filters
12602
12623
  if (presetFilterState) {
12603
- onUpdateFilters(presetFilterState, 'system');
12624
+ onUpdateFilters(assign({}, initialFilters, presetFilterState), 'system');
12604
12625
  } else {
12605
12626
  // for a preset without filters saved use the initial filters
12606
- onUpdateFilters(initialFilters, 'system');
12627
+ onUpdateFilters(Object.assign({}, initialFilters, {
12628
+ incident: makeFilterFromList(relevantIncidents),
12629
+ source: makeFilterFromList(relevantSources)
12630
+ }), 'system');
12607
12631
  }
12632
+ // eslint-disable-next-line react-hooks/exhaustive-deps
12608
12633
  }, [presetFilterState, onUpdateFilters]);
12609
12634
  var _getSelectedOptions2 = getSelectedOptions(pickedDomainFilter),
12610
12635
  allDomainSelected = _getSelectedOptions2.allSelected;
@@ -12670,21 +12695,28 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
12670
12695
  var source = relevantSources.find(function (source) {
12671
12696
  return source === warning.warningDetail.warningProposalSource;
12672
12697
  }) || emptyFilterId;
12673
- if (!pickedSourceFilter[source]) {
12698
+ if (!updatedPickedSources[source]) {
12674
12699
  return false;
12675
12700
  }
12676
12701
  var incident = relevantIncidents.find(function (incident) {
12677
12702
  return incident === warning.warningDetail.incident;
12678
12703
  }) || emptyFilterId;
12679
- if (!pickedIncidentFilter[incident]) {
12704
+ if (!updatedPickedIncidents[incident]) {
12680
12705
  return false;
12681
12706
  }
12682
12707
  return true;
12683
- }, [pickedDomainFilter, pickedLevelFilter, pickedPhenomenonFilter, relevantSources, pickedSourceFilter, relevantIncidents, pickedIncidentFilter]);
12708
+ }, [pickedDomainFilter, pickedLevelFilter, pickedPhenomenonFilter, relevantSources, updatedPickedSources, relevantIncidents, updatedPickedIncidents]);
12684
12709
  return {
12685
12710
  allSelected: allSelected,
12686
12711
  updateFilter: updateFilter,
12687
- byFilterState: byFilterState
12712
+ byFilterState: byFilterState,
12713
+ filterState: {
12714
+ domain: pickedDomainFilter,
12715
+ level: updatedPickedLevels,
12716
+ phenomenon: updatedPickedPhenomena,
12717
+ incident: updatedPickedIncidents,
12718
+ source: updatedPickedSources
12719
+ }
12688
12720
  };
12689
12721
  };
12690
12722
 
@@ -12929,7 +12961,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12929
12961
  origin: origin
12930
12962
  }));
12931
12963
  }, [dispatch, panelId]);
12932
- var filterHookState = useWarningFilters(combinedWarnings, onUpdateFilters, savedFilterState, presetFilterState, isLoading);
12964
+ var filterHookState = useWarningFilters(combinedWarnings, onUpdateFilters, savedFilterState, presetFilterState);
12933
12965
  var filteredWarnings = React__default.useMemo(function () {
12934
12966
  return combinedWarnings.filter(filterHookState.byFilterState);
12935
12967
  }, [combinedWarnings, filterHookState.byFilterState]);
@@ -12986,7 +13018,6 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12986
13018
  lastUpdatedTime: lastUpdatedTime,
12987
13019
  onRefetchWarnings: fetchWarnings,
12988
13020
  filterHookState: filterHookState,
12989
- filterState: savedFilterState,
12990
13021
  hoveredFeatureId: hoveredFeatureId
12991
13022
  }), confirmDialogOptions && jsx(ConfirmDeleteWarningDialog, {
12992
13023
  onClose: function onClose() {
@@ -13373,7 +13404,7 @@ publicWarningsListener.startListening({
13373
13404
  actionCreator: publicWarningActions.fetchWarnings,
13374
13405
  effect: function () {
13375
13406
  var _effect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_, listenerApi) {
13376
- var warningsApi, _yield$warningsApi$ge, warnings, lastUpdatedTime;
13407
+ var warningsApi, _yield$warningsApi$ge, warnings, lastUpdatedTime, taskError;
13377
13408
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13378
13409
  while (1) switch (_context.prev = _context.next) {
13379
13410
  case 0:
@@ -13394,21 +13425,21 @@ publicWarningsListener.startListening({
13394
13425
  return listenerApi.delay(pollingIntervalTimeout);
13395
13426
  case 11:
13396
13427
  listenerApi.dispatch(publicWarningActions.fetchWarnings());
13397
- _context.next = 17;
13428
+ _context.next = 18;
13398
13429
  break;
13399
13430
  case 14:
13400
13431
  _context.prev = 14;
13401
13432
  _context.t0 = _context["catch"](1);
13402
- // Don't set an error if the cancelActiveListeners was invoked (which throws a TaskAbortError)
13403
- if ((_context.t0 == null ? void 0 : _context.t0.code) !== 'listener-cancelled') {
13433
+ taskError = _context.t0; // Don't set an error if the cancelActiveListeners was invoked (which throws a TaskAbortError)
13434
+ if ((taskError == null ? void 0 : taskError.code) !== 'listener-cancelled') {
13404
13435
  listenerApi.dispatch(publicWarningActions.fetchWarningsError({
13405
13436
  error: {
13406
- name: _context.t0.name,
13407
- message: _context.t0.message
13437
+ name: taskError.name,
13438
+ message: taskError.message
13408
13439
  }
13409
13440
  }));
13410
13441
  }
13411
- case 17:
13442
+ case 18:
13412
13443
  case "end":
13413
13444
  return _context.stop();
13414
13445
  }
@@ -13457,7 +13488,7 @@ drawingsListener.startListening({
13457
13488
  actionCreator: drawActions.submitDrawValues,
13458
13489
  effect: function () {
13459
13490
  var _effect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, listenerApi) {
13460
- var payload, id, formValues, warningsApi, newID, errorMessage;
13491
+ var payload, id, formValues, warningsApi, newID, taskError, errorMessage;
13461
13492
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13462
13493
  while (1) switch (_context.prev = _context.next) {
13463
13494
  case 0:
@@ -13498,24 +13529,25 @@ drawingsListener.startListening({
13498
13529
  isLoading: false,
13499
13530
  type: drawingDialogType
13500
13531
  }));
13501
- _context.next = 23;
13532
+ _context.next = 24;
13502
13533
  break;
13503
13534
  case 20:
13504
13535
  _context.prev = 20;
13505
13536
  _context.t0 = _context["catch"](3);
13506
13537
  // Don't do anything if the cancelActiveListeners was invoked (which throws a TaskAbortError)
13507
- if (_context.t0.code !== 'listener-cancelled') {
13538
+ taskError = _context.t0;
13539
+ if ((taskError == null ? void 0 : taskError.code) !== 'listener-cancelled') {
13508
13540
  listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
13509
13541
  isLoading: false,
13510
13542
  type: drawingDialogType
13511
13543
  }));
13512
- errorMessage = isAxiosError$1(_context.t0) ? getAxiosErrorMessage(_context.t0) : _context.t0.message;
13544
+ errorMessage = isAxiosError$1(taskError) ? getAxiosErrorMessage(taskError) : taskError.message;
13513
13545
  listenerApi.dispatch(uiActions.setErrorDialog({
13514
13546
  type: drawingDialogType,
13515
13547
  error: errorMessage
13516
13548
  }));
13517
13549
  }
13518
- case 23:
13550
+ case 24:
13519
13551
  case "end":
13520
13552
  return _context.stop();
13521
13553
  }
@@ -13546,8 +13578,6 @@ drawingsListener.startListening({
13546
13578
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
13547
13579
  * */
13548
13580
  var drawingModuleConfig = {
13549
- // TODO: remove id in https://gitlab.com/opengeoweb/opengeoweb/-/issues/5561
13550
- id: 'drawing-module',
13551
13581
  reducersMap: {
13552
13582
  drawings: reducer$2,
13553
13583
  publicWarningForm: reducer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -19,7 +19,7 @@ export interface DrawingToolFormContentsProps {
19
19
  isDirty: boolean;
20
20
  errors: FieldErrors<FieldValues>;
21
21
  onChangeDrawMode: (newMode: DrawMode) => void;
22
- onChangeOpacity: (event: SelectChangeEvent) => void;
22
+ onChangeOpacity: (event: SelectChangeEvent<unknown>) => void;
23
23
  onBlurName: (event: React.FocusEvent<HTMLInputElement>) => void;
24
24
  onSubmit: () => void;
25
25
  }
@@ -22,6 +22,7 @@ export interface FilterHookState {
22
22
  allSelected: boolean;
23
23
  updateFilter: UpdateFilter;
24
24
  byFilterState: (warning: PublicWarning) => boolean;
25
+ filterState: PickedFilterState;
25
26
  }
26
- export declare const useWarningFilters: (warnings: PublicWarning[], onUpdateFilters: (filterState: PickedFilterState, origin: UpdateFiltersOrigin) => void, savedFilterState: PickedFilterState, presetFilterState?: PickedFilterState, isLoading?: boolean) => FilterHookState;
27
+ export declare const useWarningFilters: (warnings: PublicWarning[], onUpdateFilters: (filterState: PickedFilterState, origin: UpdateFiltersOrigin) => void, savedFilterState: PickedFilterState, presetFilterState?: PickedFilterState) => FilterHookState;
27
28
  export {};
@@ -26,12 +26,13 @@ export declare const defaultDomainFilter: Record<Domain, boolean>;
26
26
  export declare const domainLevels: Record<Domain, Level[]>;
27
27
  export declare const defaultLevelFilter: Record<Level | 'unspecified', boolean>;
28
28
  export declare const defaultEmptyFilter: Record<string, boolean>;
29
- export declare const defaultPhenomenonFilter: Record<Phenomenon | 'unspecified', boolean>;
29
+ export declare const makeFilterFromList: <T extends string>(options: T[]) => Record<T | 'unspecified', boolean>;
30
+ export declare const defaultPhenomenonFilter: Record<"unspecified" | Phenomenon, boolean>;
30
31
  export declare const initialFilters: {
31
32
  incident: Record<string, boolean>;
32
33
  source: Record<string, boolean>;
33
34
  domain: Record<Domain, boolean>;
34
- phenomenon: Record<string, boolean>;
35
+ phenomenon: Record<"unspecified" | Phenomenon, boolean>;
35
36
  level: Record<"unspecified" | Level, boolean>;
36
37
  };
37
38
  type OptionsType = Partial<Record<Domain | Level | Phenomenon, boolean>>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { PublicWarning } from '../../store/publicWarningForm/types';
3
- import { FilterHookState, PickedFilterState } from '../FilterList/filter-hooks';
3
+ import { FilterHookState } from '../FilterList/filter-hooks';
4
4
  import { WarningListItemActions } from './WarningListItemMenu';
5
5
  export interface PublicWarningListProps extends WarningListItemActions {
6
6
  warnings: PublicWarning[];
@@ -12,7 +12,6 @@ export interface PublicWarningListProps extends WarningListItemActions {
12
12
  onCreateWarning?: () => void;
13
13
  onRefetchWarnings?: () => void;
14
14
  filterHookState: FilterHookState;
15
- filterState: PickedFilterState;
16
15
  hoveredFeatureId?: string;
17
16
  expandedSections: Record<string, boolean>;
18
17
  setExpandedSections: (expandedSections: Record<string, boolean>) => void;
@@ -20,6 +20,7 @@ export interface FormProps {
20
20
  defaultMapPreset?: MapPreset;
21
21
  onSaveForm?: (formValues: PublicWarningDetail) => void;
22
22
  onPublishForm?: (formValues: PublicWarningDetail) => void;
23
+ onClearForm?: () => void;
23
24
  object?: DrawingListItem;
24
25
  publicWarningDetails?: PublicWarningDetail;
25
26
  error?: FormError;
@@ -1,5 +1,4 @@
1
1
  export declare const drawingModuleConfig: {
2
- id: string;
3
2
  reducersMap: {
4
3
  drawings: import("redux").Reducer<import("./drawings/types").DrawState>;
5
4
  publicWarningForm: import("redux").Reducer<import("./publicWarningForm/reducer").PublicWarningFormState>;
@@ -33,6 +33,7 @@ export declare const publicWarningFormActions: import("@reduxjs/toolkit").CaseRe
33
33
  removeArea: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
34
34
  area: Area;
35
35
  }>) => void;
36
+ removeAllAreas: (draft: Draft<PublicWarningFormState>) => void;
36
37
  openPublicWarningFormDialog: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
37
38
  object?: DrawingListItem;
38
39
  formState?: FormAction;
@@ -3,6 +3,7 @@ export interface Area {
3
3
  objectName: string;
4
4
  geoJSON: GeoJSON.FeatureCollection;
5
5
  areaId?: string;
6
+ published_warning_uuid?: string;
6
7
  }
7
8
  export interface PublicWarningDetail {
8
9
  id?: string;
@@ -17,19 +17,7 @@ export declare const getPublicWarningsLastUpdatedTime: ((state: WarningModuleSto
17
17
  }> & {
18
18
  clearCache: () => void;
19
19
  };
20
- export declare const getWarningsFilterById: ((state: WarningModuleStore, panelId?: string | undefined) => import("../../components/FilterList/filter-hooks").PickedFilterState | {
21
- incident: Record<string, boolean>;
22
- source: Record<string, boolean>;
23
- domain: Record<import("../../components/FilterList/filter-utils").Domain, boolean>;
24
- phenomenon: Record<string, boolean>;
25
- level: Record<import("../../components/FilterList/filter-utils").Level | "unspecified", boolean>;
26
- }) & import("reselect").OutputSelectorFields<(args_0: Record<string, import("../../components/FilterList/filter-hooks").PickedFilterState>, args_1: string | undefined) => import("../../components/FilterList/filter-hooks").PickedFilterState | {
27
- incident: Record<string, boolean>;
28
- source: Record<string, boolean>;
29
- domain: Record<import("../../components/FilterList/filter-utils").Domain, boolean>;
30
- phenomenon: Record<string, boolean>;
31
- level: Record<import("../../components/FilterList/filter-utils").Level | "unspecified", boolean>;
32
- }, {
20
+ export declare const getWarningsFilterById: ((state: WarningModuleStore, panelId?: string | undefined) => import("../../components/FilterList/filter-hooks").PickedFilterState) & import("reselect").OutputSelectorFields<(args_0: Record<string, import("../../components/FilterList/filter-hooks").PickedFilterState>, args_1: string | undefined) => import("../../components/FilterList/filter-hooks").PickedFilterState, {
33
21
  clearCache: () => void;
34
22
  }> & {
35
23
  clearCache: () => void;