@opengeoweb/warnings 12.6.0 → 12.8.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
@@ -7,7 +7,7 @@ import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calcula
7
7
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, current, combineReducers, configureStore } from '@reduxjs/toolkit';
8
8
  import { defaultBbox } from '@opengeoweb/core';
9
9
  import { FORM_FIELDS_NAMESPACE, useDraftFormHelpers, ReactHookFormSelect, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, errorMessages, isEmpty, ReactHookFormDateTime, isXHoursAfter, isXHoursBefore } from '@opengeoweb/form-fields';
10
- import { SA_NAMESPACE, isInstanceOfCancelSigmet, getDefaultValidFromValue, isInstanceOfCancelAirmet, getDefaultValidUntilValue, useShortTestHelpers, SigmetForm, AirmetForm, ProductAction, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, isVAPhenomenon, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, prepareCancelSigmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
10
+ import { SA_NAMESPACE, isInstanceOfCancelSigmet, getDefaultValidFromValue, isInstanceOfCancelAirmet, getTacGeometry, getMaxPolygonPoints, 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';
@@ -2227,6 +2227,9 @@ var slice$1 = createSlice({
2227
2227
  var warningId = action.payload.warningId;
2228
2228
  draft.selectedWarningId = warningId;
2229
2229
  draft.formState = 'edit';
2230
+ },
2231
+ setSelectedWarningId: function setSelectedWarningId(draft, action) {
2232
+ draft.selectedWarningId = action.payload;
2230
2233
  }
2231
2234
  },
2232
2235
  extraReducers: function extraReducers(builder) {
@@ -2989,7 +2992,7 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
2989
2992
  var _useAuthenticationCon2 = useAuthenticationContext(),
2990
2993
  auth = _useAuthenticationCon2.auth;
2991
2994
  var dispatch = useDispatch();
2992
- return useMutation(Object.assign({
2995
+ return useMutation({
2993
2996
  mutationFn: function mutationFn(_ref4) {
2994
2997
  var id = _ref4.id,
2995
2998
  data = _ref4.data;
@@ -3001,15 +3004,7 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
3001
3004
  return updatePublicWarning(id, auth, data);
3002
3005
  }
3003
3006
  return postPublicWarning(auth, data);
3004
- }
3005
- }, optimisticUpdate(['public-warning-list'], queryClient, function (_, _ref5) {
3006
- var data = _ref5.data,
3007
- id = _ref5.id;
3008
- return Object.assign({}, data, {
3009
- id: id,
3010
- lastUpdatedTime: new Date().toISOString()
3011
- });
3012
- }), {
3007
+ },
3013
3008
  onError: function onError(error) {
3014
3009
  void queryClient.invalidateQueries({
3015
3010
  queryKey: ['public-warning-list']
@@ -3020,34 +3015,17 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
3020
3015
  },
3021
3016
  onSuccess: function () {
3022
3017
  var _onSuccess2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, variables) {
3023
- var location, _variables$data, warningDetail, status, newId, newWarning;
3018
+ var location, warningDetail, newId, newWarning;
3024
3019
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3025
3020
  while (1) switch (_context2.prev = _context2.next) {
3026
3021
  case 0:
3022
+ _context2.next = 2;
3023
+ return queryClient.invalidateQueries({
3024
+ queryKey: ['public-warning-list']
3025
+ });
3026
+ case 2:
3027
3027
  location = data == null ? void 0 : data.get('location');
3028
- _variables$data = variables.data, warningDetail = _variables$data.warningDetail, status = _variables$data.status;
3029
- if (
3030
- // DRAFT_PUBLISHED warnings have linked_to_id to the published warning it is based on
3031
- // When publishing a DRAFT_PUBLISHED warning we need to update the published warning and delete the draft
3032
- warningDetail.linked_to_id && status === PublicWarningStatus.PUBLISHED) {
3033
- queryClient.setQueryData(['public-warning-list'], function (old) {
3034
- return old == null ? void 0 : old.reduce(function (acc, warning) {
3035
- if (warning.id === warningDetail.linked_to_id) {
3036
- return acc;
3037
- }
3038
- if (warning.id === warningDetail.id) {
3039
- return [].concat(acc, [Object.assign({}, warning, {
3040
- id: warningDetail.linked_to_id,
3041
- warningDetail: Object.assign({}, warning.warningDetail, {
3042
- id: warningDetail.linked_to_id
3043
- }),
3044
- lastUpdatedTime: new Date().toISOString()
3045
- })]);
3046
- }
3047
- return [].concat(acc, [warning]);
3048
- }, []);
3049
- });
3050
- }
3028
+ warningDetail = variables.data.warningDetail;
3051
3029
  if (location) {
3052
3030
  // When making a new warning we get it's ID from the location header
3053
3031
  newId = getIdFromUrl(location);
@@ -3059,9 +3037,6 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
3059
3037
  domain: 'public'
3060
3038
  })
3061
3039
  });
3062
- queryClient.setQueryData(['public-warning-list'], function (old) {
3063
- return [].concat(old || [], [newWarning]);
3064
- });
3065
3040
  dispatch(publicWarningFormActions.openPublicWarningFormDialog({
3066
3041
  warning: newWarning,
3067
3042
  formState: '',
@@ -3078,7 +3053,7 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
3078
3053
  setOpen: false
3079
3054
  }));
3080
3055
  }
3081
- case 6:
3056
+ case 7:
3082
3057
  case "end":
3083
3058
  return _context2.stop();
3084
3059
  }
@@ -3089,7 +3064,7 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
3089
3064
  }
3090
3065
  return onSuccess;
3091
3066
  }()
3092
- }));
3067
+ });
3093
3068
  };
