@opengeoweb/warnings 12.3.0 → 12.4.2

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,13 +1,13 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
3
  import { Polygons, ExitDomain, Share, 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, Update, Cancel, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
- import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, genericSelectors, selectorMemoizationOptions, useUpdateSharedData, mapListener, layersListener, drawingToolListener, syncGroupsListener, openlayersListener, syncGroupsReducer, drawingToolReducer, uiReducer, layerReducer, mapReducer } from '@opengeoweb/store';
4
+ import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, genericSelectors, useUpdateSharedData, genericActions, selectorMemoizationOptions, mapListener, layersListener, drawingToolListener, syncGroupsListener, openlayersListener, syncGroupsReducer, drawingToolReducer, uiReducer, layerReducer, mapReducer } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, viewUtils, OpenLayersMapView, MapControls, OpenLayersZoomControl, OpenLayersLayer, OpenLayersFeatureLayer, genericOpenLayersFeatureStyle } from '@opengeoweb/webmap-react';
6
6
  import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, sessionStorageProvider, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, current, createListenerMiddleware, combineReducers, configureStore } from '@reduxjs/toolkit';
8
8
  import { defaultBbox } from '@opengeoweb/core';
9
9
  import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, isEmpty, ReactHookFormDateTime, isXHoursAfter, isXHoursBefore } from '@opengeoweb/form-fields';
