@opengeoweb/taf 1.1.3 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/IssuesPane/IssuesPane.styles.d.ts +1 -1
- package/lib/components/TafForm/TafForm.styles.d.ts +1 -1
- package/lib/components/TafForm/TafFormRow/DragHandle.d.ts +8 -0
- package/lib/components/TafForm/TafFormRow/DragHandle.spec.d.ts +1 -0
- package/lib/components/TafForm/TafFormRow/TafFormRow.d.ts +1 -9
- package/lib/components/TafForm/TafFormRow/change.d.ts +2 -0
- package/lib/components/TafForm/TafFormRow/types.d.ts +29 -0
- package/lib/components/TafForm/TafFormRow/validField.d.ts +2 -0
- package/lib/components/TafForm/utils.d.ts +15 -0
- package/lib/components/TafList/TafList.d.ts +2 -2
- package/lib/components/TafList/TafListAccordion.d.ts +2 -2
- package/lib/components/TafList/TafListButtons.d.ts +2 -2
- package/lib/components/TafList/TafListSection.d.ts +2 -2
- package/lib/types.d.ts +1 -1
- package/package.json +10 -6
- package/taf.esm.js +628 -346
- package/taf.umd.js +794 -491
package/taf.esm.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
2
3
|
import { makeStyles, Grid, TextField, IconButton, Tooltip, Chip, SvgIcon, Paper, Typography, Button, Dialog, DialogTitle, DialogContent, Card, Accordion, AccordionSummary, AccordionDetails, Backdrop, CircularProgress } from '@material-ui/core';
|
|
3
|
-
import {
|
|
4
|
+
import { Skeleton } from '@material-ui/lab';
|
|
4
5
|
import moment from 'moment';
|
|
5
|
-
import {
|
|
6
|
+
import { useDraftFormHelpers, useConfirmationDialog, usePreventBrowserClose, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
|
|
7
|
+
import { Delete, Close, DragIndicator, Add, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@material-ui/icons';
|
|
6
8
|
import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
|
|
7
9
|
import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
|
|
8
10
|
import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
|
|
9
|
-
import {
|
|
11
|
+
import { ReactSortable, Sortable } from 'react-sortablejs';
|
|
10
12
|
|
|
11
13
|
/*! *****************************************************************************
|
|
12
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -113,10 +115,10 @@ function __read(o, n) {
|
|
|
113
115
|
return ar;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
function
|
|
117
|
-
for (var
|
|
118
|
-
|
|
119
|
-
return
|
|
118
|
+
function __spreadArray(to, from) {
|
|
119
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
120
|
+
to[j] = from[i];
|
|
121
|
+
return to;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/* *
|
|
@@ -175,74 +177,6 @@ var tafConfig = {
|
|
|
175
177
|
locations: locations
|
|
176
178
|
};
|
|
177
179
|
|
|
178
|
-
/* *
|
|
179
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
-
* you may not use this file except in compliance with the License.
|
|
181
|
-
* You may obtain a copy of the License at
|
|
182
|
-
*
|
|
183
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
-
*
|
|
185
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
186
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
-
* See the License for the specific language governing permissions and
|
|
189
|
-
* limitations under the License.
|
|
190
|
-
*
|
|
191
|
-
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
192
|
-
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
193
|
-
* */
|
|
194
|
-
var useStyles = makeStyles({
|
|
195
|
-
textFieldGridItem: {
|
|
196
|
-
marginRight: 4
|
|
197
|
-
},
|
|
198
|
-
textFieldInput: {
|
|
199
|
-
fontSize: '14px',
|
|
200
|
-
paddingLeft: 1,
|
|
201
|
-
paddingRight: 1,
|
|
202
|
-
color: '#051039'
|
|
203
|
-
},
|
|
204
|
-
textFieldLabel: {
|
|
205
|
-
fontSize: '14px'
|
|
206
|
-
},
|
|
207
|
-
textFieldLabelShrink: {
|
|
208
|
-
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
209
|
-
},
|
|
210
|
-
formRow: {
|
|
211
|
-
marginTop: 8
|
|
212
|
-
},
|
|
213
|
-
tacTitle: {
|
|
214
|
-
fontSize: '20px',
|
|
215
|
-
fontWeight: 500
|
|
216
|
-
},
|
|
217
|
-
tacText: {
|
|
218
|
-
fontSize: '14px',
|
|
219
|
-
color: '#000000'
|
|
220
|
-
},
|
|
221
|
-
tacLine: {
|
|
222
|
-
margin: '0',
|
|
223
|
-
padding: '.1em .1em .1em 0.8em',
|
|
224
|
-
textIndent: '-0.7em',
|
|
225
|
-
borderRadius: '3px'
|
|
226
|
-
},
|
|
227
|
-
addButton: {
|
|
228
|
-
marginRight: '38px'
|
|
229
|
-
},
|
|
230
|
-
lifecycleButtons: {
|
|
231
|
-
marginTop: '40px',
|
|
232
|
-
marginBottom: '16px'
|
|
233
|
-
},
|
|
234
|
-
actionButton: {
|
|
235
|
-
marginRight: '16px'
|
|
236
|
-
},
|
|
237
|
-
lastButton: {
|
|
238
|
-
marginRight: '90px'
|
|
239
|
-
},
|
|
240
|
-
backdrop: {
|
|
241
|
-
zIndex: 1500,
|
|
242
|
-
color: '#fff'
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
|
|
246
180
|
function _typeof(obj) {
|
|
247
181
|
"@babel/helpers - typeof";
|
|
248
182
|
|
|
@@ -341,7 +275,8 @@ var invalidValidityMinutesMessage = 'Invalid validity period, specified minutes
|
|
|
341
275
|
var invalidValidityStartTimeMessage = 'Invalid validity start time, change group validity must lie within the TAF validity period';
|
|
342
276
|
var invalidValidityPeriodMessage = 'Invalid validity period, validity end time has to be after validity start time';
|
|
343
277
|
var invalidValidityEndTimeMessage = 'Invalid validity end time, change group validity must lie within the TAF validity period';
|
|
344
|
-
var invalidValidityLengthMessage = 'Invalid validity period, expected either DDHH/DDHH or DDHHmm';
|
|
278
|
+
var invalidValidityLengthMessage = 'Invalid validity period, expected either DDHH/DDHH or DDHHmm';
|
|
279
|
+
var invalidChangeValidInterFieldMessage = 'Invalid validity period, expected DDHH/DDHH for BECMG and TEMPO or DDHHmm for FM'; // Validations
|
|
345
280
|
// Ensure all individual sections are correct (DD HH mm etc)
|
|
346
281
|
|
|
347
282
|
var validateValidSections = function validateValidSections(sections, isStartEnd) {
|
|
@@ -425,6 +360,17 @@ var validateValidField = function validateValidField(value, tafStart, tafEnd) {
|
|
|
425
360
|
|
|
426
361
|
return true;
|
|
427
362
|
};
|
|
363
|
+
var validateValidChangeGroupInterField = function validateValidChangeGroupInterField(value, valueChange) {
|
|
364
|
+
var trimmedValue = value.trim();
|
|
365
|
+
var trimmedValueChange = valueChange.trim();
|
|
366
|
+
|
|
367
|
+
if (!trimmedValue.length) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
var isValid = trimmedValue.length < 9 && trimmedValueChange === 'FM' || trimmedValue.length > 6 && trimmedValueChange !== 'FM';
|
|
372
|
+
return isValid ? true : invalidChangeValidInterFieldMessage;
|
|
373
|
+
};
|
|
428
374
|
|
|
429
375
|
/* *
|
|
430
376
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -445,19 +391,19 @@ var validateValidField = function validateValidField(value, tafStart, tafEnd) {
|
|
|
445
391
|
|
|
446
392
|
var prependZeroes = function prependZeroes(value, totalDigits) {
|
|
447
393
|
var valueAsString = value.toString();
|
|
448
|
-
return
|
|
394
|
+
return __spreadArray([], __read(Array(totalDigits - valueAsString.length))).reduce(function (newVal) {
|
|
449
395
|
return "0" + newVal;
|
|
450
396
|
}, valueAsString);
|
|
451
397
|
};
|
|
452
398
|
|
|
453
|
-
var config = [{
|
|
399
|
+
var config$1 = [{
|
|
454
400
|
key: 'range',
|
|
455
401
|
size: 4
|
|
456
402
|
}, {
|
|
457
403
|
key: 'unit',
|
|
458
404
|
size: 1
|
|
459
405
|
}];
|
|
460
|
-
var configAsObject = Object.assign(config).reduce(function (list, item) {
|
|
406
|
+
var configAsObject$1 = Object.assign(config$1).reduce(function (list, item) {
|
|
461
407
|
var _a;
|
|
462
408
|
|
|
463
409
|
return __assign(__assign({}, list), (_a = {}, _a[item.key] = item, _a));
|
|
@@ -475,7 +421,7 @@ var formatVisibilityToString = function formatVisibilityToString(value) {
|
|
|
475
421
|
} // else, format visibility number
|
|
476
422
|
|
|
477
423
|
|
|
478
|
-
var size = configAsObject.range.size;
|
|
424
|
+
var size = configAsObject$1.range.size;
|
|
479
425
|
return prependZeroes(value.range, size);
|
|
480
426
|
}; // parsers
|
|
481
427
|
// returns object with validity if passed numbers - returns object with cavOK: true if passed CAVOK
|
|
@@ -1077,16 +1023,16 @@ function parseWeatherToObject(value) {
|
|
|
1077
1023
|
|
|
1078
1024
|
|
|
1079
1025
|
var _b = obj,
|
|
1080
|
-
_c = key
|
|
1081
|
-
|
|
1082
|
-
rest = __rest(_b, [_typeof(_c) === "symbol" ? _c : _c + ""]);
|
|
1026
|
+
_c = key;
|
|
1027
|
+
_b[_c];
|
|
1028
|
+
var rest = __rest(_b, [_typeof(_c) === "symbol" ? _c : _c + ""]);
|
|
1083
1029
|
|
|
1084
1030
|
return rest;
|
|
1085
1031
|
}, value);
|
|
1086
1032
|
return trimmedWeather;
|
|
1087
1033
|
}
|
|
1088
1034
|
|
|
1089
|
-
var config
|
|
1035
|
+
var config = [{
|
|
1090
1036
|
key: 'direction',
|
|
1091
1037
|
size: 3
|
|
1092
1038
|
}, {
|
|
@@ -1103,7 +1049,7 @@ var config$1 = [{
|
|
|
1103
1049
|
key: 'unit',
|
|
1104
1050
|
size: 2
|
|
1105
1051
|
}];
|
|
1106
|
-
var configAsObject
|
|
1052
|
+
var configAsObject = Object.assign(config).reduce(function (list, item) {
|
|
1107
1053
|
var _a;
|
|
1108
1054
|
|
|
1109
1055
|
return __assign(__assign({}, list), (_a = {}, _a[item.key] = item, _a));
|
|
@@ -1114,7 +1060,7 @@ var formatWindValues = function formatWindValues(key, value) {
|
|
|
1114
1060
|
case 'direction':
|
|
1115
1061
|
{
|
|
1116
1062
|
// make sure the values get the right size
|
|
1117
|
-
var size = configAsObject
|
|
1063
|
+
var size = configAsObject[key].size;
|
|
1118
1064
|
return prependZeroes(value, size);
|
|
1119
1065
|
}
|
|
1120
1066
|
|
|
@@ -1127,7 +1073,7 @@ var formatWindValues = function formatWindValues(key, value) {
|
|
|
1127
1073
|
return 'P99';
|
|
1128
1074
|
}
|
|
1129
1075
|
|
|
1130
|
-
var size = configAsObject
|
|
1076
|
+
var size = configAsObject[key].size;
|
|
1131
1077
|
return prependZeroes(value, size);
|
|
1132
1078
|
}
|
|
1133
1079
|
|
|
@@ -1140,7 +1086,7 @@ var formatWindValues = function formatWindValues(key, value) {
|
|
|
1140
1086
|
return 'GP99';
|
|
1141
1087
|
}
|
|
1142
1088
|
|
|
1143
|
-
var size = configAsObject
|
|
1089
|
+
var size = configAsObject[key].size;
|
|
1144
1090
|
var newValue = prependZeroes(value, size);
|
|
1145
1091
|
return "G" + newValue.toString();
|
|
1146
1092
|
}
|
|
@@ -1161,7 +1107,7 @@ var formatWindToString = function formatWindToString(value) {
|
|
|
1161
1107
|
return value;
|
|
1162
1108
|
}
|
|
1163
1109
|
|
|
1164
|
-
return config
|
|
1110
|
+
return config.reduce(function (stringValue, item) {
|
|
1165
1111
|
var key = item.key;
|
|
1166
1112
|
var propValue = value[key];
|
|
1167
1113
|
var hasValue = propValue !== undefined && propValue !== null && propValue !== '';
|
|
@@ -1174,7 +1120,7 @@ var extractValidateWindSections = function extractValidateWindSections(value, va
|
|
|
1174
1120
|
validation = false;
|
|
1175
1121
|
}
|
|
1176
1122
|
|
|
1177
|
-
return config
|
|
1123
|
+
return config.reduce(function (obj, item) {
|
|
1178
1124
|
var key = item.key,
|
|
1179
1125
|
size = item.size;
|
|
1180
1126
|
var returnObj = obj;
|
|
@@ -1496,9 +1442,9 @@ var parseCloudsToObject = function parseCloudsToObject(clouds) {
|
|
|
1496
1442
|
|
|
1497
1443
|
|
|
1498
1444
|
var _e = list,
|
|
1499
|
-
_f = key
|
|
1500
|
-
|
|
1501
|
-
rest = __rest(_e, [_typeof(_f) === "symbol" ? _f : _f + ""]);
|
|
1445
|
+
_f = key;
|
|
1446
|
+
_e[_f];
|
|
1447
|
+
var rest = __rest(_e, [_typeof(_f) === "symbol" ? _f : _f + ""]);
|
|
1502
1448
|
|
|
1503
1449
|
return rest;
|
|
1504
1450
|
}, clouds);
|
|
@@ -1979,8 +1925,8 @@ row, tafStart, tafEnd) {
|
|
|
1979
1925
|
{
|
|
1980
1926
|
// if cavOK is set - remove visibility from the list
|
|
1981
1927
|
if (reducedRow.cavOK) {
|
|
1982
|
-
|
|
1983
|
-
rest = __rest(list, ["visibility"]);
|
|
1928
|
+
list.visibility;
|
|
1929
|
+
var rest = __rest(list, ["visibility"]);
|
|
1984
1930
|
|
|
1985
1931
|
return rest;
|
|
1986
1932
|
}
|
|
@@ -1992,8 +1938,8 @@ row, tafStart, tafEnd) {
|
|
|
1992
1938
|
{
|
|
1993
1939
|
// If cloud is undefined or empty, remove it from the list
|
|
1994
1940
|
if (!reducedRow.cloud || Object.keys(reducedRow.cloud).length === 0) {
|
|
1995
|
-
|
|
1996
|
-
rest = __rest(list, ["cloud"]);
|
|
1941
|
+
list.cloud;
|
|
1942
|
+
var rest = __rest(list, ["cloud"]);
|
|
1997
1943
|
|
|
1998
1944
|
return rest;
|
|
1999
1945
|
}
|
|
@@ -2005,8 +1951,8 @@ row, tafStart, tafEnd) {
|
|
|
2005
1951
|
{
|
|
2006
1952
|
// If empty, remove it from the list
|
|
2007
1953
|
if (!reducedRow.weather.weather1) {
|
|
2008
|
-
|
|
2009
|
-
rest = __rest(list, ["weather"]);
|
|
1954
|
+
list.weather;
|
|
1955
|
+
var rest = __rest(list, ["weather"]);
|
|
2010
1956
|
|
|
2011
1957
|
return rest;
|
|
2012
1958
|
}
|
|
@@ -2018,8 +1964,8 @@ row, tafStart, tafEnd) {
|
|
|
2018
1964
|
{
|
|
2019
1965
|
// If empty, remove it from the list
|
|
2020
1966
|
if (!reducedRow.wind.direction && isNaN(reducedRow.wind.direction)) {
|
|
2021
|
-
|
|
2022
|
-
rest = __rest(list, ["wind"]);
|
|
1967
|
+
list.wind;
|
|
1968
|
+
var rest = __rest(list, ["wind"]);
|
|
2023
1969
|
|
|
2024
1970
|
return rest;
|
|
2025
1971
|
}
|
|
@@ -2031,8 +1977,8 @@ row, tafStart, tafEnd) {
|
|
|
2031
1977
|
{
|
|
2032
1978
|
// If empty, remove it from the list
|
|
2033
1979
|
if (!reducedRow.visibility.range && isNaN(reducedRow.visibility.range)) {
|
|
2034
|
-
|
|
2035
|
-
rest = __rest(list, ["visibility"]);
|
|
1980
|
+
list.visibility;
|
|
1981
|
+
var rest = __rest(list, ["visibility"]);
|
|
2036
1982
|
|
|
2037
1983
|
return rest;
|
|
2038
1984
|
}
|
|
@@ -2047,9 +1993,9 @@ row, tafStart, tafEnd) {
|
|
|
2047
1993
|
// If empty, remove it from the list
|
|
2048
1994
|
if (!reducedRow[key]) {
|
|
2049
1995
|
var _a = list,
|
|
2050
|
-
_b = key
|
|
2051
|
-
|
|
2052
|
-
rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
1996
|
+
_b = key;
|
|
1997
|
+
_a[_b];
|
|
1998
|
+
var rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
2053
1999
|
|
|
2054
2000
|
return rest;
|
|
2055
2001
|
}
|
|
@@ -2067,9 +2013,12 @@ row, tafStart, tafEnd) {
|
|
|
2067
2013
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2068
2014
|
|
|
2069
2015
|
var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2016
|
+
formData.IS_DRAFT;
|
|
2017
|
+
var productToPost = __rest(formData, ["IS_DRAFT"]);
|
|
2018
|
+
|
|
2019
|
+
var tafStart = productToPost.validDateStart;
|
|
2020
|
+
var tafEnd = productToPost.validDateEnd;
|
|
2021
|
+
var parsedChangeGroups = productToPost.changeGroups && productToPost.changeGroups // parse data for each changegroup row
|
|
2073
2022
|
.map(function (row) {
|
|
2074
2023
|
return parseFormValues(row, tafStart, tafEnd);
|
|
2075
2024
|
}) // filter out empty changegroup rows
|
|
@@ -2077,8 +2026,8 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2077
2026
|
return Object.keys(value).length;
|
|
2078
2027
|
});
|
|
2079
2028
|
|
|
2080
|
-
var parsedFormValues = __assign(__assign({},
|
|
2081
|
-
baseForecast: parseFormValues(
|
|
2029
|
+
var parsedFormValues = __assign(__assign({}, productToPost), {
|
|
2030
|
+
baseForecast: parseFormValues(productToPost.baseForecast, tafStart, tafEnd),
|
|
2082
2031
|
changeGroups: parsedChangeGroups
|
|
2083
2032
|
});
|
|
2084
2033
|
|
|
@@ -2088,8 +2037,8 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2088
2037
|
{
|
|
2089
2038
|
// remove changeGroups when empty
|
|
2090
2039
|
if (!parsedFormValues.changeGroups || !parsedFormValues.changeGroups.length) {
|
|
2091
|
-
|
|
2092
|
-
rest = __rest(list, ["changeGroups"]);
|
|
2040
|
+
list.changeGroups;
|
|
2041
|
+
var rest = __rest(list, ["changeGroups"]);
|
|
2093
2042
|
|
|
2094
2043
|
return rest;
|
|
2095
2044
|
}
|
|
@@ -2105,9 +2054,9 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2105
2054
|
// remove when empty
|
|
2106
2055
|
if (!parsedFormValues[key]) {
|
|
2107
2056
|
var _a = list,
|
|
2108
|
-
_b = key
|
|
2109
|
-
|
|
2110
|
-
rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
2057
|
+
_b = key;
|
|
2058
|
+
_a[_b];
|
|
2059
|
+
var rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
2111
2060
|
|
|
2112
2061
|
return rest;
|
|
2113
2062
|
}
|
|
@@ -2122,6 +2071,38 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2122
2071
|
}
|
|
2123
2072
|
}, parsedFormValues);
|
|
2124
2073
|
};
|
|
2074
|
+
var noTAC = 'Missing data: no TAC can be generated'; // Ensure we have enough data to retrieve a TAC - we only need to check for wind and visibility/ cavok as those are the only ones required in all cases
|
|
2075
|
+
|
|
2076
|
+
var shouldRetrieveTAC = function shouldRetrieveTAC(product) {
|
|
2077
|
+
if (product && product.baseForecast && product.baseForecast.wind && product.baseForecast.wind.speed && product.baseForecast.wind.speed !== '' && (product.baseForecast.visibility && product.baseForecast.visibility.range && product.baseForecast.visibility.range !== '' || product.baseForecast.cavOK)) {
|
|
2078
|
+
return true;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
return false;
|
|
2082
|
+
};
|
|
2083
|
+
|
|
2084
|
+
var getFieldNames = function getFieldNames(isChangeGroup, index) {
|
|
2085
|
+
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[" + index + "]";
|
|
2086
|
+
return __assign(__assign(__assign({}, !isChangeGroup && {
|
|
2087
|
+
messageType: 'messageType',
|
|
2088
|
+
location: 'location',
|
|
2089
|
+
issueDate: 'issueDate'
|
|
2090
|
+
}), isChangeGroup && {
|
|
2091
|
+
probability: namePrefix + ".probability",
|
|
2092
|
+
change: namePrefix + ".change"
|
|
2093
|
+
}), {
|
|
2094
|
+
valid: namePrefix + ".valid",
|
|
2095
|
+
wind: namePrefix + ".wind",
|
|
2096
|
+
visibility: namePrefix + ".visibility",
|
|
2097
|
+
weather1: namePrefix + ".weather.weather1",
|
|
2098
|
+
weather2: namePrefix + ".weather.weather2",
|
|
2099
|
+
weather3: namePrefix + ".weather.weather3",
|
|
2100
|
+
cloud1: namePrefix + ".cloud.cloud1",
|
|
2101
|
+
cloud2: namePrefix + ".cloud.cloud2",
|
|
2102
|
+
cloud3: namePrefix + ".cloud.cloud3",
|
|
2103
|
+
cloud4: namePrefix + ".cloud.cloud4"
|
|
2104
|
+
});
|
|
2105
|
+
};
|
|
2125
2106
|
var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
|
|
2126
2107
|
if (standardTAC === void 0) {
|
|
2127
2108
|
standardTAC = '';
|
|
@@ -2132,11 +2113,15 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
|
|
|
2132
2113
|
setTAC = _a[1];
|
|
2133
2114
|
|
|
2134
2115
|
var retrieveTAC = function retrieveTAC(tafToPost) {
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2116
|
+
if (shouldRetrieveTAC(tafToPost)) {
|
|
2117
|
+
requestTAC(tafToPost).then(function (result) {
|
|
2118
|
+
setTAC(result.data);
|
|
2119
|
+
})["catch"](function () {
|
|
2120
|
+
setTAC('Failed to retrieve TAC');
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
setTAC(noTAC);
|
|
2140
2125
|
};
|
|
2141
2126
|
|
|
2142
2127
|
React__default.useEffect(function () {
|
|
@@ -2151,25 +2136,90 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
|
|
|
2151
2136
|
}
|
|
2152
2137
|
}, [standardTAC]);
|
|
2153
2138
|
return [TAC, retrieveTAC];
|
|
2139
|
+
};
|
|
2140
|
+
var getRange = function getRange(min, max) {
|
|
2141
|
+
return Array.from({
|
|
2142
|
+
length: max - min + 1
|
|
2143
|
+
}, function (_, i) {
|
|
2144
|
+
return min + i;
|
|
2145
|
+
});
|
|
2146
|
+
};
|
|
2147
|
+
var useDragOrder = function useDragOrder(trigger, move, fields) {
|
|
2148
|
+
// create simple ordered list with hover (chosen) state
|
|
2149
|
+
var _a = __read(React__default.useState([]), 2),
|
|
2150
|
+
sortedFields = _a[0],
|
|
2151
|
+
setSortedFields = _a[1];
|
|
2152
|
+
|
|
2153
|
+
var _b = __read(React__default.useState([null, null]), 2),
|
|
2154
|
+
lastDragOrder = _b[0],
|
|
2155
|
+
onUpdatelastDragOrder = _b[1];
|
|
2156
|
+
|
|
2157
|
+
var onChangeOrder = function onChangeOrder(_a) {
|
|
2158
|
+
var oldIndex = _a.oldIndex,
|
|
2159
|
+
newIndex = _a.newIndex;
|
|
2160
|
+
if (oldIndex === undefined || newIndex === undefined) return;
|
|
2161
|
+
move(oldIndex, newIndex);
|
|
2162
|
+
onUpdatelastDragOrder([oldIndex, newIndex]);
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2165
|
+
React__default.useEffect(function () {
|
|
2166
|
+
setSortedFields(fields.map(function (_a) {
|
|
2167
|
+
var id = _a.id;
|
|
2168
|
+
return {
|
|
2169
|
+
id: id,
|
|
2170
|
+
chosen: false
|
|
2171
|
+
};
|
|
2172
|
+
}));
|
|
2173
|
+
}, [fields]); // triggers validation AFTER render of new sorted elements
|
|
2174
|
+
|
|
2175
|
+
React__default.useEffect(function () {
|
|
2176
|
+
var _a = __read(lastDragOrder, 2),
|
|
2177
|
+
oldIndex = _a[0],
|
|
2178
|
+
newIndex = _a[1];
|
|
2179
|
+
|
|
2180
|
+
if (oldIndex !== null && newIndex !== null) {
|
|
2181
|
+
// trigger validation of moved rows
|
|
2182
|
+
var _b = __read([oldIndex, newIndex].sort(function (a, b) {
|
|
2183
|
+
return a - b;
|
|
2184
|
+
}), 2),
|
|
2185
|
+
start = _b[0],
|
|
2186
|
+
end = _b[1];
|
|
2187
|
+
|
|
2188
|
+
var changedRows = getRange(start, end);
|
|
2189
|
+
var fieldsToValidate = changedRows.reduce(function (list, rowIndex) {
|
|
2190
|
+
var fieldsDict = getFieldNames(true, rowIndex);
|
|
2191
|
+
var fields = Object.keys(fieldsDict).map(function (key) {
|
|
2192
|
+
return fieldsDict[key];
|
|
2193
|
+
});
|
|
2194
|
+
return list.concat(fields);
|
|
2195
|
+
}, []);
|
|
2196
|
+
trigger(fieldsToValidate);
|
|
2197
|
+
}
|
|
2198
|
+
}, [lastDragOrder, trigger]);
|
|
2199
|
+
return {
|
|
2200
|
+
onChangeOrder: onChangeOrder,
|
|
2201
|
+
sortedFields: sortedFields,
|
|
2202
|
+
setSortedFields: setSortedFields
|
|
2203
|
+
};
|
|
2154
2204
|
}; // dialog utils
|
|
2155
2205
|
|
|
2156
2206
|
var getConfirmationDialogTitle = function getConfirmationDialogTitle(action) {
|
|
2157
|
-
if (action === '
|
|
2158
|
-
if (action === '
|
|
2159
|
-
if (action === '
|
|
2160
|
-
if (action === '
|
|
2207
|
+
if (action === 'DISCARD') return 'Discard TAF';
|
|
2208
|
+
if (action === 'PUBLISH') return 'Publish';
|
|
2209
|
+
if (action === 'AMEND') return 'This TAF is an amendment';
|
|
2210
|
+
if (action === 'CORRECT') return 'This TAF is a correction';
|
|
2161
2211
|
return 'Cancel TAF';
|
|
2162
2212
|
};
|
|
2163
2213
|
var getConfirmationDialogContent = function getConfirmationDialogContent(action) {
|
|
2164
|
-
if (action === '
|
|
2165
|
-
if (action === '
|
|
2166
|
-
if (action === '
|
|
2167
|
-
if (action === '
|
|
2214
|
+
if (action === 'DISCARD') return 'Are you sure you would like to discard this TAF? Any changes made will be lost';
|
|
2215
|
+
if (action === 'PUBLISH') return 'Are you sure you want to publish this TAF?';
|
|
2216
|
+
if (action === 'AMEND') return 'Do you want to publish it?';
|
|
2217
|
+
if (action === 'CORRECT') return 'Do you want to publish it?';
|
|
2168
2218
|
return 'Are you sure you want to cancel this TAF?';
|
|
2169
2219
|
};
|
|
2170
2220
|
var getConfirmationDialogButtonLabel = function getConfirmationDialogButtonLabel(action) {
|
|
2171
2221
|
switch (action) {
|
|
2172
|
-
case '
|
|
2222
|
+
case 'DISCARD':
|
|
2173
2223
|
{
|
|
2174
2224
|
return 'Discard';
|
|
2175
2225
|
}
|
|
@@ -2181,6 +2231,86 @@ var getConfirmationDialogButtonLabel = function getConfirmationDialogButtonLabel
|
|
|
2181
2231
|
}
|
|
2182
2232
|
};
|
|
2183
2233
|
|
|
2234
|
+
/* *
|
|
2235
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2236
|
+
* you may not use this file except in compliance with the License.
|
|
2237
|
+
* You may obtain a copy of the License at
|
|
2238
|
+
*
|
|
2239
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2240
|
+
*
|
|
2241
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2242
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2243
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2244
|
+
* See the License for the specific language governing permissions and
|
|
2245
|
+
* limitations under the License.
|
|
2246
|
+
*
|
|
2247
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2248
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2249
|
+
* */
|
|
2250
|
+
var useStyles$9 = makeStyles(function (theme) {
|
|
2251
|
+
return {
|
|
2252
|
+
textFieldGridItem: {
|
|
2253
|
+
marginRight: 4
|
|
2254
|
+
},
|
|
2255
|
+
textFieldInput: {
|
|
2256
|
+
fontSize: '14px',
|
|
2257
|
+
paddingLeft: 1,
|
|
2258
|
+
paddingRight: 1,
|
|
2259
|
+
color: '#051039',
|
|
2260
|
+
WebkitTextFillColor: '#051039' // safari text color fix
|
|
2261
|
+
|
|
2262
|
+
},
|
|
2263
|
+
textFieldLabel: {
|
|
2264
|
+
fontSize: '14px'
|
|
2265
|
+
},
|
|
2266
|
+
textFieldLabelShrink: {
|
|
2267
|
+
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
2268
|
+
},
|
|
2269
|
+
formRow: {
|
|
2270
|
+
marginTop: 8,
|
|
2271
|
+
backgroundColor: theme.palette.common.white,
|
|
2272
|
+
position: 'relative',
|
|
2273
|
+
'&.sortable-chosen': {
|
|
2274
|
+
boxShadow: theme.shadows[1]
|
|
2275
|
+
},
|
|
2276
|
+
'&.sortable-ghost': {
|
|
2277
|
+
opacity: 0.5
|
|
2278
|
+
}
|
|
2279
|
+
},
|
|
2280
|
+
tacTitle: {
|
|
2281
|
+
fontSize: '20px',
|
|
2282
|
+
fontWeight: 500
|
|
2283
|
+
},
|
|
2284
|
+
tacText: {
|
|
2285
|
+
fontSize: '14px',
|
|
2286
|
+
color: '#000000'
|
|
2287
|
+
},
|
|
2288
|
+
tacLine: {
|
|
2289
|
+
margin: '0',
|
|
2290
|
+
padding: '.1em .1em .1em 0.8em',
|
|
2291
|
+
textIndent: '-0.7em',
|
|
2292
|
+
borderRadius: '3px'
|
|
2293
|
+
},
|
|
2294
|
+
addButton: {
|
|
2295
|
+
marginRight: '38px'
|
|
2296
|
+
},
|
|
2297
|
+
lifecycleButtons: {
|
|
2298
|
+
marginTop: '40px',
|
|
2299
|
+
marginBottom: '16px'
|
|
2300
|
+
},
|
|
2301
|
+
actionButton: {
|
|
2302
|
+
marginRight: '16px'
|
|
2303
|
+
},
|
|
2304
|
+
lastButton: {
|
|
2305
|
+
marginRight: '90px'
|
|
2306
|
+
},
|
|
2307
|
+
backdrop: {
|
|
2308
|
+
zIndex: 1500,
|
|
2309
|
+
color: '#fff'
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
});
|
|
2313
|
+
|
|
2184
2314
|
var getTafErrors = function getTafErrors(name, errors) {
|
|
2185
2315
|
var nameAsArray = name.split('.');
|
|
2186
2316
|
|
|
@@ -2202,7 +2332,7 @@ var getDisplayValue = function getDisplayValue(value, disabled) {
|
|
|
2202
2332
|
return disabled && !value ? '-' : value;
|
|
2203
2333
|
};
|
|
2204
2334
|
var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
|
|
2205
|
-
var classes = useStyles();
|
|
2335
|
+
var classes = useStyles$9();
|
|
2206
2336
|
return /*#__PURE__*/React__default.createElement(TextField, __assign({
|
|
2207
2337
|
type: "text",
|
|
2208
2338
|
variant: "filled",
|
|
@@ -2241,7 +2371,7 @@ var TafFormTextField = function TafFormTextField(_a) {
|
|
|
2241
2371
|
autoComplete = _h === void 0 ? [] : _h,
|
|
2242
2372
|
_j = _a.autoFocus,
|
|
2243
2373
|
autoFocus = _j === void 0 ? false : _j;
|
|
2244
|
-
var classes = useStyles();
|
|
2374
|
+
var classes = useStyles$9();
|
|
2245
2375
|
|
|
2246
2376
|
var _k = useFormContext(),
|
|
2247
2377
|
control = _k.control,
|
|
@@ -2349,13 +2479,24 @@ var TafFormTextField = function TafFormTextField(_a) {
|
|
|
2349
2479
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2350
2480
|
* */
|
|
2351
2481
|
// messages
|
|
2352
|
-
var invalidChangeMessage = 'Invalid Change input, only BECMG, TEMPO or FM are allowed';
|
|
2482
|
+
var invalidChangeMessage = 'Invalid Change input, only BECMG, TEMPO or FM are allowed';
|
|
2483
|
+
var invalidChangeProbCombinationMessage = 'A probability is only allowed in combination with TEMPO'; // validations
|
|
2353
2484
|
|
|
2354
2485
|
var validateChangeField = function validateChangeField(value) {
|
|
2355
2486
|
var trimmedValue = value.trim();
|
|
2356
2487
|
var isValid = trimmedValue === '' || trimmedValue === 'FM' || trimmedValue === 'TEMPO' || trimmedValue === 'BECMG';
|
|
2357
2488
|
return isValid ? true : invalidChangeMessage;
|
|
2358
2489
|
};
|
|
2490
|
+
var validateChangeFieldInterField = function validateChangeFieldInterField(value, valueProb) {
|
|
2491
|
+
var trimmedProbValue = valueProb.trim();
|
|
2492
|
+
var trimmedValue = value.trim();
|
|
2493
|
+
|
|
2494
|
+
if (trimmedProbValue !== '' && trimmedValue !== '' && trimmedValue !== 'TEMPO') {
|
|
2495
|
+
return invalidChangeProbCombinationMessage;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
return true;
|
|
2499
|
+
};
|
|
2359
2500
|
|
|
2360
2501
|
/* *
|
|
2361
2502
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -2390,11 +2531,11 @@ var getDefaultValue = function getDefaultValue(fieldName, data) {
|
|
|
2390
2531
|
return getDeepProperty(fieldName.split('.'), data) || '';
|
|
2391
2532
|
};
|
|
2392
2533
|
|
|
2393
|
-
var getRequiredCrossFields = function getRequiredCrossFields(
|
|
2394
|
-
return [[
|
|
2534
|
+
var getRequiredCrossFields = function getRequiredCrossFields(fieldNames) {
|
|
2535
|
+
return [[fieldNames.valid, fieldNames.change], [fieldNames.probability], [fieldNames.wind, fieldNames.visibility, fieldNames.weather1, fieldNames.cloud1]];
|
|
2395
2536
|
};
|
|
2396
2537
|
|
|
2397
|
-
var TafFormRow = function
|
|
2538
|
+
var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
2398
2539
|
var _b = _a.isChangeGroup,
|
|
2399
2540
|
isChangeGroup = _b === void 0 ? false : _b,
|
|
2400
2541
|
_c = _a.disabled,
|
|
@@ -2405,37 +2546,41 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2405
2546
|
lastRow = _e === void 0 ? false : _e,
|
|
2406
2547
|
onRemoveChangeGroup = _a.onRemoveChangeGroup,
|
|
2407
2548
|
_f = _a.field,
|
|
2408
|
-
field = _f === void 0 ? null : _f
|
|
2409
|
-
|
|
2549
|
+
field = _f === void 0 ? null : _f,
|
|
2550
|
+
_g = _a.dragHandle,
|
|
2551
|
+
dragHandle = _g === void 0 ? null : _g,
|
|
2552
|
+
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "dragHandle"]);
|
|
2553
|
+
|
|
2410
2554
|
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[" + index + "]";
|
|
2555
|
+
var fieldNames = getFieldNames(isChangeGroup, index);
|
|
2411
2556
|
|
|
2412
|
-
var
|
|
2413
|
-
getValues =
|
|
2414
|
-
trigger =
|
|
2557
|
+
var _h = useFormContext(),
|
|
2558
|
+
getValues = _h.getValues,
|
|
2559
|
+
trigger = _h.trigger;
|
|
2415
2560
|
|
|
2561
|
+
var isNotRequiredForAction = useDraftFormHelpers().isRequired; // cross-field required validation
|
|
2416
2562
|
|
|
2417
|
-
var
|
|
2418
|
-
mainFields =
|
|
2419
|
-
mainOptionalFields =
|
|
2420
|
-
subFields =
|
|
2563
|
+
var _j = __read(getRequiredCrossFields(fieldNames), 3),
|
|
2564
|
+
mainFields = _j[0],
|
|
2565
|
+
mainOptionalFields = _j[1],
|
|
2566
|
+
subFields = _j[2];
|
|
2421
2567
|
|
|
2422
2568
|
var hasFieldsValue = function hasFieldsValue(fields) {
|
|
2423
2569
|
return fields.map(getValues).find(function (field) {
|
|
2424
2570
|
return !!field;
|
|
2425
2571
|
});
|
|
2426
|
-
};
|
|
2572
|
+
}; // Used to validate the two required fields for change groups: Change and Valid
|
|
2573
|
+
|
|
2427
2574
|
|
|
2428
2575
|
var _validateRequiredMain = function validateRequiredMain(value, fieldName) {
|
|
2429
|
-
return isChangeGroup && !value.length && (hasFieldsValue(subFields) || hasFieldsValue(mainFields) || hasFieldsValue(mainOptionalFields)) ? fieldName + " is required" : true;
|
|
2430
|
-
};
|
|
2576
|
+
return isNotRequiredForAction(value) !== true && isChangeGroup && !value.length && (hasFieldsValue(subFields) || hasFieldsValue(mainFields) || hasFieldsValue(mainOptionalFields)) ? fieldName + " is required" : true;
|
|
2577
|
+
}; // Used to ensure one wind, visibility, weather or cloud is entered when start editing a changegroup and all of these are empty
|
|
2431
2578
|
|
|
2432
|
-
var _validateRequiredMainOptional = function validateRequiredMainOptional() {
|
|
2433
|
-
return isChangeGroup && (hasFieldsValue(subFields) || hasFieldsValue(mainFields)) && !hasFieldsValue(mainOptionalFields) ? 'Prob and/or Change are required' : true;
|
|
2434
|
-
};
|
|
2435
2579
|
|
|
2436
|
-
var validateRequiredSub = function validateRequiredSub() {
|
|
2437
|
-
return isChangeGroup && (hasFieldsValue(mainFields) || hasFieldsValue(mainOptionalFields)) && !hasFieldsValue(subFields) ? 'Wind, visibility, weather or cloud is required' : true;
|
|
2438
|
-
};
|
|
2580
|
+
var validateRequiredSub = function validateRequiredSub(value) {
|
|
2581
|
+
return isNotRequiredForAction(value) !== true && isChangeGroup && (hasFieldsValue(mainFields) || hasFieldsValue(mainOptionalFields)) && !hasFieldsValue(subFields) ? 'Wind, visibility, weather or cloud is required' : true;
|
|
2582
|
+
}; // Used to validate the combination of change group and wind, visibility, weather and/or cloud data entered
|
|
2583
|
+
|
|
2439
2584
|
|
|
2440
2585
|
var _validateRequiredMainFields = function validateRequiredMainFields(value, fieldName) {
|
|
2441
2586
|
var changeField = getValues(namePrefix + ".change");
|
|
@@ -2443,7 +2588,7 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2443
2588
|
var isFM = changeField && changeField.trim() === 'FM';
|
|
2444
2589
|
var isCAVOK = visibilityField && visibilityField.trim() === 'CAVOK';
|
|
2445
2590
|
|
|
2446
|
-
if (!value.length) {
|
|
2591
|
+
if (isNotRequiredForAction(value) !== true && !value.length) {
|
|
2447
2592
|
if (isChangeGroup && isFM || !isChangeGroup) {
|
|
2448
2593
|
// exception for CavOK
|
|
2449
2594
|
if (isCAVOK && (fieldName === 'Clouds' || fieldName === 'Weather')) {
|
|
@@ -2462,13 +2607,13 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2462
2607
|
return true;
|
|
2463
2608
|
};
|
|
2464
2609
|
|
|
2465
|
-
return /*#__PURE__*/React__default.createElement(Grid, {
|
|
2610
|
+
return /*#__PURE__*/React__default.createElement(Grid, __assign({
|
|
2466
2611
|
"data-testid": "row-" + namePrefix,
|
|
2467
2612
|
container: true,
|
|
2468
|
-
|
|
2469
|
-
}, !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2613
|
+
ref: ref
|
|
2614
|
+
}, props), !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2470
2615
|
label: "Type",
|
|
2471
|
-
name:
|
|
2616
|
+
name: fieldNames.messageType,
|
|
2472
2617
|
disabled: true
|
|
2473
2618
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2474
2619
|
label: "Location",
|
|
@@ -2481,18 +2626,18 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2481
2626
|
disabled: true
|
|
2482
2627
|
})), isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
2483
2628
|
item: true,
|
|
2484
|
-
xs: true
|
|
2485
|
-
|
|
2629
|
+
xs: true,
|
|
2630
|
+
style: {
|
|
2631
|
+
display: 'flex'
|
|
2632
|
+
}
|
|
2633
|
+
}, dragHandle), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2486
2634
|
label: "Prob",
|
|
2487
|
-
name:
|
|
2635
|
+
name: fieldNames.probability,
|
|
2488
2636
|
disabled: disabled,
|
|
2489
2637
|
defaultValue: getDefaultValue('probability', field),
|
|
2490
2638
|
rules: {
|
|
2491
2639
|
validate: {
|
|
2492
|
-
validateProbabilityField: validateProbabilityField
|
|
2493
|
-
validateRequiredMainOptional: function validateRequiredMainOptional() {
|
|
2494
|
-
return _validateRequiredMainOptional();
|
|
2495
|
-
}
|
|
2640
|
+
validateProbabilityField: validateProbabilityField
|
|
2496
2641
|
}
|
|
2497
2642
|
},
|
|
2498
2643
|
autoComplete: [{
|
|
@@ -2504,20 +2649,23 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2504
2649
|
}],
|
|
2505
2650
|
onBlur: function onBlur() {
|
|
2506
2651
|
if (isChangeGroup) {
|
|
2507
|
-
trigger(
|
|
2652
|
+
trigger(__spreadArray(__spreadArray(__spreadArray([], __read(subFields)), __read(mainOptionalFields)), __read(mainFields)));
|
|
2508
2653
|
}
|
|
2509
2654
|
}
|
|
2510
2655
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2511
2656
|
label: "Change",
|
|
2512
|
-
name:
|
|
2657
|
+
name: fieldNames.change,
|
|
2513
2658
|
disabled: disabled,
|
|
2514
2659
|
defaultValue: getDefaultValue('change', field),
|
|
2515
2660
|
rules: {
|
|
2516
2661
|
validate: {
|
|
2517
|
-
|
|
2518
|
-
return
|
|
2662
|
+
validateRequiredMain: function validateRequiredMain(value) {
|
|
2663
|
+
return _validateRequiredMain(value, 'Change');
|
|
2519
2664
|
},
|
|
2520
|
-
validateChangeField: validateChangeField
|
|
2665
|
+
validateChangeField: validateChangeField,
|
|
2666
|
+
validateChangeFieldInterField: function validateChangeFieldInterField$1(value) {
|
|
2667
|
+
return validateChangeFieldInterField(value, getValues(fieldNames.probability));
|
|
2668
|
+
}
|
|
2521
2669
|
}
|
|
2522
2670
|
},
|
|
2523
2671
|
autoComplete: [{
|
|
@@ -2532,12 +2680,12 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2532
2680
|
}],
|
|
2533
2681
|
onBlur: function onBlur() {
|
|
2534
2682
|
if (isChangeGroup) {
|
|
2535
|
-
trigger(
|
|
2683
|
+
trigger(__spreadArray(__spreadArray(__spreadArray([], __read(subFields)), __read(mainOptionalFields)), __read(mainFields)));
|
|
2536
2684
|
}
|
|
2537
2685
|
}
|
|
2538
2686
|
})), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2539
2687
|
label: "Valid",
|
|
2540
|
-
name:
|
|
2688
|
+
name: fieldNames.valid,
|
|
2541
2689
|
// always disabled for baseforecast row
|
|
2542
2690
|
disabled: !isChangeGroup ? true : disabled,
|
|
2543
2691
|
defaultValue: getDefaultValue('valid', field),
|
|
@@ -2548,21 +2696,23 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2548
2696
|
},
|
|
2549
2697
|
validateValidField: function validateValidField$1(value) {
|
|
2550
2698
|
return isChangeGroup ? validateValidField(value, getValues('validDateStart'), getValues('validDateEnd')) : true;
|
|
2699
|
+
},
|
|
2700
|
+
validateValidChangeGroupInterField: function validateValidChangeGroupInterField$1(value) {
|
|
2701
|
+
return isChangeGroup ? validateValidChangeGroupInterField(value, getValues(fieldNames.change)) : true;
|
|
2551
2702
|
}
|
|
2552
2703
|
}
|
|
2553
2704
|
},
|
|
2554
2705
|
onBlur: function onBlur() {
|
|
2555
2706
|
if (isChangeGroup) {
|
|
2556
|
-
trigger(
|
|
2707
|
+
trigger(__spreadArray(__spreadArray(__spreadArray([], __read(subFields)), __read(mainOptionalFields)), __read(mainFields)));
|
|
2557
2708
|
}
|
|
2558
2709
|
}
|
|
2559
2710
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2560
2711
|
label: "Wind",
|
|
2561
|
-
name:
|
|
2712
|
+
name: fieldNames.wind,
|
|
2562
2713
|
disabled: disabled,
|
|
2563
2714
|
defaultValue: getDefaultValue('wind', field),
|
|
2564
2715
|
rules: {
|
|
2565
|
-
required: !isChangeGroup,
|
|
2566
2716
|
validate: {
|
|
2567
2717
|
validateRequiredMainFields: function validateRequiredMainFields(value) {
|
|
2568
2718
|
return _validateRequiredMainFields(value, 'Wind');
|
|
@@ -2573,17 +2723,16 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2573
2723
|
},
|
|
2574
2724
|
onBlur: function onBlur() {
|
|
2575
2725
|
if (isChangeGroup) {
|
|
2576
|
-
trigger(
|
|
2726
|
+
trigger(__spreadArray(__spreadArray([], __read(subFields)), __read(mainFields)));
|
|
2577
2727
|
}
|
|
2578
2728
|
},
|
|
2579
2729
|
autoFocus: !isChangeGroup
|
|
2580
2730
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2581
2731
|
label: "Visibility",
|
|
2582
|
-
name:
|
|
2732
|
+
name: fieldNames.visibility,
|
|
2583
2733
|
disabled: disabled,
|
|
2584
2734
|
defaultValue: getDefaultValue('visibility', field),
|
|
2585
2735
|
rules: {
|
|
2586
|
-
required: !isChangeGroup,
|
|
2587
2736
|
validate: {
|
|
2588
2737
|
validateRequiredMainFields: function validateRequiredMainFields(value) {
|
|
2589
2738
|
return _validateRequiredMainFields(value, 'Visibility');
|
|
@@ -2597,11 +2746,11 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2597
2746
|
value: 'CAVOK'
|
|
2598
2747
|
}],
|
|
2599
2748
|
onBlur: function onBlur() {
|
|
2600
|
-
trigger(isChangeGroup ?
|
|
2749
|
+
trigger(isChangeGroup ? __spreadArray(__spreadArray([], __read(subFields)), __read(mainFields)) : subFields);
|
|
2601
2750
|
}
|
|
2602
2751
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2603
2752
|
label: "Weather",
|
|
2604
|
-
name:
|
|
2753
|
+
name: fieldNames.weather1,
|
|
2605
2754
|
disabled: disabled,
|
|
2606
2755
|
defaultValue: getDefaultValue('weather.weather1', field),
|
|
2607
2756
|
rules: {
|
|
@@ -2616,40 +2765,40 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2616
2765
|
}
|
|
2617
2766
|
},
|
|
2618
2767
|
onBlur: function onBlur() {
|
|
2619
|
-
var fields = isChangeGroup ?
|
|
2620
|
-
return trigger(
|
|
2768
|
+
var fields = isChangeGroup ? __spreadArray(__spreadArray([], __read(subFields)), __read(mainFields)) : [];
|
|
2769
|
+
return trigger(__spreadArray(__spreadArray([], __read(fields)), [fieldNames.weather2, fieldNames.weather3]));
|
|
2621
2770
|
}
|
|
2622
2771
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2623
2772
|
label: "Weather",
|
|
2624
|
-
name:
|
|
2773
|
+
name: fieldNames.weather2,
|
|
2625
2774
|
disabled: disabled,
|
|
2626
2775
|
defaultValue: getDefaultValue('weather.weather2', field),
|
|
2627
2776
|
rules: {
|
|
2628
2777
|
validate: {
|
|
2629
2778
|
validateSecondWeatherField: function validateSecondWeatherField$1(value) {
|
|
2630
|
-
return validateSecondWeatherField(getValues(
|
|
2779
|
+
return validateSecondWeatherField(getValues(fieldNames.weather1), value);
|
|
2631
2780
|
}
|
|
2632
2781
|
}
|
|
2633
2782
|
},
|
|
2634
2783
|
onBlur: function onBlur() {
|
|
2635
|
-
var fields = isChangeGroup ?
|
|
2636
|
-
return trigger(
|
|
2784
|
+
var fields = isChangeGroup ? __spreadArray(__spreadArray([], __read(subFields)), __read(mainFields)) : [];
|
|
2785
|
+
return trigger(__spreadArray(__spreadArray([], __read(fields)), [fieldNames.weather3]));
|
|
2637
2786
|
}
|
|
2638
2787
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2639
2788
|
label: "Weather",
|
|
2640
|
-
name:
|
|
2789
|
+
name: fieldNames.weather3,
|
|
2641
2790
|
disabled: disabled,
|
|
2642
2791
|
defaultValue: getDefaultValue('weather.weather3', field),
|
|
2643
2792
|
rules: {
|
|
2644
2793
|
validate: {
|
|
2645
2794
|
validateThirdWeatherField: function validateThirdWeatherField$1(value) {
|
|
2646
|
-
return validateThirdWeatherField(getValues(
|
|
2795
|
+
return validateThirdWeatherField(getValues(fieldNames.weather1), getValues(fieldNames.weather2), value);
|
|
2647
2796
|
}
|
|
2648
2797
|
}
|
|
2649
2798
|
}
|
|
2650
2799
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2651
2800
|
label: "Cloud",
|
|
2652
|
-
name:
|
|
2801
|
+
name: fieldNames.cloud1,
|
|
2653
2802
|
disabled: disabled,
|
|
2654
2803
|
defaultValue: getDefaultValue('cloud.cloud1', field),
|
|
2655
2804
|
rules: {
|
|
@@ -2662,48 +2811,48 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2662
2811
|
}
|
|
2663
2812
|
},
|
|
2664
2813
|
onBlur: function onBlur() {
|
|
2665
|
-
var fields = isChangeGroup ?
|
|
2666
|
-
return trigger(
|
|
2814
|
+
var fields = isChangeGroup ? __spreadArray(__spreadArray([], __read(subFields)), __read(mainFields)) : [];
|
|
2815
|
+
return trigger(__spreadArray(__spreadArray([], __read(fields)), [fieldNames.cloud2, fieldNames.cloud3, fieldNames.cloud4]));
|
|
2667
2816
|
}
|
|
2668
2817
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2669
2818
|
label: "Cloud",
|
|
2670
|
-
name:
|
|
2819
|
+
name: fieldNames.cloud2,
|
|
2671
2820
|
disabled: disabled,
|
|
2672
2821
|
defaultValue: getDefaultValue('cloud.cloud2', field),
|
|
2673
2822
|
rules: {
|
|
2674
2823
|
validate: {
|
|
2675
2824
|
validateSecondCloud: function validateSecondCloud$1(value) {
|
|
2676
|
-
return validateSecondCloud(getValues(
|
|
2825
|
+
return validateSecondCloud(getValues(fieldNames.cloud1), value);
|
|
2677
2826
|
}
|
|
2678
2827
|
}
|
|
2679
2828
|
},
|
|
2680
2829
|
onBlur: function onBlur() {
|
|
2681
|
-
return trigger([
|
|
2830
|
+
return trigger([fieldNames.cloud3, fieldNames.cloud4]);
|
|
2682
2831
|
}
|
|
2683
2832
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2684
2833
|
label: "Cloud",
|
|
2685
|
-
name:
|
|
2834
|
+
name: fieldNames.cloud3,
|
|
2686
2835
|
disabled: disabled,
|
|
2687
2836
|
defaultValue: getDefaultValue('cloud.cloud3', field),
|
|
2688
2837
|
rules: {
|
|
2689
2838
|
validate: {
|
|
2690
2839
|
validateThirdCloud: function validateThirdCloud$1(value) {
|
|
2691
|
-
return validateThirdCloud(getValues(
|
|
2840
|
+
return validateThirdCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), value);
|
|
2692
2841
|
}
|
|
2693
2842
|
}
|
|
2694
2843
|
},
|
|
2695
2844
|
onBlur: function onBlur() {
|
|
2696
|
-
return trigger(
|
|
2845
|
+
return trigger(fieldNames.cloud4);
|
|
2697
2846
|
}
|
|
2698
2847
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2699
2848
|
label: "Cloud",
|
|
2700
|
-
name:
|
|
2849
|
+
name: fieldNames.cloud4,
|
|
2701
2850
|
disabled: disabled,
|
|
2702
2851
|
defaultValue: getDefaultValue('cloud.cloud4', field),
|
|
2703
2852
|
rules: {
|
|
2704
2853
|
validate: {
|
|
2705
2854
|
validateFourthCloud: function validateFourthCloud$1(value) {
|
|
2706
|
-
return validateFourthCloud(getValues(
|
|
2855
|
+
return validateFourthCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), getValues(fieldNames.cloud3), value);
|
|
2707
2856
|
}
|
|
2708
2857
|
}
|
|
2709
2858
|
}
|
|
@@ -2722,7 +2871,7 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2722
2871
|
}, lastRow ? {
|
|
2723
2872
|
tabIndex: '-1'
|
|
2724
2873
|
} : {}), /*#__PURE__*/React__default.createElement(Delete, null))));
|
|
2725
|
-
};
|
|
2874
|
+
});
|
|
2726
2875
|
|
|
2727
2876
|
var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
|
|
2728
2877
|
switch (sumOfErrors) {
|
|
@@ -2761,9 +2910,9 @@ var IssuesButton = function IssuesButton(_a) {
|
|
|
2761
2910
|
var togglePane = _a.togglePane,
|
|
2762
2911
|
sumOfErrors = _a.sumOfErrors;
|
|
2763
2912
|
var color = sumOfErrors > 0 ? 'red' : 'green';
|
|
2764
|
-
return /*#__PURE__*/createElement(Tooltip, {
|
|
2913
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
2765
2914
|
title: "View details"
|
|
2766
|
-
}, /*#__PURE__*/createElement(Chip, {
|
|
2915
|
+
}, /*#__PURE__*/React.createElement(Chip, {
|
|
2767
2916
|
size: "small",
|
|
2768
2917
|
label: getIssuesLabel(sumOfErrors),
|
|
2769
2918
|
style: __assign({}, buttonStyle(color)),
|
|
@@ -2808,7 +2957,7 @@ var ThumbsUp = function ThumbsUp(props) {
|
|
|
2808
2957
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2809
2958
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2810
2959
|
* */
|
|
2811
|
-
var useStyles$
|
|
2960
|
+
var useStyles$8 = makeStyles({
|
|
2812
2961
|
issuesPane: {
|
|
2813
2962
|
display: 'flex',
|
|
2814
2963
|
flexDirection: 'column',
|
|
@@ -2910,26 +3059,26 @@ var IssuesPane = function IssuesPane(_a) {
|
|
|
2910
3059
|
var handleClose = _a.handleClose,
|
|
2911
3060
|
_b = _a.errorList,
|
|
2912
3061
|
errorList = _b === void 0 ? [] : _b;
|
|
2913
|
-
var classes = useStyles$
|
|
2914
|
-
return /*#__PURE__*/createElement(Paper, {
|
|
3062
|
+
var classes = useStyles$8();
|
|
3063
|
+
return /*#__PURE__*/React.createElement(Paper, {
|
|
2915
3064
|
elevation: 3,
|
|
2916
3065
|
className: classes.issuesPane
|
|
2917
|
-
}, /*#__PURE__*/createElement("div", {
|
|
3066
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2918
3067
|
className: classes.paneHeader
|
|
2919
|
-
}, /*#__PURE__*/createElement(Typography, {
|
|
3068
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
2920
3069
|
"data-testid": "issuesPaneTitle",
|
|
2921
3070
|
className: classes.paneTitle
|
|
2922
|
-
}, getPaneTitle(errorList.length)), /*#__PURE__*/createElement(IconButton, {
|
|
3071
|
+
}, getPaneTitle(errorList.length)), /*#__PURE__*/React.createElement(IconButton, {
|
|
2923
3072
|
"data-testid": "closeIssuesPane",
|
|
2924
3073
|
size: "small",
|
|
2925
3074
|
onClick: handleClose
|
|
2926
|
-
}, /*#__PURE__*/createElement(Close, null))), /*#__PURE__*/createElement("div", {
|
|
3075
|
+
}, /*#__PURE__*/React.createElement(Close, null))), /*#__PURE__*/React.createElement("div", {
|
|
2927
3076
|
className: classes.paneContent
|
|
2928
|
-
}, errorList.length === 0 && /*#__PURE__*/createElement("div", {
|
|
3077
|
+
}, errorList.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
2929
3078
|
className: classes.image,
|
|
2930
3079
|
"data-testid": "zeroIssuesImage"
|
|
2931
|
-
}, /*#__PURE__*/createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
|
|
2932
|
-
return /*#__PURE__*/createElement(Typography // eslint-disable-next-line react/no-array-index-key
|
|
3080
|
+
}, /*#__PURE__*/React.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
|
|
3081
|
+
return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
|
|
2933
3082
|
, {
|
|
2934
3083
|
// eslint-disable-next-line react/no-array-index-key
|
|
2935
3084
|
key: "message-" + index,
|
|
@@ -2971,7 +3120,7 @@ var getErrors = function getErrors(errors) {
|
|
|
2971
3120
|
var errorValues = errorValue.reduce(function (l, i) {
|
|
2972
3121
|
return l.concat(getErrorValues(i));
|
|
2973
3122
|
}, []);
|
|
2974
|
-
return list.concat.apply(list,
|
|
3123
|
+
return list.concat.apply(list, __spreadArray([], __read(errorValues)));
|
|
2975
3124
|
}
|
|
2976
3125
|
|
|
2977
3126
|
return list.concat(getErrorValues(errorValue));
|
|
@@ -2996,7 +3145,7 @@ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
|
|
|
2996
3145
|
var TafFormButtons = function TafFormButtons(_a) {
|
|
2997
3146
|
var tafAction = _a.tafAction,
|
|
2998
3147
|
onTafFormButtonPress = _a.onTafFormButtonPress;
|
|
2999
|
-
var classes = useStyles();
|
|
3148
|
+
var classes = useStyles$9();
|
|
3000
3149
|
var errors = useFormContext().errors;
|
|
3001
3150
|
var errorList = filterDuplicateErrors(getErrors(errors));
|
|
3002
3151
|
|
|
@@ -3028,7 +3177,7 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3028
3177
|
className: classes.actionButton,
|
|
3029
3178
|
onClick: function onClick() {
|
|
3030
3179
|
// Simply discard the changes and close the dialog.
|
|
3031
|
-
onTafFormButtonPress('
|
|
3180
|
+
onTafFormButtonPress('DISCARD');
|
|
3032
3181
|
}
|
|
3033
3182
|
}, "Discard"), /*#__PURE__*/React__default.createElement(Button, {
|
|
3034
3183
|
"data-testid": "savedrafttaf",
|
|
@@ -3039,20 +3188,20 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3039
3188
|
onClick: function onClick() {
|
|
3040
3189
|
/* Save the TAF as draft:
|
|
3041
3190
|
if action NEW or DRAFT - new status will be DRAFT -- default
|
|
3042
|
-
if action
|
|
3043
|
-
if action
|
|
3044
|
-
if action
|
|
3045
|
-
if action
|
|
3191
|
+
if action AMEND - new status will be DRAFT_AMENDED
|
|
3192
|
+
if action CORRECT - new status will be DRAFT_CORRECTED
|
|
3193
|
+
if action DRAFT_AMEND - new status will be DRAFT_AMENDED
|
|
3194
|
+
if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
|
|
3046
3195
|
*/
|
|
3047
3196
|
switch (tafAction) {
|
|
3048
|
-
case '
|
|
3049
|
-
case '
|
|
3050
|
-
onTafFormButtonPress('
|
|
3197
|
+
case 'AMEND':
|
|
3198
|
+
case 'DRAFT_AMEND':
|
|
3199
|
+
onTafFormButtonPress('DRAFT_AMEND');
|
|
3051
3200
|
break;
|
|
3052
3201
|
|
|
3053
|
-
case '
|
|
3054
|
-
case '
|
|
3055
|
-
onTafFormButtonPress('
|
|
3202
|
+
case 'CORRECT':
|
|
3203
|
+
case 'DRAFT_CORRECT':
|
|
3204
|
+
onTafFormButtonPress('DRAFT_CORRECT');
|
|
3056
3205
|
break;
|
|
3057
3206
|
|
|
3058
3207
|
default:
|
|
@@ -3069,24 +3218,24 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3069
3218
|
onClick: function onClick() {
|
|
3070
3219
|
/* Publish the TAF:
|
|
3071
3220
|
if action NEW or DRAFT - new status will be PUBLISHED -- default
|
|
3072
|
-
if action
|
|
3073
|
-
if action
|
|
3074
|
-
if action
|
|
3075
|
-
if action
|
|
3221
|
+
if action AMEND - new status will be AMENDED
|
|
3222
|
+
if action CORRECT - new status will be CORRECTED
|
|
3223
|
+
if action DRAFT_AMEND - new status will be AMENDED
|
|
3224
|
+
if action DRAFT_CORRECT - new status will be CORRECTED
|
|
3076
3225
|
*/
|
|
3077
3226
|
switch (tafAction) {
|
|
3078
|
-
case '
|
|
3079
|
-
case '
|
|
3080
|
-
onTafFormButtonPress('
|
|
3227
|
+
case 'AMEND':
|
|
3228
|
+
case 'DRAFT_AMEND':
|
|
3229
|
+
onTafFormButtonPress('AMEND');
|
|
3081
3230
|
break;
|
|
3082
3231
|
|
|
3083
|
-
case '
|
|
3084
|
-
case '
|
|
3085
|
-
onTafFormButtonPress('
|
|
3232
|
+
case 'CORRECT':
|
|
3233
|
+
case 'DRAFT_CORRECT':
|
|
3234
|
+
onTafFormButtonPress('CORRECT');
|
|
3086
3235
|
break;
|
|
3087
3236
|
|
|
3088
3237
|
default:
|
|
3089
|
-
onTafFormButtonPress('
|
|
3238
|
+
onTafFormButtonPress('PUBLISH');
|
|
3090
3239
|
break;
|
|
3091
3240
|
}
|
|
3092
3241
|
}
|
|
@@ -3096,6 +3245,50 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3096
3245
|
}));
|
|
3097
3246
|
};
|
|
3098
3247
|
|
|
3248
|
+
/* *
|
|
3249
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3250
|
+
* you may not use this file except in compliance with the License.
|
|
3251
|
+
* You may obtain a copy of the License at
|
|
3252
|
+
*
|
|
3253
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3254
|
+
*
|
|
3255
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3256
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3257
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3258
|
+
* See the License for the specific language governing permissions and
|
|
3259
|
+
* limitations under the License.
|
|
3260
|
+
*
|
|
3261
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3262
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3263
|
+
* */
|
|
3264
|
+
var useStyles$7 = makeStyles(function () {
|
|
3265
|
+
return {
|
|
3266
|
+
dragHandle: {
|
|
3267
|
+
backgroundColor: 'transparent',
|
|
3268
|
+
'&:hover': {
|
|
3269
|
+
backgroundColor: 'transparent'
|
|
3270
|
+
},
|
|
3271
|
+
cursor: function cursor(isSorting) {
|
|
3272
|
+
return isSorting ? 'grabbing' : 'grab';
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
});
|
|
3277
|
+
|
|
3278
|
+
var DragHandle = function DragHandle(_a) {
|
|
3279
|
+
var _b = _a.isSorting,
|
|
3280
|
+
isSorting = _b === void 0 ? false : _b,
|
|
3281
|
+
_c = _a.isDisabled,
|
|
3282
|
+
isDisabled = _c === void 0 ? false : _c;
|
|
3283
|
+
var classes = useStyles$7(isSorting);
|
|
3284
|
+
return /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3285
|
+
className: classes.dragHandle + " handle",
|
|
3286
|
+
"data-testid": "dragHandle",
|
|
3287
|
+
disableRipple: true,
|
|
3288
|
+
disabled: isDisabled
|
|
3289
|
+
}, /*#__PURE__*/React__default.createElement(DragIndicator, null));
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3099
3292
|
var emptyRow = {
|
|
3100
3293
|
valid: '',
|
|
3101
3294
|
wind: '',
|
|
@@ -3125,27 +3318,33 @@ var TafForm = function TafForm(_a) {
|
|
|
3125
3318
|
onFormAction = _c === void 0 ? function () {
|
|
3126
3319
|
return null;
|
|
3127
3320
|
} : _c;
|
|
3128
|
-
var classes = useStyles();
|
|
3321
|
+
var classes = useStyles$9();
|
|
3129
3322
|
var confirmDialog = useConfirmationDialog();
|
|
3323
|
+
|
|
3324
|
+
var _d = useDraftFormHelpers(),
|
|
3325
|
+
toggleIsDraft = _d.toggleIsDraft,
|
|
3326
|
+
DraftFieldHelper = _d.DraftFieldHelper;
|
|
3327
|
+
|
|
3130
3328
|
var api = useApiContext().api;
|
|
3131
3329
|
var isDisabled = mode === 'view';
|
|
3132
3330
|
|
|
3133
|
-
var
|
|
3134
|
-
control =
|
|
3135
|
-
handleSubmit =
|
|
3136
|
-
watch =
|
|
3137
|
-
getValues =
|
|
3138
|
-
errors =
|
|
3331
|
+
var _e = useFormContext(),
|
|
3332
|
+
control = _e.control,
|
|
3333
|
+
handleSubmit = _e.handleSubmit,
|
|
3334
|
+
watch = _e.watch,
|
|
3335
|
+
getValues = _e.getValues,
|
|
3336
|
+
errors = _e.errors,
|
|
3337
|
+
trigger = _e.trigger;
|
|
3139
3338
|
|
|
3140
3339
|
var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
|
|
3141
3340
|
|
|
3142
|
-
var
|
|
3143
|
-
delayedFormValues =
|
|
3144
|
-
setDelayedFormValues =
|
|
3341
|
+
var _f = __read(React__default.useState(watch()), 2),
|
|
3342
|
+
delayedFormValues = _f[0],
|
|
3343
|
+
setDelayedFormValues = _f[1];
|
|
3145
3344
|
|
|
3146
|
-
var
|
|
3147
|
-
TAC =
|
|
3148
|
-
updateTAC =
|
|
3345
|
+
var _g = __read(useTACGenerator(convertTafValuesToObject(delayedFormValues), api.getTAC, staticTAC), 2),
|
|
3346
|
+
TAC = _g[0],
|
|
3347
|
+
updateTAC = _g[1];
|
|
3149
3348
|
|
|
3150
3349
|
React__default.useEffect(function () {
|
|
3151
3350
|
if (!Object.keys(errors).length && staticTAC === '') {
|
|
@@ -3158,9 +3357,9 @@ var TafForm = function TafForm(_a) {
|
|
|
3158
3357
|
setDelayedFormValues(getValues());
|
|
3159
3358
|
};
|
|
3160
3359
|
|
|
3161
|
-
var
|
|
3162
|
-
isFormDirty =
|
|
3163
|
-
setFormDirty =
|
|
3360
|
+
var _h = __read(React__default.useState(false), 2),
|
|
3361
|
+
isFormDirty = _h[0],
|
|
3362
|
+
setFormDirty = _h[1];
|
|
3164
3363
|
|
|
3165
3364
|
var onFormChange = function onFormChange() {
|
|
3166
3365
|
return !isFormDirty ? setFormDirty(true) : null;
|
|
@@ -3168,13 +3367,14 @@ var TafForm = function TafForm(_a) {
|
|
|
3168
3367
|
|
|
3169
3368
|
usePreventBrowserClose(isFormDirty && !isDisabled);
|
|
3170
3369
|
|
|
3171
|
-
var
|
|
3370
|
+
var _j = useFieldArray({
|
|
3172
3371
|
control: control,
|
|
3173
3372
|
name: 'changeGroups'
|
|
3174
3373
|
}),
|
|
3175
|
-
fields =
|
|
3176
|
-
append =
|
|
3177
|
-
remove =
|
|
3374
|
+
fields = _j.fields,
|
|
3375
|
+
append = _j.append,
|
|
3376
|
+
remove = _j.remove,
|
|
3377
|
+
move = _j.move;
|
|
3178
3378
|
|
|
3179
3379
|
var onSubmit = function onSubmit(data) {
|
|
3180
3380
|
// eslint-disable-next-line no-console
|
|
@@ -3192,14 +3392,15 @@ var TafForm = function TafForm(_a) {
|
|
|
3192
3392
|
var onTafButtonPress = function onTafButtonPress(action) {
|
|
3193
3393
|
switch (action) {
|
|
3194
3394
|
case 'DRAFT':
|
|
3195
|
-
case '
|
|
3196
|
-
case '
|
|
3395
|
+
case 'DRAFT_AMEND':
|
|
3396
|
+
case 'DRAFT_CORRECT':
|
|
3397
|
+
toggleIsDraft(true);
|
|
3197
3398
|
handleSubmit(function (data) {
|
|
3198
3399
|
onFormAction(action, convertTafValuesToObject(data));
|
|
3199
3400
|
})();
|
|
3200
3401
|
break;
|
|
3201
3402
|
|
|
3202
|
-
case '
|
|
3403
|
+
case 'DISCARD':
|
|
3203
3404
|
if (isFormDirty) {
|
|
3204
3405
|
showConfirmDialog(action).then(function () {
|
|
3205
3406
|
onFormAction(action);
|
|
@@ -3210,9 +3411,10 @@ var TafForm = function TafForm(_a) {
|
|
|
3210
3411
|
|
|
3211
3412
|
break;
|
|
3212
3413
|
|
|
3213
|
-
case '
|
|
3214
|
-
case '
|
|
3215
|
-
case '
|
|
3414
|
+
case 'AMEND':
|
|
3415
|
+
case 'CORRECT':
|
|
3416
|
+
case 'PUBLISH':
|
|
3417
|
+
toggleIsDraft(false);
|
|
3216
3418
|
handleSubmit(function (data) {
|
|
3217
3419
|
showConfirmDialog(action).then(function () {
|
|
3218
3420
|
onFormAction(action, convertTafValuesToObject(data));
|
|
@@ -3230,10 +3432,6 @@ var TafForm = function TafForm(_a) {
|
|
|
3230
3432
|
append(emptyRow);
|
|
3231
3433
|
};
|
|
3232
3434
|
|
|
3233
|
-
var onRemoverow = function onRemoverow(index) {
|
|
3234
|
-
remove(index);
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
3435
|
React__default.useEffect(function () {
|
|
3238
3436
|
// set changegroups on mount (if no changegroups - add empty one by default)
|
|
3239
3437
|
if (changeGroups.length > 0) {
|
|
@@ -3245,6 +3443,20 @@ var TafForm = function TafForm(_a) {
|
|
|
3245
3443
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3246
3444
|
|
|
3247
3445
|
}, []);
|
|
3446
|
+
|
|
3447
|
+
var _k = useDragOrder(trigger, move, fields),
|
|
3448
|
+
onChangeOrder = _k.onChangeOrder,
|
|
3449
|
+
sortedFields = _k.sortedFields,
|
|
3450
|
+
setSortedFields = _k.setSortedFields;
|
|
3451
|
+
|
|
3452
|
+
var onRemoverow = function onRemoverow(index) {
|
|
3453
|
+
remove(index);
|
|
3454
|
+
var newList = fields.length > 1 ? fields.filter(function (_, fieldIndex) {
|
|
3455
|
+
return fieldIndex === index;
|
|
3456
|
+
}) : [];
|
|
3457
|
+
setSortedFields(newList);
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3248
3460
|
return /*#__PURE__*/React__default.createElement("form", {
|
|
3249
3461
|
onSubmit: handleSubmit(onSubmit),
|
|
3250
3462
|
onChange: onFormChange,
|
|
@@ -3262,17 +3474,37 @@ var TafForm = function TafForm(_a) {
|
|
|
3262
3474
|
}, line);
|
|
3263
3475
|
})), /*#__PURE__*/React__default.createElement(TafFormRow, {
|
|
3264
3476
|
disabled: isDisabled
|
|
3265
|
-
}),
|
|
3477
|
+
}), /*#__PURE__*/React__default.createElement(ReactSortable, {
|
|
3478
|
+
tag: "div",
|
|
3479
|
+
list: sortedFields,
|
|
3480
|
+
setList: setSortedFields,
|
|
3481
|
+
animation: 200,
|
|
3482
|
+
onSort: onChangeOrder,
|
|
3483
|
+
handle: ".handle",
|
|
3484
|
+
direction: "vertical",
|
|
3485
|
+
// hover props
|
|
3486
|
+
forceFallback: true,
|
|
3487
|
+
onStart: function onStart() {
|
|
3488
|
+
Sortable.ghost.style.opacity = '1';
|
|
3489
|
+
}
|
|
3490
|
+
}, sortedFields.map(function (_a, index) {
|
|
3491
|
+
var chosen = _a.chosen;
|
|
3492
|
+
var item = fields[index];
|
|
3266
3493
|
return /*#__PURE__*/React__default.createElement(TafFormRow, {
|
|
3267
3494
|
field: item,
|
|
3495
|
+
className: classes.formRow,
|
|
3268
3496
|
key: item.id,
|
|
3269
3497
|
index: index,
|
|
3270
3498
|
lastRow: fields.length === index + 1,
|
|
3271
3499
|
disabled: isDisabled,
|
|
3272
3500
|
onRemoveChangeGroup: onRemoverow,
|
|
3273
|
-
isChangeGroup: true
|
|
3501
|
+
isChangeGroup: true,
|
|
3502
|
+
dragHandle: /*#__PURE__*/React__default.createElement(DragHandle, {
|
|
3503
|
+
isDisabled: sortedFields.length === 1 || isDisabled,
|
|
3504
|
+
isSorting: chosen
|
|
3505
|
+
})
|
|
3274
3506
|
});
|
|
3275
|
-
}), !isDisabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3507
|
+
})), !isDisabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3276
3508
|
container: true,
|
|
3277
3509
|
item: true,
|
|
3278
3510
|
xs: 12,
|
|
@@ -3290,15 +3522,15 @@ var TafForm = function TafForm(_a) {
|
|
|
3290
3522
|
name: field,
|
|
3291
3523
|
key: field
|
|
3292
3524
|
});
|
|
3293
|
-
}));
|
|
3525
|
+
}), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null));
|
|
3294
3526
|
};
|
|
3295
3527
|
|
|
3296
3528
|
var getMessageType = function getMessageType(taf, tafAction) {
|
|
3297
|
-
if (tafAction === '
|
|
3529
|
+
if (tafAction === 'CORRECT') {
|
|
3298
3530
|
return 'COR';
|
|
3299
3531
|
}
|
|
3300
3532
|
|
|
3301
|
-
if (tafAction === '
|
|
3533
|
+
if (tafAction === 'AMEND') {
|
|
3302
3534
|
return 'AMD';
|
|
3303
3535
|
}
|
|
3304
3536
|
|
|
@@ -3306,11 +3538,11 @@ var getMessageType = function getMessageType(taf, tafAction) {
|
|
|
3306
3538
|
}; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
|
|
3307
3539
|
|
|
3308
3540
|
var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafAction) {
|
|
3309
|
-
var previousValidDateStart = taf.previousValidDateStart && tafAction !== '
|
|
3310
|
-
var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== '
|
|
3541
|
+
var previousValidDateStart = taf.previousValidDateStart && tafAction !== 'AMEND' ? taf.previousValidDateStart : taf.validDateStart;
|
|
3542
|
+
var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== 'AMEND' ? taf.previousValidDateEnd : taf.validDateEnd; // For amendment change valid start time to current time
|
|
3311
3543
|
// only do this if we're already within the validity period
|
|
3312
3544
|
|
|
3313
|
-
if ((tafAction === '
|
|
3545
|
+
if ((tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND') && moment.utc() >= moment.utc(taf.validDateStart)) {
|
|
3314
3546
|
var now = moment.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
|
|
3315
3547
|
var validObj = {
|
|
3316
3548
|
start: now,
|
|
@@ -3332,9 +3564,9 @@ var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafA
|
|
|
3332
3564
|
});
|
|
3333
3565
|
};
|
|
3334
3566
|
var prepareTafValues = function prepareTafValues(_taf, tafAction) {
|
|
3335
|
-
// If action is
|
|
3336
|
-
// If action is
|
|
3337
|
-
var taf = tafAction === '
|
|
3567
|
+
// If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
|
|
3568
|
+
// If action is AMEND/DRAFT_AMEND - update validity start time to current time
|
|
3569
|
+
var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
|
|
3338
3570
|
return __assign(__assign(__assign({}, taf), {
|
|
3339
3571
|
messageType: getMessageType(taf, tafAction),
|
|
3340
3572
|
baseForecast: formatFormValues(taf.baseForecast)
|
|
@@ -3374,7 +3606,7 @@ var TafFormWrapper = function TafFormWrapper(_a) {
|
|
|
3374
3606
|
}));
|
|
3375
3607
|
};
|
|
3376
3608
|
|
|
3377
|
-
var useStyles$
|
|
3609
|
+
var useStyles$6 = makeStyles({
|
|
3378
3610
|
dialogHeader: {
|
|
3379
3611
|
borderRadius: '3px',
|
|
3380
3612
|
border: 'solid 1px #f6f5f5',
|
|
@@ -3399,45 +3631,45 @@ var useStyles$2 = makeStyles({
|
|
|
3399
3631
|
});
|
|
3400
3632
|
|
|
3401
3633
|
var ContentDialog = function ContentDialog(_a) {
|
|
3402
|
-
var open = _a.open
|
|
3403
|
-
|
|
3404
|
-
titleComponent = _a.titleComponent,
|
|
3405
|
-
children = _a.children
|
|
3406
|
-
|
|
3407
|
-
_b = _a.alertBanner,
|
|
3634
|
+
var open = _a.open;
|
|
3635
|
+
_a.toggleDialogStatus;
|
|
3636
|
+
var titleComponent = _a.titleComponent,
|
|
3637
|
+
children = _a.children;
|
|
3638
|
+
_a.onClose;
|
|
3639
|
+
var _b = _a.alertBanner,
|
|
3408
3640
|
alertBanner = _b === void 0 ? null : _b,
|
|
3409
3641
|
onFormAction = _a.onFormAction,
|
|
3410
3642
|
other = __rest(_a, ["open", "toggleDialogStatus", "titleComponent", "children", "onClose", "alertBanner", "onFormAction"]);
|
|
3411
3643
|
|
|
3412
|
-
var classes = useStyles$
|
|
3413
|
-
return /*#__PURE__*/createElement(Dialog, __assign({
|
|
3644
|
+
var classes = useStyles$6();
|
|
3645
|
+
return /*#__PURE__*/React.createElement(Dialog, __assign({
|
|
3414
3646
|
"data-testid": "contentDialog",
|
|
3415
3647
|
open: open,
|
|
3416
3648
|
onClose: function onClose() {
|
|
3417
|
-
return onFormAction('
|
|
3649
|
+
return onFormAction('CLOSE');
|
|
3418
3650
|
},
|
|
3419
3651
|
maxWidth: other.maxWidth ? other.maxWidth : 'lg',
|
|
3420
3652
|
disableBackdropClick: true
|
|
3421
|
-
}, other), /*#__PURE__*/createElement(DialogTitle, {
|
|
3653
|
+
}, other), /*#__PURE__*/React.createElement(DialogTitle, {
|
|
3422
3654
|
disableTypography: true,
|
|
3423
3655
|
className: classes.dialogHeader
|
|
3424
|
-
}, /*#__PURE__*/createElement(Grid, {
|
|
3656
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
3425
3657
|
container: true
|
|
3426
|
-
}, /*#__PURE__*/createElement(Grid, {
|
|
3658
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
3427
3659
|
item: true,
|
|
3428
3660
|
xs: 11,
|
|
3429
3661
|
className: classes.dialogTitle
|
|
3430
|
-
}, titleComponent), /*#__PURE__*/createElement(Grid, {
|
|
3662
|
+
}, titleComponent), /*#__PURE__*/React.createElement(Grid, {
|
|
3431
3663
|
item: true,
|
|
3432
3664
|
xs: true,
|
|
3433
3665
|
className: classes.dialogCloseButton
|
|
3434
|
-
}, /*#__PURE__*/createElement(IconButton, {
|
|
3666
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
3435
3667
|
"data-testid": "closeDialog",
|
|
3436
3668
|
size: "small",
|
|
3437
3669
|
onClick: function onClick() {
|
|
3438
|
-
return onFormAction('
|
|
3670
|
+
return onFormAction('CLOSE');
|
|
3439
3671
|
}
|
|
3440
|
-
}, /*#__PURE__*/createElement(Close, null))))), alertBanner !== null && alertBanner, /*#__PURE__*/createElement(DialogContent, {
|
|
3672
|
+
}, /*#__PURE__*/React.createElement(Close, null))))), alertBanner !== null && alertBanner, /*#__PURE__*/React.createElement(DialogContent, {
|
|
3441
3673
|
className: classes.dialogChildren
|
|
3442
3674
|
}, children));
|
|
3443
3675
|
};
|
|
@@ -3499,7 +3731,7 @@ var getDraftTitle = function getDraftTitle(status) {
|
|
|
3499
3731
|
|
|
3500
3732
|
return 'Draft';
|
|
3501
3733
|
};
|
|
3502
|
-
var useStyles$
|
|
3734
|
+
var useStyles$5 = makeStyles({
|
|
3503
3735
|
cardWrapper: {
|
|
3504
3736
|
width: '100%'
|
|
3505
3737
|
},
|
|
@@ -3525,7 +3757,7 @@ var TafListRow = function TafListRow(_a) {
|
|
|
3525
3757
|
TAC = _b === void 0 ? '' : _b,
|
|
3526
3758
|
_c = _a.showTac,
|
|
3527
3759
|
showTac = _c === void 0 ? false : _c;
|
|
3528
|
-
var classes = useStyles$
|
|
3760
|
+
var classes = useStyles$5();
|
|
3529
3761
|
var validTimeDate = moment.utc(taf.validDateStart).format('DD MMM');
|
|
3530
3762
|
var baseTime = moment.utc(taf.baseTime).format('HH:mm');
|
|
3531
3763
|
return /*#__PURE__*/React__default.createElement(Card, {
|
|
@@ -3742,7 +3974,7 @@ var TafListButtons = function TafListButtons(_a) {
|
|
|
3742
3974
|
variant: "outlined",
|
|
3743
3975
|
color: "secondary",
|
|
3744
3976
|
onClick: function onClick() {
|
|
3745
|
-
return onClickTafActionButton(uuid, '
|
|
3977
|
+
return onClickTafActionButton(uuid, 'CANCEL');
|
|
3746
3978
|
}
|
|
3747
3979
|
}, "Cancel")), /*#__PURE__*/React__default.createElement(Grid, {
|
|
3748
3980
|
item: true
|
|
@@ -3751,7 +3983,7 @@ var TafListButtons = function TafListButtons(_a) {
|
|
|
3751
3983
|
variant: "outlined",
|
|
3752
3984
|
color: "secondary",
|
|
3753
3985
|
onClick: function onClick() {
|
|
3754
|
-
return onClickTafActionButton(uuid, '
|
|
3986
|
+
return onClickTafActionButton(uuid, 'CORRECT');
|
|
3755
3987
|
}
|
|
3756
3988
|
}, "Correct")), /*#__PURE__*/React__default.createElement(Grid, {
|
|
3757
3989
|
item: true
|
|
@@ -3760,12 +3992,12 @@ var TafListButtons = function TafListButtons(_a) {
|
|
|
3760
3992
|
variant: "outlined",
|
|
3761
3993
|
color: "secondary",
|
|
3762
3994
|
onClick: function onClick() {
|
|
3763
|
-
return onClickTafActionButton(uuid, '
|
|
3995
|
+
return onClickTafActionButton(uuid, 'AMEND');
|
|
3764
3996
|
}
|
|
3765
3997
|
}, "Amend")));
|
|
3766
3998
|
};
|
|
3767
3999
|
|
|
3768
|
-
var useStyles$
|
|
4000
|
+
var useStyles$3 = makeStyles({
|
|
3769
4001
|
accordion: {
|
|
3770
4002
|
marginBottom: '5px'
|
|
3771
4003
|
},
|
|
@@ -3774,13 +4006,29 @@ var useStyles$5 = makeStyles({
|
|
|
3774
4006
|
}
|
|
3775
4007
|
});
|
|
3776
4008
|
|
|
4009
|
+
var fromStatusToAction = function fromStatusToAction(tafStatus) {
|
|
4010
|
+
switch (tafStatus) {
|
|
4011
|
+
case 'DRAFT':
|
|
4012
|
+
return 'DRAFT';
|
|
4013
|
+
|
|
4014
|
+
case 'DRAFT_AMENDED':
|
|
4015
|
+
return 'DRAFT_AMEND';
|
|
4016
|
+
|
|
4017
|
+
case 'DRAFT_CORRECTED':
|
|
4018
|
+
return 'DRAFT_CORRECT';
|
|
4019
|
+
|
|
4020
|
+
default:
|
|
4021
|
+
return 'NEW';
|
|
4022
|
+
}
|
|
4023
|
+
};
|
|
4024
|
+
|
|
3777
4025
|
var TafListAccordion = function TafListAccordion(_a) {
|
|
3778
4026
|
var tafListItem = _a.tafListItem,
|
|
3779
4027
|
listType = _a.listType,
|
|
3780
4028
|
_b = _a.errorCancelTaf,
|
|
3781
4029
|
errorCancelTaf = _b === void 0 ? [] : _b,
|
|
3782
4030
|
onClickTafActionButton = _a.onClickTafActionButton;
|
|
3783
|
-
var classes = useStyles$
|
|
4031
|
+
var classes = useStyles$3();
|
|
3784
4032
|
var status = tafListItem.taf.status;
|
|
3785
4033
|
var api = useApiContext().api;
|
|
3786
4034
|
|
|
@@ -3804,7 +4052,7 @@ var TafListAccordion = function TafListAccordion(_a) {
|
|
|
3804
4052
|
} : {}, {
|
|
3805
4053
|
onClick: function onClick() {
|
|
3806
4054
|
if (popOut) {
|
|
3807
|
-
onClickTafActionButton(tafListItem.taf.uuid, tafListItem.taf.status);
|
|
4055
|
+
onClickTafActionButton(tafListItem.taf.uuid, fromStatusToAction(tafListItem.taf.status));
|
|
3808
4056
|
}
|
|
3809
4057
|
},
|
|
3810
4058
|
TransitionProps: {
|
|
@@ -3830,10 +4078,11 @@ var TafListAccordion = function TafListAccordion(_a) {
|
|
|
3830
4078
|
direction: "column"
|
|
3831
4079
|
}, errorCancelTaf.length > 0 && errorCancelTaf.find(function (uuid) {
|
|
3832
4080
|
return uuid === tafListItem.taf.uuid;
|
|
3833
|
-
}) && /*#__PURE__*/React__default.createElement(
|
|
4081
|
+
}) && /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
3834
4082
|
severity: "error",
|
|
3835
|
-
|
|
3836
|
-
|
|
4083
|
+
title: "Cancelling this TAF failed, please try again",
|
|
4084
|
+
dataTestId: "tafList-cancelAlert"
|
|
4085
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
3837
4086
|
className: classes.formPadding
|
|
3838
4087
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3839
4088
|
item: true
|
|
@@ -3866,7 +4115,7 @@ var TafListAccordion = function TafListAccordion(_a) {
|
|
|
3866
4115
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3867
4116
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3868
4117
|
* */
|
|
3869
|
-
var useStyles$
|
|
4118
|
+
var useStyles$2 = makeStyles({
|
|
3870
4119
|
listHeaders: {
|
|
3871
4120
|
color: '#9d9d9d'
|
|
3872
4121
|
},
|
|
@@ -3885,7 +4134,7 @@ var TafListSection = function TafListSection(_a) {
|
|
|
3885
4134
|
_b = _a.errorCancelTaf,
|
|
3886
4135
|
errorCancelTaf = _b === void 0 ? [] : _b,
|
|
3887
4136
|
onClickTafActionButton = _a.onClickTafActionButton;
|
|
3888
|
-
var classes = useStyles$
|
|
4137
|
+
var classes = useStyles$2();
|
|
3889
4138
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Typography, {
|
|
3890
4139
|
variant: "subtitle2",
|
|
3891
4140
|
className: classes.listHeaders
|
|
@@ -3902,11 +4151,7 @@ var TafListSection = function TafListSection(_a) {
|
|
|
3902
4151
|
})));
|
|
3903
4152
|
};
|
|
3904
4153
|
|
|
3905
|
-
var useStyles$
|
|
3906
|
-
errorMessage: {
|
|
3907
|
-
marginBottom: '16px',
|
|
3908
|
-
border: '1px solid #f44336'
|
|
3909
|
-
},
|
|
4154
|
+
var useStyles$1 = makeStyles({
|
|
3910
4155
|
accordion: {
|
|
3911
4156
|
marginBottom: '5px'
|
|
3912
4157
|
},
|
|
@@ -3928,7 +4173,7 @@ var TafList = function TafList(_a) {
|
|
|
3928
4173
|
_c = _a.errorCancelTaf,
|
|
3929
4174
|
errorCancelTaf = _c === void 0 ? [] : _c,
|
|
3930
4175
|
onClickTafActionButton = _a.onClickTafActionButton;
|
|
3931
|
-
var classes = useStyles$
|
|
4176
|
+
var classes = useStyles$1();
|
|
3932
4177
|
var locationSettings = useTafSettings(tafConfig).locations;
|
|
3933
4178
|
var upcomingTafs = [];
|
|
3934
4179
|
var currentTafs = [];
|
|
@@ -3971,11 +4216,12 @@ var TafList = function TafList(_a) {
|
|
|
3971
4216
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3972
4217
|
item: true,
|
|
3973
4218
|
className: classes.listBody
|
|
3974
|
-
}, error && /*#__PURE__*/React__default.createElement(
|
|
4219
|
+
}, error && /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
3975
4220
|
severity: "error",
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4221
|
+
title: "An error has occurred while retrieving the list, please try again",
|
|
4222
|
+
info: error.message ? error.message : '',
|
|
4223
|
+
dataTestId: "tafList-alert"
|
|
4224
|
+
}), tafList && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafListSection, {
|
|
3979
4225
|
title: "Upcoming",
|
|
3980
4226
|
listType: "UPCOMING",
|
|
3981
4227
|
tafList: upcomingTafs,
|
|
@@ -4016,7 +4262,7 @@ var TafList = function TafList(_a) {
|
|
|
4016
4262
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
4017
4263
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
4018
4264
|
* */
|
|
4019
|
-
var useStyles
|
|
4265
|
+
var useStyles = makeStyles({
|
|
4020
4266
|
backdrop: {
|
|
4021
4267
|
zIndex: 1500,
|
|
4022
4268
|
color: '#fff'
|
|
@@ -4024,7 +4270,7 @@ var useStyles$8 = makeStyles({
|
|
|
4024
4270
|
});
|
|
4025
4271
|
|
|
4026
4272
|
var Spinner = function Spinner() {
|
|
4027
|
-
var classes = useStyles
|
|
4273
|
+
var classes = useStyles();
|
|
4028
4274
|
return /*#__PURE__*/React__default.createElement(Backdrop, {
|
|
4029
4275
|
open: true,
|
|
4030
4276
|
className: classes.backdrop
|
|
@@ -4084,21 +4330,25 @@ var TafWrapper = function TafWrapper() {
|
|
|
4084
4330
|
errorPostMessage = _d[0],
|
|
4085
4331
|
setErrorPostMessage = _d[1];
|
|
4086
4332
|
|
|
4087
|
-
var _e = __read(React__default.useState(
|
|
4088
|
-
|
|
4089
|
-
|
|
4333
|
+
var _e = __read(React__default.useState(''), 2),
|
|
4334
|
+
errorPostMessageText = _e[0],
|
|
4335
|
+
setErrorPostMessageText = _e[1];
|
|
4336
|
+
|
|
4337
|
+
var _f = __read(React__default.useState(false), 2),
|
|
4338
|
+
showSpinner = _f[0],
|
|
4339
|
+
setSpinner = _f[1]; // clear error message for cancel after 10 seconds
|
|
4090
4340
|
|
|
4091
4341
|
|
|
4092
|
-
var
|
|
4093
|
-
errorCancelTaf =
|
|
4094
|
-
setErrorCancelTaf =
|
|
4342
|
+
var _g = __read(useTimeoutCancelError(), 2),
|
|
4343
|
+
errorCancelTaf = _g[0],
|
|
4344
|
+
setErrorCancelTaf = _g[1]; // Retrieve list of tafs
|
|
4095
4345
|
|
|
4096
4346
|
|
|
4097
|
-
var
|
|
4098
|
-
errorList =
|
|
4099
|
-
isLoadingList =
|
|
4100
|
-
tafList =
|
|
4101
|
-
fetchNewTafList =
|
|
4347
|
+
var _h = useApi(api.getTafList),
|
|
4348
|
+
errorList = _h.error,
|
|
4349
|
+
isLoadingList = _h.isLoading,
|
|
4350
|
+
tafList = _h.result,
|
|
4351
|
+
fetchNewTafList = _h.fetchApiData;
|
|
4102
4352
|
|
|
4103
4353
|
var getNewTafList = function getNewTafList() {
|
|
4104
4354
|
fetchNewTafList({});
|
|
@@ -4111,6 +4361,7 @@ var TafWrapper = function TafWrapper() {
|
|
|
4111
4361
|
if (isTafDialogOpen === true) getNewTafList(); // Set error message back to false
|
|
4112
4362
|
|
|
4113
4363
|
setErrorPostMessage(false);
|
|
4364
|
+
setErrorPostMessageText('');
|
|
4114
4365
|
setTafDialogOpen(!isTafDialogOpen);
|
|
4115
4366
|
};
|
|
4116
4367
|
|
|
@@ -4122,7 +4373,7 @@ var TafWrapper = function TafWrapper() {
|
|
|
4122
4373
|
}, [selectedTafId]);
|
|
4123
4374
|
|
|
4124
4375
|
var onClickTafActionButton = function onClickTafActionButton(tafUuid, action) {
|
|
4125
|
-
if (action === '
|
|
4376
|
+
if (action === 'CANCEL') {
|
|
4126
4377
|
confirmDialog({
|
|
4127
4378
|
title: 'Cancel TAF',
|
|
4128
4379
|
description: 'Are you sure you want to cancel this TAF?',
|
|
@@ -4131,7 +4382,7 @@ var TafWrapper = function TafWrapper() {
|
|
|
4131
4382
|
var taf = getSelectedTaf(tafUuid, tafList).taf;
|
|
4132
4383
|
postTaf({
|
|
4133
4384
|
taf: taf,
|
|
4134
|
-
changeStatusTo:
|
|
4385
|
+
changeStatusTo: 'CANCELLED'
|
|
4135
4386
|
});
|
|
4136
4387
|
});
|
|
4137
4388
|
} else if (selectedTafId === tafUuid) {
|
|
@@ -4176,9 +4427,13 @@ var TafWrapper = function TafWrapper() {
|
|
|
4176
4427
|
error_1 = _a.sent();
|
|
4177
4428
|
|
|
4178
4429
|
if (data.changeStatusTo === 'CANCELLED') {
|
|
4179
|
-
setErrorCancelTaf(
|
|
4430
|
+
setErrorCancelTaf(__spreadArray(__spreadArray([], __read(errorCancelTaf)), [data.taf.uuid]));
|
|
4180
4431
|
} else {
|
|
4181
4432
|
setErrorPostMessage(true);
|
|
4433
|
+
|
|
4434
|
+
if (isAxiosError(error_1)) {
|
|
4435
|
+
setErrorPostMessageText(getAxiosErrorMessage(error_1));
|
|
4436
|
+
}
|
|
4182
4437
|
}
|
|
4183
4438
|
|
|
4184
4439
|
setSpinner(false);
|
|
@@ -4195,10 +4450,35 @@ var TafWrapper = function TafWrapper() {
|
|
|
4195
4450
|
});
|
|
4196
4451
|
};
|
|
4197
4452
|
|
|
4453
|
+
var fromActionToStatus = function fromActionToStatus(tafAction) {
|
|
4454
|
+
switch (tafAction) {
|
|
4455
|
+
case 'DRAFT':
|
|
4456
|
+
return 'DRAFT';
|
|
4457
|
+
|
|
4458
|
+
case 'DRAFT_AMEND':
|
|
4459
|
+
return 'DRAFT_AMENDED';
|
|
4460
|
+
|
|
4461
|
+
case 'DRAFT_CORRECT':
|
|
4462
|
+
return 'DRAFT_CORRECTED';
|
|
4463
|
+
|
|
4464
|
+
case 'PUBLISH':
|
|
4465
|
+
return 'PUBLISHED';
|
|
4466
|
+
|
|
4467
|
+
case 'AMEND':
|
|
4468
|
+
return 'AMENDED';
|
|
4469
|
+
|
|
4470
|
+
case 'CORRECT':
|
|
4471
|
+
return 'CORRECTED';
|
|
4472
|
+
|
|
4473
|
+
default:
|
|
4474
|
+
return 'NEW';
|
|
4475
|
+
}
|
|
4476
|
+
};
|
|
4477
|
+
|
|
4198
4478
|
var onFormAction = function onFormAction(action, taf) {
|
|
4199
4479
|
// Add right actions and their follow up calls to the BE
|
|
4200
4480
|
switch (action) {
|
|
4201
|
-
case '
|
|
4481
|
+
case 'CLOSE':
|
|
4202
4482
|
confirmDialog({
|
|
4203
4483
|
title: 'Closing TAF',
|
|
4204
4484
|
description: 'Are you sure you want to close this TAF? Any changes made will be lost.',
|
|
@@ -4209,14 +4489,14 @@ var TafWrapper = function TafWrapper() {
|
|
|
4209
4489
|
break;
|
|
4210
4490
|
|
|
4211
4491
|
case 'DRAFT':
|
|
4212
|
-
case '
|
|
4213
|
-
case '
|
|
4214
|
-
case '
|
|
4215
|
-
case '
|
|
4216
|
-
case '
|
|
4492
|
+
case 'DRAFT_AMEND':
|
|
4493
|
+
case 'DRAFT_CORRECT':
|
|
4494
|
+
case 'PUBLISH':
|
|
4495
|
+
case 'AMEND':
|
|
4496
|
+
case 'CORRECT':
|
|
4217
4497
|
postTaf({
|
|
4218
4498
|
taf: taf,
|
|
4219
|
-
changeStatusTo: action
|
|
4499
|
+
changeStatusTo: fromActionToStatus(action)
|
|
4220
4500
|
});
|
|
4221
4501
|
break;
|
|
4222
4502
|
|
|
@@ -4237,9 +4517,11 @@ var TafWrapper = function TafWrapper() {
|
|
|
4237
4517
|
open: isTafDialogOpen,
|
|
4238
4518
|
toggleFormDialog: toggleTafDialog,
|
|
4239
4519
|
tafFromBackend: selectedTaf,
|
|
4240
|
-
alertBanner: errorPostMessage ? /*#__PURE__*/React__default.createElement(
|
|
4241
|
-
severity: "error"
|
|
4242
|
-
|
|
4520
|
+
alertBanner: errorPostMessage ? /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
4521
|
+
severity: "error",
|
|
4522
|
+
title: "An error has occurred while saving, please try again",
|
|
4523
|
+
info: errorPostMessageText
|
|
4524
|
+
}) : null,
|
|
4243
4525
|
onFormAction: onFormAction
|
|
4244
4526
|
}, /*#__PURE__*/React__default.createElement(TafFormWrapper, {
|
|
4245
4527
|
mode: "edit",
|