@opengeoweb/warnings 12.3.0 → 12.4.1

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
@@ -7,7 +7,7 @@ import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calcula
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: {
@@ -11174,6 +11243,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11174
11243
  formState = _useSelector.formState,
11175
11244
  error = _useSelector.error,
11176
11245
  panelId = _useSelector.panelId;
11246
+ var aviationWarnings = useAviationWarnings();
11177
11247
  var _usePublishWarning = usePublishWarning(),
11178
11248
  publishWarning = _usePublishWarning.mutateAsync;
11179
11249
  var _useSaveWarning = useSaveWarning(),
@@ -11220,45 +11290,58 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11220
11290
  type: publicWarningDialogType
11221
11291
  }));
11222
11292
  };
11293
+ var selectedBackendProduct = React.useMemo(function () {
11294
+ return aviationWarnings.find(function (aviationProduct) {
11295
+ return aviationProduct.uuid === (selectedAviationProduct == null ? void 0 : selectedAviationProduct.id);
11296
+ });
11297
+ }, [aviationWarnings, selectedAviationProduct]);
11298
+ var getCancelSigmet = function getCancelSigmet(selectedProduct, vaSigmetMoveToFIR) {
11299
+ if ('sigmet' in selectedProduct) {
11300
+ return prepareCancelSigmet(selectedProduct.sigmet, vaSigmetMoveToFIR || 'UNKNOWN');
11301
+ }
11302
+ return selectedProduct.airmet;
11303
+ };
11223
11304
  var saveAviationForm = /*#__PURE__*/function () {
11224
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType) {
11225
- var uuid, _postProductParam, postProductParam, errorMessage;
11305
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR) {
11306
+ var product, uuid, _postProductParam, postProductParam, errorMessage;
11226
11307
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
11227
11308
  while (1) switch (_context2.prev = _context2.next) {
11228
11309
  case 0:
11229
- _context2.prev = 0;
11310
+ // if volcanic sigmet - add to which FIR it's moving
11311
+ product = newStatus === 'CANCELLED' && selectedBackendProduct ? getCancelSigmet(selectedBackendProduct, vaSigmetMoveToFIR) : productToPost;
11312
+ _context2.prev = 1;
11230
11313
  uuid = (selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid) || null;
11231
11314
  if (!(warningType === 'sigmet')) {
11232
- _context2.next = 7;
11315
+ _context2.next = 8;
11233
11316
  break;
11234
11317
  }
11235
- _postProductParam = createSigmetPostParameter(productToPost, newStatus, uuid);
11236
- _context2.next = 6;
11318
+ _postProductParam = createSigmetPostParameter(product, newStatus, uuid);
11319
+ _context2.next = 7;
11237
11320
  return postSigmet(_postProductParam);
11238
- case 6:
11239
- return _context2.abrupt("return", _context2.sent);
11240
11321
  case 7:
11241
- postProductParam = createAirmetPostParameter(productToPost, newStatus, uuid);
11242
- _context2.next = 10;
11322
+ return _context2.abrupt("return", _context2.sent);
11323
+ case 8:
11324
+ postProductParam = createAirmetPostParameter(product, newStatus, uuid);
11325
+ _context2.next = 11;
11243
11326
  return postAirmet(postProductParam);
11244
- case 10:
11327
+ case 11:
11245
11328
  return _context2.abrupt("return", _context2.sent);
11246
- case 13:
11247
- _context2.prev = 13;
11248
- _context2.t0 = _context2["catch"](0);
11329
+ case 14:
11330
+ _context2.prev = 14;
11331
+ _context2.t0 = _context2["catch"](1);
11249
11332
  errorMessage = _context2.t0 instanceof Error ? _context2.t0 : 'Unknown error occurred';
11250
11333
  dispatch(snackbarActions.openSnackbar({
11251
11334
  type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
11252
11335
  message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
11253
11336
  }));
11254
11337
  throw _context2.t0;
11255
- case 18:
11338
+ case 19:
11256
11339
  case "end":
11257
11340
  return _context2.stop();
11258
11341
  }
11259
- }, _callee2, null, [[0, 13]]);
11342
+ }, _callee2, null, [[1, 14]]);
11260
11343
  }));