10
- import { SA_NAMESPACE, airmetConfig, sigmetConfig, isInstanceOfCancelSigmet, isInstanceOfCancelAirmet, getDefaultValidUntilValue, useShortTestHelpers, SigmetForm, AirmetForm, ProductAction, isVAPhenomenon, prepareCancelSigmet, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, getProductFormMode } from '@opengeoweb/sigmet-airmet';
10
+ import { SA_NAMESPACE, airmetConfig, sigmetConfig, isInstanceOfCancelSigmet, isInstanceOfCancelAirmet, getDefaultValidUntilValue, useShortTestHelpers, SigmetForm, AirmetForm, ProductAction, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, isVAPhenomenon, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, prepareCancelSigmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
11
11
  import { LayerType, generateMapId } from '@opengeoweb/webmap';
12
12
  import { t } from 'i18next';
13
13
  import { useTranslation } from 'react-i18next';
@@ -201,12 +201,14 @@ var en = {
201
201
  "warning-dialog-withdraw-description": "Are you sure you want to withdraw this warning?",
202
202
  "tac-missing-data": "Missing data: no TAC can be generated",
203
203
  "warning-list-button-renew": "Renew",
204
+ "warning-list-button-amend": "Amend",
204
205
  "aviation-save-success": "{{warningType}} has succesfully been saved!",
205
206
  "aviation-publish-success": "{{warningType}} has succesfully been published!",
206
207
  "publish-this-product": "Are you sure you want to publish this {{product}}?",
207
208
  "yes-cancel": "Yes, cancel {{product}}",
208
209
  "cancel-this-product": "Are you sure you want to cancel this {{product}}?",
209
- "aviation-cancel-success": "{{warningType}} has succesfully been cancelled!"
210
+ "aviation-cancel-success": "{{warningType}} has succesfully been cancelled!",
211
+ "aviation-discard-success": "{{warningType}} has been discarded!"
210
212
  };
211
213
  var nl = {
212
214
  "drawing-tool-form-tools": "Gereedschap",
@@ -298,6 +300,7 @@ var nl = {
298
300
  "warning-list-button-update": "Bijwerken",
299
301
  "warning-list-button-expire": "Verlopen",
300
302
  "warning-list-button-withdraw": "Intrekken",
303
+ "warning-list-button-amend": "Pas aan",
301
304
  "warning-list-status-draft": "Concepten",
302
305
  "warning-list-status-published": "Gepubliceerd",
303
306
  "warning-list-status-todo": "Te doen",
@@ -351,7 +354,8 @@ var nl = {
351
354
  "publish-this-product": "Weet je zeker dat je dit {{product}} wilt publiceren?",
352
355
  "yes-cancel": "Ja, annuleer {{product}}",
353
356
  "cancel-this-product": "Weet je zeker dat je dit {{product}} wilt annuleren?",
354
- "aviation-cancel-success": "niet vertaald"
357
+ "aviation-cancel-success": "niet vertaald",
358
+ "aviation-discard-success": "niet vertaald"
355
359
  };
356
360
  var fi = {
357
361
  "drawing-tool-form-tools": "Työkalut",
@@ -443,6 +447,7 @@ var fi = {
443
447
  "warning-list-button-update": "Päivitä",
444
448
  "warning-list-button-expire": "Vanhentua",
445
449
  "warning-list-button-withdraw": "Peruuttaa",
450
+ "warning-list-button-amend": "Amend",
446
451
  "warning-list-status-draft": "Luonnosta",
447
452
  "warning-list-status-published": "Julkaistua",
448
453
  "warning-list-status-todo": "Arvostelua",
@@ -496,7 +501,8 @@ var fi = {
496
501
  "publish-this-product": "Oletko varma, että haluat julkaista tämän {{product}}:n?",
497
502
  "yes-cancel": "Kyllä, peruuta {{product}}",
498
503
  "cancel-this-product": "Oletko varma, että haluat peruuttaa tämän {{product}}:n?",
499
- "aviation-cancel-success": "ei käännetty"
504
+ "aviation-cancel-success": "ei käännetty",
505
+ "aviation-discard-success": "{{warningType}} er forkastet!"
500
506
  };
501
507
  var no = {
502
508
  "drawing-tool-form-tools": "Verktøy",
@@ -588,6 +594,7 @@ var no = {
588
594
  "warning-list-button-update": "Oppdater",
589
595
  "warning-list-button-expire": "Sett som utgått",
590
596
  "warning-list-button-withdraw": "Ta ut",
597
+ "warning-list-button-amend": "Amend",
591
598
  "warning-list-status-draft": "Utkast",
592
599
  "warning-list-status-published": "Publisert",
593
600
  "warning-list-status-todo": "Til sjekk",
@@ -641,7 +648,8 @@ var no = {
641
648
  "publish-this-product": "Er du sikker på at du vil publisere dette {{product}}?",
642
649
  "yes-cancel": "Ja, kanseller {{product}}",
643
650
  "cancel-this-product": "Er du sikker på at du vil avbryte dette {{product}}?",
644
- "aviation-cancel-success": "{{warningType}} er kansellert!"
651
+ "aviation-cancel-success": "{{warningType}} er kansellert!",
652
+ "aviation-discard-success": "{{warningType}} er forkastet!"
645
653
  };
646
654
  var warningsTranslations = {
647
655
  en: en,
@@ -8527,6 +8535,8 @@ var getAviationSnackbarKey = function getAviationSnackbarKey(status) {
8527
8535
  return 'aviation-publish-success';
8528
8536
  case 'CANCELLED':
8529
8537
  return 'aviation-cancel-success';
8538
+ case 'DISCARDED':
8539
+ return 'aviation-discard-success';
8530
8540
  default:
8531
8541
  return 'aviation-save-success';
8532
8542
  }
@@ -8543,6 +8553,13 @@ var useSigmetList = function useSigmetList(disabled) {
8543
8553
  }
8544
8554
  return useAuthQuery(['sigmet-list'], getSigmetList, disabled);
8545
8555
  };
8556
+ var useAviationWarnings = function useAviationWarnings() {
8557
+ var _useAirmetList = useAirmetList(),
8558
+ airmets = _useAirmetList.data;
8559
+ var _useSigmetList = useSigmetList(),
8560
+ sigmets = _useSigmetList.data;
8561
+ return (airmets || []).concat(sigmets || []);
8562
+ };
8546
8563
  var useProductConfig = function useProductConfig(warningType, disabled) {
8547
8564
  if (disabled === void 0) {
8548
8565
  disabled = false;
@@ -8560,7 +8577,8 @@ var useTACApi = function useTACApi() {
8560
8577
  queryKey: ['sigmet-tac', product],
8561
8578
  queryFn: function queryFn() {
8562
8579
  return getSigmetTAC(auth, product);
8563
- }
8580
+ },
8581
+ staleTime: 1000 * 15
8564
8582
  });
8565
8583
  };
8566
8584
  var fetchAirmetTAC = function fetchAirmetTAC(product) {
@@ -8568,7 +8586,8 @@ var useTACApi = function useTACApi() {
8568
8586
  queryKey: ['airmet-tac', product],
8569
8587
  queryFn: function queryFn() {
8570
8588
  return getAirmetTAC(auth, product);
8571
- }
8589
+ },
8590
+ staleTime: 1000 * 15
8572
8591
  });
8573
8592
  };
8574
8593
  return {
@@ -8999,6 +9018,23 @@ var renewAviationProduct = function renewAviationProduct(aviationWarning, produc
8999
9018
  sigmetAirmetDetails: renewedWarningDetail
9000
9019
  });
9001
9020
  };
9021
+ var amendAviationProduct = function amendAviationProduct(aviationWarning, productConfig) {
9022
+ var warningDetail = aviationWarning.sigmetAirmetDetails;
9023
+ var newValidStart = dateUtils.dateToString(dateUtils.add(new Date(), {
9024
+ minutes: 5
9025
+ }));
9026
+ var newValidUntil = 'phenomenon' in warningDetail ? getDefaultValidUntilValue(productConfig, warningDetail.phenomenon, warningDetail.locationIndicatorATSR, newValidStart) : warningDetail.validDateEnd;
9027
+ var amendedWarningDetail = Object.assign({}, warningDetail, {
9028
+ validDateStart: newValidStart,
9029
+ validDateEnd: newValidUntil,
9030
+ status: ProductStatus.DRAFT,
9031
+ uuid: undefined,
9032
+ sequence: '-1'
9033
+ });
9034
+ return Object.assign({}, aviationWarning, {
9035
+ sigmetAirmetDetails: amendedWarningDetail
9036
+ });
9037
+ };
9002
9038
  var duplicateAviationProduct = function duplicateAviationProduct(aviationWarning) {
9003
9039
  var duplicatedWarningDetail = Object.assign({}, aviationWarning.sigmetAirmetDetails, {
9004
9040
  status: ProductStatus.DRAFT,
@@ -10373,6 +10409,9 @@ var Form = function Form(_ref5) {
10373
10409
  })) : null
10374
10410
  });
10375
10411
  };
10412
+ var cancelAviationProduct = function cancelAviationProduct(warningType) {
10413
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
10414
+ };
10376
10415
  var handleSubmitAviationProduct = function handleSubmitAviationProduct(action, warningType) {
10377
10416
  if (isSaving) {
10378
10417
  return;
@@ -10438,16 +10477,46 @@ var Form = function Form(_ref5) {
10438
10477
  case ProductAction.CANCEL:
10439
10478
  void showConfirmDialog(action).then(function () {
10440
10479
  setIsPublishing(true);
10441
- // if volcanic sigmet - add to which FIR it's moving
10442
- if (isVAPhenomenon(selectedAviationProduct, action)) {
10443
- void onSaveAviationForm(prepareCancelSigmet(selectedAviationProduct, watch('vaSigmetMoveToFIR')), 'CANCELLED', warningType);
10444
- } else {
10445
- void onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType);
10446
- }
10480
+ void cancelAviationProduct(warningType);
10447
10481
  setIsPublishing(false);
10448
10482
  onCloseForm();
10449
10483
  });
10450
10484
  break;
10485
+ case ProductAction.AMEND:
10486
+ void handleSubmit( /*#__PURE__*/function () {
10487
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(formValues) {
10488
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
10489
+ while (1) switch (_context10.prev = _context10.next) {
10490
+ case 0:
10491
+ _context10.next = 2;
10492
+ return showConfirmDialog(action).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
10493
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
10494
+ while (1) switch (_context9.prev = _context9.next) {
10495
+ case 0:
10496
+ setIsPublishing(true);
10497
+ void cancelAviationProduct(warningType).then(function () {
10498
+ void onSaveAviationForm(formValues, 'PUBLISHED', warningType).then(function () {
10499
+ setIsPublishing(false);
10500
+ onCloseForm();
10501
+ });
10502
+ });
10503
+ case 2:
10504
+ case "end":
10505
+ return _context9.stop();
10506
+ }
10507
+ }, _callee9);
10508
+ })));
10509
+ case 2:
10510
+ case "end":
10511
+ return _context10.stop();
10512
+ }
10513
+ }, _callee10);
10514
+ }));
10515
+ return function (_x5) {
10516
+ return _ref14.apply(this, arguments);
10517
+ };
10518
+ }())();
10519
+ break;
10451
10520
  case ProductAction.RENEW:
