@opengeoweb/sigmet-airmet 4.8.0 → 4.10.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 +181 -86
- package/index.umd.js +185 -86
- package/lib/components/ProductForms/ProductFormDialog.d.ts +1 -1
- package/lib/components/ProductForms/ProductFormDialogContent.d.ts +1 -1
- package/lib/components/ProductForms/ProductFormTac.d.ts +3 -2
- package/lib/components/ProductForms/utils.d.ts +1 -1
- package/package.json +8 -8
package/index.esm.js
CHANGED
|
@@ -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
|
|
1475
|
+
var prepareFormValues = function prepareFormValues(product) {
|
|
1476
1476
|
return Object.keys(product).reduce(function (list, key) {
|
|
1477
|
-
var value = product[key]; //
|
|
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 =
|
|
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 =
|
|
1523
|
+
var airmet = prepareFormValues(airmetIncludingUuid);
|
|
1506
1524
|
return {
|
|
1507
1525
|
changeStatusTo: newStatus,
|
|
1508
1526
|
airmet: airmet
|
|
@@ -1740,12 +1758,13 @@ var Levels = function Levels(_ref) {
|
|
|
1740
1758
|
setValue = _useFormContext.setValue,
|
|
1741
1759
|
trigger = _useFormContext.trigger,
|
|
1742
1760
|
getValues = _useFormContext.getValues,
|
|
1743
|
-
|
|
1744
|
-
|
|
1761
|
+
clearErrors = _useFormContext.clearErrors,
|
|
1762
|
+
unregister = _useFormContext.unregister;
|
|
1745
1763
|
|
|
1746
1764
|
var _useDraftFormHelpers = useDraftFormHelpers(),
|
|
1747
1765
|
isRequired = _useDraftFormHelpers.isRequired;
|
|
1748
1766
|
|
|
1767
|
+
var levelInfoMode = watch('levelInfoMode');
|
|
1749
1768
|
var config = productType === 'sigmet' ? sigmetConfig : airmetConfig;
|
|
1750
1769
|
|
|
1751
1770
|
var _useProductSettings = useProductSettings(config),
|
|
@@ -1754,6 +1773,11 @@ var Levels = function Levels(_ref) {
|
|
|
1754
1773
|
var selectedFIR = watch('locationIndicatorATSR'); // Get allowed level units based on selected FIR - if no FIR selected, allow all default units
|
|
1755
1774
|
|
|
1756
1775
|
var allowedLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'level_unit', LevelUnits);
|
|
1776
|
+
React__default.useEffect(function () {
|
|
1777
|
+
if (levelInfoMode !== 'BETW') {
|
|
1778
|
+
unregister('lowerLevel');
|
|
1779
|
+
}
|
|
1780
|
+
}, [levelInfoMode, unregister]);
|
|
1757
1781
|
return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
|
|
1758
1782
|
title: "Levels",
|
|
1759
1783
|
sx: styles$2.containerItem
|
|
@@ -1771,29 +1795,18 @@ var Levels = function Levels(_ref) {
|
|
|
1771
1795
|
isReadOnly: isReadOnly,
|
|
1772
1796
|
onChange: function onChange() {
|
|
1773
1797
|
// Reset default value for the level value to '' so when it rerenders it uses this empty default value
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
level: {
|
|
1777
|
-
unit: 'FL',
|
|
1778
|
-
value: null
|
|
1779
|
-
}
|
|
1780
|
-
}), {
|
|
1781
|
-
keepErrors: true,
|
|
1782
|
-
keepDirty: true,
|
|
1783
|
-
keepIsSubmitted: false,
|
|
1784
|
-
keepTouched: false,
|
|
1785
|
-
keepIsValid: false
|
|
1786
|
-
}); // Clear out errors for the levels
|
|
1798
|
+
setValue('level.unit', 'FL');
|
|
1799
|
+
setValue('level.value', null); // Clear out errors for the levels
|
|
1787
1800
|
|
|
1788
1801
|
clearErrors(['level', 'lowerLevel']);
|
|
1789
1802
|
}
|
|
1790
1803
|
}, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
|
|
1791
1804
|
value: "AT",
|
|
1792
1805
|
label: "At",
|
|
1793
|
-
checked:
|
|
1806
|
+
checked: levelInfoMode === 'AT' || levelInfoMode === 'TOPS',
|
|
1794
1807
|
"data-testid": "levels-AT",
|
|
1795
1808
|
disabled: isDisabled
|
|
1796
|
-
}),
|
|
1809
|
+
}), levelInfoMode === 'AT' || levelInfoMode === 'TOPS' ? /*#__PURE__*/React__default.createElement(Grid, {
|
|
1797
1810
|
item: true,
|
|
1798
1811
|
xs: 12,
|
|
1799
1812
|
container: true,
|
|
@@ -1806,7 +1819,7 @@ var Levels = function Levels(_ref) {
|
|
|
1806
1819
|
md: 3
|
|
1807
1820
|
}, /*#__PURE__*/React__default.createElement(FormControlLabel, {
|
|
1808
1821
|
control: /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
1809
|
-
checked:
|
|
1822
|
+
checked: levelInfoMode === 'TOPS',
|
|
1810
1823
|
onChange: function onChange() {
|
|
1811
1824
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'AT' ? 'TOPS' : 'AT', {
|
|
1812
1825
|
shouldDirty: true
|
|
@@ -1880,10 +1893,10 @@ var Levels = function Levels(_ref) {
|
|
|
1880
1893
|
}))) : null, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
|
|
1881
1894
|
value: "BETW",
|
|
1882
1895
|
label: "Between",
|
|
1883
|
-
checked:
|
|
1896
|
+
checked: levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC',
|
|
1884
1897
|
"data-testid": "levels-BETW",
|
|
1885
1898
|
disabled: isDisabled
|
|
1886
|
-
}),
|
|
1899
|
+
}), levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC' ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
1887
1900
|
item: true,
|
|
1888
1901
|
xs: 12,
|
|
1889
1902
|
container: true,
|
|
@@ -1904,7 +1917,7 @@ var Levels = function Levels(_ref) {
|
|
|
1904
1917
|
isRequired: isRequired,
|
|
1905
1918
|
validateLevelUnitCombinations: function validateLevelUnitCombinations(value) {
|
|
1906
1919
|
return (// level step depends on the unit
|
|
1907
|
-
_validateLevelUnitCombinations(value,
|
|
1920
|
+
_validateLevelUnitCombinations(value, levelInfoMode === 'BETW_SFC' ? 'SFC' : getValues('lowerLevel.unit')) === true
|
|
1908
1921
|
);
|
|
1909
1922
|
}
|
|
1910
1923
|
}
|
|
@@ -1971,7 +1984,7 @@ var Levels = function Levels(_ref) {
|
|
|
1971
1984
|
md: 3
|
|
1972
1985
|
}, /*#__PURE__*/React__default.createElement(FormControlLabel, {
|
|
1973
1986
|
control: /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
1974
|
-
checked:
|
|
1987
|
+
checked: levelInfoMode === 'BETW_SFC',
|
|
1975
1988
|
onChange: function onChange() {
|
|
1976
1989
|
getValues('level.unit') && trigger('level.unit');
|
|
1977
1990
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'BETW' ? 'BETW_SFC' : 'BETW', {
|
|
@@ -1984,7 +1997,7 @@ var Levels = function Levels(_ref) {
|
|
|
1984
1997
|
}),
|
|
1985
1998
|
"data-testid": "levels-SFC",
|
|
1986
1999
|
label: "SFC"
|
|
1987
|
-
})),
|
|
2000
|
+
})), levelInfoMode !== 'BETW_SFC' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
1988
2001
|
item: true,
|
|
1989
2002
|
xs: 4,
|
|
1990
2003
|
md: 3
|
|
@@ -2058,9 +2071,9 @@ var Levels = function Levels(_ref) {
|
|
|
2058
2071
|
value: "ABV",
|
|
2059
2072
|
label: "Above",
|
|
2060
2073
|
disabled: isDisabled,
|
|
2061
|
-
checked:
|
|
2074
|
+
checked: levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV',
|
|
2062
2075
|
"data-testid": "levels-ABV"
|
|
2063
|
-
}),
|
|
2076
|
+
}), levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV' ? /*#__PURE__*/React__default.createElement(Grid, {
|
|
2064
2077
|
item: true,
|
|
2065
2078
|
xs: 12,
|
|
2066
2079
|
container: true,
|
|
@@ -2073,7 +2086,7 @@ var Levels = function Levels(_ref) {
|
|
|
2073
2086
|
md: 3
|
|
2074
2087
|
}, /*#__PURE__*/React__default.createElement(FormControlLabel, {
|
|
2075
2088
|
control: /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
2076
|
-
checked:
|
|
2089
|
+
checked: levelInfoMode === 'TOPS_ABV',
|
|
2077
2090
|
onChange: function onChange() {
|
|
2078
2091
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'ABV' ? 'TOPS_ABV' : 'ABV', {
|
|
2079
2092
|
shouldDirty: true
|
|
@@ -2275,7 +2288,8 @@ var Phenomenon = function Phenomenon(_ref) {
|
|
|
2275
2288
|
setValue = _useFormContext.setValue,
|
|
2276
2289
|
trigger = _useFormContext.trigger;
|
|
2277
2290
|
|
|
2278
|
-
var
|
|
2291
|
+
var isSigmet = productType === 'sigmet';
|
|
2292
|
+
var phenomenaList = isSigmet ? SigmetPhenomena : AirmetPhenomena;
|
|
2279
2293
|
var label = getFieldLabel('Phenomenon', isReadOnly);
|
|
2280
2294
|
return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
|
|
2281
2295
|
title: "What"
|
|
@@ -2293,17 +2307,6 @@ var Phenomenon = function Phenomenon(_ref) {
|
|
|
2293
2307
|
setValue('movementType', null);
|
|
2294
2308
|
}
|
|
2295
2309
|
|
|
2296
|
-
if (getValues('phenomenon') !== 'SFC_VIS') {
|
|
2297
|
-
setValue('visibilityValue', null);
|
|
2298
|
-
setValue('visibilityCause', null);
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
if (getValues('phenomenon') !== 'SFC_WIND') {
|
|
2302
|
-
setValue('windDirection', null);
|
|
2303
|
-
setValue('windUnit', null);
|
|
2304
|
-
setValue('windSpeed', null);
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2307
2310
|
_onChange();
|
|
2308
2311
|
|
|
2309
2312
|
return trigger([].concat(_toConsumableArray(getValues('validDateStart') ? ['validDateStart'] : []), _toConsumableArray(getValues('validDateEnd') ? ['validDateEnd'] : [])));
|
|
@@ -2475,7 +2478,8 @@ var Progress = function Progress(_ref) {
|
|
|
2475
2478
|
watch = _useFormContext.watch,
|
|
2476
2479
|
getValues = _useFormContext.getValues,
|
|
2477
2480
|
trigger = _useFormContext.trigger,
|
|
2478
|
-
errors = _useFormContext.formState.errors
|
|
2481
|
+
errors = _useFormContext.formState.errors,
|
|
2482
|
+
unregister = _useFormContext.unregister;
|
|
2479
2483
|
|
|
2480
2484
|
var _useDraftFormHelpers = useDraftFormHelpers(),
|
|
2481
2485
|
isRequired = _useDraftFormHelpers.isRequired,
|
|
@@ -2490,6 +2494,18 @@ var Progress = function Progress(_ref) {
|
|
|
2490
2494
|
var selectedFIR = watch('locationIndicatorATSR'); // Get allowed movement units based on selected FIR - if no FIR selected, allow all units
|
|
2491
2495
|
|
|
2492
2496
|
var allowedMovementUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'movement_unit', MovementUnit);
|
|
2497
|
+
React__default.useEffect(function () {
|
|
2498
|
+
if (movementType !== 'MOVEMENT') {
|
|
2499
|
+
unregister('movementDirection');
|
|
2500
|
+
unregister('movementSpeed');
|
|
2501
|
+
unregister('movementUnit');
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
if (movementType !== 'FORECAST_POSITION') {
|
|
2505
|
+
unregister('endGeometry');
|
|
2506
|
+
unregister('endGeometryIntersect');
|
|
2507
|
+
}
|
|
2508
|
+
}, [movementType, unregister]);
|
|
2493
2509
|
return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
|
|
2494
2510
|
title: "Progress",
|
|
2495
2511
|
sx: styles$2.containerItem
|
|
@@ -3355,7 +3371,8 @@ var CloudLevels = function CloudLevels(_ref) {
|
|
|
3355
3371
|
watch = _useFormContext.watch,
|
|
3356
3372
|
setValue = _useFormContext.setValue,
|
|
3357
3373
|
trigger = _useFormContext.trigger,
|
|
3358
|
-
getValues = _useFormContext.getValues
|
|
3374
|
+
getValues = _useFormContext.getValues,
|
|
3375
|
+
unregister = _useFormContext.unregister;
|
|
3359
3376
|
|
|
3360
3377
|
var _useDraftFormHelpers = useDraftFormHelpers(),
|
|
3361
3378
|
isRequired = _useDraftFormHelpers.isRequired;
|
|
@@ -3363,9 +3380,15 @@ var CloudLevels = function CloudLevels(_ref) {
|
|
|
3363
3380
|
var _useProductSettings = useProductSettings(airmetConfig),
|
|
3364
3381
|
allowedUnits = _useProductSettings.allowedUnits;
|
|
3365
3382
|
|
|
3366
|
-
var selectedFIR = watch('locationIndicatorATSR');
|
|
3383
|
+
var selectedFIR = watch('locationIndicatorATSR');
|
|
3384
|
+
var cloudLevelInfoMode = watch('cloudLevelInfoMode'); // Get allowed cloud level units based on selected FIR - if no FIR selected, allow all default units
|
|
3367
3385
|
|
|
3368
3386
|
var allowedCloudLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'cloud_level_unit', CloudLevelUnits);
|
|
3387
|
+
React__default.useEffect(function () {
|
|
3388
|
+
if (cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') {
|
|
3389
|
+
unregister('cloudLowerLevel');
|
|
3390
|
+
}
|
|
3391
|
+
}, [cloudLevelInfoMode, unregister]);
|
|
3369
3392
|
return /*#__PURE__*/React__default.createElement(Grid, {
|
|
3370
3393
|
item: true,
|
|
3371
3394
|
container: true,
|
|
@@ -3397,12 +3420,12 @@ var CloudLevels = function CloudLevels(_ref) {
|
|
|
3397
3420
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3398
3421
|
item: true,
|
|
3399
3422
|
xs: 4
|
|
3400
|
-
}, (!isReadOnly ||
|
|
3423
|
+
}, (!isReadOnly || cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
|
|
3401
3424
|
disabled: isDisabled,
|
|
3402
3425
|
isReadOnly: isReadOnly
|
|
3403
3426
|
}, /*#__PURE__*/React__default.createElement(FormControlLabel, {
|
|
3404
3427
|
control: /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
3405
|
-
checked:
|
|
3428
|
+
checked: cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV',
|
|
3406
3429
|
onChange: function onChange() {
|
|
3407
3430
|
switch (getValues('cloudLevelInfoMode')) {
|
|
3408
3431
|
case 'BETW':
|
|
@@ -3510,12 +3533,12 @@ var CloudLevels = function CloudLevels(_ref) {
|
|
|
3510
3533
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3511
3534
|
item: true,
|
|
3512
3535
|
xs: 4
|
|
3513
|
-
}, (!isReadOnly ||
|
|
3536
|
+
}, (!isReadOnly || cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
|
|
3514
3537
|
disabled: isDisabled,
|
|
3515
3538
|
isReadOnly: isReadOnly
|
|
3516
3539
|
}, /*#__PURE__*/React__default.createElement(FormControlLabel, {
|
|
3517
3540
|
control: /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
3518
|
-
checked:
|
|
3541
|
+
checked: cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV',
|
|
3519
3542
|
onChange: function onChange() {
|
|
3520
3543
|
switch (getValues('cloudLevelInfoMode')) {
|
|
3521
3544
|
case 'BETW':
|
|
@@ -3549,7 +3572,7 @@ var CloudLevels = function CloudLevels(_ref) {
|
|
|
3549
3572
|
}),
|
|
3550
3573
|
"data-testid": "cloudLevels-SFC",
|
|
3551
3574
|
label: "SFC"
|
|
3552
|
-
}))),
|
|
3575
|
+
}))), cloudLevelInfoMode !== 'BETW_SFC' && cloudLevelInfoMode !== 'BETW_SFC_ABV' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3553
3576
|
item: true,
|
|
3554
3577
|
xs: 3
|
|
3555
3578
|
}, /*#__PURE__*/React__default.createElement(ReactHookFormSelect, {
|
|
@@ -3652,7 +3675,7 @@ var useTAC = function useTAC(initialProduct, getTAC) {
|
|
|
3652
3675
|
case 0:
|
|
3653
3676
|
_context.prev = 0;
|
|
3654
3677
|
_context.next = 3;
|
|
3655
|
-
return getTAC(product);
|
|
3678
|
+
return getTAC(prepareFormValues(product));
|
|
3656
3679
|
|
|
3657
3680
|
case 3:
|
|
3658
3681
|
result = _context.sent;
|
|
@@ -3694,10 +3717,14 @@ var useTAC = function useTAC(initialProduct, getTAC) {
|
|
|
3694
3717
|
} else if (isMounted.current) {
|
|
3695
3718
|
setTAC(noTAC);
|
|
3696
3719
|
}
|
|
3697
|
-
};
|
|
3698
|
-
|
|
3720
|
+
};
|
|
3699
3721
|
|
|
3700
|
-
var delayedQuery = React__default.
|
|
3722
|
+
var delayedQuery = React__default.useMemo(function () {
|
|
3723
|
+
return debounce(function (formFn) {
|
|
3724
|
+
return update(formFn());
|
|
3725
|
+
}, 1000);
|
|
3726
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3727
|
+
[]);
|
|
3701
3728
|
return [TAC, delayedQuery];
|
|
3702
3729
|
};
|
|
3703
3730
|
|
|
@@ -4086,6 +4113,23 @@ var ProductFormLayout = function ProductFormLayout(_a) {
|
|
|
4086
4113
|
}, children));
|
|
4087
4114
|
};
|
|
4088
4115
|
|
|
4116
|
+
var useConditionalFields$1 = function useConditionalFields() {
|
|
4117
|
+
var _useFormContext = useFormContext(),
|
|
4118
|
+
watch = _useFormContext.watch,
|
|
4119
|
+
unregister = _useFormContext.unregister; // phenomenon: VA_CLD
|
|
4120
|
+
|
|
4121
|
+
|
|
4122
|
+
var hasVolcanicAshes = watch('phenomenon') === 'VA_CLD';
|
|
4123
|
+
React__default.useEffect(function () {
|
|
4124
|
+
if (!hasVolcanicAshes) {
|
|
4125
|
+
unregister(['vaSigmetVolcanoName', 'vaSigmetVolcanoCoordinates.latitude', 'vaSigmetVolcanoCoordinates.longitude']);
|
|
4126
|
+
}
|
|
4127
|
+
}, [hasVolcanicAshes, unregister]);
|
|
4128
|
+
return {
|
|
4129
|
+
hasVolcanicAshes: hasVolcanicAshes
|
|
4130
|
+
};
|
|
4131
|
+
};
|
|
4132
|
+
|
|
4089
4133
|
var SigmetForm = function SigmetForm(_ref) {
|
|
4090
4134
|
var mode = _ref.mode,
|
|
4091
4135
|
_ref$isCancelSigmet = _ref.isCancelSigmet,
|
|
@@ -4100,11 +4144,10 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
4100
4144
|
var _useApiContext = useApiContext(),
|
|
4101
4145
|
api = _useApiContext.api;
|
|
4102
4146
|
|
|
4103
|
-
var
|
|
4104
|
-
watch =
|
|
4105
|
-
setValue =
|
|
4106
|
-
handleSubmit =
|
|
4107
|
-
getValues = _useFormContext.getValues;
|
|
4147
|
+
var _useFormContext2 = useFormContext(),
|
|
4148
|
+
watch = _useFormContext2.watch,
|
|
4149
|
+
setValue = _useFormContext2.setValue,
|
|
4150
|
+
handleSubmit = _useFormContext2.handleSubmit;
|
|
4108
4151
|
|
|
4109
4152
|
var _React$useState = React__default.useState(mode === 'view'),
|
|
4110
4153
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -4120,7 +4163,7 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
4120
4163
|
updateTac = _useTAC2[1];
|
|
4121
4164
|
|
|
4122
4165
|
var onChangeForm = function onChangeForm() {
|
|
4123
|
-
updateTac(
|
|
4166
|
+
updateTac(watch);
|
|
4124
4167
|
}; // TODO: [Loes Cornelis]: fix this whole mess of if statements for isCancelSigmet and hidden fields if disabled throughout the form
|
|
4125
4168
|
|
|
4126
4169
|
|
|
@@ -4185,6 +4228,9 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
4185
4228
|
}
|
|
4186
4229
|
}, [drawMode.start, drawMode.end, isReadOnly, isDisabled]);
|
|
4187
4230
|
|
|
4231
|
+
var _useConditionalFields = useConditionalFields$1(),
|
|
4232
|
+
hasVolcanicAshes = _useConditionalFields.hasVolcanicAshes;
|
|
4233
|
+
|
|
4188
4234
|
var renderForm = function renderForm() {
|
|
4189
4235
|
return /*#__PURE__*/React__default.createElement(Grid, {
|
|
4190
4236
|
container: true,
|
|
@@ -4203,7 +4249,7 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
4203
4249
|
isReadOnly: isReadOnly,
|
|
4204
4250
|
helperText: helperText,
|
|
4205
4251
|
onChange: onChangeForm
|
|
4206
|
-
}), !isCancelSigmet &&
|
|
4252
|
+
}), !isCancelSigmet && hasVolcanicAshes && /*#__PURE__*/React__default.createElement(VolcanicFields, {
|
|
4207
4253
|
isDisabled: isDisabled,
|
|
4208
4254
|
isReadOnly: isReadOnly,
|
|
4209
4255
|
helperText: helperText
|
|
@@ -4300,6 +4346,48 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
4300
4346
|
}, renderForm()));
|
|
4301
4347
|
};
|
|
4302
4348
|
|
|
4349
|
+
var useConditionalFields = function useConditionalFields() {
|
|
4350
|
+
var _useFormContext = useFormContext(),
|
|
4351
|
+
watch = _useFormContext.watch,
|
|
4352
|
+
unregister = _useFormContext.unregister; // phenomenon: SFC_VIS
|
|
4353
|
+
|
|
4354
|
+
|
|
4355
|
+
var phenomenon = watch('phenomenon');
|
|
4356
|
+
var hasSurfaceVisiblity = phenomenon === 'SFC_VIS';
|
|
4357
|
+
React__default.useEffect(function () {
|
|
4358
|
+
if (!hasSurfaceVisiblity) {
|
|
4359
|
+
unregister(['visibilityValue', 'visibilityCause']);
|
|
4360
|
+
}
|
|
4361
|
+
}, [hasSurfaceVisiblity, unregister]); // phenomenon: SFC_WIND
|
|
4362
|
+
|
|
4363
|
+
var hasSurfaceWind = watch('phenomenon') === 'SFC_WIND';
|
|
4364
|
+
React__default.useEffect(function () {
|
|
4365
|
+
if (!hasSurfaceWind) {
|
|
4366
|
+
unregister(['windDirection', 'windUnit', 'windSpeed']);
|
|
4367
|
+
}
|
|
4368
|
+
}, [hasSurfaceWind, unregister]); // phenomenon: SFC_WIND, SFC_VIS, BKN_CLD, OVC_CLD
|
|
4369
|
+
|
|
4370
|
+
var hasLevels = phenomenon !== 'SFC_WIND' && phenomenon !== 'SFC_VIS' && phenomenon !== 'BKN_CLD' && phenomenon !== 'OVC_CLD';
|
|
4371
|
+
React__default.useEffect(function () {
|
|
4372
|
+
if (!hasLevels) {
|
|
4373
|
+
unregister(['levelInfoMode', 'level', 'lowerLevel']);
|
|
4374
|
+
}
|
|
4375
|
+
}, [hasLevels, unregister]); // phenomenon: BKN_CLD
|
|
4376
|
+
|
|
4377
|
+
var hasCloudLevels = phenomenon === 'BKN_CLD' || phenomenon === 'OVC_CLD';
|
|
4378
|
+
React__default.useEffect(function () {
|
|
4379
|
+
if (!hasCloudLevels) {
|
|
4380
|
+
unregister(['cloudLevelInfoMode', 'cloudLevel', 'cloudLowerLevel']);
|
|
4381
|
+
}
|
|
4382
|
+
}, [hasCloudLevels, unregister]);
|
|
4383
|
+
return {
|
|
4384
|
+
hasSurfaceVisiblity: hasSurfaceVisiblity,
|
|
4385
|
+
hasSurfaceWind: hasSurfaceWind,
|
|
4386
|
+
hasLevels: hasLevels,
|
|
4387
|
+
hasCloudLevels: hasCloudLevels
|
|
4388
|
+
};
|
|
4389
|
+
};
|
|
4390
|
+
|
|
4303
4391
|
var AirmetForm = function AirmetForm(_ref) {
|
|
4304
4392
|
var mode = _ref.mode,
|
|
4305
4393
|
_ref$isCancelAirmet = _ref.isCancelAirmet,
|
|
@@ -4314,13 +4402,10 @@ var AirmetForm = function AirmetForm(_ref) {
|
|
|
4314
4402
|
var _useApiContext = useApiContext(),
|
|
4315
4403
|
api = _useApiContext.api;
|
|
4316
4404
|
|
|
4317
|
-
var
|
|
4318
|
-
watch =
|
|
4319
|
-
setValue =
|
|
4320
|
-
handleSubmit =
|
|
4321
|
-
getValues = _useFormContext.getValues;
|
|
4322
|
-
|
|
4323
|
-
var phenomenon = watch('phenomenon');
|
|
4405
|
+
var _useFormContext2 = useFormContext(),
|
|
4406
|
+
watch = _useFormContext2.watch,
|
|
4407
|
+
setValue = _useFormContext2.setValue,
|
|
4408
|
+
handleSubmit = _useFormContext2.handleSubmit;
|
|
4324
4409
|
|
|
4325
4410
|
var _React$useState = React__default.useState(mode === 'view'),
|
|
4326
4411
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -4336,7 +4421,7 @@ var AirmetForm = function AirmetForm(_ref) {
|
|
|
4336
4421
|
updateTac = _useTAC2[1];
|
|
4337
4422
|
|
|
4338
4423
|
var onChangeForm = function onChangeForm() {
|
|
4339
|
-
updateTac(
|
|
4424
|
+
updateTac(watch);
|
|
4340
4425
|
};
|
|
4341
4426
|
|
|
4342
4427
|
var initialGeometry = initialAirmet && !isCancelAirmet ? {
|
|
@@ -4379,6 +4464,12 @@ var AirmetForm = function AirmetForm(_ref) {
|
|
|
4379
4464
|
}
|
|
4380
4465
|
}, [drawMode.start, isReadOnly, isDisabled]);
|
|
4381
4466
|
|
|
4467
|
+
var _useConditionalFields = useConditionalFields(),
|
|
4468
|
+
hasSurfaceVisiblity = _useConditionalFields.hasSurfaceVisiblity,
|
|
4469
|
+
hasSurfaceWind = _useConditionalFields.hasSurfaceWind,
|
|
4470
|
+
hasLevels = _useConditionalFields.hasLevels,
|
|
4471
|
+
hasCloudLevels = _useConditionalFields.hasCloudLevels;
|
|
4472
|
+
|
|
4382
4473
|
var renderForm = function renderForm() {
|
|
4383
4474
|
return /*#__PURE__*/React__default.createElement(Grid, {
|
|
4384
4475
|
container: true,
|
|
@@ -4389,11 +4480,11 @@ var AirmetForm = function AirmetForm(_ref) {
|
|
|
4389
4480
|
isDisabled: isDisabled,
|
|
4390
4481
|
isReadOnly: isReadOnly,
|
|
4391
4482
|
onChange: onChangeForm
|
|
4392
|
-
}), !isCancelAirmet &&
|
|
4483
|
+
}), !isCancelAirmet && hasSurfaceVisiblity && /*#__PURE__*/React__default.createElement(SurfaceVisibility, {
|
|
4393
4484
|
isReadOnly: isReadOnly,
|
|
4394
4485
|
isDisabled: isDisabled,
|
|
4395
4486
|
onChange: onChangeForm
|
|
4396
|
-
}), !isCancelAirmet &&
|
|
4487
|
+
}), !isCancelAirmet && hasSurfaceWind && /*#__PURE__*/React__default.createElement(SurfaceWind, {
|
|
4397
4488
|
isReadOnly: isReadOnly,
|
|
4398
4489
|
isDisabled: isDisabled,
|
|
4399
4490
|
onChange: onChangeForm
|
|
@@ -4426,12 +4517,12 @@ var AirmetForm = function AirmetForm(_ref) {
|
|
|
4426
4517
|
setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
|
|
4427
4518
|
_setDrawModeType(mapDrawMode, StartOrEndDrawing, updateStartDrawing);
|
|
4428
4519
|
}
|
|
4429
|
-
}), !isCancelAirmet &&
|
|
4520
|
+
}), !isCancelAirmet && hasLevels && /*#__PURE__*/React__default.createElement(Levels, {
|
|
4430
4521
|
isDisabled: isDisabled,
|
|
4431
4522
|
isReadOnly: isReadOnly,
|
|
4432
4523
|
onChange: onChangeForm,
|
|
4433
4524
|
productType: "airmet"
|
|
4434
|
-
}), !isCancelAirmet &&
|
|
4525
|
+
}), !isCancelAirmet && hasCloudLevels && /*#__PURE__*/React__default.createElement(CloudLevels, {
|
|
4435
4526
|
isDisabled: isDisabled,
|
|
4436
4527
|
isReadOnly: isReadOnly,
|
|
4437
4528
|
onChange: onChangeForm
|
|
@@ -5067,18 +5158,16 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
5067
5158
|
|
|
5068
5159
|
React.useEffect(function () {
|
|
5069
5160
|
// set the values of the newly selected product
|
|
5070
|
-
reset(product !== null ? Object.assign({}, product) : {}
|
|
5161
|
+
reset(product !== null ? Object.assign({}, product) : {}, {
|
|
5162
|
+
keepDefaultValues: true
|
|
5163
|
+
});
|
|
5071
5164
|
return function () {
|
|
5072
5165
|
// reset form on unmount
|
|
5073
5166
|
reset({});
|
|
5074
5167
|
};
|
|
5075
5168
|
}, [reset, product]);
|
|
5076
5169
|
|
|
5077
|
-
var postProduct = function postProduct(
|
|
5078
|
-
// remove hidden helper fields
|
|
5079
|
-
_productToPost.IS_DRAFT;
|
|
5080
|
-
var productToPost = __rest(_productToPost, ["IS_DRAFT"]);
|
|
5081
|
-
|
|
5170
|
+
var postProduct = function postProduct(productToPost, newStatus) {
|
|
5082
5171
|
var uuid = product !== null && product.uuid ? product.uuid : null;
|
|
5083
5172
|
var postProductParam = productType === 'sigmet' ? createSigmetPostParameter(productToPost, newStatus, uuid) : createAirmetPostParameter(productToPost, newStatus, uuid);
|
|
5084
5173
|
setLoader(true);
|
|
@@ -5098,8 +5187,9 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
5098
5187
|
};
|
|
5099
5188
|
|
|
5100
5189
|
var onToggleDialog = function onToggleDialog() {
|
|
5190
|
+
var shouldRefreshList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
5101
5191
|
setLoader(false);
|
|
5102
|
-
toggleDialogStatus();
|
|
5192
|
+
toggleDialogStatus(shouldRefreshList);
|
|
5103
5193
|
};
|
|
5104
5194
|
|
|
5105
5195
|
var showConfirmDialog = function showConfirmDialog(action) {
|
|
@@ -5119,7 +5209,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
5119
5209
|
switch (action) {
|
|
5120
5210
|
case 'CLOSED':
|
|
5121
5211
|
if (mode === 'view' || !isDirty) {
|
|
5122
|
-
onToggleDialog();
|
|
5212
|
+
onToggleDialog(false);
|
|
5123
5213
|
} else {
|
|
5124
5214
|
toggleIsDraft(true);
|
|
5125
5215
|
showConfirmDialog(action).then(function () {
|
|
@@ -5129,7 +5219,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
5129
5219
|
})["catch"](function (reason) {
|
|
5130
5220
|
if (reason === 'CANCELLED') {
|
|
5131
5221
|
// close without save
|
|
5132
|
-
onToggleDialog();
|
|
5222
|
+
onToggleDialog(false);
|
|
5133
5223
|
}
|
|
5134
5224
|
});
|
|
5135
5225
|
}
|
|
@@ -5151,7 +5241,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
5151
5241
|
showConfirmDialog(action).then(function () {
|
|
5152
5242
|
// If we're discarding a new SIGMET/AIRMET - just close the dialog
|
|
5153
5243
|
if (mode === 'new') {
|
|
5154
|
-
onToggleDialog();
|
|
5244
|
+
onToggleDialog(false);
|
|
5155
5245
|
} else {
|
|
5156
5246
|
// If we're discarding an existing SIGMET/AIRMET - make call to BE
|
|
5157
5247
|
postProduct(product, action);
|
|
@@ -5270,14 +5360,18 @@ var ProductFormDialog = function ProductFormDialog(_ref) {
|
|
|
5270
5360
|
return null;
|
|
5271
5361
|
}
|
|
5272
5362
|
|
|
5363
|
+
var product = productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null;
|
|
5273
5364
|
return /*#__PURE__*/React.createElement(ReactHookFormProvider, {
|
|
5274
|
-
options: defaultFormOptions
|
|
5365
|
+
options: Object.assign(Object.assign({}, defaultFormOptions), {
|
|
5366
|
+
defaultValues: product,
|
|
5367
|
+
values: product
|
|
5368
|
+
})
|
|
5275
5369
|
}, /*#__PURE__*/React.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React.createElement(ProductFormDialogContent, {
|
|
5276
5370
|
isOpen: isOpen,
|
|
5277
5371
|
toggleDialogStatus: toggleDialogStatus,
|
|
5278
5372
|
mode: mode,
|
|
5279
5373
|
productCanBe: productCanBe,
|
|
5280
|
-
product:
|
|
5374
|
+
product: product,
|
|
5281
5375
|
productType: productType
|
|
5282
5376
|
})));
|
|
5283
5377
|
};
|
|
@@ -5328,8 +5422,9 @@ var MetInfoWrapper = function MetInfoWrapper(_ref) {
|
|
|
5328
5422
|
}, [selectedProduct]);
|
|
5329
5423
|
|
|
5330
5424
|
var toggleDialogOpen = function toggleDialogOpen() {
|
|
5425
|
+
var shouldRefreshList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
5331
5426
|
// Refresh list on closing dialog
|
|
5332
|
-
if (isFormDialogOpen === true) getNewProductList();
|
|
5427
|
+
if (isFormDialogOpen === true && shouldRefreshList) getNewProductList();
|
|
5333
5428
|
setIsFormDialogOpen(!isFormDialogOpen);
|
|
5334
5429
|
};
|
|
5335
5430
|
|
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
|
|
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 && (
|
|
1494
|
+
return __assign(__assign({}, list), !hasNaNValue && (_c = {}, _c[key] = value, _c));
|
|
1477
1495
|
}
|
|
1478
1496
|
|
|
1479
|
-
return __assign(__assign({}, list), hasValue(value) && (
|
|
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 =
|
|
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 =
|
|
1516
|
+
var airmet = prepareFormValues(airmetIncludingUuid);
|
|
1499
1517
|
return {
|
|
1500
1518
|
changeStatusTo: newStatus,
|
|
1501
1519
|
airmet: airmet
|
|
@@ -1738,15 +1756,21 @@
|
|
|
1738
1756
|
setValue = _c.setValue,
|
|
1739
1757
|
trigger = _c.trigger,
|
|
1740
1758
|
getValues = _c.getValues,
|
|
1741
|
-
|
|
1742
|
-
|
|
1759
|
+
clearErrors = _c.clearErrors,
|
|
1760
|
+
unregister = _c.unregister;
|
|
1743
1761
|
|
|
1744
1762
|
var isRequired = shared.useDraftFormHelpers().isRequired;
|
|
1763
|
+
var levelInfoMode = watch('levelInfoMode');
|
|
1745
1764
|
var config = productType === 'sigmet' ? sigmetConfig : airmetConfig;
|
|
1746
1765
|
var allowedUnits = useProductSettings(config).allowedUnits;
|
|
1747
1766
|
var selectedFIR = watch('locationIndicatorATSR'); // Get allowed level units based on selected FIR - if no FIR selected, allow all default units
|
|
1748
1767
|
|
|
1749
1768
|
var allowedLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'level_unit', LevelUnits);
|
|
1769
|
+
React__default["default"].useEffect(function () {
|
|
1770
|
+
if (levelInfoMode !== 'BETW') {
|
|
1771
|
+
unregister('lowerLevel');
|
|
1772
|
+
}
|
|
1773
|
+
}, [levelInfoMode, unregister]);
|
|
1750
1774
|
return /*#__PURE__*/React__default["default"].createElement(ProductFormFieldLayout, {
|
|
1751
1775
|
title: "Levels",
|
|
1752
1776
|
sx: styles$2.containerItem
|
|
@@ -1764,29 +1788,18 @@
|
|
|
1764
1788
|
isReadOnly: isReadOnly,
|
|
1765
1789
|
onChange: function onChange() {
|
|
1766
1790
|
// Reset default value for the level value to '' so when it rerenders it uses this empty default value
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
level: {
|
|
1770
|
-
unit: 'FL',
|
|
1771
|
-
value: null
|
|
1772
|
-
}
|
|
1773
|
-
}), {
|
|
1774
|
-
keepErrors: true,
|
|
1775
|
-
keepDirty: true,
|
|
1776
|
-
keepIsSubmitted: false,
|
|
1777
|
-
keepTouched: false,
|
|
1778
|
-
keepIsValid: false
|
|
1779
|
-
}); // Clear out errors for the levels
|
|
1791
|
+
setValue('level.unit', 'FL');
|
|
1792
|
+
setValue('level.value', null); // Clear out errors for the levels
|
|
1780
1793
|
|
|
1781
1794
|
clearErrors(['level', 'lowerLevel']);
|
|
1782
1795
|
}
|
|
1783
1796
|
}, /*#__PURE__*/React__default["default"].createElement(RadioButtonAndLabel, {
|
|
1784
1797
|
value: "AT",
|
|
1785
1798
|
label: "At",
|
|
1786
|
-
checked:
|
|
1799
|
+
checked: levelInfoMode === 'AT' || levelInfoMode === 'TOPS',
|
|
1787
1800
|
"data-testid": "levels-AT",
|
|
1788
1801
|
disabled: isDisabled
|
|
1789
|
-
}),
|
|
1802
|
+
}), levelInfoMode === 'AT' || levelInfoMode === 'TOPS' ? /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
1790
1803
|
item: true,
|
|
1791
1804
|
xs: 12,
|
|
1792
1805
|
container: true,
|
|
@@ -1799,7 +1812,7 @@
|
|
|
1799
1812
|
md: 3
|
|
1800
1813
|
}, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
|
|
1801
1814
|
control: /*#__PURE__*/React__default["default"].createElement(material.Checkbox, {
|
|
1802
|
-
checked:
|
|
1815
|
+
checked: levelInfoMode === 'TOPS',
|
|
1803
1816
|
onChange: function onChange() {
|
|
1804
1817
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'AT' ? 'TOPS' : 'AT', {
|
|
1805
1818
|
shouldDirty: true
|
|
@@ -1870,10 +1883,10 @@
|
|
|
1870
1883
|
}))) : null, /*#__PURE__*/React__default["default"].createElement(RadioButtonAndLabel, {
|
|
1871
1884
|
value: "BETW",
|
|
1872
1885
|
label: "Between",
|
|
1873
|
-
checked:
|
|
1886
|
+
checked: levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC',
|
|
1874
1887
|
"data-testid": "levels-BETW",
|
|
1875
1888
|
disabled: isDisabled
|
|
1876
|
-
}),
|
|
1889
|
+
}), levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC' ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
1877
1890
|
item: true,
|
|
1878
1891
|
xs: 12,
|
|
1879
1892
|
container: true,
|
|
@@ -1894,7 +1907,7 @@
|
|
|
1894
1907
|
isRequired: isRequired,
|
|
1895
1908
|
validateLevelUnitCombinations: function validateLevelUnitCombinations(value) {
|
|
1896
1909
|
// level step depends on the unit
|
|
1897
|
-
return _validateLevelUnitCombinations(value,
|
|
1910
|
+
return _validateLevelUnitCombinations(value, levelInfoMode === 'BETW_SFC' ? 'SFC' : getValues('lowerLevel.unit')) === true;
|
|
1898
1911
|
}
|
|
1899
1912
|
}
|
|
1900
1913
|
},
|
|
@@ -1957,7 +1970,7 @@
|
|
|
1957
1970
|
md: 3
|
|
1958
1971
|
}, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
|
|
1959
1972
|
control: /*#__PURE__*/React__default["default"].createElement(material.Checkbox, {
|
|
1960
|
-
checked:
|
|
1973
|
+
checked: levelInfoMode === 'BETW_SFC',
|
|
1961
1974
|
onChange: function onChange() {
|
|
1962
1975
|
getValues('level.unit') && trigger('level.unit');
|
|
1963
1976
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'BETW' ? 'BETW_SFC' : 'BETW', {
|
|
@@ -1970,7 +1983,7 @@
|
|
|
1970
1983
|
}),
|
|
1971
1984
|
"data-testid": "levels-SFC",
|
|
1972
1985
|
label: "SFC"
|
|
1973
|
-
})),
|
|
1986
|
+
})), levelInfoMode !== 'BETW_SFC' && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
1974
1987
|
item: true,
|
|
1975
1988
|
xs: 4,
|
|
1976
1989
|
md: 3
|
|
@@ -2039,9 +2052,9 @@
|
|
|
2039
2052
|
value: "ABV",
|
|
2040
2053
|
label: "Above",
|
|
2041
2054
|
disabled: isDisabled,
|
|
2042
|
-
checked:
|
|
2055
|
+
checked: levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV',
|
|
2043
2056
|
"data-testid": "levels-ABV"
|
|
2044
|
-
}),
|
|
2057
|
+
}), levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV' ? /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
2045
2058
|
item: true,
|
|
2046
2059
|
xs: 12,
|
|
2047
2060
|
container: true,
|
|
@@ -2054,7 +2067,7 @@
|
|
|
2054
2067
|
md: 3
|
|
2055
2068
|
}, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
|
|
2056
2069
|
control: /*#__PURE__*/React__default["default"].createElement(material.Checkbox, {
|
|
2057
|
-
checked:
|
|
2070
|
+
checked: levelInfoMode === 'TOPS_ABV',
|
|
2058
2071
|
onChange: function onChange() {
|
|
2059
2072
|
setValue('levelInfoMode', getValues('levelInfoMode') === 'ABV' ? 'TOPS_ABV' : 'ABV', {
|
|
2060
2073
|
shouldDirty: true
|
|
@@ -2248,7 +2261,8 @@
|
|
|
2248
2261
|
setValue = _c.setValue,
|
|
2249
2262
|
trigger = _c.trigger;
|
|
2250
2263
|
|
|
2251
|
-
var
|
|
2264
|
+
var isSigmet = productType === 'sigmet';
|
|
2265
|
+
var phenomenaList = isSigmet ? SigmetPhenomena : AirmetPhenomena;
|
|
2252
2266
|
var label = getFieldLabel('Phenomenon', isReadOnly);
|
|
2253
2267
|
return /*#__PURE__*/React__default["default"].createElement(ProductFormFieldLayout, {
|
|
2254
2268
|
title: "What"
|
|
@@ -2266,17 +2280,6 @@
|
|
|
2266
2280
|
setValue('movementType', null);
|
|
2267
2281
|
}
|
|
2268
2282
|
|
|
2269
|
-
if (getValues('phenomenon') !== 'SFC_VIS') {
|
|
2270
|
-
setValue('visibilityValue', null);
|
|
2271
|
-
setValue('visibilityCause', null);
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
if (getValues('phenomenon') !== 'SFC_WIND') {
|
|
2275
|
-
setValue('windDirection', null);
|
|
2276
|
-
setValue('windUnit', null);
|
|
2277
|
-
setValue('windSpeed', null);
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
2283
|
_onChange();
|
|
2281
2284
|
|
|
2282
2285
|
return trigger(__spreadArray(__spreadArray([], __read(getValues('validDateStart') ? ['validDateStart'] : [])), __read(getValues('validDateEnd') ? ['validDateEnd'] : [])));
|
|
@@ -2446,7 +2449,8 @@
|
|
|
2446
2449
|
watch = _e.watch,
|
|
2447
2450
|
getValues = _e.getValues,
|
|
2448
2451
|
trigger = _e.trigger,
|
|
2449
|
-
errors = _e.formState.errors
|
|
2452
|
+
errors = _e.formState.errors,
|
|
2453
|
+
unregister = _e.unregister;
|
|
2450
2454
|
|
|
2451
2455
|
var _f = shared.useDraftFormHelpers(),
|
|
2452
2456
|
isRequired = _f.isRequired,
|
|
@@ -2458,6 +2462,18 @@
|
|
|
2458
2462
|
var selectedFIR = watch('locationIndicatorATSR'); // Get allowed movement units based on selected FIR - if no FIR selected, allow all units
|
|
2459
2463
|
|
|
2460
2464
|
var allowedMovementUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'movement_unit', MovementUnit);
|
|
2465
|
+
React__default["default"].useEffect(function () {
|
|
2466
|
+
if (movementType !== 'MOVEMENT') {
|
|
2467
|
+
unregister('movementDirection');
|
|
2468
|
+
unregister('movementSpeed');
|
|
2469
|
+
unregister('movementUnit');
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
if (movementType !== 'FORECAST_POSITION') {
|
|
2473
|
+
unregister('endGeometry');
|
|
2474
|
+
unregister('endGeometryIntersect');
|
|
2475
|
+
}
|
|
2476
|
+
}, [movementType, unregister]);
|
|
2461
2477
|
return /*#__PURE__*/React__default["default"].createElement(ProductFormFieldLayout, {
|
|
2462
2478
|
title: "Progress",
|
|
2463
2479
|
sx: styles$2.containerItem
|
|
@@ -3283,13 +3299,20 @@
|
|
|
3283
3299
|
watch = _c.watch,
|
|
3284
3300
|
setValue = _c.setValue,
|
|
3285
3301
|
trigger = _c.trigger,
|
|
3286
|
-
getValues = _c.getValues
|
|
3302
|
+
getValues = _c.getValues,
|
|
3303
|
+
unregister = _c.unregister;
|
|
3287
3304
|
|
|
3288
3305
|
var isRequired = shared.useDraftFormHelpers().isRequired;
|
|
3289
3306
|
var allowedUnits = useProductSettings(airmetConfig).allowedUnits;
|
|
3290
|
-
var selectedFIR = watch('locationIndicatorATSR');
|
|
3307
|
+
var selectedFIR = watch('locationIndicatorATSR');
|
|
3308
|
+
var cloudLevelInfoMode = watch('cloudLevelInfoMode'); // Get allowed cloud level units based on selected FIR - if no FIR selected, allow all default units
|
|
3291
3309
|
|
|
3292
3310
|
var allowedCloudLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'cloud_level_unit', CloudLevelUnits);
|
|
3311
|
+
React__default["default"].useEffect(function () {
|
|
3312
|
+
if (cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') {
|
|
3313
|
+
unregister('cloudLowerLevel');
|
|
3314
|
+
}
|
|
3315
|
+
}, [cloudLevelInfoMode, unregister]);
|
|
3293
3316
|
return /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
3294
3317
|
item: true,
|
|
3295
3318
|
container: true,
|
|
@@ -3321,12 +3344,12 @@
|
|
|
3321
3344
|
}, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
3322
3345
|
item: true,
|
|
3323
3346
|
xs: 4
|
|
3324
|
-
}, (!isReadOnly ||
|
|
3347
|
+
}, (!isReadOnly || cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default["default"].createElement(formFields.ReactHookFormFormControl, {
|
|
3325
3348
|
disabled: isDisabled,
|
|
3326
3349
|
isReadOnly: isReadOnly
|
|
3327
3350
|
}, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
|
|
3328
3351
|
control: /*#__PURE__*/React__default["default"].createElement(material.Checkbox, {
|
|
3329
|
-
checked:
|
|
3352
|
+
checked: cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV',
|
|
3330
3353
|
onChange: function onChange() {
|
|
3331
3354
|
switch (getValues('cloudLevelInfoMode')) {
|
|
3332
3355
|
case 'BETW':
|
|
@@ -3432,12 +3455,12 @@
|
|
|
3432
3455
|
}, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
3433
3456
|
item: true,
|
|
3434
3457
|
xs: 4
|
|
3435
|
-
}, (!isReadOnly ||
|
|
3458
|
+
}, (!isReadOnly || cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default["default"].createElement(formFields.ReactHookFormFormControl, {
|
|
3436
3459
|
disabled: isDisabled,
|
|
3437
3460
|
isReadOnly: isReadOnly
|
|
3438
3461
|
}, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
|
|
3439
3462
|
control: /*#__PURE__*/React__default["default"].createElement(material.Checkbox, {
|
|
3440
|
-
checked:
|
|
3463
|
+
checked: cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV',
|
|
3441
3464
|
onChange: function onChange() {
|
|
3442
3465
|
switch (getValues('cloudLevelInfoMode')) {
|
|
3443
3466
|
case 'BETW':
|
|
@@ -3471,7 +3494,7 @@
|
|
|
3471
3494
|
}),
|
|
3472
3495
|
"data-testid": "cloudLevels-SFC",
|
|
3473
3496
|
label: "SFC"
|
|
3474
|
-
}))),
|
|
3497
|
+
}))), cloudLevelInfoMode !== 'BETW_SFC' && cloudLevelInfoMode !== 'BETW_SFC_ABV' && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
3475
3498
|
item: true,
|
|
3476
3499
|
xs: 3
|
|
3477
3500
|
}, /*#__PURE__*/React__default["default"].createElement(formFields.ReactHookFormSelect, {
|
|
@@ -3570,7 +3593,7 @@
|
|
|
3570
3593
|
|
|
3571
3594
|
return [4
|
|
3572
3595
|
/*yield*/
|
|
3573
|
-
, getTAC(product)];
|
|
3596
|
+
, getTAC(prepareFormValues(product))];
|
|
3574
3597
|
|
|
3575
3598
|
case 1:
|
|
3576
3599
|
result = _a.sent();
|
|
@@ -3616,10 +3639,14 @@
|
|
|
3616
3639
|
} else if (isMounted.current) {
|
|
3617
3640
|
setTAC(noTAC);
|
|
3618
3641
|
}
|
|
3619
|
-
};
|
|
3620
|
-
|
|
3642
|
+
};
|
|
3621
3643
|
|
|
3622
|
-
var delayedQuery = React__default["default"].
|
|
3644
|
+
var delayedQuery = React__default["default"].useMemo(function () {
|
|
3645
|
+
return lodash.debounce(function (formFn) {
|
|
3646
|
+
return update(formFn());
|
|
3647
|
+
}, 1000);
|
|
3648
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3649
|
+
[]);
|
|
3623
3650
|
return [TAC, delayedQuery];
|
|
3624
3651
|
};
|
|
3625
3652
|
|
|
@@ -3977,6 +4004,23 @@
|
|
|
3977
4004
|
}, children));
|
|
3978
4005
|
};
|
|
3979
4006
|
|
|
4007
|
+
var useConditionalFields$1 = function useConditionalFields() {
|
|
4008
|
+
var _a = reactHookForm.useFormContext(),
|
|
4009
|
+
watch = _a.watch,
|
|
4010
|
+
unregister = _a.unregister; // phenomenon: VA_CLD
|
|
4011
|
+
|
|
4012
|
+
|
|
4013
|
+
var hasVolcanicAshes = watch('phenomenon') === 'VA_CLD';
|
|
4014
|
+
React__default["default"].useEffect(function () {
|
|
4015
|
+
if (!hasVolcanicAshes) {
|
|
4016
|
+
unregister(['vaSigmetVolcanoName', 'vaSigmetVolcanoCoordinates.latitude', 'vaSigmetVolcanoCoordinates.longitude']);
|
|
4017
|
+
}
|
|
4018
|
+
}, [hasVolcanicAshes, unregister]);
|
|
4019
|
+
return {
|
|
4020
|
+
hasVolcanicAshes: hasVolcanicAshes
|
|
4021
|
+
};
|
|
4022
|
+
};
|
|
4023
|
+
|
|
3980
4024
|
var SigmetForm = function SigmetForm(_a) {
|
|
3981
4025
|
var mode = _a.mode,
|
|
3982
4026
|
_b = _a.isCancelSigmet,
|
|
@@ -3992,8 +4036,7 @@
|
|
|
3992
4036
|
var _f = reactHookForm.useFormContext(),
|
|
3993
4037
|
watch = _f.watch,
|
|
3994
4038
|
setValue = _f.setValue,
|
|
3995
|
-
handleSubmit = _f.handleSubmit
|
|
3996
|
-
getValues = _f.getValues;
|
|
4039
|
+
handleSubmit = _f.handleSubmit;
|
|
3997
4040
|
|
|
3998
4041
|
var _g = __read(React__default["default"].useState(mode === 'view'), 2),
|
|
3999
4042
|
isDisabled = _g[0],
|
|
@@ -4007,7 +4050,7 @@
|
|
|
4007
4050
|
updateTac = _h[1];
|
|
4008
4051
|
|
|
4009
4052
|
var onChangeForm = function onChangeForm() {
|
|
4010
|
-
updateTac(
|
|
4053
|
+
updateTac(watch);
|
|
4011
4054
|
}; // TODO: [Loes Cornelis]: fix this whole mess of if statements for isCancelSigmet and hidden fields if disabled throughout the form
|
|
4012
4055
|
|
|
4013
4056
|
|
|
@@ -4071,6 +4114,7 @@
|
|
|
4071
4114
|
setIsDisabled(isInDrawMode);
|
|
4072
4115
|
}
|
|
4073
4116
|
}, [drawMode.start, drawMode.end, isReadOnly, isDisabled]);
|
|
4117
|
+
var hasVolcanicAshes = useConditionalFields$1().hasVolcanicAshes;
|
|
4074
4118
|
|
|
4075
4119
|
var renderForm = function renderForm() {
|
|
4076
4120
|
return /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
@@ -4090,7 +4134,7 @@
|
|
|
4090
4134
|
isReadOnly: isReadOnly,
|
|
4091
4135
|
helperText: helperText,
|
|
4092
4136
|
onChange: onChangeForm
|
|
4093
|
-
}), !isCancelSigmet &&
|
|
4137
|
+
}), !isCancelSigmet && hasVolcanicAshes && /*#__PURE__*/React__default["default"].createElement(VolcanicFields, {
|
|
4094
4138
|
isDisabled: isDisabled,
|
|
4095
4139
|
isReadOnly: isReadOnly,
|
|
4096
4140
|
helperText: helperText
|
|
@@ -4187,6 +4231,48 @@
|
|
|
4187
4231
|
}, renderForm()));
|
|
4188
4232
|
};
|
|
4189
4233
|
|
|
4234
|
+
var useConditionalFields = function useConditionalFields() {
|
|
4235
|
+
var _a = reactHookForm.useFormContext(),
|
|
4236
|
+
watch = _a.watch,
|
|
4237
|
+
unregister = _a.unregister; // phenomenon: SFC_VIS
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
var phenomenon = watch('phenomenon');
|
|
4241
|
+
var hasSurfaceVisiblity = phenomenon === 'SFC_VIS';
|
|
4242
|
+
React__default["default"].useEffect(function () {
|
|
4243
|
+
if (!hasSurfaceVisiblity) {
|
|
4244
|
+
unregister(['visibilityValue', 'visibilityCause']);
|
|
4245
|
+
}
|
|
4246
|
+
}, [hasSurfaceVisiblity, unregister]); // phenomenon: SFC_WIND
|
|
4247
|
+
|
|
4248
|
+
var hasSurfaceWind = watch('phenomenon') === 'SFC_WIND';
|
|
4249
|
+
React__default["default"].useEffect(function () {
|
|
4250
|
+
if (!hasSurfaceWind) {
|
|
4251
|
+
unregister(['windDirection', 'windUnit', 'windSpeed']);
|
|
4252
|
+
}
|
|
4253
|
+
}, [hasSurfaceWind, unregister]); // phenomenon: SFC_WIND, SFC_VIS, BKN_CLD, OVC_CLD
|
|
4254
|
+
|
|
4255
|
+
var hasLevels = phenomenon !== 'SFC_WIND' && phenomenon !== 'SFC_VIS' && phenomenon !== 'BKN_CLD' && phenomenon !== 'OVC_CLD';
|
|
4256
|
+
React__default["default"].useEffect(function () {
|
|
4257
|
+
if (!hasLevels) {
|
|
4258
|
+
unregister(['levelInfoMode', 'level', 'lowerLevel']);
|
|
4259
|
+
}
|
|
4260
|
+
}, [hasLevels, unregister]); // phenomenon: BKN_CLD
|
|
4261
|
+
|
|
4262
|
+
var hasCloudLevels = phenomenon === 'BKN_CLD' || phenomenon === 'OVC_CLD';
|
|
4263
|
+
React__default["default"].useEffect(function () {
|
|
4264
|
+
if (!hasCloudLevels) {
|
|
4265
|
+
unregister(['cloudLevelInfoMode', 'cloudLevel', 'cloudLowerLevel']);
|
|
4266
|
+
}
|
|
4267
|
+
}, [hasCloudLevels, unregister]);
|
|
4268
|
+
return {
|
|
4269
|
+
hasSurfaceVisiblity: hasSurfaceVisiblity,
|
|
4270
|
+
hasSurfaceWind: hasSurfaceWind,
|
|
4271
|
+
hasLevels: hasLevels,
|
|
4272
|
+
hasCloudLevels: hasCloudLevels
|
|
4273
|
+
};
|
|
4274
|
+
};
|
|
4275
|
+
|
|
4190
4276
|
var AirmetForm = function AirmetForm(_a) {
|
|
4191
4277
|
var mode = _a.mode,
|
|
4192
4278
|
_b = _a.isCancelAirmet,
|
|
@@ -4202,10 +4288,7 @@
|
|
|
4202
4288
|
var _f = reactHookForm.useFormContext(),
|
|
4203
4289
|
watch = _f.watch,
|
|
4204
4290
|
setValue = _f.setValue,
|
|
4205
|
-
handleSubmit = _f.handleSubmit
|
|
4206
|
-
getValues = _f.getValues;
|
|
4207
|
-
|
|
4208
|
-
var phenomenon = watch('phenomenon');
|
|
4291
|
+
handleSubmit = _f.handleSubmit;
|
|
4209
4292
|
|
|
4210
4293
|
var _g = __read(React__default["default"].useState(mode === 'view'), 2),
|
|
4211
4294
|
isDisabled = _g[0],
|
|
@@ -4219,7 +4302,7 @@
|
|
|
4219
4302
|
updateTac = _h[1];
|
|
4220
4303
|
|
|
4221
4304
|
var onChangeForm = function onChangeForm() {
|
|
4222
|
-
updateTac(
|
|
4305
|
+
updateTac(watch);
|
|
4223
4306
|
};
|
|
4224
4307
|
|
|
4225
4308
|
var initialGeometry = initialAirmet && !isCancelAirmet ? {
|
|
@@ -4262,6 +4345,12 @@
|
|
|
4262
4345
|
}
|
|
4263
4346
|
}, [drawMode.start, isReadOnly, isDisabled]);
|
|
4264
4347
|
|
|
4348
|
+
var _k = useConditionalFields(),
|
|
4349
|
+
hasSurfaceVisiblity = _k.hasSurfaceVisiblity,
|
|
4350
|
+
hasSurfaceWind = _k.hasSurfaceWind,
|
|
4351
|
+
hasLevels = _k.hasLevels,
|
|
4352
|
+
hasCloudLevels = _k.hasCloudLevels;
|
|
4353
|
+
|
|
4265
4354
|
var renderForm = function renderForm() {
|
|
4266
4355
|
return /*#__PURE__*/React__default["default"].createElement(material.Grid, {
|
|
4267
4356
|
container: true,
|
|
@@ -4272,11 +4361,11 @@
|
|
|
4272
4361
|
isDisabled: isDisabled,
|
|
4273
4362
|
isReadOnly: isReadOnly,
|
|
4274
4363
|
onChange: onChangeForm
|
|
4275
|
-
}), !isCancelAirmet &&
|
|
4364
|
+
}), !isCancelAirmet && hasSurfaceVisiblity && /*#__PURE__*/React__default["default"].createElement(SurfaceVisibility, {
|
|
4276
4365
|
isReadOnly: isReadOnly,
|
|
4277
4366
|
isDisabled: isDisabled,
|
|
4278
4367
|
onChange: onChangeForm
|
|
4279
|
-
}), !isCancelAirmet &&
|
|
4368
|
+
}), !isCancelAirmet && hasSurfaceWind && /*#__PURE__*/React__default["default"].createElement(SurfaceWind, {
|
|
4280
4369
|
isReadOnly: isReadOnly,
|
|
4281
4370
|
isDisabled: isDisabled,
|
|
4282
4371
|
onChange: onChangeForm
|
|
@@ -4309,12 +4398,12 @@
|
|
|
4309
4398
|
setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
|
|
4310
4399
|
_setDrawModeType(mapDrawMode, StartOrEndDrawing, updateStartDrawing);
|
|
4311
4400
|
}
|
|
4312
|
-
}), !isCancelAirmet &&
|
|
4401
|
+
}), !isCancelAirmet && hasLevels && /*#__PURE__*/React__default["default"].createElement(Levels, {
|
|
4313
4402
|
isDisabled: isDisabled,
|
|
4314
4403
|
isReadOnly: isReadOnly,
|
|
4315
4404
|
onChange: onChangeForm,
|
|
4316
4405
|
productType: "airmet"
|
|
4317
|
-
}), !isCancelAirmet &&
|
|
4406
|
+
}), !isCancelAirmet && hasCloudLevels && /*#__PURE__*/React__default["default"].createElement(CloudLevels, {
|
|
4318
4407
|
isDisabled: isDisabled,
|
|
4319
4408
|
isReadOnly: isReadOnly,
|
|
4320
4409
|
onChange: onChangeForm
|
|
@@ -4956,18 +5045,16 @@
|
|
|
4956
5045
|
|
|
4957
5046
|
React__namespace.useEffect(function () {
|
|
4958
5047
|
// set the values of the newly selected product
|
|
4959
|
-
reset(product !== null ? __assign({}, product) : {}
|
|
5048
|
+
reset(product !== null ? __assign({}, product) : {}, {
|
|
5049
|
+
keepDefaultValues: true
|
|
5050
|
+
});
|
|
4960
5051
|
return function () {
|
|
4961
5052
|
// reset form on unmount
|
|
4962
5053
|
reset({});
|
|
4963
5054
|
};
|
|
4964
5055
|
}, [reset, product]);
|
|
4965
5056
|
|
|
4966
|
-
var postProduct = function postProduct(
|
|
4967
|
-
// remove hidden helper fields
|
|
4968
|
-
_productToPost.IS_DRAFT;
|
|
4969
|
-
var productToPost = __rest(_productToPost, ["IS_DRAFT"]);
|
|
4970
|
-
|
|
5057
|
+
var postProduct = function postProduct(productToPost, newStatus) {
|
|
4971
5058
|
var uuid = product !== null && product.uuid ? product.uuid : null;
|
|
4972
5059
|
var postProductParam = productType === 'sigmet' ? createSigmetPostParameter(productToPost, newStatus, uuid) : createAirmetPostParameter(productToPost, newStatus, uuid);
|
|
4973
5060
|
setLoader(true);
|
|
@@ -4986,9 +5073,13 @@
|
|
|
4986
5073
|
});
|
|
4987
5074
|
};
|
|
4988
5075
|
|
|
4989
|
-
var onToggleDialog = function onToggleDialog() {
|
|
5076
|
+
var onToggleDialog = function onToggleDialog(shouldRefreshList) {
|
|
5077
|
+
if (shouldRefreshList === void 0) {
|
|
5078
|
+
shouldRefreshList = true;
|
|
5079
|
+
}
|
|
5080
|
+
|
|
4990
5081
|
setLoader(false);
|
|
4991
|
-
toggleDialogStatus();
|
|
5082
|
+
toggleDialogStatus(shouldRefreshList);
|
|
4992
5083
|
};
|
|
4993
5084
|
|
|
4994
5085
|
var showConfirmDialog = function showConfirmDialog(action) {
|
|
@@ -5008,7 +5099,7 @@
|
|
|
5008
5099
|
switch (action) {
|
|
5009
5100
|
case 'CLOSED':
|
|
5010
5101
|
if (mode === 'view' || !isDirty) {
|
|
5011
|
-
onToggleDialog();
|
|
5102
|
+
onToggleDialog(false);
|
|
5012
5103
|
} else {
|
|
5013
5104
|
toggleIsDraft(true);
|
|
5014
5105
|
showConfirmDialog(action).then(function () {
|
|
@@ -5018,7 +5109,7 @@
|
|
|
5018
5109
|
})["catch"](function (reason) {
|
|
5019
5110
|
if (reason === 'CANCELLED') {
|
|
5020
5111
|
// close without save
|
|
5021
|
-
onToggleDialog();
|
|
5112
|
+
onToggleDialog(false);
|
|
5022
5113
|
}
|
|
5023
5114
|
});
|
|
5024
5115
|
}
|
|
@@ -5040,7 +5131,7 @@
|
|
|
5040
5131
|
showConfirmDialog(action).then(function () {
|
|
5041
5132
|
// If we're discarding a new SIGMET/AIRMET - just close the dialog
|
|
5042
5133
|
if (mode === 'new') {
|
|
5043
|
-
onToggleDialog();
|
|
5134
|
+
onToggleDialog(false);
|
|
5044
5135
|
} else {
|
|
5045
5136
|
// If we're discarding an existing SIGMET/AIRMET - make call to BE
|
|
5046
5137
|
postProduct(product, action);
|
|
@@ -5143,14 +5234,18 @@
|
|
|
5143
5234
|
return null;
|
|
5144
5235
|
}
|
|
5145
5236
|
|
|
5237
|
+
var product = productListItem !== null ? prepareProductValues(productListItem[productType], productType) : null;
|
|
5146
5238
|
return /*#__PURE__*/React__namespace.createElement(formFields.ReactHookFormProvider, {
|
|
5147
|
-
options: formFields.defaultFormOptions
|
|
5239
|
+
options: __assign(__assign({}, formFields.defaultFormOptions), {
|
|
5240
|
+
defaultValues: product,
|
|
5241
|
+
values: product
|
|
5242
|
+
})
|
|
5148
5243
|
}, /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(ProductFormDialogContent, {
|
|
5149
5244
|
isOpen: isOpen,
|
|
5150
5245
|
toggleDialogStatus: toggleDialogStatus,
|
|
5151
5246
|
mode: mode,
|
|
5152
5247
|
productCanBe: productCanBe,
|
|
5153
|
-
product:
|
|
5248
|
+
product: product,
|
|
5154
5249
|
productType: productType
|
|
5155
5250
|
})));
|
|
5156
5251
|
};
|
|
@@ -5196,9 +5291,13 @@
|
|
|
5196
5291
|
|
|
5197
5292
|
}, [selectedProduct]);
|
|
5198
5293
|
|
|
5199
|
-
var toggleDialogOpen = function toggleDialogOpen() {
|
|
5200
|
-
|
|
5201
|
-
|
|
5294
|
+
var toggleDialogOpen = function toggleDialogOpen(shouldRefreshList) {
|
|
5295
|
+
if (shouldRefreshList === void 0) {
|
|
5296
|
+
shouldRefreshList = true;
|
|
5297
|
+
} // Refresh list on closing dialog
|
|
5298
|
+
|
|
5299
|
+
|
|
5300
|
+
if (isFormDialogOpen === true && shouldRefreshList) getNewProductList();
|
|
5202
5301
|
setIsFormDialogOpen(!isFormDialogOpen);
|
|
5203
5302
|
};
|
|
5204
5303
|
|
|
@@ -4,7 +4,7 @@ export declare const prepareProductValues: (product: Sigmet | Airmet | CancelSig
|
|
|
4
4
|
interface ProductFormDialogProps {
|
|
5
5
|
isOpen: boolean;
|
|
6
6
|
productType: ProductType;
|
|
7
|
-
toggleDialogStatus: () => void;
|
|
7
|
+
toggleDialogStatus: (shouldRefreshList?: boolean) => void;
|
|
8
8
|
productListItem?: SigmetFromBackend | AirmetFromBackend;
|
|
9
9
|
}
|
|
10
10
|
export declare const ProductFormDialog: React.FC<ProductFormDialogProps>;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { CancelSigmet, Sigmet, FormMode, CancelAirmet, Airmet, ProductType } from '../../types';
|
|
3
3
|
interface ProductFormDialogContentProps {
|
|
4
4
|
isOpen: boolean;
|
|
5
|
-
toggleDialogStatus: () => void;
|
|
5
|
+
toggleDialogStatus: (shouldRefreshList?: boolean) => void;
|
|
6
6
|
mode: FormMode;
|
|
7
7
|
productType: ProductType;
|
|
8
8
|
productCanBe: string[];
|
|
@@ -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:
|
|
5
|
-
export declare const useTAC: (initialProduct:
|
|
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
|
|
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];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/sigmet-airmet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "GeoWeb Sigmet/Airmet library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"react": "^17.0.2",
|
|
15
15
|
"react-redux": "^8.0.4",
|
|
16
16
|
"@mui/material": "^5.10.8",
|
|
17
|
-
"@opengeoweb/shared": "4.
|
|
18
|
-
"@opengeoweb/theme": "4.
|
|
17
|
+
"@opengeoweb/shared": "4.10.0",
|
|
18
|
+
"@opengeoweb/theme": "4.10.0",
|
|
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.
|
|
22
|
+
"@opengeoweb/form-fields": "4.10.0",
|
|
23
23
|
"react-hook-form": "^7.41.5",
|
|
24
24
|
"moment": "^2.29.0",
|
|
25
25
|
"moment-timezone": "^0.5.31",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"lodash": "^4.17.20",
|
|
28
28
|
"axios": "^0.25.0",
|
|
29
29
|
"date-fns": "^2.29.3",
|
|
30
|
-
"@opengeoweb/core": "4.
|
|
31
|
-
"@opengeoweb/webmap": "4.
|
|
30
|
+
"@opengeoweb/core": "4.10.0",
|
|
31
|
+
"@opengeoweb/webmap": "4.10.0",
|
|
32
32
|
"throttle-debounce": "^3.0.1",
|
|
33
33
|
"proj4": "^2.6.2",
|
|
34
|
-
"@opengeoweb/api": "4.
|
|
34
|
+
"@opengeoweb/api": "4.10.0",
|
|
35
35
|
"react-intl": "^5.17.5",
|
|
36
36
|
"react-sortablejs": "^6.1.4",
|
|
37
37
|
"sortablejs": "^1.15.0",
|
|
38
|
-
"react-window": "^1.8.7",
|
|
39
38
|
"immer": "^9.0.15",
|
|
39
|
+
"react-window": "^1.8.7",
|
|
40
40
|
"@reduxjs/toolkit": "^1.8.3",
|
|
41
41
|
"lodash.clonedeep": "^4.5.0",
|
|
42
42
|
"@turf/turf": "^5.1.6",
|