@opengeoweb/sigmet-airmet 4.7.1 → 4.9.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
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { FormControlLabel, Radio, Grid, Typography, Box, Button, Checkbox, MenuItem, FormHelperText, useTheme, Dialog, DialogTitle, DialogContent, Card, List, ListItem, Skeleton, Backdrop, CircularProgress } from '@mui/material';
3
+ import { FormControlLabel, Radio, Grid, Typography, Box, Button, Checkbox, MenuItem, FormHelperText, useTheme, Dialog, DialogTitle, DialogContent, Card, LinearProgress, List, ListItem, Backdrop, CircularProgress } from '@mui/material';
4
4
  import { useFormContext } from 'react-hook-form';
5
- import { ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormNumberField, isInteger, isValidMax, isValidMin, isEmpty, ReactHookFormDateTime, isValidDate, isBefore, isBetween, hasMaxFeaturePoints, hasMulitpleIntersections, ReactHookFormHiddenInput, isMaximumOneDrawing, hasIntersectionWithFIR, isValidGeoJsonCoordinates, isXHoursBefore, isAfter, isXHoursAfter, ReactHookFormTextField, containsNoCommas, isLatitude, isNonOrBothCoordinates, isLongitude, errorMessages, ReactHookFormFormControl, isGeometryDirty, ReactHookFormProvider, defaultFormOptions } from '@opengeoweb/form-fields';
5
+ import { ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormNumberField, isInteger, isValidMax, isValidMin, isEmpty, ReactHookFormDateTime, isValidDate, isBefore, isBetween, hasMaxFeaturePoints, hasMulitpleIntersections, ReactHookFormHiddenInput, isMaximumOneDrawing, hasIntersectionWithFIR, isValidGeoJsonCoordinates, isXHoursBefore, isAfter, isXHoursAfter, ReactHookFormTextField, isLatitude, isNonOrBothCoordinates, isLongitude, errorMessages, ReactHookFormFormControl, isGeometryDirty, ReactHookFormProvider, defaultFormOptions } from '@opengeoweb/form-fields';
6
6
  import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
7
7
  import produce, { produce as produce$1 } from 'immer';
8
8
  import * as turf from '@turf/turf';