10452
10521
  case ProductAction.DISCARD:
10453
10522
  case ProductAction.DUPLICATE:
@@ -10728,7 +10797,7 @@ var Form = function Form(_ref5) {
10728
10797
  width: '100%',
10729
10798
  marginBottom: 1
10730
10799
  },
10731
- disabled: isPublishing,
10800
+ disabled: isPublishing || formState === 'amending',
10732
10801
  onClick: function onClick() {
10733
10802
  return selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.SAVE, warningType) : onPressSave();
10734
10803
  },
@@ -10755,7 +10824,7 @@ var Form = function Form(_ref5) {
10755
10824
  },
10756
10825
  disabled: isSaving,
10757
10826
  onClick: function onClick() {
10758
- selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.PUBLISH, warningType) : onPressPublish();
10827
+ selectedAviationProduct ? handleSubmitAviationProduct(formState === 'amending' ? ProductAction.AMEND : ProductAction.PUBLISH, warningType) : onPressPublish();
10759
10828
  },
10760
10829
  children: jsxs("span", {
10761
10830
  style: {
@@ -11160,6 +11229,9 @@ var getSelectedPublicIsFormDirty = createSelector(getPublicWarningStore, functio
11160
11229
  var getWarningType = createSelector(getPublicWarningStore, function (publicWarningStore) {
11161
11230
  return publicWarningStore == null ? void 0 : publicWarningStore.warningType;
11162
11231
  });
11232
+ var getPublicWarningPanelId = createSelector(getPublicWarningStore, function (publicWarningStore) {
11233
+ return (publicWarningStore == null ? void 0 : publicWarningStore.panelId) || '';
11234
+ });
11163
11235
 
11164
11236
  var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11165
11237
  var editor = _ref.editor,
@@ -11174,6 +11246,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11174
11246
  formState = _useSelector.formState,
11175
11247
  error = _useSelector.error,
11176
11248
  panelId = _useSelector.panelId;
11249
+ var aviationWarnings = useAviationWarnings();
11177
11250
  var _usePublishWarning = usePublishWarning(),
11178
11251
  publishWarning = _usePublishWarning.mutateAsync;
11179
11252
  var _useSaveWarning = useSaveWarning(),
@@ -11220,45 +11293,58 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11220
11293
  type: publicWarningDialogType
11221
11294
  }));
11222
11295
  };