3094
3069
  var useMutateDeleteWarning = function useMutateDeleteWarning() {
3095
3070
  var queryClient = useQueryClient();
@@ -3097,8 +3072,8 @@ var useMutateDeleteWarning = function useMutateDeleteWarning() {
3097
3072
  var _useAuthenticationCon3 = useAuthenticationContext(),
3098
3073
  auth = _useAuthenticationCon3.auth;
3099
3074
  return useMutation({
3100
- mutationFn: function mutationFn(_ref6) {
3101
- var id = _ref6.id;
3075
+ mutationFn: function mutationFn(_ref5) {
3076
+ var id = _ref5.id;
3102
3077
  if (!auth) {
3103
3078
  throw new Error('Authentication context not found');
3104
3079
  }
@@ -3173,12 +3148,12 @@ var useMutateSaveOrUpdateDrawing = function useMutateSaveOrUpdateDrawing() {
3173
3148
  var queryClient = useQueryClient();
3174
3149
  return useMutation({
3175
3150
  mutationFn: function () {
3176
- var _mutationFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref7) {
3151
+ var _mutationFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref6) {
3177
3152
  var data, id, headers, location, newId;
3178
3153
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3179
3154
  while (1) switch (_context4.prev = _context4.next) {
3180
3155
  case 0:
3181
- data = _ref7.data, id = _ref7.id;
3156
+ data = _ref6.data, id = _ref6.id;
3182
3157
  if (auth) {
3183
3158
  _context4.next = 3;
3184
3159
  break;
@@ -3222,8 +3197,8 @@ var useMutateSaveOrUpdateDrawing = function useMutateSaveOrUpdateDrawing() {
3222
3197
  }
3223
3198
  return mutationFn;
3224
3199
  }(),
3225
- onSuccess: function onSuccess(_ref8, variables) {
3226
- var id = _ref8.id;
3200
+ onSuccess: function onSuccess(_ref7, variables) {
3201
+ var id = _ref7.id;
3227
3202
  dispatch(warningsDrawingsActions.setDrawValues({
3228
3203
  drawingInstanceId: drawingDialogType,
3229
3204
  id: String(id),
@@ -3243,12 +3218,12 @@ var useMutateDeleteDrawing = function useMutateDeleteDrawing() {
3243
3218
  var dispatch = useDispatch();
3244
3219
  return useMutation({
3245
3220
  mutationFn: function () {
3246
- var _mutationFn2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref9) {
3221
+ var _mutationFn2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref8) {
3247
3222
  var drawingId;
3248
3223
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3249
3224
  while (1) switch (_context5.prev = _context5.next) {
3250
3225
  case 0:
3251
- drawingId = _ref9.drawingId;
3226
+ drawingId = _ref8.drawingId;
3252
3227
  if (auth) {
3253
3228
  _context5.next = 3;
3254
3229
  break;
@@ -3272,8 +3247,8 @@ var useMutateDeleteDrawing = function useMutateDeleteDrawing() {
3272
3247
  }
3273
3248
  return mutationFn;
3274
3249
  }(),
3275
- onSuccess: function onSuccess(_, _ref10) {
3276
- var objectName = _ref10.objectName;
3250
+ onSuccess: function onSuccess(_, _ref9) {
3251
+ var objectName = _ref9.objectName;
3277
3252
  void queryClient.invalidateQueries({
3278
3253
  queryKey: ['drawings']
3279
3254
  });
@@ -4188,14 +4163,19 @@ var DrawingToolConnect = function DrawingToolConnect(_ref) {
4188
4163
 
4189
4164
  var WarningAvatar = function WarningAvatar(_ref) {
4190
4165
  var editor = _ref.editor,
4166
+ status = _ref.status,
4191
4167
  _ref$tooltipPlacement = _ref.tooltipPlacement,
4192
4168
  tooltipPlacement = _ref$tooltipPlacement === void 0 ? 'bottom' : _ref$tooltipPlacement;
4169
+ var effectiveStatus = status != null ? status : 'DRAFT';
4170
+ var isDraft = effectiveStatus === 'DRAFT';
4171
+ var label = isDraft ? 'Editor' : 'Author';
4193
4172
  return jsx(CustomTooltip, {
4194
- title: "Editor: " + editor,
4173
+ title: label + ": " + editor,
4195
4174
  placement: tooltipPlacement,
4196
4175
  children: jsx("span", {
4197
4176
  children: jsx(Avatar, {
4198
4177
  size: "small",
4178
+ author: !isDraft,
4199
4179
  children: getInitials(editor)
4200
4180
  })
4201
4181
  })
@@ -4336,7 +4316,8 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
4336
4316
  width: '16px'
4337
4317
  },
4338
4318
  children: publicWarningEditor && jsx(WarningAvatar, {
4339
- editor: publicWarningEditor
4319
+ editor: publicWarningEditor,
4320
+ status: selectedAviationProduct == null ? void 0 : selectedAviationProduct.status
4340
4321
  })
4341
4322
  })]
4342
4323
  })
@@ -4560,6 +4541,15 @@ var usePostSigmet = function usePostSigmet() {
4560
4541
  }
4561
4542
  return postSigmet(auth, formData);
4562
4543
  },
4544
+ onError: function onError(error) {
4545
+ void queryClient.invalidateQueries({
4546
+ queryKey: ['sigmet']
4547
+ });
4548
+ var errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
4549
+ dispatch(publicWarningFormActions.setFormError({
4550
+ message: "Failed to save SIGMET: " + errorMessage
4551
+ }));
4552
+ },
4563
4553
  onSuccess: function () {
4564
4554
  var _onSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, variables) {
4565
4555
  var snackbarKey, warningType;
@@ -4612,6 +4602,15 @@ var usePostAirmet = function usePostAirmet() {
4612
4602
  }
4613
4603
  return postAirmet(auth, formData);
4614
4604
  },
4605
+ onError: function onError(error) {
4606
+ void queryClient.invalidateQueries({
4607
+ queryKey: ['airmet']
4608
+ });
4609
+ var errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
4610
+ dispatch(publicWarningFormActions.setFormError({
4611
+ message: "Failed to save AIRMET: " + errorMessage
4612
+ }));
4613
+ },
4615
4614
  onSuccess: function () {
4616
4615
  var _onSuccess2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, variables) {
4617
4616
  var snackbarKey, warningType;
@@ -4659,16 +4658,23 @@ var flattenPublicWarning = function flattenPublicWarning(publicWarning) {
4659
4658
  rest = _objectWithoutPropertiesLoose(publicWarning, _excluded$6);
4660
4659
  return Object.assign({}, rest, sigmetAirmetDetails);
4661
4660
  };
4662
- var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(apiAirmet) {
4661
+ var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(apiAirmet, productConfig) {
4663
4662
  var airmet = apiAirmet.airmet;
4663
+ var tacGeometry = getTacGeometry({
4664
+ startGeometry: airmet.startGeometry,
4665
+ startGeometryIntersect: airmet.startGeometryIntersect,
4666
+ maxPoints: getMaxPolygonPoints(airmet.locationIndicatorATSR, productConfig)
4667
+ });
4664
4668
  var areas = [];
4665
4669
  if (airmet.startGeometry) {
4666
4670
  areas.push({
4667
- geoJSON: Object.assign({}, airmet.startGeometry, {
4668
- features: airmet.startGeometry.features.map(function (feature) {
4671
+ areaId: airmet.uuid + "-start",
4672
+ geoJSON: Object.assign({}, tacGeometry, {
4673
+ features: tacGeometry.features.map(function (feature) {
4669
4674
  return Object.assign({}, feature, {
4670
4675
  properties: Object.assign({}, feature.properties, {
4671
- isStartGeometry: true
4676
+ isStartGeometry: true,
4677
+ source: tacGeometry === airmet.startGeometry ? 'drawn' : 'intersected'
4672
4678
  })
4673
4679
  });
4674
4680
  })
@@ -4680,6 +4686,7 @@ var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(api
4680
4686
  id: apiAirmet.uuid,
4681
4687
  lastUpdatedTime: apiAirmet.lastUpdateDate,
4682
4688
  productStatus: airmet.status,
4689
+ editor: apiAirmet.author,
4683
4690
  warningDetail: {
4684
4691
  id: airmet.uuid,
4685
4692
  phenomenon: airmet.phenomenon,
@@ -4696,14 +4703,24 @@ var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(api
4696
4703
  type: 'airmet'
4697
4704
  };
4698
4705
  };
4699
- var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(apiSigmet) {
4706
+ var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(apiSigmet, productConfig) {
4700
4707
  var sigmet = apiSigmet.sigmet;
4708
+ var tacGeometryStart = getTacGeometry({
4709
+ startGeometry: sigmet.startGeometry,
4710
+ startGeometryIntersect: sigmet.startGeometryIntersect,
4711
+ maxPoints: getMaxPolygonPoints(sigmet.locationIndicatorATSR, productConfig)
4712
+ });
4713
+ var tacGeometryEnd = getTacGeometry({
4714
+ startGeometry: sigmet.endGeometry,
4715
+ startGeometryIntersect: sigmet.endGeometryIntersect,
4716
+ maxPoints: getMaxPolygonPoints(sigmet.locationIndicatorATSR, productConfig)
4717
+ });
4701
4718
  var areas = [];
4702
4719
  if (sigmet.startGeometry) {
4703
4720
  areas.push({
4704
4721
  areaId: sigmet.uuid + "-start",
4705
- geoJSON: Object.assign({}, sigmet.startGeometry, {
4706
- features: sigmet.startGeometry.features.map(function (feature) {
4722
+ geoJSON: Object.assign({}, tacGeometryStart, {
4723
+ features: tacGeometryStart.features.map(function (feature) {
4707
4724
  return Object.assign({}, feature, {
4708
4725
  properties: Object.assign({}, feature.properties, {
4709
4726
  isStartGeometry: true
@@ -4717,8 +4734,8 @@ var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(api
4717
4734
  if (sigmet.endGeometry) {
4718
4735
  areas.push({
4719
4736
  areaId: sigmet.uuid + "-end",
4720
- geoJSON: Object.assign({}, sigmet.endGeometry, {
4721
- features: sigmet.endGeometry.features.map(function (feature) {
4737
+ geoJSON: Object.assign({}, tacGeometryEnd, {
4738
+ features: tacGeometryEnd.features.map(function (feature) {
4722
4739
  return Object.assign({}, feature, {
4723
4740
  properties: Object.assign({}, feature.properties, {
4724
4741
  isStartGeometry: false
@@ -4733,6 +4750,7 @@ var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(api
4733
4750
  id: apiSigmet.uuid,
4734
4751
  lastUpdatedTime: apiSigmet.lastUpdateDate,
4735
4752
  productStatus: sigmet.status,
4753
+ editor: apiSigmet.author,
4736
4754
  warningDetail: {
4737
4755
  id: sigmet.uuid,
4738
4756
  phenomenon: sigmet.phenomenon,
@@ -5923,7 +5941,9 @@ var Form = function Form(_ref5) {
5923
5941
  });
5924
5942
  };
5925
5943
  var cancelAviationProduct = function cancelAviationProduct(warningType) {
5926
- return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
5944
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR')).then(function (result) {
5945
+ return result != null ? result : null;
5946
+ });
5927
5947
  };
5928
5948
  var getPublishButtonLabel = function getPublishButtonLabel() {
5929
5949
  if (isCancelling) {
@@ -5952,7 +5972,7 @@ var Form = function Form(_ref5) {
5952
5972
  return _context10.abrupt("return");
5953
5973
  case 2:
5954
5974
  _context10.t0 = action;
5955
- _context10.next = _context10.t0 === ProductAction.SAVE ? 5 : _context10.t0 === ProductAction.PUBLISH ? 14 : _context10.t0 === ProductAction.CANCEL ? 16 : _context10.t0 === ProductAction.AMEND ? 18 : _context10.t0 === ProductAction.RENEW ? 20 : _context10.t0 === ProductAction.DISCARD ? 20 : _context10.t0 === ProductAction.DUPLICATE ? 20 : _context10.t0 === ProductAction.CLOSE ? 20 : 21;
5975
+ _context10.next = _context10.t0 === ProductAction.SAVE ? 5 : _context10.t0 === ProductAction.PUBLISH ? 14 : _context10.t0 === ProductAction.CANCEL ? 17 : _context10.t0 === ProductAction.AMEND ? 19 : _context10.t0 === ProductAction.RENEW ? 21 : _context10.t0 === ProductAction.DISCARD ? 21 : _context10.t0 === ProductAction.DUPLICATE ? 21 : _context10.t0 === ProductAction.CLOSE ? 21 : 22;
5956
5976
  break;
5957
5977
  case 5:
5958
5978
  toggleIsDraft(true);
@@ -5963,11 +5983,17 @@ var Form = function Form(_ref5) {
5963
5983
  formValues = getValues();
5964
5984
  setIsSaving(true);
5965
5985
  _context10.next = 12;
5966
- return onSaveAviationForm(formValues, 'DRAFT', warningType)["catch"](function () {});
5986
+ return onSaveAviationForm(formValues, 'DRAFT', warningType, undefined, function (uuid) {
5987
+ setValue('uuid', uuid, {
5988
+ shouldValidate: true,
5989
+ shouldDirty: false
5990
+ });
5991
+ })["catch"](function () {});
5967
5992
  case 12:
5968
5993
  setIsSaving(false);
5969
- return _context10.abrupt("break", 22);
5994
+ return _context10.abrupt("break", 23);
5970
5995
  case 14:
5996
+ toggleIsDraft(false);
5971
5997
  void handleSubmit( /*#__PURE__*/function () {
5972
5998
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(formValues) {
5973
5999
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
@@ -6000,8 +6026,8 @@ var Form = function Form(_ref5) {
6000
6026
  return _ref12.apply(this, arguments);
6001
6027
  };
6002
6028
  }())();
6003
- return _context10.abrupt("break", 22);
6004
- case 16:
6029
+ return _context10.abrupt("break", 23);
6030
+ case 17:
6005
6031
  void showConfirmDialog(action).then(function () {
6006
6032
  setIsCancelling(true);
6007
6033
  void cancelAviationProduct(warningType)["finally"](function () {
@@ -6009,8 +6035,8 @@ var Form = function Form(_ref5) {
6009
6035
  onCloseForm();
6010
6036
  });
6011
6037
  });
6012
- return _context10.abrupt("break", 22);
6013
- case 18:
6038
+ return _context10.abrupt("break", 23);
6039
+ case 19:
6014
6040
  void handleSubmit( /*#__PURE__*/function () {
6015
6041
  var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
6016
6042
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
@@ -6044,12 +6070,12 @@ var Form = function Form(_ref5) {
6044
6070
  return _ref14.apply(this, arguments);
6045
6071
  };
6046
6072
  }())();
6047
- return _context10.abrupt("break", 22);
6048
- case 20:
6049
- return _context10.abrupt("break", 22);
6073
+ return _context10.abrupt("break", 23);
6050
6074
  case 21:
6051
- console.warn("Unhandled product action: " + action);
6075
+ return _context10.abrupt("break", 23);
6052
6076
  case 22:
6077
+ console.warn("Unhandled product action: " + action);
6078
+ case 23:
6053
6079
  case "end":
6054
6080
  return _context10.stop();
6055
6081
  }
@@ -6570,46 +6596,44 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
6570
6596
  return selectedProduct.airmet;
6571
6597
  };
6572
6598
  var saveAviationForm = /*#__PURE__*/function () {
6573
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR) {
6574
- var product, uuid, _postProductParam, postProductParam, errorMessage;
6599
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR, setSelectedUUID) {
6600
+ var _result;
6601
+ var product, uuid, result, postProductParam, _postProductParam;
6575
6602
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6576
6603
  while (1) switch (_context2.prev = _context2.next) {
6577
6604
  case 0:
6578
- // if volcanic sigmet - add to which FIR it's moving
6579
6605
  product = newStatus === 'CANCELLED' && selectedBackendProduct ? getCancelSigmet(selectedBackendProduct, vaSigmetMoveToFIR) : productToPost;
6580
- _context2.prev = 1;
6581
6606
  uuid = (selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid) || null;
6582
6607
  if (!(warningType === 'sigmet')) {
6583
- _context2.next = 8;
6608
+ _context2.next = 9;
6584
6609
  break;
6585
6610
  }
6586
- _postProductParam = createSigmetPostParameter(product, newStatus, uuid);
6587
- _context2.next = 7;
6588
- return postSigmet(_postProductParam);
6589
- case 7:
6590
- return _context2.abrupt("return", _context2.sent);
6591
- case 8:
6592
- postProductParam = createAirmetPostParameter(product, newStatus, uuid);
6593
- _context2.next = 11;
6594
- return postAirmet(postProductParam);
6595
- case 11:
6596
- return _context2.abrupt("return", _context2.sent);
6597
- case 14:
6598
- _context2.prev = 14;
6599
- _context2.t0 = _context2["catch"](1);
6600
- errorMessage = _context2.t0 instanceof Error ? _context2.t0 : 'Unknown error occurred';
6601
- dispatch(snackbarActions.openSnackbar({
6602
- type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
6603
- message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
6604
- }));
6605
- throw _context2.t0;
6606
- case 19:
6611
+ postProductParam = createSigmetPostParameter(product, newStatus, uuid);
6612
+ _context2.next = 6;
6613
+ return postSigmet(postProductParam);
6614
+ case 6:
6615
+ result = _context2.sent;
6616
+ _context2.next = 13;
6617
+ break;
6618
+ case 9:
6619
+ _postProductParam = createAirmetPostParameter(product, newStatus, uuid);
6620
+ _context2.next = 12;
6621
+ return postAirmet(_postProductParam);
6622
+ case 12:
6623
+ result = _context2.sent;
6624
+ case 13:
6625
+ if ((_result = result) != null && _result.uuid) {
6626
+ setSelectedUUID == null || setSelectedUUID(result.uuid);
6627
+ dispatch(publicWarningFormActions.setSelectedWarningId(result.uuid));
6628
+ }
6629
+ return _context2.abrupt("return", result);
6630
+ case 15:
6607
6631
  case "end":
6608
6632
  return _context2.stop();
6609
6633
  }
6610
- }, _callee2, null, [[1, 14]]);
6634
+ }, _callee2);
6611
6635
  }));
6612
- return function saveAviationForm(_x2, _x3, _x4, _x5) {
6636
+ return function saveAviationForm(_x2, _x3, _x4, _x5, _x6) {
6613
6637
  return _ref3.apply(this, arguments);
6614
6638
  };
6615
6639
  }();
@@ -6636,7 +6660,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
6636
6660
  }
6637
6661
  }, _callee3);
6638
6662
  }));
6639
- return function saveForm(_x6) {
6663
+ return function saveForm(_x7) {
6640
6664
  return _ref4.apply(this, arguments);
6641
6665
  };
6642
6666
  }();
@@ -7402,11 +7426,18 @@ var useWarnings = function useWarnings(disabled) {
7402
7426
  sigmetWarnings = _useSigmetList.data,
7403
7427
  refetchSigmet = _useSigmetList.refetch,
7404
7428
  isFetchingSigmet = _useSigmetList.isFetching;
7429
+ var warningType = useSelector(getWarningType);
7430
+ var _useProductConfig = useProductConfig(warningType, false),
7431
+ aviationConfig = _useProductConfig.data;
7405
7432
  var combinedWarnings = useMemo(function () {
7406
- var transformedSigmets = (sigmetWarnings == null ? void 0 : sigmetWarnings.map(transformSigmetToWarningFormat)) || [];
7407
- var transformedAirmets = (airmetWarnings == null ? void 0 : airmetWarnings.map(transformAirmetToWarningFormat)) || [];
7433
+ var transformedSigmets = (sigmetWarnings == null ? void 0 : sigmetWarnings.map(function (sigmet) {
7434
+ return transformSigmetToWarningFormat(sigmet, aviationConfig);
7435
+ })) || [];
7436
+ var transformedAirmets = (airmetWarnings == null ? void 0 : airmetWarnings.map(function (airmet) {
7437
+ return transformAirmetToWarningFormat(airmet, aviationConfig);
7438
+ })) || [];
7408
7439
  return concat(publicWarnings || [], transformedSigmets, transformedAirmets);
7409
- }, [publicWarnings, sigmetWarnings, airmetWarnings]);
7440
+ }, [sigmetWarnings, airmetWarnings, publicWarnings, aviationConfig]);
7410
7441
  var refetchWarnings = function refetchWarnings() {
7411
7442
  void refetchPublicWarnings();
7412
7443
  void refetchAirmet();
@@ -7484,7 +7515,7 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
7484
7515
  var isEditor = (selectedWarning == null ? void 0 : selectedWarning.editor) === (auth == null ? void 0 : auth.username) || false;
7485
7516
  var shouldGiveEditorWarning = React__default.useCallback(function (newEditor, oldEditor) {
7486
7517
  var oldEditorIsYou = oldEditor && oldEditor === (auth == null ? void 0 : auth.username);
7487
- if (oldEditorIsYou && newEditor !== oldEditor) {
7518
+ if (oldEditorIsYou && newEditor && newEditor !== oldEditor) {
7488
7519
  dispatch(publicWarningFormActions.setFormError({
7489
7520
  severity: 'warning',
7490
7521
  message: TAKEOVER_MESSAGE
@@ -8521,7 +8552,8 @@ var WarningListItem = function WarningListItem(_ref) {
8521
8552
  right: '4px'
8522
8553
  },
8523
8554
  children: jsx(WarningAvatar, {
8524
- editor: warning.editor
8555
+ editor: warning.editor,
8556
+ status: warning.productStatus
8525
8557
  })
8526
8558
  })]
8527
8559
  })
@@ -9616,18 +9648,22 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
9616
9648
  void openPublicWarningDialog('cancel', warning, type);
9617
9649
  break;
9618
9650
  case 'DISCARD':
9619
- setConfirmDialogOptions({
9620
- confirmLabel: t('warning-dialog-delete-confirm'),
9621
- title: t('warning-dialog-delete-title'),
9622
- description: t('warning-dialog-delete-description'),
9623
- request: function request() {
9624
- return deleteAviationProduct(warning, 'DISCARDED', type);
9625
- },
9626
- callback: function callback() {
9627
- return onRemoveSuccess(warning.id);
9628
- }
9629
- });
9630
- break;
9651
+ {
9652
+ var isLocked = warning.editor && warning.editor !== (auth == null ? void 0 : auth.username) || false;
9653
+ setConfirmDialogOptions({
9654
+ confirmLabel: t('warning-dialog-delete-confirm'),
9655
+ title: t('warning-dialog-delete-title'),
9656
+ description: t('warning-dialog-delete-description'),
9657
+ request: function request() {
9658
+ return deleteAviationProduct(warning, 'DISCARDED', type);
9659
+ },
9660
+ callback: function callback() {
9661
+ return onRemoveSuccess(warning.id);
9662
+ },
9663
+ isLocked: isLocked
9664
+ });
9665
+ break;
9666
+ }
9631
9667
  }
9632
9668
  };
9633
9669
  var openSnackbar = function openSnackbar(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "12.6.0",
3
+ "version": "12.8.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,30 +8,31 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "12.6.0",
12
- "@opengeoweb/shared": "12.6.0",
13
- "@opengeoweb/store": "12.6.0",
14
- "@opengeoweb/webmap-react": "12.6.0",
11
+ "@opengeoweb/api": "12.8.0",
12
+ "@opengeoweb/shared": "12.8.0",
13
+ "@opengeoweb/store": "12.8.0",
14
+ "@opengeoweb/webmap-react": "12.8.0",
15
15
  "@tanstack/react-query": "^5.69.2",
16
16
  "react-redux": "^9.2.0",
17
- "@opengeoweb/theme": "12.6.0",
18
- "@opengeoweb/form-fields": "12.6.0",
17
+ "@opengeoweb/theme": "12.8.0",
18
+ "@opengeoweb/form-fields": "12.8.0",
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.6.0",
22
+ "@opengeoweb/snackbar": "12.8.0",
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.6.0",
27
- "@opengeoweb/webmap": "12.6.0",
28
- "@opengeoweb/authentication": "12.6.0",
29
- "@opengeoweb/sigmet-airmet": "12.6.0",
26
+ "@opengeoweb/core": "12.8.0",
27
+ "@opengeoweb/webmap": "12.8.0",
28
+ "@opengeoweb/authentication": "12.8.0",
29
+ "@opengeoweb/sigmet-airmet": "12.8.0",
30
30
  "react-i18next": "^15.1.1",
31
31
  "i18next": "^25.0.1",
32
32
  "@mui/material": "^7.0.1",
33
33
  "ol": "^10.4.0",
34
- "msw": "^2.7.3"
34
+ "msw": "^2.7.3",
35
+ "@types/geojson": "^7946.0.14"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "react": "18",
@@ -41,5 +42,5 @@
41
42
  "module": "./index.esm.js",
42
43
  "type": "module",
43
44
  "main": "./index.esm.js",
44
- "types": "./index.esm.d.ts"
45
+ "types": "./index.d.ts"
45
46
  }
@@ -13,5 +13,5 @@ export declare const getAirmetTAC: (auth: Credentials, product: AviationProduct)
13
13
  export declare const getSigmetTAC: (auth: Credentials, product: AviationProduct) => Promise<{
14
14
  data: string;
15
15
  }>;
16
- export declare const postSigmet: (auth: Credentials, data: SigmetFromFrontend) => Promise<Headers | null>;
17
- export declare const postAirmet: (auth: Credentials, data: AirmetFromFrontend) => Promise<Headers | null>;
16
+ export declare const postSigmet: (auth: Credentials, data: SigmetFromFrontend) => Promise<SigmetFromBackend>;
17
+ export declare const postAirmet: (auth: Credentials, data: AirmetFromFrontend) => Promise<AirmetFromBackend>;
@@ -1,3 +1,6 @@
1
+ import { AirmetFromBackend, SigmetFromBackend } from '@opengeoweb/api';
2
+ export declare const airmetList: AirmetFromBackend[];
3
+ export declare const sigmetList: SigmetFromBackend[];
1
4
  export declare const fakeSigmetTAC = "EHAA SIGMET 1 VALID 121249/121449 EHDB- EHAA AMSTERDAM FIR FRQ TS OBS ENTIRE FIR FL010 STNR WKN";
2
5
  export declare const fakeAirmetTAC = "EHAA AIRMET -1 VALID 310700/311100 EHDB- EHAA AMSTERDAM FIR ISOL CB OBS ENTIRE FIR FL020 STNR NC";
3
6
  export declare const aviationEndpoints: import("msw").HttpHandler[];
@@ -13,9 +13,6 @@ export declare const useTACApi: () => {
13
13
  fetchSigmetTAC: (product: AviationProduct) => FetchTACData;
14
14
  fetchAirmetTAC: (product: AviationProduct) => FetchTACData;
15
15
  };
16
- type MutationReturnType<T> = UseMutationResult<Headers | null, Error, T, {
17
- oldData: AirmetFromFrontend[] | SigmetFromFrontend[] | undefined;
18
- }>;
19
16
  /**
20
17
  * Hook for posting a SIGMET, with feedback.
21
18
  *
@@ -23,7 +20,7 @@ type MutationReturnType<T> = UseMutationResult<Headers | null, Error, T, {
23
20
  * @param onDialogClose - Optional callback to close a dialog.
24
21
  * @returns A mutation result for posting a SIGMET.
25
22
  */
26
- export declare const usePostSigmet: () => MutationReturnType<SigmetFromFrontend>;
23
+ export declare const usePostSigmet: () => UseMutationResult<SigmetFromBackend, Error, SigmetFromFrontend>;
27
24
  /**
28
25
  * Hook for posting an AIRMET, with feedback.
29
26
  *
@@ -31,5 +28,5 @@ export declare const usePostSigmet: () => MutationReturnType<SigmetFromFrontend>
31
28
  * @param onDialogClose - Optional callback to close a dialog.
32
29
  * @returns A mutation result for posting an AIRMET.
33
30
  */
34
- export declare const usePostAirmet: () => MutationReturnType<AirmetFromFrontend>;
31
+ export declare const usePostAirmet: () => UseMutationResult<AirmetFromBackend, Error, AirmetFromFrontend>;
35
32
  export {};
@@ -11,10 +11,10 @@ declare const _default: {
11
11
  onMouseDown?: (() => void) | undefined;
12
12
  isOpen: boolean;
13
13
  order?: number | undefined;
14
- source?: import("dist/libs/shared/src").Source | undefined;
15
- size?: import("dist/libs/shared/src").DraggableSize | undefined;
16
- startPosition?: import("dist/libs/shared/src").Position | undefined;
17
- headerSize?: import("dist/libs/shared/src").HeaderSize | undefined;
14
+ source?: import("@opengeoweb/shared").Source | undefined;
15
+ size?: import("@opengeoweb/shared").DraggableSize | undefined;
16
+ startPosition?: import("@opengeoweb/shared").Position | undefined;
17
+ headerSize?: import("@opengeoweb/shared").HeaderSize | undefined;
18
18
  drawingListItems: DrawingListItem[];
19
19
  onClickDrawing?: ((drawing: DrawingListItem) => void) | undefined;
20
20
  onEditDrawing?: ((drawingId: string) => void) | undefined;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { AirmetFromBackend, SigmetFromBackend } from '@opengeoweb/api';
2
3
  export interface ConfirmDialogProps {
3
4
  title: string;
4
5
  description: string;
5
- request: () => Promise<void> | Promise<Headers | null>;
6
+ request: () => Promise<void> | Promise<Headers | null> | Promise<SigmetFromBackend | AirmetFromBackend>;
6
7
  confirmLabel: string;
7
8
  callback?: (data?: unknown) => void;
8
9
  isLocked?: boolean;
@@ -2,6 +2,7 @@ import { AviationProduct, FormMode, ProductStatus } from '@opengeoweb/sigmet-air
2
2
  import * as React from 'react';
3
3
  import { MapPreset } from '@opengeoweb/store';
4
4
  import { FeatureCollection, GeoJsonProperties, Geometry } from 'geojson';
5
+ import { AirmetFromBackend, SigmetFromBackend } from '@opengeoweb/api';
5
6
  import { FormError } from '../../store/publicWarningForm/reducer';
6
7
  import { Area, PublicWarningDetail, WarningType } from '../../store/publicWarningForm/types';
7
8
  import { BaseDrawingListItem, DrawingListItem } from '../../store/warningsDrawings/types';
@@ -21,7 +22,7 @@ export interface FormProps {
21
22
  onPublishForm?: (formValues: PublicWarningDetail) => Promise<Headers | null>;
22
23
  onClearForm?: () => void;
23
24
  onCloseForm?: () => void;
24
- onSaveAviationForm?: (formValues: AviationProduct, action: ProductStatus, warningType: 'sigmet' | 'airmet', vaSigmetMoveToFIR?: string) => Promise<Headers | null>;
25
+ onSaveAviationForm?: (productToPost: AviationProduct, newStatus: ProductStatus, warningType: 'sigmet' | 'airmet', vaSigmetMoveToFIR?: string, setSelectedUUID?: (uuid: string) => void) => Promise<SigmetFromBackend | AirmetFromBackend | undefined>;
25
26
  object?: DrawingListItem;
26
27
  publicWarningDetails?: PublicWarningDetail;
27
28
  error?: FormError;
@@ -1,7 +1,8 @@
1
1
  import { TooltipProps } from '@mui/material';
2
2
  import * as React from 'react';
3
- interface WarningAvatarProps {
3
+ export interface WarningAvatarProps {
4
4
  editor: string;
5
+ status?: string;
5
6
  tooltipPlacement?: TooltipProps['placement'];
6
7
  }
7
8
  declare const WarningAvatar: React.FC<WarningAvatarProps>;
@@ -47,4 +47,5 @@ export declare const publicWarningFormReducer: import("redux").Reducer<WarningFo
47
47
  setEditMode: (draft: Draft<WarningFormState>, action: PayloadAction<{
48
48
  warningId: string;
49
49
  }>) => void;
50
+ setSelectedWarningId: (draft: Draft<WarningFormState>, action: PayloadAction<string>) => void;
50
51
  }, "publicWarningForm">;
@@ -1,6 +1,8 @@
1
1
  import { RequestHandler } from 'msw';
2
+ import { SigmetFromBackend } from '@opengeoweb/api';
2
3
  import type { DrawingFromBE, DrawingListItem } from '../../store/warningsDrawings/types';
3
4
  import type { AirmetWarning, PublicWarning, SigmetWarning, Warning } from '../../store/publicWarningForm/types';
5
+ export declare const newSigmet: SigmetFromBackend;
4
6
  declare const drawingList: DrawingListItem[];
5
7
  declare const drawingsListFullContent: DrawingFromBE[];
6
8
  declare const warningList: PublicWarning[];
@@ -4,8 +4,8 @@ import { Warning, PublicWarningStatus, AviationWarningDetails, AirmetWarning, Si
4
4
  export declare function isCancelAirmet(warningDetail: AviationWarningDetails): warningDetail is CancelAirmet;
5
5
  export declare function isCancelSigmet(warningDetail: AviationWarningDetails): warningDetail is CancelSigmet;
6
6
  export declare const flattenPublicWarning: (publicWarning: Warning) => Partial<AviationWarningDetails>;
7
- export declare const transformAirmetToWarningFormat: (apiAirmet: AirmetFromBackend) => AirmetWarning;
8
- export declare const transformSigmetToWarningFormat: (apiSigmet: SigmetFromBackend) => SigmetWarning;
7
+ export declare const transformAirmetToWarningFormat: (apiAirmet: AirmetFromBackend, productConfig: ProductConfig) => AirmetWarning;
8
+ export declare const transformSigmetToWarningFormat: (apiSigmet: SigmetFromBackend, productConfig: ProductConfig) => SigmetWarning;
9
9
  export declare const mapProductStatusToWarningStatus: (productStatus?: ProductStatus) => PublicWarningStatus;
10
10
  export declare const transformSigmetToProductFormat: (warning: SigmetFromBackend | undefined) => AviationProduct;
11
11
  export declare const transformAirmetToProductFormat: (warning: AirmetFromBackend | undefined) => AviationProduct;
File without changes