@@ -1472,9 +1472,27 @@ var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(can
1472
1472
  var hasValue = function hasValue(value) {
1473
1473
  return value !== null && value.toString() !== 'NaN';
1474
1474
  };
1475
- var removeEmptyNumberFieldValues = function removeEmptyNumberFieldValues(product) {
1475
+ var prepareFormValues = function prepareFormValues(product) {
1476
1476
  return Object.keys(product).reduce(function (list, key) {
1477
- var value = product[key]; // check if nested object has value
1477
+ var value = product[key]; // remove hidden form values
1478
+
1479
+ if (key === 'IS_DRAFT') {
1480
+ return list;
1481
+ } // remove geometry if empty coordinates
1482
+
1483
+
1484
+ if (key === 'endGeometry' || key === 'endGeometryIntersect' || key === 'startGeometry' || key === 'startGeometryIntersect') {
1485
+ if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Polygon' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates[0].length)) {
1486
+ return Object.assign(Object.assign({}, list), _defineProperty({}, key, value));
1487
+ }
1488
+
1489
+ if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Point' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates.length)) {
1490
+ return Object.assign(Object.assign({}, list), _defineProperty({}, key, value));
1491
+ }
1492
+
1493
+ return list;
1494
+ } // check if nested object has value
1495
+
1478
1496
 
1479
1497
  if (_typeof(value) === 'object' && value !== null && value !== undefined) {
1480
1498
  var hasNaNValue = Object.keys(value).reduce(function (total, valKey) {
@@ -1491,7 +1509,7 @@ var createSigmetPostParameter = function createSigmetPostParameter(sigmetToPost,
1491
1509
  uuid: previousUuid
1492
1510
  }) : sigmetToPost; // Do not send empty numbered fields to the BE to prevent errors
1493
1511
 
1494
- var sigmet = removeEmptyNumberFieldValues(sigmetIncludingUuid);
1512
+ var sigmet = prepareFormValues(sigmetIncludingUuid);
1495
1513
  return {
1496
1514
  changeStatusTo: newStatus,
1497
1515
  sigmet: sigmet
@@ -1502,7 +1520,7 @@ var createAirmetPostParameter = function createAirmetPostParameter(airmetToPost,
1502
1520
  uuid: previousUuid
1503
1521
  }) : airmetToPost; // Do not send empty numbered fields to the BE to prevent errors
1504
1522
 
1505
- var airmet = removeEmptyNumberFieldValues(airmetIncludingUuid);
1523
+ var airmet = prepareFormValues(airmetIncludingUuid);
1506
1524
  return {
1507
1525
  changeStatusTo: newStatus,
1508
1526
  airmet: airmet
@@ -1775,15 +1793,14 @@ var Levels = function Levels(_ref) {
1775
1793
  reset(Object.assign(Object.assign({}, currentValues), {
1776
1794
  level: {
1777
1795
  unit: 'FL',
1778
- value: ''
1796
+ value: null
1779
1797
  }
1780
1798
  }), {
1781
- errors: true,
1782
- dirtyFields: true,
1783
- isDirty: true,
1784
- isSubmitted: false,
1785
- touched: false,
1786
- isValid: false
1799
+ keepErrors: true,
1800
+ keepDirty: true,
1801
+ keepIsSubmitted: false,
1802
+ keepTouched: false,
1803
+ keepIsValid: false
1787
1804
  }); // Clear out errors for the levels
1788
1805
 
1789
1806
  clearErrors(['level', 'lowerLevel']);
@@ -2276,7 +2293,8 @@ var Phenomenon = function Phenomenon(_ref) {
2276
2293
  setValue = _useFormContext.setValue,
2277
2294
  trigger = _useFormContext.trigger;
2278
2295
 
2279
- var phenomenaList = productType === 'sigmet' ? SigmetPhenomena : AirmetPhenomena;
2296
+ var isSigmet = productType === 'sigmet';
2297
+ var phenomenaList = isSigmet ? SigmetPhenomena : AirmetPhenomena;
2280
2298
  var label = getFieldLabel('Phenomenon', isReadOnly);
2281
2299
  return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
2282
2300
  title: "What"
@@ -2294,15 +2312,17 @@ var Phenomenon = function Phenomenon(_ref) {
2294
2312
  setValue('movementType', null);
2295
2313
  }
2296
2314
 
2297
- if (getValues('phenomenon') !== 'SFC_VIS') {
2298
- setValue('visibilityValue', null);
2299
- setValue('visibilityCause', null);
2300
- }
2315
+ if (!isSigmet) {
2316
+ if (getValues('phenomenon') !== 'SFC_VIS') {
2317
+ setValue('visibilityValue', null);
2318
+ setValue('visibilityCause', null);
2319
+ }
2301
2320
 
2302
- if (getValues('phenomenon') !== 'SFC_WIND') {
2303
- setValue('windDirection', null);
2304
- setValue('windUnit', null);
2305
- setValue('windSpeed', null);
2321
+ if (getValues('phenomenon') !== 'SFC_WIND') {
2322
+ setValue('windDirection', null);
2323
+ setValue('windUnit', null);
2324
+ setValue('windSpeed', null);
2325
+ }
2306
2326
  }
2307
2327
 
2308
2328
  _onChange();
@@ -2348,7 +2368,7 @@ var StartGeometry = function StartGeometry(_ref) {
2348
2368
  setDrawModeType = _ref.setDrawModeType;
2349
2369
 
2350
2370
  var _useFormContext = useFormContext(),
2351
- errors = _useFormContext.errors,
2371
+ errors = _useFormContext.formState.errors,
2352
2372
  watch = _useFormContext.watch;
2353
2373
 
2354
2374
  var _useDraftFormHelpers = useDraftFormHelpers(),
@@ -2476,7 +2496,7 @@ var Progress = function Progress(_ref) {
2476
2496
  watch = _useFormContext.watch,
2477
2497
  getValues = _useFormContext.getValues,
2478
2498
  trigger = _useFormContext.trigger,
2479
- errors = _useFormContext.errors;
2499
+ errors = _useFormContext.formState.errors;
2480
2500
 
2481
2501
  var _useDraftFormHelpers = useDraftFormHelpers(),
2482
2502
  isRequired = _useDraftFormHelpers.isRequired,
@@ -3014,7 +3034,6 @@ var VolcanicFields = function VolcanicFields(_ref) {
3014
3034
  rules: {
3015
3035
  required: false,
3016
3036
  validate: {
3017
- containsNoCommas: containsNoCommas,
3018
3037
  isLatitude: isLatitude,
3019
3038
  isNonOrBothCoordinates: function isNonOrBothCoordinates$1(value) {
3020
3039
  return isNonOrBothCoordinates(value, getValues('vaSigmetVolcanoCoordinates.longitude'));
@@ -3039,7 +3058,6 @@ var VolcanicFields = function VolcanicFields(_ref) {
3039
3058
  rules: {
3040
3059
  required: false,
3041
3060
  validate: {
3042
- containsNoCommas: containsNoCommas,
3043
3061
  isLongitude: isLongitude,
3044
3062
  isNonOrBothCoordinates: function isNonOrBothCoordinates$1(value) {
3045
3063
  return isNonOrBothCoordinates(value, getValues('vaSigmetVolcanoCoordinates.latitude'));
@@ -3655,7 +3673,7 @@ var useTAC = function useTAC(initialProduct, getTAC) {
3655
3673
  case 0:
3656
3674
  _context.prev = 0;
3657
3675
  _context.next = 3;
3658
- return getTAC(product);
3676
+ return getTAC(prepareFormValues(product));
3659
3677
 
3660
3678
  case 3:
3661
3679
  result = _context.sent;
@@ -3697,10 +3715,14 @@ var useTAC = function useTAC(initialProduct, getTAC) {
3697
3715
  } else if (isMounted.current) {
3698
3716
  setTAC(noTAC);
3699
3717
  }
3700
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
3701
-
3718
+ };
3702
3719
 
3703
- var delayedQuery = React__default.useCallback(debounce(update, 1000), []);
3720
+ var delayedQuery = React__default.useMemo(function () {
3721
+ return debounce(function (formFn) {
3722
+ return update(formFn());
3723
+ }, 1000);
3724
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3725
+ []);
3704
3726
  return [TAC, delayedQuery];
3705
3727
  };
3706
3728
 
@@ -4106,8 +4128,7 @@ var SigmetForm = function SigmetForm(_ref) {
4106
4128
  var _useFormContext = useFormContext(),
4107
4129
  watch = _useFormContext.watch,
4108
4130
  setValue = _useFormContext.setValue,
4109
- handleSubmit = _useFormContext.handleSubmit,
4110
- getValues = _useFormContext.getValues;
4131
+ handleSubmit = _useFormContext.handleSubmit;
4111
4132
 
4112
4133
  var _React$useState = React__default.useState(mode === 'view'),
4113
4134
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -4123,7 +4144,7 @@ var SigmetForm = function SigmetForm(_ref) {
4123
4144
  updateTac = _useTAC2[1];
4124
4145
 
4125
4146
  var onChangeForm = function onChangeForm() {
4126
- updateTac(getValues());
4147
+ updateTac(watch);
4127
4148
  }; // TODO: [Loes Cornelis]: fix this whole mess of if statements for isCancelSigmet and hidden fields if disabled throughout the form
4128
4149
 
4129
4150
 
@@ -4320,8 +4341,7 @@ var AirmetForm = function AirmetForm(_ref) {
4320
4341
  var _useFormContext = useFormContext(),
4321
4342
  watch = _useFormContext.watch,
4322
4343
  setValue = _useFormContext.setValue,
4323
- handleSubmit = _useFormContext.handleSubmit,
4324
- getValues = _useFormContext.getValues;
4344
+ handleSubmit = _useFormContext.handleSubmit;
4325
4345
 
4326
4346
  var phenomenon = watch('phenomenon');
4327
4347
 
@@ -4339,7 +4359,7 @@ var AirmetForm = function AirmetForm(_ref) {
4339
4359
  updateTac = _useTAC2[1];
4340
4360
 
4341
4361
  var onChangeForm = function onChangeForm() {
4342
- updateTac(getValues());
4362
+ updateTac(watch);
4343
4363
  };
4344
4364
 
4345
4365
  var initialGeometry = initialAirmet && !isCancelAirmet ? {
@@ -4922,7 +4942,14 @@ var ProductList = function ProductList(_ref) {
4922
4942
  width: '100%',
4923
4943
  minHeight: '600px'
4924
4944
  }
4925
- }, error && /*#__PURE__*/React__default.createElement(AlertBanner, {
4945
+ }, isLoading && /*#__PURE__*/React__default.createElement(LinearProgress, {
4946
+ "data-testid": "productlist-loadingbar",
4947
+ color: "secondary",
4948
+ sx: {
4949
+ marginTop: '28px',
4950
+ marginBottom: '-32px'
4951
+ }
4952
+ }), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
4926
4953
  severity: "error",
4927
4954
  title: "An error has occurred while retrieving the list, please try again",
4928
4955
  info: error.message ? error.message : '',
@@ -4948,11 +4975,7 @@ var ProductList = function ProductList(_ref) {
4948
4975
  product: product,
4949
4976
  productType: productType
4950
4977
  }));
4951
- })), isLoading && /*#__PURE__*/React__default.createElement(Skeleton, {
4952
- "data-testid": "productList-skeleton",
4953
- variant: "rectangular",
4954
- height: "660px"
4955
- })));
4978
+ }))));
4956
4979
  };
4957
4980
 
4958
4981
  /* *
@@ -5040,7 +5063,8 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5040
5063
  formState = _useFormContext.formState,
5041
5064
  watch = _useFormContext.watch;
5042
5065
 
5043
- var isDirty = formState.isDirty;
5066
+ var dirtyFields = formState.dirtyFields;
5067
+ var isDirty = Object.keys(dirtyFields).length > 0;
5044
5068
 
5045
5069
  var _useDraftFormHelpers = useDraftFormHelpers(),
5046
5070
  toggleIsDraft = _useDraftFormHelpers.toggleIsDraft,
@@ -5066,18 +5090,16 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5066
5090
 
5067
5091
  React.useEffect(function () {
5068
5092
  // set the values of the newly selected product
5069
- reset(product !== null ? Object.assign({}, product) : {});
5093
+ reset(product !== null ? Object.assign({}, product) : {}, {
5094
+ keepDefaultValues: true
5095
+ });
5070
5096
  return function () {
5071
5097
  // reset form on unmount
5072
5098
  reset({});
5073
5099
  };
5074
5100
  }, [reset, product]);
5075
5101
 
5076
- var postProduct = function postProduct(_productToPost, newStatus) {
5077
- // remove hidden helper fields
5078
- _productToPost.IS_DRAFT;
5079
- var productToPost = __rest(_productToPost, ["IS_DRAFT"]);
5080
-
5102
+ var postProduct = function postProduct(productToPost, newStatus) {
5081
5103
  var uuid = product !== null && product.uuid ? product.uuid : null;
5082
5104
  var postProductParam = productType === 'sigmet' ? createSigmetPostParameter(productToPost, newStatus, uuid) : createAirmetPostParameter(productToPost, newStatus, uuid);
5083
5105
  setLoader(true);
@@ -5269,14 +5291,18 @@ var ProductFormDialog = function ProductFormDialog(_ref) {
5269
5291
  return null;
5270
5292
  }
5271
5293
 
5294
+ var product = productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null;
5272
5295
  return /*#__PURE__*/React.createElement(ReactHookFormProvider, {
5273
- options: defaultFormOptions
5296
+ options: Object.assign(Object.assign({}, defaultFormOptions), {
5297
+ defaultValues: product,
5298
+ shouldUnregister: true
5299
+ })
5274
5300
  }, /*#__PURE__*/React.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React.createElement(ProductFormDialogContent, {
5275
5301
  isOpen: isOpen,
5276
5302
  toggleDialogStatus: toggleDialogStatus,
5277
5303
  mode: mode,
5278
5304
  productCanBe: productCanBe,
5279
- product: productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null,
5305
+ product: product,
5280
5306
  productType: productType
5281
5307
  })));
5282
5308
  };
package/index.umd.js CHANGED
@@ -1463,20 +1463,38 @@
1463
1463
  var hasValue = function hasValue(value) {
1464
1464
  return value !== null && value.toString() !== 'NaN';
1465
1465
  };
1466
- var removeEmptyNumberFieldValues = function removeEmptyNumberFieldValues(product) {
1466
+ var prepareFormValues = function prepareFormValues(product) {
1467
1467
  return Object.keys(product).reduce(function (list, key) {
1468
- var _a, _b;
1468
+ var _a, _b, _c, _d;
1469
+
1470
+ var value = product[key]; // remove hidden form values
1471
+
1472
+ if (key === 'IS_DRAFT') {
1473
+ return list;
1474
+ } // remove geometry if empty coordinates
1475
+
1476
+
1477
+ if (key === 'endGeometry' || key === 'endGeometryIntersect' || key === 'startGeometry' || key === 'startGeometryIntersect') {
1478
+ if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Polygon' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates[0].length)) {
1479
+ return __assign(__assign({}, list), (_a = {}, _a[key] = value, _a));
1480
+ }
1481
+
1482
+ if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Point' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates.length)) {
1483
+ return __assign(__assign({}, list), (_b = {}, _b[key] = value, _b));
1484
+ }
1485
+
1486
+ return list;
1487
+ } // check if nested object has value
1469
1488
 
1470
- var value = product[key]; // check if nested object has value
1471
1489
 
1472
1490
  if (_typeof(value) === 'object' && value !== null && value !== undefined) {
1473
1491
  var hasNaNValue = Object.keys(value).reduce(function (total, valKey) {
1474
1492
  return !hasValue(value[valKey]) || total;
1475
1493
  }, false);
1476
- return __assign(__assign({}, list), !hasNaNValue && (_a = {}, _a[key] = value, _a));
1494
+ return __assign(__assign({}, list), !hasNaNValue && (_c = {}, _c[key] = value, _c));
1477
1495
  }
1478
1496
 
1479
- return __assign(__assign({}, list), hasValue(value) && (_b = {}, _b[key] = value, _b));
1497
+ return __assign(__assign({}, list), hasValue(value) && (_d = {}, _d[key] = value, _d));
1480
1498
  }, {});
1481
1499
  };
1482
1500
  var createSigmetPostParameter = function createSigmetPostParameter(sigmetToPost, newStatus, previousUuid) {
@@ -1484,7 +1502,7 @@
1484
1502
  uuid: previousUuid
1485
1503
  }) : sigmetToPost; // Do not send empty numbered fields to the BE to prevent errors
1486
1504
 
1487
- var sigmet = removeEmptyNumberFieldValues(sigmetIncludingUuid);
1505
+ var sigmet = prepareFormValues(sigmetIncludingUuid);
1488
1506
  return {
1489
1507
  changeStatusTo: newStatus,
1490
1508
  sigmet: sigmet
@@ -1495,7 +1513,7 @@
1495
1513
  uuid: previousUuid
1496
1514
  }) : airmetToPost; // Do not send empty numbered fields to the BE to prevent errors
1497
1515
 
1498
- var airmet = removeEmptyNumberFieldValues(airmetIncludingUuid);
1516
+ var airmet = prepareFormValues(airmetIncludingUuid);
1499
1517
  return {
1500
1518
  changeStatusTo: newStatus,
1501
1519
  airmet: airmet
@@ -1768,15 +1786,14 @@
1768
1786
  reset(__assign(__assign({}, currentValues), {
1769
1787
  level: {
1770
1788
  unit: 'FL',
1771
- value: ''
1789
+ value: null
1772
1790
  }
1773
1791
  }), {
1774
- errors: true,
1775
- dirtyFields: true,
1776
- isDirty: true,
1777
- isSubmitted: false,
1778
- touched: false,
1779
- isValid: false
1792
+ keepErrors: true,
1793
+ keepDirty: true,
1794
+ keepIsSubmitted: false,
1795
+ keepTouched: false,
1796
+ keepIsValid: false
1780
1797
  }); // Clear out errors for the levels
1781
1798
 
1782
1799
  clearErrors(['level', 'lowerLevel']);
@@ -2249,7 +2266,8 @@
2249
2266
  setValue = _c.setValue,
2250
2267
  trigger = _c.trigger;
2251
2268
 
2252
- var phenomenaList = productType === 'sigmet' ? SigmetPhenomena : AirmetPhenomena;
2269
+ var isSigmet = productType === 'sigmet';
2270
+ var phenomenaList = isSigmet ? SigmetPhenomena : AirmetPhenomena;
2253
2271
  var label = getFieldLabel('Phenomenon', isReadOnly);
2254
2272
  return /*#__PURE__*/React__default["default"].createElement(ProductFormFieldLayout, {
2255
2273
  title: "What"
@@ -2267,15 +2285,17 @@
2267
2285
  setValue('movementType', null);
2268
2286
  }
2269
2287
 
2270
- if (getValues('phenomenon') !== 'SFC_VIS') {
2271
- setValue('visibilityValue', null);
2272
- setValue('visibilityCause', null);
2273
- }
2288
+ if (!isSigmet) {
2289
+ if (getValues('phenomenon') !== 'SFC_VIS') {
2290
+ setValue('visibilityValue', null);
2291
+ setValue('visibilityCause', null);
2292
+ }
2274
2293
 
2275
- if (getValues('phenomenon') !== 'SFC_WIND') {
2276
- setValue('windDirection', null);
2277
- setValue('windUnit', null);
2278
- setValue('windSpeed', null);
2294
+ if (getValues('phenomenon') !== 'SFC_WIND') {
2295
+ setValue('windDirection', null);
2296
+ setValue('windUnit', null);
2297
+ setValue('windSpeed', null);
2298
+ }
2279
2299
  }
2280
2300
 
2281
2301
  _onChange();
@@ -2321,7 +2341,7 @@
2321
2341
  setDrawModeType = _a.setDrawModeType;
2322
2342
 
2323
2343
  var _c = reactHookForm.useFormContext(),
2324
- errors = _c.errors,
2344
+ errors = _c.formState.errors,
2325
2345
  watch = _c.watch;
2326
2346
 
2327
2347
  var isDraft = shared.useDraftFormHelpers().isDraft;
@@ -2447,7 +2467,7 @@
2447
2467
  watch = _e.watch,
2448
2468
  getValues = _e.getValues,
2449
2469
  trigger = _e.trigger,
2450
- errors = _e.errors;
2470
+ errors = _e.formState.errors;
2451
2471
 
2452
2472
  var _f = shared.useDraftFormHelpers(),
2453
2473
  isRequired = _f.isRequired,
@@ -2950,7 +2970,6 @@
2950
2970
  rules: {
2951
2971
  required: false,
2952
2972
  validate: {
2953
- containsNoCommas: formFields.containsNoCommas,
2954
2973
  isLatitude: formFields.isLatitude,
2955
2974
  isNonOrBothCoordinates: function isNonOrBothCoordinates(value) {
2956
2975
  return formFields.isNonOrBothCoordinates(value, getValues('vaSigmetVolcanoCoordinates.longitude'));
@@ -2975,7 +2994,6 @@
2975
2994
  rules: {
2976
2995
  required: false,
2977
2996
  validate: {
2978
- containsNoCommas: formFields.containsNoCommas,
2979
2997
  isLongitude: formFields.isLongitude,
2980
2998
  isNonOrBothCoordinates: function isNonOrBothCoordinates(value) {
2981
2999
  return formFields.isNonOrBothCoordinates(value, getValues('vaSigmetVolcanoCoordinates.latitude'));
@@ -3573,7 +3591,7 @@
3573
3591
 
3574
3592
  return [4
3575
3593
  /*yield*/
3576
- , getTAC(product)];
3594
+ , getTAC(prepareFormValues(product))];
3577
3595
 
3578
3596
  case 1:
3579
3597
  result = _a.sent();
@@ -3619,10 +3637,14 @@
3619
3637
  } else if (isMounted.current) {
3620
3638
  setTAC(noTAC);
3621
3639
  }
3622
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
3623
-
3640
+ };
3624
3641
 
3625
- var delayedQuery = React__default["default"].useCallback(lodash.debounce(update, 1000), []);
3642
+ var delayedQuery = React__default["default"].useMemo(function () {
3643
+ return lodash.debounce(function (formFn) {
3644
+ return update(formFn());
3645
+ }, 1000);
3646
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3647
+ []);
3626
3648
  return [TAC, delayedQuery];
3627
3649
  };
3628
3650
 
@@ -3995,8 +4017,7 @@
3995
4017
  var _f = reactHookForm.useFormContext(),
3996
4018
  watch = _f.watch,
3997
4019
  setValue = _f.setValue,
3998
- handleSubmit = _f.handleSubmit,
3999
- getValues = _f.getValues;
4020
+ handleSubmit = _f.handleSubmit;
4000
4021
 
4001
4022
  var _g = __read(React__default["default"].useState(mode === 'view'), 2),
4002
4023
  isDisabled = _g[0],
@@ -4010,7 +4031,7 @@
4010
4031
  updateTac = _h[1];
4011
4032
 
4012
4033
  var onChangeForm = function onChangeForm() {
4013
- updateTac(getValues());
4034
+ updateTac(watch);
4014
4035
  }; // TODO: [Loes Cornelis]: fix this whole mess of if statements for isCancelSigmet and hidden fields if disabled throughout the form
4015
4036
 
4016
4037
 
@@ -4205,8 +4226,7 @@
4205
4226
  var _f = reactHookForm.useFormContext(),
4206
4227
  watch = _f.watch,
4207
4228
  setValue = _f.setValue,
4208
- handleSubmit = _f.handleSubmit,
4209
- getValues = _f.getValues;
4229
+ handleSubmit = _f.handleSubmit;
4210
4230
 
4211
4231
  var phenomenon = watch('phenomenon');
4212
4232
 
@@ -4222,7 +4242,7 @@
4222
4242
  updateTac = _h[1];
4223
4243
 
4224
4244
  var onChangeForm = function onChangeForm() {
4225
- updateTac(getValues());
4245
+ updateTac(watch);
4226
4246
  };
4227
4247
 
4228
4248
  var initialGeometry = initialAirmet && !isCancelAirmet ? {
@@ -4822,7 +4842,14 @@
4822
4842
  width: '100%',
4823
4843
  minHeight: '600px'
4824
4844
  }
4825
- }, error && /*#__PURE__*/React__default["default"].createElement(shared.AlertBanner, {
4845
+ }, isLoading && /*#__PURE__*/React__default["default"].createElement(material.LinearProgress, {
4846
+ "data-testid": "productlist-loadingbar",
4847
+ color: "secondary",
4848
+ sx: {
4849
+ marginTop: '28px',
4850
+ marginBottom: '-32px'
4851
+ }
4852
+ }), error && /*#__PURE__*/React__default["default"].createElement(shared.AlertBanner, {
4826
4853
  severity: "error",
4827
4854
  title: "An error has occurred while retrieving the list, please try again",
4828
4855
  info: error.message ? error.message : '',
@@ -4848,11 +4875,7 @@
4848
4875
  product: product,
4849
4876
  productType: productType
4850
4877
  }));
4851
- })), isLoading && /*#__PURE__*/React__default["default"].createElement(material.Skeleton, {
4852
- "data-testid": "productList-skeleton",
4853
- variant: "rectangular",
4854
- height: "660px"
4855
- })));
4878
+ }))));
4856
4879
  };