11296
+ var selectedBackendProduct = React.useMemo(function () {
11297
+ return aviationWarnings.find(function (aviationProduct) {
11298
+ return aviationProduct.uuid === (selectedAviationProduct == null ? void 0 : selectedAviationProduct.id);
11299
+ });
11300
+ }, [aviationWarnings, selectedAviationProduct]);
11301
+ var getCancelSigmet = function getCancelSigmet(selectedProduct, vaSigmetMoveToFIR) {
11302
+ if ('sigmet' in selectedProduct) {
11303
+ return prepareCancelSigmet(selectedProduct.sigmet, vaSigmetMoveToFIR || 'UNKNOWN');
11304
+ }
11305
+ return selectedProduct.airmet;
11306
+ };
11223
11307
  var saveAviationForm = /*#__PURE__*/function () {
11224
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType) {
11225
- var uuid, _postProductParam, postProductParam, errorMessage;
11308
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR) {
11309
+ var product, uuid, _postProductParam, postProductParam, errorMessage;
11226
11310
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
11227
11311
  while (1) switch (_context2.prev = _context2.next) {
11228
11312
  case 0:
11229
- _context2.prev = 0;
11313
+ // if volcanic sigmet - add to which FIR it's moving
11314
+ product = newStatus === 'CANCELLED' && selectedBackendProduct ? getCancelSigmet(selectedBackendProduct, vaSigmetMoveToFIR) : productToPost;
11315
+ _context2.prev = 1;
11230
11316
  uuid = (selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid) || null;
11231
11317
  if (!(warningType === 'sigmet')) {
11232
- _context2.next = 7;
11318
+ _context2.next = 8;
11233
11319
  break;
11234
11320
  }
11235
- _postProductParam = createSigmetPostParameter(productToPost, newStatus, uuid);
11236
- _context2.next = 6;
11321
+ _postProductParam = createSigmetPostParameter(product, newStatus, uuid);
11322
+ _context2.next = 7;
11237
11323
  return postSigmet(_postProductParam);
11238
- case 6:
11239
- return _context2.abrupt("return", _context2.sent);
11240
11324
  case 7:
11241
- postProductParam = createAirmetPostParameter(productToPost, newStatus, uuid);
11242
- _context2.next = 10;
11325
+ return _context2.abrupt("return", _context2.sent);
11326
+ case 8:
11327
+ postProductParam = createAirmetPostParameter(product, newStatus, uuid);
11328
+ _context2.next = 11;
11243
11329
  return postAirmet(postProductParam);
11244
- case 10:
11330
+ case 11:
11245
11331
  return _context2.abrupt("return", _context2.sent);
11246
- case 13:
11247
- _context2.prev = 13;
11248
- _context2.t0 = _context2["catch"](0);
11332
+ case 14:
11333
+ _context2.prev = 14;
11334
+ _context2.t0 = _context2["catch"](1);
11249
11335
  errorMessage = _context2.t0 instanceof Error ? _context2.t0 : 'Unknown error occurred';
11250
11336
  dispatch(snackbarActions.openSnackbar({
11251
11337
  type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
11252
11338
  message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
11253
11339
  }));
11254
11340
  throw _context2.t0;
11255
- case 18:
11341
+ case 19:
11256
11342
  case "end":
11257
11343
  return _context2.stop();
11258
11344
  }
11259
- }, _callee2, null, [[0, 13]]);
11345
+ }, _callee2, null, [[1, 14]]);
11260
11346
  }));
11261
- return function saveAviationForm(_x2, _x3, _x4) {
11347
+ return function saveAviationForm(_x2, _x3, _x4, _x5) {
11262
11348
  return _ref3.apply(this, arguments);
11263
11349
  };
11264
11350
  }();
@@ -11285,7 +11371,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11285
11371
  }
11286
11372
  }, _callee3);
11287
11373
  }));
11288
- return function saveForm(_x5) {
11374
+ return function saveForm(_x6) {
11289
11375
  return _ref4.apply(this, arguments);
11290
11376
  };
11291
11377
  }();
@@ -11313,7 +11399,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11313
11399
  if (formState === 'cancel') {
11314
11400
  return true;
11315
11401
  }