11261
- return function saveAviationForm(_x2, _x3, _x4) {
11344
+ return function saveAviationForm(_x2, _x3, _x4, _x5) {
11262
11345
  return _ref3.apply(this, arguments);
11263
11346
  };
11264
11347
  }();
@@ -11285,7 +11368,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11285
11368
  }
11286
11369
  }, _callee3);
11287
11370
  }));
11288
- return function saveForm(_x5) {
11371
+ return function saveForm(_x6) {
11289
11372
  return _ref4.apply(this, arguments);
11290
11373
  };
11291
11374
  }();
@@ -11313,7 +11396,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11313
11396
  if (formState === 'cancel') {
11314
11397
  return true;
11315
11398
  }
11316
- if (formState === 'edit') {
11399
+ if (formState === 'edit' || formState === 'amending') {
11317
11400
  return false;
11318
11401
  }
11319
11402
  if (mode === 'new') {
@@ -11322,7 +11405,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11322
11405
  return true;
11323
11406
  };
11324
11407
  var isReadOnly = getIsReadOnly();
11325
- var formMode = formState === 'edit' ? 'edit' : mode;
11408
+ var formMode = formState === 'edit' || formState === 'amending' ? 'edit' : mode;
11326
11409
  var onAddObject = function onAddObject() {
11327
11410
  dispatch(uiActions.setToggleOpenDialog({
11328
11411
  type: uiTypes.DialogTypes.AreaObjectLoader,
@@ -12785,6 +12868,13 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12785
12868
  },
12786
12869
  icon: jsx(Copy, {})
12787
12870
  };
12871
+ var aviationDelete = {
12872
+ text: t('object-manager-button-delete'),
12873
+ action: function action() {
12874
+ return onActionAviationWarning(warning, ProductAction.DISCARD);
12875
+ },
12876
+ icon: jsx(Delete, {})
12877
+ };
12788
12878
  // disable Expire option if warning is not active
12789
12879
  var shouldDisableExpire = !dateUtils.isBetween(dateUtils.getNowUtc(), dateUtils.createDate(warning.warningDetail.validFrom), dateUtils.createDate(warning.warningDetail.validUntil), '[]');
12790
12880
  switch (warning.status) {
@@ -12845,7 +12935,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12845
12935
  default:
12846
12936
  switch (warning.productStatus) {
12847
12937
  case ProductStatus.DRAFT:
12848
- return [aviationDuplicate];
12938
+ return [aviationDuplicate, aviationDelete];
12849
12939
  case ProductStatus.PUBLISHED:
12850
12940
  if (warning.type !== 'public' && (isInstanceOfCancelSigmet(warning.sigmetAirmetDetails) || isInstanceOfCancelAirmet(warning.sigmetAirmetDetails))) {
12851
12941
  return [];
@@ -12858,6 +12948,13 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12858
12948
  }
12859
12949
  },
12860
12950
  icon: jsx(Update, {})
12951
+ }, {
12952
+ text: t('warning-list-button-amend'),
12953
+ action: function action() {
12954
+ if (warning) {
12955
+ onActionAviationWarning(warning, ProductAction.AMEND);
12956
+ }
12957
+ }
12861
12958
  }, aviationDuplicate, {
12862
12959
  text: 'CNL',
12863
12960
  action: function action() {
@@ -14297,6 +14394,52 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14297
14394
  var warningType = useSelector(getWarningType);
14298
14395
  var _useProductConfig = useProductConfig(warningType, false),
14299
14396
  aviationConfig = _useProductConfig.data;
14397
+ var _usePostSigmet = usePostSigmet(),
14398
+ postSigmet = _usePostSigmet.mutateAsync;
14399
+ var _usePostAirmet = usePostAirmet(),
14400
+ postAirmet = _usePostAirmet.mutateAsync;
14401
+ var deleteAviationProduct = /*#__PURE__*/function () {
14402
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productToPost, newStatus, warningType) {
14403
+ var uuid, _postProductParam, postProductParam, errorMessage;
14404
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
14405
+ while (1) switch (_context5.prev = _context5.next) {
14406
+ case 0:
14407
+ _context5.prev = 0;
14408
+ uuid = (productToPost == null ? void 0 : productToPost.sigmetAirmetDetails.uuid) || null;
14409
+ if (!(warningType === 'sigmet')) {
14410
+ _context5.next = 7;
14411
+ break;
14412
+ }
14413
+ _postProductParam = createSigmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14414
+ _context5.next = 6;
14415
+ return postSigmet(_postProductParam);
14416
+ case 6:
14417
+ return _context5.abrupt("return", _context5.sent);
14418
+ case 7:
14419
+ postProductParam = createAirmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14420
+ _context5.next = 10;
14421
+ return postAirmet(postProductParam);
14422
+ case 10:
14423
+ return _context5.abrupt("return", _context5.sent);
14424
+ case 13:
14425
+ _context5.prev = 13;
14426
+ _context5.t0 = _context5["catch"](0);
14427
+ errorMessage = _context5.t0 instanceof Error ? _context5.t0 : 'Unknown error occurred';
14428
+ dispatch(snackbarActions.openSnackbar({
14429
+ type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
14430
+ message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
14431
+ }));
14432
+ throw _context5.t0;
14433
+ case 18:
14434
+ case "end":
14435
+ return _context5.stop();
14436
+ }
14437
+ }, _callee5, null, [[0, 13]]);
14438
+ }));
14439
+ return function deleteAviationProduct(_x7, _x8, _x9) {
14440
+ return _ref6.apply(this, arguments);
14441
+ };
14442
+ }();
14300
14443
  var handleAviationProductClick = function handleAviationProductClick(warning, actionType) {
14301
14444
  if (!warning) {
14302
14445
  return;
@@ -14304,6 +14447,9 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14304
14447
  var type = warning.warningDetail.level === 'SIG' ? 'sigmet' : 'airmet';
14305
14448
  var updatedWarning;
14306
14449
  switch (actionType) {
14450
+ case ProductAction.AMEND:
14451
+ void openPublicWarningDialog('amending', amendAviationProduct(warning, aviationConfig), type);
14452
+ break;
14307
14453
  case 'RENEW':
14308
14454
  updatedWarning = renewAviationProduct(warning, aviationConfig);
14309
14455
  void openPublicWarningDialog('edit', updatedWarning, type);
@@ -14315,6 +14461,19 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14315
14461
  case 'CANCEL':
14316
14462
  void openPublicWarningDialog('cancel', warning, type);
14317
14463
  break;
14464
+ case 'DISCARD':
14465
+ setConfirmDialogOptions({
14466
+ confirmLabel: t('warning-dialog-delete-confirm'),
14467
+ title: t('warning-dialog-delete-title'),
14468
+ description: t('warning-dialog-delete-description'),
14469
+ request: function request() {
14470
+ return deleteAviationProduct(warning, 'DISCARDED', type);
14471
+ },
14472
+ callback: function callback() {
14473
+ return onRemoveSuccess(warning.id);
14474
+ }
14475
+ });
14476
+ break;
14318
14477
  }
14319
14478
  };
14320
14479
  var openSnackbar = function openSnackbar(message) {
@@ -14378,7 +14537,9 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14378
14537
  type: publicWarningDialogType
14379
14538
  }));
14380
14539
  }
14381
- openSnackbar(snackbarMessage);
14540
+ if (snackbarMessage) {
14541
+ openSnackbar(snackbarMessage);
14542
+ }
14382
14543
  refetchWarnings();
14383
14544
  };
14384
14545
  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.1",
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.1",
12
+ "@opengeoweb/shared": "12.4.1",
13
+ "@opengeoweb/store": "12.4.1",
14
+ "@opengeoweb/webmap-react": "12.4.1",
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.1",
18
+ "@opengeoweb/form-fields": "12.4.1",
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.1",
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.1",
27
+ "@opengeoweb/webmap": "12.4.1",
28
+ "@opengeoweb/authentication": "12.4.1",
29
+ "@opengeoweb/sigmet-airmet": "12.4.1",
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;
@@ -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;