4857
4880
 
4858
4881
  /* *
@@ -4932,7 +4955,8 @@
4932
4955
  formState = _b.formState,
4933
4956
  watch = _b.watch;
4934
4957
 
4935
- var isDirty = formState.isDirty;
4958
+ var dirtyFields = formState.dirtyFields;
4959
+ var isDirty = Object.keys(dirtyFields).length > 0;
4936
4960
 
4937
4961
  var _c = shared.useDraftFormHelpers(),
4938
4962
  toggleIsDraft = _c.toggleIsDraft,
@@ -4955,18 +4979,16 @@
4955
4979
 
4956
4980
  React__namespace.useEffect(function () {
4957
4981
  // set the values of the newly selected product
4958
- reset(product !== null ? __assign({}, product) : {});
4982
+ reset(product !== null ? __assign({}, product) : {}, {
4983
+ keepDefaultValues: true
4984
+ });
4959
4985
  return function () {
4960
4986
  // reset form on unmount
4961
4987
  reset({});
4962
4988
  };
4963
4989
  }, [reset, product]);
4964
4990
 
4965
- var postProduct = function postProduct(_productToPost, newStatus) {
4966
- // remove hidden helper fields
4967
- _productToPost.IS_DRAFT;
4968
- var productToPost = __rest(_productToPost, ["IS_DRAFT"]);
4969
-
4991
+ var postProduct = function postProduct(productToPost, newStatus) {
4970
4992
  var uuid = product !== null && product.uuid ? product.uuid : null;
4971
4993
  var postProductParam = productType === 'sigmet' ? createSigmetPostParameter(productToPost, newStatus, uuid) : createAirmetPostParameter(productToPost, newStatus, uuid);
4972
4994
  setLoader(true);
@@ -5142,14 +5164,18 @@
5142
5164
  return null;
5143
5165
  }
5144
5166
 
5167
+ var product = productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null;
5145
5168
  return /*#__PURE__*/React__namespace.createElement(formFields.ReactHookFormProvider, {
5146
- options: formFields.defaultFormOptions
5169
+ options: __assign(__assign({}, formFields.defaultFormOptions), {
5170
+ defaultValues: product,
5171
+ shouldUnregister: true
5172
+ })
5147
5173
  }, /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(ProductFormDialogContent, {
5148
5174
  isOpen: isOpen,
5149
5175
  toggleDialogStatus: toggleDialogStatus,
5150
5176
  mode: mode,
5151
5177
  productCanBe: productCanBe,
5152
- product: productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null,
5178
+ product: product,
5153
5179
  productType: productType
5154
5180
  })));