11316
- if (formState === 'edit') {
11402
+ if (formState === 'edit' || formState === 'amending') {
11317
11403
  return false;
11318
11404
  }
11319
11405
  if (mode === 'new') {
@@ -11322,7 +11408,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11322
11408
  return true;
11323
11409
  };
11324
11410
  var isReadOnly = getIsReadOnly();
11325
- var formMode = formState === 'edit' ? 'edit' : mode;
11411
+ var formMode = formState === 'edit' || formState === 'amending' ? 'edit' : mode;
11326
11412
  var onAddObject = function onAddObject() {
11327
11413
  dispatch(uiActions.setToggleOpenDialog({
11328
11414
  type: uiTypes.DialogTypes.AreaObjectLoader,
@@ -11840,6 +11926,7 @@ var useAreaRequest = function useAreaRequest(warningsApi) {
11840
11926
  };
11841
11927
  };
11842
11928
  var AreaObjectLoaderConnect = function AreaObjectLoaderConnect(_ref) {
11929
+ var _selectedWarning$warn, _selectedWarning$warn2, _styledGeoJSON$featur;
11843
11930
  var bounds = _ref.bounds,
11844
11931
  _ref$source = _ref.source,
11845
11932
  source = _ref$source === void 0 ? 'app' : _ref$source;
@@ -11877,6 +11964,31 @@ var AreaObjectLoaderConnect = function AreaObjectLoaderConnect(_ref) {
11877
11964
  var warningStatus = useSelector(function (store) {
11878
11965
  return getPublicWarningStatus(store);
11879
11966
  });
11967
+ var selectedWarning = useSelector(function (store) {
11968
+ return getPublicWarning(store);
11969
+ });
11970
+ var isAviationWarning = (selectedWarning == null ? void 0 : selectedWarning.warningDetail.level) === 'SIG' || (selectedWarning == null ? void 0 : selectedWarning.warningDetail.level) === 'AIR';
11971
+ var styledGeoJSON = warningLevelFeatureColors(selectedWarning == null || (_selectedWarning$warn = selectedWarning.warningDetail) == null ? void 0 : _selectedWarning$warn.level, selectedWarning == null || (_selectedWarning$warn2 = selectedWarning.warningDetail) == null || (_selectedWarning$warn2 = _selectedWarning$warn2.areas) == null || (_selectedWarning$warn2 = _selectedWarning$warn2[0]) == null ? void 0 : _selectedWarning$warn2.geoJSON, isAviationWarning);
11972
+ // Inject warning level into feature properties to be read in OlMapViewConnect
11973
+ if (styledGeoJSON && (_styledGeoJSON$featur = styledGeoJSON.features) != null && _styledGeoJSON$featur.length) {
11974
+ styledGeoJSON.features.forEach(function (feature) {
11975
+ // eslint-disable-next-line no-param-reassign
11976
+ feature.properties = Object.assign({}, feature.properties, {
11977
+ warningLevel: selectedWarning == null ? void 0 : selectedWarning.warningDetail.level,
11978
+ hover: true
11979
+ });
11980
+ });
11981
+ }
11982
+ var sharedData = React__default.useMemo(function () {
11983
+ var _selectedWarning$warn3;
11984
+ return {
11985
+ features: [{
11986
+ id: (selectedWarning == null || (_selectedWarning$warn3 = selectedWarning.warningDetail.areas) == null || (_selectedWarning$warn3 = _selectedWarning$warn3[0]) == null ? void 0 : _selectedWarning$warn3.areaId) || '',
11987
+ geoJSON: styledGeoJSON
11988
+ }]
11989
+ };
11990
+ }, [selectedWarning, styledGeoJSON]);
11991
+ useUpdateSharedData(sharedData, 'warning-dialog');
11880
11992
  var fetchItems = function fetchItems() {
11881
11993
  dispatch(uiActions.setErrorDialog({
11882
11994
  error: '',
@@ -12136,6 +12248,21 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
12136
12248
  return _ref3.apply(this, arguments);
12137
12249
  };
12138
12250
  }();
12251
+ var panelId = useSelector(function (store) {
12252
+ return getPublicWarningPanelId(store);
12253
+ });
12254
+ var linkedMaps = useSelector(function (store) {
12255
+ return genericSelectors.getLinkedMaps(store, panelId);
12256
+ });
12257
+ React__default.useEffect(function () {
12258
+ if (linkedMaps) {
12259
+ dispatch(genericActions.updateLinkedMap({
12260
+ panelId: 'warning-dialog',
12261
+ mapIds: linkedMaps
12262
+ }));
12263
+ }
12264
+ // eslint-disable-next-line react-hooks/exhaustive-deps
12265
+ }, [dispatch, linkedMaps == null ? void 0 : linkedMaps.join(',')]);
12139
12266
  React__default.useEffect(function () {
12140
12267
  if (editor !== (selectedWarning == null ? void 0 : selectedWarning.editor) && status !== 'TODO') {
12141
12268
  void setIsEditor(editor !== (auth == null ? void 0 : auth.username));
@@ -12785,6 +12912,13 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12785
12912
  },
12786
12913
  icon: jsx(Copy, {})
12787
12914
  };
12915
+ var aviationDelete = {
12916
+ text: t('object-manager-button-delete'),
12917
+ action: function action() {
12918
+ return onActionAviationWarning(warning, ProductAction.DISCARD);
12919
+ },
12920
+ icon: jsx(Delete, {})
12921
+ };
12788
12922
  // disable Expire option if warning is not active
12789
12923
  var shouldDisableExpire = !dateUtils.isBetween(dateUtils.getNowUtc(), dateUtils.createDate(warning.warningDetail.validFrom), dateUtils.createDate(warning.warningDetail.validUntil), '[]');
12790
12924
  switch (warning.status) {
@@ -12845,7 +12979,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12845
12979
  default:
12846
12980
  switch (warning.productStatus) {
12847
12981
  case ProductStatus.DRAFT:
12848
- return [aviationDuplicate];
12982
+ return [aviationDuplicate, aviationDelete];
12849
12983
  case ProductStatus.PUBLISHED:
12850
12984
  if (warning.type !== 'public' && (isInstanceOfCancelSigmet(warning.sigmetAirmetDetails) || isInstanceOfCancelAirmet(warning.sigmetAirmetDetails))) {
12851
12985
  return [];
@@ -12858,6 +12992,13 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12858
12992
  }
12859
12993
  },
12860
12994
  icon: jsx(Update, {})
12995
+ }, {
12996
+ text: t('warning-list-button-amend'),
12997
+ action: function action() {
12998
+ if (warning) {
12999
+ onActionAviationWarning(warning, ProductAction.AMEND);
13000
+ }
13001
+ }
12861
13002
  }, aviationDuplicate, {
12862
13003
  text: 'CNL',
12863
13004
  action: function action() {
@@ -14297,6 +14438,52 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14297
14438
  var warningType = useSelector(getWarningType);
14298
14439
  var _useProductConfig = useProductConfig(warningType, false),
14299
14440
  aviationConfig = _useProductConfig.data;
14441
+ var _usePostSigmet = usePostSigmet(),
14442
+ postSigmet = _usePostSigmet.mutateAsync;
14443
+ var _usePostAirmet = usePostAirmet(),
14444
+ postAirmet = _usePostAirmet.mutateAsync;
14445
+ var deleteAviationProduct = /*#__PURE__*/function () {
14446
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productToPost, newStatus, warningType) {
14447
+ var uuid, _postProductParam, postProductParam, errorMessage;
14448
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
14449
+ while (1) switch (_context5.prev = _context5.next) {
14450
+ case 0:
14451
+ _context5.prev = 0;
14452
+ uuid = (productToPost == null ? void 0 : productToPost.sigmetAirmetDetails.uuid) || null;
14453
+ if (!(warningType === 'sigmet')) {
14454
+ _context5.next = 7;
14455
+ break;
14456
+ }
14457
+ _postProductParam = createSigmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14458
+ _context5.next = 6;
14459
+ return postSigmet(_postProductParam);
14460
+ case 6:
14461
+ return _context5.abrupt("return", _context5.sent);
14462
+ case 7:
14463
+ postProductParam = createAirmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14464
+ _context5.next = 10;
14465
+ return postAirmet(postProductParam);
14466
+ case 10:
14467
+ return _context5.abrupt("return", _context5.sent);
14468
+ case 13:
14469
+ _context5.prev = 13;
14470
+ _context5.t0 = _context5["catch"](0);
14471
+ errorMessage = _context5.t0 instanceof Error ? _context5.t0 : 'Unknown error occurred';
14472
+ dispatch(snackbarActions.openSnackbar({
14473
+ type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
14474
+ message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
14475
+ }));
14476
+ throw _context5.t0;
14477
+ case 18:
14478
+ case "end":
14479
+ return _context5.stop();
14480
+ }
14481
+ }, _callee5, null, [[0, 13]]);
14482
+ }));
14483
+ return function deleteAviationProduct(_x7, _x8, _x9) {
14484
+ return _ref6.apply(this, arguments);
14485
+ };
14486
+ }();
14300
14487
  var handleAviationProductClick = function handleAviationProductClick(warning, actionType) {
14301
14488
  if (!warning) {
14302
14489
  return;
@@ -14304,6 +14491,9 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14304
14491
  var type = warning.warningDetail.level === 'SIG' ? 'sigmet' : 'airmet';
14305
14492
  var updatedWarning;
14306
14493
  switch (actionType) {
14494
+ case ProductAction.AMEND:
14495
+ void openPublicWarningDialog('amending', amendAviationProduct(warning, aviationConfig), type);
14496
+ break;
14307
14497
  case 'RENEW':
14308
14498
  updatedWarning = renewAviationProduct(warning, aviationConfig);
14309
14499
  void openPublicWarningDialog('edit', updatedWarning, type);
@@ -14315,6 +14505,19 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14315
14505
  case 'CANCEL':
14316
14506
  void openPublicWarningDialog('cancel', warning, type);
14317
14507
  break;
14508
+ case 'DISCARD':
14509
+ setConfirmDialogOptions({
14510
+ confirmLabel: t('warning-dialog-delete-confirm'),
14511
+ title: t('warning-dialog-delete-title'),
14512
+ description: t('warning-dialog-delete-description'),
14513
+ request: function request() {
14514
+ return deleteAviationProduct(warning, 'DISCARDED', type);
14515
+ },
14516
+ callback: function callback() {
14517
+ return onRemoveSuccess(warning.id);
14518
+ }
14519
+ });
14520
+ break;
14318
14521
  }
14319
14522
  };
14320
14523
  var openSnackbar = function openSnackbar(message) {
@@ -14378,7 +14581,9 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14378
14581
  type: publicWarningDialogType
14379
14582
  }));
14380
14583
  }
14381
- openSnackbar(snackbarMessage);
14584
+ if (snackbarMessage) {
14585
+ openSnackbar(snackbarMessage);
14586
+ }
14382
14587
  refetchWarnings();
14383
14588
  };
14384
14589
  var onUpdateFilters = React__default.useCallback(function (filterState, systemUpdate) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "12.3.0",
3
+ "version": "12.4.2",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,27 +8,27 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "12.3.0",
12
- "@opengeoweb/shared": "12.3.0",
13
- "@opengeoweb/store": "12.3.0",
14
- "@opengeoweb/webmap-react": "12.3.0",
11
+ "@opengeoweb/api": "12.4.2",
12
+ "@opengeoweb/shared": "12.4.2",
13
+ "@opengeoweb/store": "12.4.2",
14
+ "@opengeoweb/webmap-react": "12.4.2",
15
15
  "@tanstack/react-query": "^5.69.2",
16
16
  "react-redux": "^9.2.0",
17
- "@opengeoweb/theme": "12.3.0",
18
- "@opengeoweb/form-fields": "12.3.0",
17
+ "@opengeoweb/theme": "12.4.2",
18
+ "@opengeoweb/form-fields": "12.4.2",
19
19
  "react-hook-form": "^7.50.1",
20
20
  "lodash": "^4.17.21",
21
21
  "@reduxjs/toolkit": "^2.6.1",
22
- "@opengeoweb/snackbar": "12.3.0",
22
+ "@opengeoweb/snackbar": "12.4.2",
23
23
  "react-window": "^1.8.10",
24
24
  "react-virtualized-auto-sizer": "^1.0.20",
25
25
  "axios": "^1.7.7",
26
- "@opengeoweb/core": "12.3.0",
27
- "@opengeoweb/webmap": "12.3.0",
28
- "@opengeoweb/authentication": "12.3.0",
29
- "@opengeoweb/sigmet-airmet": "12.3.0",
26
+ "@opengeoweb/core": "12.4.2",
27
+ "@opengeoweb/webmap": "12.4.2",
28
+ "@opengeoweb/authentication": "12.4.2",
29
+ "@opengeoweb/sigmet-airmet": "12.4.2",
30
30
  "react-i18next": "^15.1.1",
31
- "i18next": "^23.11.5",
31
+ "i18next": "^25.0.1",
32
32
  "@mui/material": "^7.0.1",
33
33
  "ol": "^10.4.0",
34
34
  "msw": "^2.7.3"
@@ -4,6 +4,7 @@ import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
4
4
  import { WarningType } from '../../store/publicWarningForm/types';
5
5
  export declare const useAirmetList: (disabled?: boolean) => UseQueryResult<AirmetFromBackend[]>;
6
6
  export declare const useSigmetList: (disabled?: boolean) => UseQueryResult<SigmetFromBackend[]>;
7
+ export declare const useAviationWarnings: () => (SigmetFromBackend | AirmetFromBackend)[];
7
8
  export declare const useProductConfig: (warningType?: WarningType, disabled?: boolean) => UseQueryResult<SigmetConfig | AirmetConfig>;
8
9
  type FetchTACData = Promise<{
9
10
  data: string;
@@ -1,6 +1,5 @@
1
1
  import { AviationProduct, FormMode, ProductStatus } from '@opengeoweb/sigmet-airmet';
2
2
  import * as React from 'react';
3
- import { FieldValues } from 'react-hook-form';
4
3
  import { MapPreset } from '@opengeoweb/store';
5
4
  import { FeatureCollection, GeoJsonProperties, Geometry } from 'geojson';
6
5
  import { FormError } from '../../store/publicWarningForm/reducer';
@@ -22,7 +21,7 @@ export interface FormProps {
22
21
  onPublishForm?: (formValues: PublicWarningDetail) => Promise<Headers | null>;
23
22
  onClearForm?: () => void;
24
23
  onCloseForm?: () => void;
25
- onSaveAviationForm?: (formValues: FieldValues, action: ProductStatus, warningType: 'sigmet' | 'airmet') => Promise<Headers | null>;
24
+ onSaveAviationForm?: (formValues: AviationProduct, action: ProductStatus, warningType: 'sigmet' | 'airmet', vaSigmetMoveToFIR?: string) => Promise<Headers | null>;
26
25
  object?: DrawingListItem;
27
26
  publicWarningDetails?: PublicWarningDetail;
28
27
  error?: FormError;
@@ -4,7 +4,9 @@ import { MapPreset } from '@opengeoweb/store';
4
4
  import { WarningType } from '../../store/publicWarningForm/types';
5
5
  export interface PublicWarningsFormConnectProps {
6
6
  editor?: string;
7
- selectedAviationProduct?: AviationProduct;
7
+ selectedAviationProduct?: AviationProduct & {
8
+ id?: string;
9
+ };
8
10
  warningType?: WarningType;
9
11
  mode?: FormMode;
10
12
  defaultMapPreset?: MapPreset;
@@ -2,7 +2,7 @@ import { AlertColor } from '@mui/material';
2
2
  import { Draft, PayloadAction } from '@reduxjs/toolkit';
3
3
  import { DrawingListItem } from '../warningsDrawings/types';
4
4
  import { Area, Warning, WarningType } from './types';
5
- export type FormAction = '' | 'saving' | 'publishing' | 'readonly' | 'edit' | 'cancel';
5
+ export type FormAction = '' | 'saving' | 'publishing' | 'readonly' | 'edit' | 'amending' | 'cancel';
6
6
  export interface FormError {
7
7
  severity?: AlertColor;
8
8
  message: string;
@@ -127,18 +127,18 @@ export declare const getPublicWarningAreas: ((state: WarningModuleStore) => impo
127
127
  argsMemoize: typeof import("reselect").weakMapMemoize;
128
128
  memoize: typeof import("reselect").weakMapMemoize;
129
129
  };
130
- export declare const getPublicWarningFormState: ((state: WarningModuleStore) => "" | "saving" | "publishing" | "readonly" | "edit" | "cancel") & {
130
+ export declare const getPublicWarningFormState: ((state: WarningModuleStore) => "" | "saving" | "publishing" | "readonly" | "edit" | "amending" | "cancel") & {
131
131
  clearCache: () => void;
132
132
  resultsCount: () => number;
133
133
  resetResultsCount: () => void;
134
134
  } & {
135
- resultFunc: (resultFuncArgs_0: WarningFormState) => "" | "saving" | "publishing" | "readonly" | "edit" | "cancel";
136
- memoizedResultFunc: ((resultFuncArgs_0: WarningFormState) => "" | "saving" | "publishing" | "readonly" | "edit" | "cancel") & {
135
+ resultFunc: (resultFuncArgs_0: WarningFormState) => "" | "saving" | "publishing" | "readonly" | "edit" | "amending" | "cancel";
136
+ memoizedResultFunc: ((resultFuncArgs_0: WarningFormState) => "" | "saving" | "publishing" | "readonly" | "edit" | "amending" | "cancel") & {
137
137
  clearCache: () => void;
138
138
  resultsCount: () => number;
139
139
  resetResultsCount: () => void;
140
140
  };
141
- lastResult: () => "" | "saving" | "publishing" | "readonly" | "edit" | "cancel";
141
+ lastResult: () => "" | "saving" | "publishing" | "readonly" | "edit" | "amending" | "cancel";
142
142
  dependencies: [(store: WarningModuleStore) => WarningFormState];
143
143
  recomputations: () => number;
144
144
  resetRecomputations: () => void;
@@ -232,3 +232,24 @@ export declare const getWarningType: ((state: WarningModuleStore) => import("./t
232
232
  argsMemoize: typeof import("reselect").weakMapMemoize;
233
233
  memoize: typeof import("reselect").weakMapMemoize;
234
234
  };
235
+ export declare const getPublicWarningPanelId: ((state: WarningModuleStore) => string) & {
236
+ clearCache: () => void;
237
+ resultsCount: () => number;
238
+ resetResultsCount: () => void;
239
+ } & {
240
+ resultFunc: (resultFuncArgs_0: WarningFormState) => string;
241
+ memoizedResultFunc: ((resultFuncArgs_0: WarningFormState) => string) & {
242
+ clearCache: () => void;
243
+ resultsCount: () => number;
244
+ resetResultsCount: () => void;
245
+ };
246
+ lastResult: () => string;
247
+ dependencies: [(store: WarningModuleStore) => WarningFormState];
248
+ recomputations: () => number;
249
+ resetRecomputations: () => void;
250
+ dependencyRecomputations: () => number;
251
+ resetDependencyRecomputations: () => void;
252
+ } & {
253
+ argsMemoize: typeof import("reselect").weakMapMemoize;
254
+ memoize: typeof import("reselect").weakMapMemoize;
255
+ };
@@ -14,4 +14,5 @@ export declare const transformAirmetFromBackendToProductFormat: (warning: Airmet
14
14
  export declare const getEmptySigmetWarning: () => AviationProduct;
15
15
  export declare const getEmptyAirmetWarning: () => AviationProduct;
16
16
  export declare const renewAviationProduct: <T extends AirmetWarning | SigmetWarning>(aviationWarning: T, productConfig: ProductConfig) => T;
17
+ export declare const amendAviationProduct: <T extends AirmetWarning | SigmetWarning>(aviationWarning: T, productConfig: ProductConfig) => T;
17
18
  export declare const duplicateAviationProduct: <T extends AirmetWarning | SigmetWarning>(aviationWarning: T) => T;