5155
5181
  };
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { CancelSigmet, Sigmet, Airmet, CancelAirmet } from '../../types';
3
+ declare type AviationProduct = Sigmet | CancelSigmet | Airmet | CancelAirmet;
3
4
  export declare const noTAC = "Missing data: no TAC can be generated";
4
- export declare const shouldRetrieveTAC: (product: Sigmet | CancelSigmet | Airmet | CancelAirmet) => boolean;
5
- export declare const useTAC: (initialProduct: Sigmet | CancelSigmet | Airmet | CancelAirmet, getTAC: (product: Sigmet | CancelSigmet | Airmet | CancelAirmet) => Promise<{
5
+ export declare const shouldRetrieveTAC: (product: AviationProduct) => boolean;
6
+ export declare const useTAC: (initialProduct: AviationProduct, getTAC: (product: AviationProduct) => Promise<{
6
7
  data: string;
7
8
  }>) => [string, any];
8
9
  interface ProductFormTACProps {
@@ -27,7 +27,7 @@ export declare const getProductFormMode: (canBeOptions: ProductCanbe[], productL
27
27
  export declare const getProductFormLifecycleButtons: (canBe: string[], onButtonPress: (newStatus: ProductStatus | 'DISCARDED') => void) => React.ReactElement;
28
28
  declare type Product = Sigmet | Airmet | CancelSigmet | CancelAirmet;
29
29
  export declare const hasValue: (value: number) => boolean;
30
- export declare const removeEmptyNumberFieldValues: <T extends Product>(product: T) => T;
30
+ export declare const prepareFormValues: <T extends Product>(product: T) => T;
31
31
  export declare const createSigmetPostParameter: (sigmetToPost: Sigmet | CancelSigmet, newStatus: ProductStatus, previousUuid: string) => SigmetFromFrontend;
32
32
  export declare const createAirmetPostParameter: (airmetToPost: Airmet | CancelAirmet, newStatus: ProductStatus, previousUuid: string) => AirmetFromFrontend;
33
33
  export declare const useDelayedFormValues: (getValues: () => void, register: () => void, delay?: number) => [unknown, () => void];
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  };
5
5
  export default _default;
6
6
  export declare const SigmetListDemo: () => React.ReactElement;
7
+ export declare const SigmetListLoading: () => React.ReactElement;
7
8
  export declare const SigmetListDemoSnapshot: {
8
9
  (): React.ReactElement;
9
10
  storyName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/sigmet-airmet",
3
- "version": "4.7.1",
3
+ "version": "4.9.1",
4
4
  "description": "GeoWeb Sigmet/Airmet library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,24 +14,24 @@
14
14
  "react": "^17.0.2",
15
15
  "react-redux": "^8.0.4",
16
16
  "@mui/material": "^5.10.8",
17
- "@opengeoweb/shared": "4.7.1",
18
- "@opengeoweb/theme": "4.7.1",
17
+ "@opengeoweb/shared": "4.9.1",
18
+ "@opengeoweb/theme": "4.9.1",
19
19
  "react-draggable": "^4.4.5",
20
20
  "re-resizable": "^6.9.0",
21
21
  "@redux-eggs/core": "^2.2.0",
22
- "@opengeoweb/form-fields": "4.7.1",
23
- "react-hook-form": "^6.12.1",
22
+ "@opengeoweb/form-fields": "4.9.1",
23
+ "react-hook-form": "^7.41.5",
24
24
  "moment": "^2.29.0",
25
25
  "moment-timezone": "^0.5.31",
26
26
  "@mui/x-date-pickers": "^5.0.4",
27
27
  "lodash": "^4.17.20",
28
28
  "axios": "^0.25.0",
29
29
  "date-fns": "^2.29.3",
30
- "@opengeoweb/core": "4.7.1",
31
- "@opengeoweb/webmap": "4.7.1",
30
+ "@opengeoweb/core": "4.9.1",
31
+ "@opengeoweb/webmap": "4.9.1",
32
32
  "throttle-debounce": "^3.0.1",
33
33
  "proj4": "^2.6.2",
34
- "@opengeoweb/api": "4.7.1",
34
+ "@opengeoweb/api": "4.9.1",
35
35
  "react-intl": "^5.17.5",
36
36
  "react-sortablejs": "^6.1.4",
37
37
  "sortablejs": "^1.15.0",