@opengeoweb/taf 1.2.2 → 2.1.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/lib/TafDemo.stories.d.ts +1 -0
- package/lib/components/IssuesPane/IssuesPane.d.ts +1 -0
- package/lib/components/IssuesPane/IssuesPane.styles.d.ts +1 -1
- package/lib/components/Providers/Providers.d.ts +11 -0
- package/lib/components/TafForm/TafForm.d.ts +20 -3
- package/lib/components/TafForm/TafFormRow/DragHandle.d.ts +1 -0
- package/lib/components/TafForm/TafFormRow/change.d.ts +1 -1
- package/lib/components/TafForm/TafFormRow/clouds.d.ts +5 -4
- package/lib/components/TafForm/TafFormRow/validField.d.ts +9 -3
- package/lib/components/TafForm/TafFormRow/weather.d.ts +8 -3
- package/lib/components/TafForm/TafFormWrapper.d.ts +2 -2
- package/lib/components/TafForm/TafFormWrapper.stories.d.ts +1 -0
- package/lib/components/TafForm/utils.d.ts +14 -10
- package/lib/components/TafList/TafList.stories.d.ts +1 -0
- package/lib/types.d.ts +44 -3
- package/lib/utils/api.d.ts +1 -1
- package/lib/utils/mockdata/fakeTafList.d.ts +1 -0
- package/package.json +10 -10
- package/taf.esm.js +1089 -793
- package/taf.umd.js +550 -400
package/taf.esm.js
CHANGED
|
@@ -1,124 +1,177 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { makeStyles, Grid, TextField, IconButton, Tooltip, Chip, SvgIcon,
|
|
3
|
+
import { makeStyles, Grid, TextField, IconButton, Tooltip, Chip, SvgIcon, Typography, Button, Dialog, DialogTitle, DialogContent, Card, Accordion, AccordionSummary, AccordionDetails, Backdrop, CircularProgress } from '@material-ui/core';
|
|
4
4
|
import { Skeleton } from '@material-ui/lab';
|
|
5
5
|
import moment from 'moment';
|
|
6
|
-
import { useDraftFormHelpers, useConfirmationDialog, usePreventBrowserClose, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
|
|
7
|
-
import { Delete,
|
|
6
|
+
import { useIsMounted, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, usePrevious, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
|
|
7
|
+
import { Delete, DragIndicator, Add, Close, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@material-ui/icons';
|
|
8
8
|
import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
|
|
9
9
|
import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
|
|
10
10
|
import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
|
|
11
11
|
import { ReactSortable, Sortable } from 'react-sortablejs';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
13
|
+
function _typeof(obj) {
|
|
14
|
+
"@babel/helpers - typeof";
|
|
15
|
+
|
|
16
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
17
|
+
_typeof = function (obj) {
|
|
18
|
+
return typeof obj;
|
|
19
|
+
};
|
|
20
|
+
} else {
|
|
21
|
+
_typeof = function (obj) {
|
|
22
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return _typeof(obj);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _defineProperty(obj, key, value) {
|
|
30
|
+
if (key in obj) {
|
|
31
|
+
Object.defineProperty(obj, key, {
|
|
32
|
+
value: value,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
obj[key] = value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _slicedToArray(arr, i) {
|
|
45
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _toArray(arr) {
|
|
49
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _toConsumableArray(arr) {
|
|
53
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _arrayWithoutHoles(arr) {
|
|
57
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _arrayWithHoles(arr) {
|
|
61
|
+
if (Array.isArray(arr)) return arr;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _iterableToArray(iter) {
|
|
65
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _iterableToArrayLimit(arr, i) {
|
|
69
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
70
|
+
var _arr = [];
|
|
71
|
+
var _n = true;
|
|
72
|
+
var _d = false;
|
|
73
|
+
var _e = undefined;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
77
|
+
_arr.push(_s.value);
|
|
78
|
+
|
|
79
|
+
if (i && _arr.length === i) break;
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
_d = true;
|
|
83
|
+
_e = err;
|
|
84
|
+
} finally {
|
|
85
|
+
try {
|
|
86
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
87
|
+
} finally {
|
|
88
|
+
if (_d) throw _e;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return _arr;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
96
|
+
if (!o) return;
|
|
97
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
98
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
99
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
100
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
101
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _arrayLikeToArray(arr, len) {
|
|
105
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
106
|
+
|
|
107
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
108
|
+
|
|
109
|
+
return arr2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function _nonIterableSpread() {
|
|
113
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function _nonIterableRest() {
|
|
117
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
121
|
+
var it;
|
|
122
|
+
|
|
123
|
+
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
124
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
125
|
+
if (it) o = it;
|
|
126
|
+
var i = 0;
|
|
127
|
+
|
|
128
|
+
var F = function () {};
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
s: F,
|
|
132
|
+
n: function () {
|
|
133
|
+
if (i >= o.length) return {
|
|
134
|
+
done: true
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
done: false,
|
|
138
|
+
value: o[i++]
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
e: function (e) {
|
|
142
|
+
throw e;
|
|
143
|
+
},
|
|
144
|
+
f: F
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var normalCompletion = true,
|
|
152
|
+
didErr = false,
|
|
153
|
+
err;
|
|
154
|
+
return {
|
|
155
|
+
s: function () {
|
|
156
|
+
it = o[Symbol.iterator]();
|
|
157
|
+
},
|
|
158
|
+
n: function () {
|
|
159
|
+
var step = it.next();
|
|
160
|
+
normalCompletion = step.done;
|
|
161
|
+
return step;
|
|
162
|
+
},
|
|
163
|
+
e: function (e) {
|
|
164
|
+
didErr = true;
|
|
165
|
+
err = e;
|
|
166
|
+
},
|
|
167
|
+
f: function () {
|
|
168
|
+
try {
|
|
169
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
170
|
+
} finally {
|
|
171
|
+
if (didErr) throw err;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
122
175
|
}
|
|
123
176
|
|
|
124
177
|
/* *
|
|
@@ -177,20 +230,41 @@ var tafConfig = {
|
|
|
177
230
|
locations: locations
|
|
178
231
|
};
|
|
179
232
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
233
|
+
/*! *****************************************************************************
|
|
234
|
+
Copyright (c) Microsoft Corporation.
|
|
235
|
+
|
|
236
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
237
|
+
purpose with or without fee is hereby granted.
|
|
238
|
+
|
|
239
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
240
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
241
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
242
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
243
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
244
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
245
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
246
|
+
***************************************************************************** */
|
|
247
|
+
|
|
248
|
+
function __rest(s, e) {
|
|
249
|
+
var t = {};
|
|
250
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
251
|
+
t[p] = s[p];
|
|
252
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
253
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
254
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
255
|
+
t[p[i]] = s[p[i]];
|
|
256
|
+
}
|
|
257
|
+
return t;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
261
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
262
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
263
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
264
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
265
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
266
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
267
|
+
});
|
|
194
268
|
}
|
|
195
269
|
|
|
196
270
|
/* *
|
|
@@ -209,19 +283,21 @@ function _typeof(obj) {
|
|
|
209
283
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
210
284
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
211
285
|
* */
|
|
286
|
+
var FORMAT_DAYS_HOURS = 'DDHH';
|
|
287
|
+
var FORMAT_DAYS_HOURS_MINUTS = 'DDHHmm'; // formatters
|
|
212
288
|
|
|
213
289
|
var formatValidToString = function formatValidToString(valid) {
|
|
214
290
|
// Ensure end of valid period if midnight is shown as 24 and not 00
|
|
215
291
|
var endHours = moment.utc(valid.end).format('kk');
|
|
216
292
|
var endDate = endHours === '24' ? moment.utc(valid.end).add(-1, 'day').format('DD') : moment.utc(valid.end).format('DD');
|
|
217
|
-
return valid.end ? moment.utc(valid.start).format(
|
|
293
|
+
return valid.end ? "".concat(moment.utc(valid.start).format(FORMAT_DAYS_HOURS), "/").concat(endDate).concat(endHours) : moment.utc(valid.start).format(FORMAT_DAYS_HOURS_MINUTS);
|
|
218
294
|
};
|
|
219
295
|
|
|
220
296
|
var getSections = function getSections(value, format) {
|
|
221
297
|
return {
|
|
222
298
|
day: parseInt(value.substring(0, 2), 10),
|
|
223
299
|
hour: parseInt(value.substring(2, 4), 10),
|
|
224
|
-
min: format ===
|
|
300
|
+
min: format === FORMAT_DAYS_HOURS_MINUTS ? parseInt(value.substring(4), 10) : 0
|
|
225
301
|
};
|
|
226
302
|
};
|
|
227
303
|
|
|
@@ -251,7 +327,7 @@ var parseValidToObject = function parseValidToObject(value, tafStart, tafEnd) {
|
|
|
251
327
|
var tafStartMoment = moment.utc(tafStart);
|
|
252
328
|
var tafEndMoment = moment.utc(tafEnd);
|
|
253
329
|
var startEnd = trimmedValue.split('/');
|
|
254
|
-
var format = trimmedValue.indexOf('/') === -1 ?
|
|
330
|
+
var format = trimmedValue.indexOf('/') === -1 ? FORMAT_DAYS_HOURS_MINUTS : FORMAT_DAYS_HOURS;
|
|
255
331
|
var startSections = getSections(startEnd[0], format);
|
|
256
332
|
var start = getValidityTimeStamp('start', startSections, tafStartMoment, tafEndMoment).format('YYYY-MM-DDTHH:mm:ss[Z]'); // If we only have start value - return that otherwise, also get end time
|
|
257
333
|
|
|
@@ -261,7 +337,7 @@ var parseValidToObject = function parseValidToObject(value, tafStart, tafEnd) {
|
|
|
261
337
|
};
|
|
262
338
|
}
|
|
263
339
|
|
|
264
|
-
var endSections = getSections(startEnd[1],
|
|
340
|
+
var endSections = getSections(startEnd[1], FORMAT_DAYS_HOURS);
|
|
265
341
|
var end = getValidityTimeStamp('end', endSections, tafStartMoment, tafEndMoment).format('YYYY-MM-DDTHH:mm:ss[Z]');
|
|
266
342
|
return {
|
|
267
343
|
start: start,
|
|
@@ -275,8 +351,8 @@ var invalidValidityMinutesMessage = 'Invalid validity period, specified minutes
|
|
|
275
351
|
var invalidValidityStartTimeMessage = 'Invalid validity start time, change group validity must lie within the TAF validity period';
|
|
276
352
|
var invalidValidityPeriodMessage = 'Invalid validity period, validity end time has to be after validity start time';
|
|
277
353
|
var invalidValidityEndTimeMessage = 'Invalid validity end time, change group validity must lie within the TAF validity period';
|
|
278
|
-
var
|
|
279
|
-
var
|
|
354
|
+
var invalidChangeValidInterFieldMessage = 'Invalid validity period, expected DDHH/DDHH for BECMG and TEMPO or DDHHmm for FM';
|
|
355
|
+
var invalidBECMGDurationValidInterFieldMessage = 'Invalid validity period, for BECMG only validity periods with a duration of 1, 2, 3 or 4 hours are allowed'; // Validations
|
|
280
356
|
// Ensure all individual sections are correct (DD HH mm etc)
|
|
281
357
|
|
|
282
358
|
var validateValidSections = function validateValidSections(sections, isStartEnd) {
|
|
@@ -300,7 +376,7 @@ var validateIsValidDates = function validateIsValidDates(value, tafStart, tafEnd
|
|
|
300
376
|
var tafStartMoment = moment.utc(tafStart);
|
|
301
377
|
var tafEndMoment = moment.utc(tafEnd);
|
|
302
378
|
var startEnd = value.split('/');
|
|
303
|
-
var format = value.indexOf('/') === -1 ?
|
|
379
|
+
var format = value.indexOf('/') === -1 ? FORMAT_DAYS_HOURS_MINUTS : FORMAT_DAYS_HOURS;
|
|
304
380
|
var validateMsg = []; // Validate start time
|
|
305
381
|
|
|
306
382
|
var startSections = getSections(startEnd[0], format); // Validate individual sections for start
|
|
@@ -316,7 +392,7 @@ var validateIsValidDates = function validateIsValidDates(value, tafStart, tafEnd
|
|
|
316
392
|
|
|
317
393
|
|
|
318
394
|
if (startEnd.length > 1) {
|
|
319
|
-
var endSections = getSections(startEnd[1],
|
|
395
|
+
var endSections = getSections(startEnd[1], FORMAT_DAYS_HOURS); // Validate individual sections for end
|
|
320
396
|
|
|
321
397
|
var sectionValidationEnd = validateValidSections(endSections, 'end'); // If invalid end - return with errors
|
|
322
398
|
|
|
@@ -346,7 +422,7 @@ var validateValidField = function validateValidField(value, tafStart, tafEnd) {
|
|
|
346
422
|
|
|
347
423
|
|
|
348
424
|
if (trimmedValue.length < 6 || trimmedValue.length > 9 || !(trimmedValue.match(/^[0-9]{4}\/[0-9]{4}$/) || trimmedValue.match(/^[0-9]{6}$/))) {
|
|
349
|
-
return
|
|
425
|
+
return invalidChangeValidInterFieldMessage;
|
|
350
426
|
} // Ensure valid date(s) can be made
|
|
351
427
|
|
|
352
428
|
|
|
@@ -360,16 +436,89 @@ var validateValidField = function validateValidField(value, tafStart, tafEnd) {
|
|
|
360
436
|
|
|
361
437
|
return true;
|
|
362
438
|
};
|
|
363
|
-
var validateValidChangeGroupInterField = function validateValidChangeGroupInterField(value, valueChange) {
|
|
439
|
+
var validateValidChangeGroupInterField = function validateValidChangeGroupInterField(value, valueChange, tafStart, tafEnd) {
|
|
364
440
|
var trimmedValue = value.trim();
|
|
365
441
|
var trimmedValueChange = valueChange.trim();
|
|
366
442
|
|
|
367
443
|
if (!trimmedValue.length) {
|
|
368
444
|
return true;
|
|
445
|
+
} // Ensure format for FM changegroups is correct DDHHmm
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
if (trimmedValue.length > 6 && trimmedValueChange === 'FM' || trimmedValue.length < 9 && trimmedValueChange !== 'FM') {
|
|
449
|
+
return invalidChangeValidInterFieldMessage;
|
|
450
|
+
} // Ensure BECMG changegroup has duration of 1,2,3,4 hours
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
if (trimmedValueChange === 'BECMG') {
|
|
454
|
+
var tafStartMoment = moment.utc(tafStart);
|
|
455
|
+
var tafEndMoment = moment.utc(tafEnd);
|
|
456
|
+
var startEnd = trimmedValue.split('/');
|
|
457
|
+
var format = trimmedValue.indexOf('/') === -1 ? FORMAT_DAYS_HOURS_MINUTS : FORMAT_DAYS_HOURS; // Validate start time
|
|
458
|
+
|
|
459
|
+
var startSections = getSections(startEnd[0], format);
|
|
460
|
+
var startTimestamp = getValidityTimeStamp('start', startSections, tafStartMoment, tafEndMoment);
|
|
461
|
+
var endSections = getSections(startEnd[1], FORMAT_DAYS_HOURS);
|
|
462
|
+
var endTimestamp = getValidityTimeStamp('end', endSections, tafStartMoment, tafEndMoment);
|
|
463
|
+
var timeDifference = endTimestamp.diff(startTimestamp, 'hours');
|
|
464
|
+
|
|
465
|
+
if (![1, 2, 3, 4].includes(timeDifference)) {
|
|
466
|
+
return invalidBECMGDurationValidInterFieldMessage;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return true;
|
|
471
|
+
}; // validate previous changeGroup
|
|
472
|
+
|
|
473
|
+
var validProbChangeOrder = ['FM', 'BECMG', 'TEMPO', 'PROB40', 'PROB30', 'PROB40 TEMPO', 'PROB30 TEMPO'];
|
|
474
|
+
var invalidPreviousChangeGroupIsBeforeMessage = 'Valid time should be after previous valid time';
|
|
475
|
+
var invalidPreviousChangeGroupOrderMessage = "When valid times are equal, the change/probability order should be: ".concat(validProbChangeOrder.join(', '));
|
|
476
|
+
var invalidPreviousChangeGroupHasSameValue = "When valid times are equal, probability/change can't have the same value as previous row value";
|
|
477
|
+
var validatePreviousChangeGroup = function validatePreviousChangeGroup(currentChangeGroup, nextChangeGroup, tafStart, tafEnd) {
|
|
478
|
+
// extract the needed values from changeGroups
|
|
479
|
+
var valid = currentChangeGroup.valid,
|
|
480
|
+
_currentChangeGroup$c = currentChangeGroup.change,
|
|
481
|
+
change = _currentChangeGroup$c === void 0 ? '' : _currentChangeGroup$c,
|
|
482
|
+
_currentChangeGroup$p = currentChangeGroup.probability,
|
|
483
|
+
probability = _currentChangeGroup$p === void 0 ? '' : _currentChangeGroup$p;
|
|
484
|
+
var previousValid = nextChangeGroup.valid,
|
|
485
|
+
_nextChangeGroup$chan = nextChangeGroup.change,
|
|
486
|
+
previousChange = _nextChangeGroup$chan === void 0 ? '' : _nextChangeGroup$chan,
|
|
487
|
+
_nextChangeGroup$prob = nextChangeGroup.probability,
|
|
488
|
+
previousProbability = _nextChangeGroup$prob === void 0 ? '' : _nextChangeGroup$prob; // get the parsed values
|
|
489
|
+
|
|
490
|
+
var validValue = parseValidToObject(valid, tafStart, tafEnd);
|
|
491
|
+
var previousValidValue = parseValidToObject(previousValid, tafStart, tafEnd);
|
|
492
|
+
|
|
493
|
+
if (!validValue || !previousValidValue || !change.length && !probability.length) {
|
|
494
|
+
return true;
|
|
495
|
+
} // validate is valid time before
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
var currentStartTime = moment(validValue.start);
|
|
499
|
+
var previousRowStartTime = moment(previousValidValue.start);
|
|
500
|
+
|
|
501
|
+
if (currentStartTime.isBefore(previousRowStartTime)) {
|
|
502
|
+
return invalidPreviousChangeGroupIsBeforeMessage;
|
|
503
|
+
} // validate same valid time
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
if (currentStartTime.isSame(previousRowStartTime)) {
|
|
507
|
+
// validate change/probability order
|
|
508
|
+
var currentProbChangeValue = "".concat(probability, " ").concat(change).trim();
|
|
509
|
+
var previousProbChangeValue = "".concat(previousProbability, " ").concat(previousChange).trim();
|
|
510
|
+
|
|
511
|
+
if (validProbChangeOrder.indexOf(currentProbChangeValue) < validProbChangeOrder.indexOf(previousProbChangeValue)) {
|
|
512
|
+
return invalidPreviousChangeGroupOrderMessage;
|
|
513
|
+
} // validate same valid + change/probability value
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
if (currentProbChangeValue === previousProbChangeValue) {
|
|
517
|
+
return invalidPreviousChangeGroupHasSameValue;
|
|
518
|
+
}
|
|
369
519
|
}
|
|
370
520
|
|
|
371
|
-
|
|
372
|
-
return isValid ? true : invalidChangeValidInterFieldMessage;
|
|
521
|
+
return true;
|
|
373
522
|
};
|
|
374
523
|
|
|
375
524
|
/* *
|
|
@@ -388,11 +537,10 @@ var validateValidChangeGroupInterField = function validateValidChangeGroupInterF
|
|
|
388
537
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
389
538
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
390
539
|
* */
|
|
391
|
-
|
|
392
540
|
var prependZeroes = function prependZeroes(value, totalDigits) {
|
|
393
541
|
var valueAsString = value.toString();
|
|
394
|
-
return
|
|
395
|
-
return "0"
|
|
542
|
+
return _toConsumableArray(Array(totalDigits - valueAsString.length)).reduce(function (newVal) {
|
|
543
|
+
return "0".concat(newVal);
|
|
396
544
|
}, valueAsString);
|
|
397
545
|
};
|
|
398
546
|
|
|
@@ -404,9 +552,7 @@ var config$1 = [{
|
|
|
404
552
|
size: 1
|
|
405
553
|
}];
|
|
406
554
|
var configAsObject$1 = Object.assign(config$1).reduce(function (list, item) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return __assign(__assign({}, list), (_a = {}, _a[item.key] = item, _a));
|
|
555
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, item.key, item));
|
|
410
556
|
}, {}); // formatters
|
|
411
557
|
// if passed true - visibility is CAVOK, if passed a number - prepend zeroes to size 4
|
|
412
558
|
|
|
@@ -943,22 +1089,59 @@ var WeatherPhenomena;
|
|
|
943
1089
|
})(WeatherPhenomena || (WeatherPhenomena = {}));
|
|
944
1090
|
|
|
945
1091
|
var invalidWeatherMessage = 'Invalid weather input, expected NSW or a valid weather code';
|
|
1092
|
+
var invalidWeatherCodeMessage = 'Invalid weather input, invalid weather code';
|
|
946
1093
|
var invalidWeatherNSWMessage = 'Invalid weather input, NSW is not allowed in the baseforecast and can only be used in the first weather group';
|
|
947
1094
|
var invalidWeatherWithPreviousEmptyWeather = 'Invalid weather input, value is not allowed when previous weather group(s) are empty';
|
|
948
1095
|
var invalidWeatherNonUniqueValue = 'Invalid weather input, weather groups must be unique';
|
|
949
|
-
var invalidWeatherNonEmptyNSWGroups = 'Invalid weather input, when NSW is used, other weather groups must be empty';
|
|
1096
|
+
var invalidWeatherNonEmptyNSWGroups = 'Invalid weather input, when NSW is used, other weather groups must be empty';
|
|
1097
|
+
var invalidWeatherCAVOKMessage = 'Invalid weather input, when CAVOK is used, weather groups must be empty';
|
|
1098
|
+
var invalidWeatherVisibilityBelow5000 = 'Invalid weather input, weather codes FU, DU, HZ, DRDU and BLDU need to be combined with a visibility of 5000m or less';
|
|
1099
|
+
var invalidWeatherBRVisibility = 'Invalid weather input, weather code BR needs to be combined with a visibility between 1000 and 5000m';
|
|
1100
|
+
var invalidWeatherFGVisibility = 'Invalid weather input, weather code FG needs to be combined with a visibility below 1000m'; // validations
|
|
1101
|
+
|
|
1102
|
+
var WeatherVisibilityBelow5000 = [WeatherPhenomena.FU, WeatherPhenomena.DU, WeatherPhenomena.HZ, WeatherPhenomena.DRDU, WeatherPhenomena.BLDU];
|
|
1103
|
+
var validateWeatherField = function validateWeatherField(value, visibilityValue) {
|
|
1104
|
+
var NSWAllowed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1105
|
+
var trimmedValue = value.trim(); // if empty, validate as true
|
|
1106
|
+
|
|
1107
|
+
if (trimmedValue === '') {
|
|
1108
|
+
return true;
|
|
1109
|
+
} // In case of NSW - validate if allowed
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
if (trimmedValue === 'NSW' && !NSWAllowed) {
|
|
1113
|
+
return invalidWeatherNSWMessage;
|
|
1114
|
+
} // Check if cavOK - then weather group should be empty
|
|
1115
|
+
|
|
950
1116
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1117
|
+
if (trimmedValue && visibilityValue === 'CAVOK') {
|
|
1118
|
+
return invalidWeatherCAVOKMessage;
|
|
1119
|
+
} // Validate if entered weather is one of the allowed weather phenomena
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
if (!(trimmedValue in WeatherPhenomena) && trimmedValue !== 'NSW') {
|
|
1123
|
+
return NSWAllowed ? invalidWeatherMessage : invalidWeatherCodeMessage;
|
|
1124
|
+
} // Validate the weather code in combination with the visibility range
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
var visibilityRange = parseInt(visibilityValue, 10);
|
|
1128
|
+
|
|
1129
|
+
if (WeatherVisibilityBelow5000.includes(trimmedValue) && visibilityRange > 5000) {
|
|
1130
|
+
return invalidWeatherVisibilityBelow5000;
|
|
954
1131
|
}
|
|
955
1132
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1133
|
+
if (trimmedValue === WeatherPhenomena.BR && (visibilityRange < 1000 || visibilityRange > 5000)) {
|
|
1134
|
+
return invalidWeatherBRVisibility;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
if (trimmedValue === WeatherPhenomena.FG && visibilityRange >= 1000) {
|
|
1138
|
+
return invalidWeatherFGVisibility;
|
|
1139
|
+
} // Everything validated ok - return true
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
return true;
|
|
960
1143
|
};
|
|
961
|
-
var validateSecondWeatherField = function validateSecondWeatherField(weather1Value, weather2Value) {
|
|
1144
|
+
var validateSecondWeatherField = function validateSecondWeatherField(weather1Value, weather2Value, visibilityValue) {
|
|
962
1145
|
var trimmedWeather2Value = weather2Value.trim(); // Field can be left empty
|
|
963
1146
|
|
|
964
1147
|
if (!trimmedWeather2Value.length) {
|
|
@@ -981,9 +1164,9 @@ var validateSecondWeatherField = function validateSecondWeatherField(weather1Val
|
|
|
981
1164
|
return invalidWeatherNonUniqueValue;
|
|
982
1165
|
}
|
|
983
1166
|
|
|
984
|
-
return validateWeatherField(weather2Value, false);
|
|
1167
|
+
return validateWeatherField(weather2Value, visibilityValue, false);
|
|
985
1168
|
};
|
|
986
|
-
var validateThirdWeatherField = function validateThirdWeatherField(weather1Value, weather2Value, weather3Value) {
|
|
1169
|
+
var validateThirdWeatherField = function validateThirdWeatherField(weather1Value, weather2Value, weather3Value, visibilityValue) {
|
|
987
1170
|
var trimmedWeather3Value = weather3Value.trim(); // Field can be left empty
|
|
988
1171
|
|
|
989
1172
|
if (!trimmedWeather3Value.length) {
|
|
@@ -1007,25 +1190,23 @@ var validateThirdWeatherField = function validateThirdWeatherField(weather1Value
|
|
|
1007
1190
|
return invalidWeatherNonUniqueValue;
|
|
1008
1191
|
}
|
|
1009
1192
|
|
|
1010
|
-
return validateWeatherField(weather3Value, false);
|
|
1193
|
+
return validateWeatherField(weather3Value, visibilityValue, false);
|
|
1011
1194
|
}; // parser
|
|
1012
1195
|
// TODO: value type = Weather, but couldn't get it to work properly https://gitlab.com/opengeoweb/opengeoweb/-/issues/119
|
|
1013
1196
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1014
1197
|
|
|
1015
1198
|
function parseWeatherToObject(value) {
|
|
1016
1199
|
var trimmedWeather = Object.keys(value).reduce(function (obj, key) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1200
|
+
// only parse it if it has a value
|
|
1020
1201
|
if (value[key] && value[key].trim()) {
|
|
1021
|
-
return
|
|
1202
|
+
return Object.assign(Object.assign({}, obj), _defineProperty({}, key, obj[key].trim()));
|
|
1022
1203
|
} // if it doesn't have a value, remove it from the list
|
|
1023
1204
|
|
|
1024
1205
|
|
|
1025
|
-
var
|
|
1026
|
-
|
|
1027
|
-
_b
|
|
1028
|
-
var rest = __rest(
|
|
1206
|
+
var _a = obj,
|
|
1207
|
+
_b = key;
|
|
1208
|
+
_a[_b];
|
|
1209
|
+
var rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
1029
1210
|
|
|
1030
1211
|
return rest;
|
|
1031
1212
|
}, value);
|
|
@@ -1050,9 +1231,7 @@ var config = [{
|
|
|
1050
1231
|
size: 2
|
|
1051
1232
|
}];
|
|
1052
1233
|
var configAsObject = Object.assign(config).reduce(function (list, item) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
return __assign(__assign({}, list), (_a = {}, _a[item.key] = item, _a));
|
|
1234
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, item.key, item));
|
|
1056
1235
|
}, {}); // wind formatters:
|
|
1057
1236
|
|
|
1058
1237
|
var formatWindValues = function formatWindValues(key, value) {
|
|
@@ -1073,22 +1252,22 @@ var formatWindValues = function formatWindValues(key, value) {
|
|
|
1073
1252
|
return 'P99';
|
|
1074
1253
|
}
|
|
1075
1254
|
|
|
1076
|
-
var
|
|
1077
|
-
return prependZeroes(value,
|
|
1255
|
+
var _size = configAsObject[key].size;
|
|
1256
|
+
return prependZeroes(value, _size);
|
|
1078
1257
|
}
|
|
1079
1258
|
|
|
1080
1259
|
case 'gust':
|
|
1081
1260
|
{
|
|
1082
1261
|
// if there is a P as first character - return P99
|
|
1083
|
-
var
|
|
1262
|
+
var _valueAsString = value.toString();
|
|
1084
1263
|
|
|
1085
|
-
if (
|
|
1264
|
+
if (_valueAsString.length && _valueAsString[0] === 'P') {
|
|
1086
1265
|
return 'GP99';
|
|
1087
1266
|
}
|
|
1088
1267
|
|
|
1089
|
-
var
|
|
1090
|
-
var newValue = prependZeroes(value,
|
|
1091
|
-
return "G"
|
|
1268
|
+
var _size2 = configAsObject[key].size;
|
|
1269
|
+
var newValue = prependZeroes(value, _size2);
|
|
1270
|
+
return "G".concat(newValue.toString());
|
|
1092
1271
|
}
|
|
1093
1272
|
|
|
1094
1273
|
case 'unit':
|
|
@@ -1115,11 +1294,8 @@ var formatWindToString = function formatWindToString(value) {
|
|
|
1115
1294
|
}, '');
|
|
1116
1295
|
};
|
|
1117
1296
|
|
|
1118
|
-
var extractValidateWindSections = function extractValidateWindSections(value
|
|
1119
|
-
|
|
1120
|
-
validation = false;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1297
|
+
var extractValidateWindSections = function extractValidateWindSections(value) {
|
|
1298
|
+
var validation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1123
1299
|
return config.reduce(function (obj, item) {
|
|
1124
1300
|
var key = item.key,
|
|
1125
1301
|
size = item.size;
|
|
@@ -1136,14 +1312,14 @@ var extractValidateWindSections = function extractValidateWindSections(value, va
|
|
|
1136
1312
|
var valDirection = validateDirection(direction); // If validated not ok - add validation feedback
|
|
1137
1313
|
|
|
1138
1314
|
var validations = valDirection !== true ? obj.validations.concat(valDirection) : obj.validations;
|
|
1139
|
-
return
|
|
1315
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1140
1316
|
direction: direction,
|
|
1141
1317
|
remainder: remainder,
|
|
1142
1318
|
validations: validations
|
|
1143
1319
|
});
|
|
1144
1320
|
}
|
|
1145
1321
|
|
|
1146
|
-
return
|
|
1322
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1147
1323
|
direction: direction,
|
|
1148
1324
|
remainder: remainder
|
|
1149
1325
|
});
|
|
@@ -1156,22 +1332,25 @@ var extractValidateWindSections = function extractValidateWindSections(value, va
|
|
|
1156
1332
|
|
|
1157
1333
|
var dirLength = obj.remainder.length && obj.remainder[0] === 'P' ? maxSize : minSize;
|
|
1158
1334
|
var speed = obj.remainder.slice(0, dirLength);
|
|
1159
|
-
|
|
1335
|
+
|
|
1336
|
+
var _remainder = obj.remainder.substring(dirLength); // Validate speed
|
|
1337
|
+
|
|
1160
1338
|
|
|
1161
1339
|
if (validation) {
|
|
1162
1340
|
var valSpeed = validateSpeed(speed); // If validated not ok - add validation feedback
|
|
1163
1341
|
|
|
1164
|
-
var
|
|
1165
|
-
|
|
1342
|
+
var _validations = valSpeed !== true ? obj.validations.concat(valSpeed) : obj.validations;
|
|
1343
|
+
|
|
1344
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1166
1345
|
speed: speed,
|
|
1167
|
-
remainder:
|
|
1168
|
-
validations:
|
|
1346
|
+
remainder: _remainder,
|
|
1347
|
+
validations: _validations
|
|
1169
1348
|
});
|
|
1170
1349
|
}
|
|
1171
1350
|
|
|
1172
|
-
return
|
|
1351
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1173
1352
|
speed: speed,
|
|
1174
|
-
remainder:
|
|
1353
|
+
remainder: _remainder
|
|
1175
1354
|
});
|
|
1176
1355
|
}
|
|
1177
1356
|
|
|
@@ -1179,30 +1358,35 @@ var extractValidateWindSections = function extractValidateWindSections(value, va
|
|
|
1179
1358
|
{
|
|
1180
1359
|
// Only parse gust if still chars left and these start with G
|
|
1181
1360
|
if (obj.remainder.length && obj.remainder !== 'KT' && obj.remainder[0] === 'G') {
|
|
1182
|
-
var
|
|
1183
|
-
|
|
1361
|
+
var _maxSize = item.maxSize,
|
|
1362
|
+
_minSize = item.minSize; // Remove G
|
|
1184
1363
|
|
|
1185
1364
|
var rest = obj.remainder.substring(1); // In case the first char of the gust is a P - it's 3 chars long, otherwise 2
|
|
1186
1365
|
|
|
1187
|
-
var
|
|
1188
|
-
|
|
1189
|
-
var
|
|
1366
|
+
var _dirLength = rest[0] === 'P' ? _maxSize : _minSize;
|
|
1367
|
+
|
|
1368
|
+
var gust = rest.slice(0, _dirLength);
|
|
1369
|
+
|
|
1370
|
+
var _remainder2 = rest.substring(_dirLength); // Validate gusts
|
|
1371
|
+
|
|
1190
1372
|
|
|
1191
1373
|
if (validation) {
|
|
1192
1374
|
var valGust = validateGust(gust); // If validated not ok - add validation feedback
|
|
1193
1375
|
|
|
1194
1376
|
valGust !== true && returnObj.validations.push(valGust);
|
|
1195
|
-
|
|
1196
|
-
|
|
1377
|
+
|
|
1378
|
+
var _validations2 = valGust !== true ? obj.validations.concat(valGust) : obj.validations;
|
|
1379
|
+
|
|
1380
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1197
1381
|
gust: gust,
|
|
1198
|
-
remainder:
|
|
1199
|
-
validations:
|
|
1382
|
+
remainder: _remainder2,
|
|
1383
|
+
validations: _validations2
|
|
1200
1384
|
});
|
|
1201
1385
|
}
|
|
1202
1386
|
|
|
1203
|
-
return
|
|
1387
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1204
1388
|
gust: gust,
|
|
1205
|
-
remainder:
|
|
1389
|
+
remainder: _remainder2
|
|
1206
1390
|
});
|
|
1207
1391
|
}
|
|
1208
1392
|
|
|
@@ -1214,9 +1398,11 @@ var extractValidateWindSections = function extractValidateWindSections(value, va
|
|
|
1214
1398
|
if (obj.remainder.length) {
|
|
1215
1399
|
// Validate units
|
|
1216
1400
|
var valUnits = validateUnit(returnObj.remainder);
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1401
|
+
|
|
1402
|
+
var _validations3 = valUnits !== true ? obj.validations.concat(valUnits) : obj.validations;
|
|
1403
|
+
|
|
1404
|
+
return Object.assign(Object.assign({}, obj), {
|
|
1405
|
+
validations: _validations3
|
|
1220
1406
|
});
|
|
1221
1407
|
}
|
|
1222
1408
|
|
|
@@ -1243,8 +1429,7 @@ var parseWindToObject = function parseWindToObject(value) {
|
|
|
1243
1429
|
|
|
1244
1430
|
var windSections = extractValidateWindSections(trimmedValue, false);
|
|
1245
1431
|
var gust = windSections.gust === 'P99' || windSections.gust === '' ? windSections.gust : parseInt(windSections.gust, 10);
|
|
1246
|
-
|
|
1247
|
-
var windObject = __assign(__assign({
|
|
1432
|
+
var windObject = Object.assign(Object.assign({
|
|
1248
1433
|
direction: windSections.direction === 'VRB' ? windSections.direction : parseInt(windSections.direction, 10),
|
|
1249
1434
|
speed: windSections.speed === 'P99' ? windSections.speed : parseInt(windSections.speed, 10)
|
|
1250
1435
|
}, gust !== '' ? {
|
|
@@ -1252,7 +1437,6 @@ var parseWindToObject = function parseWindToObject(value) {
|
|
|
1252
1437
|
} : {}), {
|
|
1253
1438
|
unit: windSections.unit
|
|
1254
1439
|
});
|
|
1255
|
-
|
|
1256
1440
|
return windObject;
|
|
1257
1441
|
}; // messages
|
|
1258
1442
|
|
|
@@ -1351,7 +1535,7 @@ var validateWindField = function validateWindField(value) {
|
|
|
1351
1535
|
|
|
1352
1536
|
var formatSingleCloud = function formatSingleCloud(value) {
|
|
1353
1537
|
if (!value) return null;
|
|
1354
|
-
return value.type ? ""
|
|
1538
|
+
return value.type ? "".concat(value.coverage).concat(prependZeroes(value.height, 3)).concat(value.type) : "".concat(value.coverage).concat(prependZeroes(value.height, 3));
|
|
1355
1539
|
}; // TODO: clouds type = Clouds, but couldn't get it to work properly https://gitlab.com/opengeoweb/opengeoweb/-/issues/119
|
|
1356
1540
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1357
1541
|
|
|
@@ -1360,30 +1544,28 @@ var formatCloudsToString = function formatCloudsToString(clouds) {
|
|
|
1360
1544
|
if (!clouds) return null;
|
|
1361
1545
|
return Object.keys(clouds).reduce(function (list, key) {
|
|
1362
1546
|
// only format it if it has a value
|
|
1363
|
-
var _a, _b, _c, _d;
|
|
1364
|
-
|
|
1365
1547
|
if (clouds[key]) {
|
|
1366
1548
|
switch (key) {
|
|
1367
1549
|
case 'cloud1':
|
|
1368
1550
|
{
|
|
1369
1551
|
if (clouds[key].verticalVisibility !== undefined) {
|
|
1370
1552
|
// Format Vertical Visibility
|
|
1371
|
-
return
|
|
1553
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, "VV".concat(prependZeroes(clouds[key].verticalVisibility, 3))));
|
|
1372
1554
|
}
|
|
1373
1555
|
|
|
1374
1556
|
if (clouds[key].coverage) {
|
|
1375
1557
|
// Format Cloud
|
|
1376
|
-
return
|
|
1558
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, formatSingleCloud(clouds[key])));
|
|
1377
1559
|
} // Format No Significant Clouds
|
|
1378
1560
|
|
|
1379
1561
|
|
|
1380
|
-
return
|
|
1562
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, clouds[key]));
|
|
1381
1563
|
}
|
|
1382
1564
|
|
|
1383
1565
|
default:
|
|
1384
1566
|
{
|
|
1385
1567
|
// Other cloud keys can only contain a cloud
|
|
1386
|
-
return
|
|
1568
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, formatSingleCloud(clouds[key])));
|
|
1387
1569
|
}
|
|
1388
1570
|
}
|
|
1389
1571
|
}
|
|
@@ -1396,7 +1578,7 @@ var parseSingleCloud = function parseSingleCloud(value) {
|
|
|
1396
1578
|
if (!value) return null;
|
|
1397
1579
|
var trimmedCloud = value.trim();
|
|
1398
1580
|
var cloudType = trimmedCloud.substr(6, 3);
|
|
1399
|
-
return
|
|
1581
|
+
return Object.assign({
|
|
1400
1582
|
coverage: trimmedCloud.substr(0, 3),
|
|
1401
1583
|
height: parseInt(trimmedCloud.substr(3, 3), 10)
|
|
1402
1584
|
}, cloudType && {
|
|
@@ -1409,42 +1591,40 @@ var parseSingleCloud = function parseSingleCloud(value) {
|
|
|
1409
1591
|
var parseCloudsToObject = function parseCloudsToObject(clouds) {
|
|
1410
1592
|
if (!clouds) return null;
|
|
1411
1593
|
return Object.keys(clouds).reduce(function (list, key) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1594
|
+
// only parse it if it has a value
|
|
1415
1595
|
if (clouds[key] && clouds[key].trim()) {
|
|
1416
1596
|
switch (key) {
|
|
1417
1597
|
case 'cloud1':
|
|
1418
1598
|
{
|
|
1419
1599
|
if (isVerticalVisibility(clouds[key])) {
|
|
1420
1600
|
// Parse Vertical Visibility
|
|
1421
|
-
return
|
|
1601
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, {
|
|
1422
1602
|
verticalVisibility: parseInt(clouds[key].substr(2, 3), 10)
|
|
1423
|
-
}
|
|
1603
|
+
}));
|
|
1424
1604
|
}
|
|
1425
1605
|
|
|
1426
1606
|
if (clouds[key] === 'NSC') {
|
|
1427
1607
|
// Parse No Significant Clouds
|
|
1428
|
-
return
|
|
1608
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, clouds[key]));
|
|
1429
1609
|
} // Parse Cloud
|
|
1430
1610
|
|
|
1431
1611
|
|
|
1432
|
-
return
|
|
1612
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, parseSingleCloud(clouds[key])));
|
|
1433
1613
|
}
|
|
1434
1614
|
|
|
1435
1615
|
default:
|
|
1436
1616
|
{
|
|
1437
1617
|
// Other cloud keys can only contain a cloud
|
|
1438
|
-
return
|
|
1618
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, parseSingleCloud(clouds[key])));
|
|
1439
1619
|
}
|
|
1440
1620
|
}
|
|
1441
1621
|
} // if it doesn't have a value, remove it from the list
|
|
1442
1622
|
|
|
1443
1623
|
|
|
1444
|
-
var
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
var rest = __rest(
|
|
1624
|
+
var _a = list,
|
|
1625
|
+
_b = key;
|
|
1626
|
+
_a[_b];
|
|
1627
|
+
var rest = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
1448
1628
|
|
|
1449
1629
|
return rest;
|
|
1450
1630
|
}, clouds);
|
|
@@ -1465,7 +1645,8 @@ var invalidCloud3CoverageTypeCombinationMessage = 'Invalid cloud input, cloud ty
|
|
|
1465
1645
|
var invalidCloudWithVerticalVisibilityMessage = 'Invalid cloud input, third or fourth cloud group is not allowed when Vertical Visibility is given';
|
|
1466
1646
|
var invalidCloudWithPreviousEmptyCloud = 'Invalid cloud input, value is not allowed when previous cloud group is empty';
|
|
1467
1647
|
var invalidCloudWithNSCMessage = 'Invalid cloud input, other cloud groups are not allowed when No Significant Clouds is given';
|
|
1468
|
-
var invalidCloud4WithPreviousType = 'Invalid cloud input, value is not allowed when previous cloud group has a type';
|
|
1648
|
+
var invalidCloud4WithPreviousType = 'Invalid cloud input, value is not allowed when previous cloud group has a type';
|
|
1649
|
+
var invalidCloudCAVOKMessage = 'Invalid cloud input, when CAVOK is used, cloud groups must be empty'; // validations
|
|
1469
1650
|
|
|
1470
1651
|
var isLengthValid = function isLengthValid(value) {
|
|
1471
1652
|
var onlyDigitsOrSpecificLetters = RegExp(/^[0-9FEWSCTBKNOVU]+$/);
|
|
@@ -1536,10 +1717,10 @@ var isVerticalVisibilityValid = function isVerticalVisibilityValid(value) {
|
|
|
1536
1717
|
return true;
|
|
1537
1718
|
};
|
|
1538
1719
|
|
|
1539
|
-
var sharedCloudValidations = function sharedCloudValidations(
|
|
1540
|
-
var value =
|
|
1541
|
-
|
|
1542
|
-
canBeNSC =
|
|
1720
|
+
var sharedCloudValidations = function sharedCloudValidations(_ref) {
|
|
1721
|
+
var value = _ref.value,
|
|
1722
|
+
_ref$canBeNSC = _ref.canBeNSC,
|
|
1723
|
+
canBeNSC = _ref$canBeNSC === void 0 ? false : _ref$canBeNSC;
|
|
1543
1724
|
var errorMessages = []; // Validate length and ensure it doesn't contain any invalid characters
|
|
1544
1725
|
|
|
1545
1726
|
if (!isLengthValid(value)) {
|
|
@@ -1582,11 +1763,15 @@ var sharedCloudValidations = function sharedCloudValidations(_a) {
|
|
|
1582
1763
|
};
|
|
1583
1764
|
};
|
|
1584
1765
|
|
|
1585
|
-
var validateFirstCloud = function validateFirstCloud(value) {
|
|
1766
|
+
var validateFirstCloud = function validateFirstCloud(value, visibilityValue) {
|
|
1586
1767
|
var trimmedValue = value.trim(); // Field can be left empty
|
|
1587
1768
|
|
|
1588
1769
|
if (!trimmedValue.length) {
|
|
1589
1770
|
return true;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
if (trimmedValue && visibilityValue === 'CAVOK') {
|
|
1774
|
+
return invalidCloudCAVOKMessage;
|
|
1590
1775
|
} // Check for No Signicant Clouds
|
|
1591
1776
|
|
|
1592
1777
|
|
|
@@ -1611,14 +1796,16 @@ var validateFirstCloud = function validateFirstCloud(value) {
|
|
|
1611
1796
|
return true;
|
|
1612
1797
|
}
|
|
1613
1798
|
|
|
1614
|
-
var
|
|
1799
|
+
var _sharedCloudValidatio = sharedCloudValidations({
|
|
1615
1800
|
value: trimmedValue,
|
|
1616
1801
|
canBeNSC: true
|
|
1617
|
-
})
|
|
1802
|
+
}),
|
|
1803
|
+
errorMessages = _sharedCloudValidatio.errorMessages; // Return first error if any
|
|
1804
|
+
|
|
1618
1805
|
|
|
1619
1806
|
return errorMessages.length ? errorMessages[0] : true;
|
|
1620
1807
|
};
|
|
1621
|
-
var validateSecondCloud = function validateSecondCloud(firstCloudValue, secondCloudValue) {
|
|
1808
|
+
var validateSecondCloud = function validateSecondCloud(firstCloudValue, secondCloudValue, visibilityValue) {
|
|
1622
1809
|
var trimmedValue = secondCloudValue.trim(); // Field can be left empty
|
|
1623
1810
|
|
|
1624
1811
|
if (!trimmedValue.length) {
|
|
@@ -1626,13 +1813,13 @@ var validateSecondCloud = function validateSecondCloud(firstCloudValue, secondCl
|
|
|
1626
1813
|
} // Generic validations
|
|
1627
1814
|
|
|
1628
1815
|
|
|
1629
|
-
var
|
|
1816
|
+
var _sharedCloudValidatio2 = sharedCloudValidations({
|
|
1630
1817
|
value: trimmedValue
|
|
1631
1818
|
}),
|
|
1632
|
-
coverage =
|
|
1633
|
-
height =
|
|
1634
|
-
type =
|
|
1635
|
-
errorMessages =
|
|
1819
|
+
coverage = _sharedCloudValidatio2.coverage,
|
|
1820
|
+
height = _sharedCloudValidatio2.height,
|
|
1821
|
+
type = _sharedCloudValidatio2.type,
|
|
1822
|
+
errorMessages = _sharedCloudValidatio2.errorMessages; // Return first error if any
|
|
1636
1823
|
|
|
1637
1824
|
|
|
1638
1825
|
if (errorMessages.length) {
|
|
@@ -1646,7 +1833,7 @@ var validateSecondCloud = function validateSecondCloud(firstCloudValue, secondCl
|
|
|
1646
1833
|
} // If Cloud1 is not valid, skip further validation of Cloud2
|
|
1647
1834
|
|
|
1648
1835
|
|
|
1649
|
-
if (validateFirstCloud(firstCloudValue) !== true) {
|
|
1836
|
+
if (validateFirstCloud(firstCloudValue, visibilityValue) !== true) {
|
|
1650
1837
|
return true;
|
|
1651
1838
|
} // If Cloud1 is NSC, Cloud2 has to be empty
|
|
1652
1839
|
|
|
@@ -1676,7 +1863,7 @@ var validateSecondCloud = function validateSecondCloud(firstCloudValue, secondCl
|
|
|
1676
1863
|
|
|
1677
1864
|
return true;
|
|
1678
1865
|
};
|
|
1679
|
-
var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondCloudValue, thirdCloudValue) {
|
|
1866
|
+
var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondCloudValue, thirdCloudValue, visibilityValue) {
|
|
1680
1867
|
var trimmedValue = thirdCloudValue.trim(); // Field can be left empty
|
|
1681
1868
|
|
|
1682
1869
|
if (!trimmedValue.length) {
|
|
@@ -1684,13 +1871,13 @@ var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondClou
|
|
|
1684
1871
|
} // Generic validations
|
|
1685
1872
|
|
|
1686
1873
|
|
|
1687
|
-
var
|
|
1874
|
+
var _sharedCloudValidatio3 = sharedCloudValidations({
|
|
1688
1875
|
value: trimmedValue
|
|
1689
1876
|
}),
|
|
1690
|
-
coverage =
|
|
1691
|
-
height =
|
|
1692
|
-
type =
|
|
1693
|
-
errorMessages =
|
|
1877
|
+
coverage = _sharedCloudValidatio3.coverage,
|
|
1878
|
+
height = _sharedCloudValidatio3.height,
|
|
1879
|
+
type = _sharedCloudValidatio3.type,
|
|
1880
|
+
errorMessages = _sharedCloudValidatio3.errorMessages; // Return generic errors if any
|
|
1694
1881
|
|
|
1695
1882
|
|
|
1696
1883
|
if (errorMessages.length) {
|
|
@@ -1704,7 +1891,7 @@ var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondClou
|
|
|
1704
1891
|
} // If Cloud1 is not valid, skip further validation of Cloud3
|
|
1705
1892
|
|
|
1706
1893
|
|
|
1707
|
-
if (validateFirstCloud(firstCloudValue) !== true) {
|
|
1894
|
+
if (validateFirstCloud(firstCloudValue, visibilityValue) !== true) {
|
|
1708
1895
|
return true;
|
|
1709
1896
|
} // If Cloud1 is empty Cloud3 should be empty
|
|
1710
1897
|
|
|
@@ -1724,7 +1911,7 @@ var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondClou
|
|
|
1724
1911
|
} // If Cloud2 is not valid, skip further validation of Cloud3
|
|
1725
1912
|
|
|
1726
1913
|
|
|
1727
|
-
if (validateSecondCloud(firstCloudValue, secondCloudValue) !== true) {
|
|
1914
|
+
if (validateSecondCloud(firstCloudValue, secondCloudValue, visibilityValue) !== true) {
|
|
1728
1915
|
return true;
|
|
1729
1916
|
} // If Cloud2 is empty Cloud3 should be empty
|
|
1730
1917
|
|
|
@@ -1742,7 +1929,7 @@ var validateThirdCloud = function validateThirdCloud(firstCloudValue, secondClou
|
|
|
1742
1929
|
|
|
1743
1930
|
return true;
|
|
1744
1931
|
};
|
|
1745
|
-
var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCloudValue, thirdCloudValue, fourthCloudValue) {
|
|
1932
|
+
var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCloudValue, thirdCloudValue, fourthCloudValue, visibilityValue) {
|
|
1746
1933
|
var trimmedValue = fourthCloudValue.trim(); // Field can be left empty
|
|
1747
1934
|
|
|
1748
1935
|
if (!trimmedValue.length) {
|
|
@@ -1750,12 +1937,12 @@ var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCl
|
|
|
1750
1937
|
} // Generic validations
|
|
1751
1938
|
|
|
1752
1939
|
|
|
1753
|
-
var
|
|
1940
|
+
var _sharedCloudValidatio4 = sharedCloudValidations({
|
|
1754
1941
|
value: trimmedValue
|
|
1755
1942
|
}),
|
|
1756
|
-
height =
|
|
1757
|
-
type =
|
|
1758
|
-
errorMessages =
|
|
1943
|
+
height = _sharedCloudValidatio4.height,
|
|
1944
|
+
type = _sharedCloudValidatio4.type,
|
|
1945
|
+
errorMessages = _sharedCloudValidatio4.errorMessages; // Return generic errors if any
|
|
1759
1946
|
|
|
1760
1947
|
|
|
1761
1948
|
if (errorMessages.length) {
|
|
@@ -1769,7 +1956,7 @@ var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCl
|
|
|
1769
1956
|
} // If Cloud1 is not valid, skip further validation of Cloud4
|
|
1770
1957
|
|
|
1771
1958
|
|
|
1772
|
-
if (validateFirstCloud(firstCloudValue) !== true) {
|
|
1959
|
+
if (validateFirstCloud(firstCloudValue, visibilityValue) !== true) {
|
|
1773
1960
|
return true;
|
|
1774
1961
|
} // If Cloud1 contains Vertical Visibility then Cloud4 should be empty
|
|
1775
1962
|
|
|
@@ -1789,7 +1976,7 @@ var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCl
|
|
|
1789
1976
|
} // If Cloud3 is not valid, skip further validation of Cloud4
|
|
1790
1977
|
|
|
1791
1978
|
|
|
1792
|
-
if (validateThirdCloud(firstCloudValue, secondCloudValue, thirdCloudValue) !== true) {
|
|
1979
|
+
if (validateThirdCloud(firstCloudValue, secondCloudValue, thirdCloudValue, visibilityValue) !== true) {
|
|
1793
1980
|
return true;
|
|
1794
1981
|
} // If Cloud3 contains a type, Cloud4 should be empty
|
|
1795
1982
|
|
|
@@ -1812,21 +1999,21 @@ var validateFourthCloud = function validateFourthCloud(firstCloudValue, secondCl
|
|
|
1812
1999
|
};
|
|
1813
2000
|
|
|
1814
2001
|
var formatIssueTime = function formatIssueTime(issueDate) {
|
|
1815
|
-
return issueDate ? moment(issueDate).utc().format('DDHHmm')
|
|
2002
|
+
return issueDate ? "".concat(moment(issueDate).utc().format('DDHHmm'), "Z") : 'Not issued';
|
|
1816
2003
|
};
|
|
1817
2004
|
function formatFormValues(row) {
|
|
1818
2005
|
return Object.keys(row).reduce(function (list, key) {
|
|
1819
2006
|
switch (key) {
|
|
1820
2007
|
case 'valid':
|
|
1821
2008
|
{
|
|
1822
|
-
return
|
|
2009
|
+
return Object.assign(Object.assign({}, list), {
|
|
1823
2010
|
valid: formatValidToString(list[key])
|
|
1824
2011
|
});
|
|
1825
2012
|
}
|
|
1826
2013
|
|
|
1827
2014
|
case 'wind':
|
|
1828
2015
|
{
|
|
1829
|
-
return
|
|
2016
|
+
return Object.assign(Object.assign({}, list), {
|
|
1830
2017
|
wind: formatWindToString(list[key])
|
|
1831
2018
|
});
|
|
1832
2019
|
}
|
|
@@ -1834,7 +2021,7 @@ function formatFormValues(row) {
|
|
|
1834
2021
|
case 'visibility':
|
|
1835
2022
|
{
|
|
1836
2023
|
// Assume if visibility field set - no cavOK
|
|
1837
|
-
return
|
|
2024
|
+
return Object.assign(Object.assign({}, list), {
|
|
1838
2025
|
visibility: formatVisibilityToString(list[key])
|
|
1839
2026
|
});
|
|
1840
2027
|
}
|
|
@@ -1842,14 +2029,14 @@ function formatFormValues(row) {
|
|
|
1842
2029
|
case 'cavOK':
|
|
1843
2030
|
{
|
|
1844
2031
|
// Assume if cavOK field set to true - no visibility field, otherwise return the original list containing the visibility
|
|
1845
|
-
return list[key] ?
|
|
2032
|
+
return list[key] ? Object.assign(Object.assign({}, list), {
|
|
1846
2033
|
visibility: formatVisibilityToString(list[key])
|
|
1847
2034
|
}) : list;
|
|
1848
2035
|
}
|
|
1849
2036
|
|
|
1850
2037
|
case 'cloud':
|
|
1851
2038
|
{
|
|
1852
|
-
return
|
|
2039
|
+
return Object.assign(Object.assign({}, list), {
|
|
1853
2040
|
cloud: formatCloudsToString(list[key])
|
|
1854
2041
|
});
|
|
1855
2042
|
}
|
|
@@ -1869,33 +2056,33 @@ function reduceRowValues(row, tafStart, tafEnd) {
|
|
|
1869
2056
|
switch (key) {
|
|
1870
2057
|
case 'valid':
|
|
1871
2058
|
{
|
|
1872
|
-
return
|
|
2059
|
+
return Object.assign(Object.assign({}, list), {
|
|
1873
2060
|
valid: parseValidToObject(list[key], tafStart, tafEnd)
|
|
1874
2061
|
});
|
|
1875
2062
|
}
|
|
1876
2063
|
|
|
1877
2064
|
case 'wind':
|
|
1878
2065
|
{
|
|
1879
|
-
return
|
|
2066
|
+
return Object.assign(Object.assign({}, list), {
|
|
1880
2067
|
wind: parseWindToObject(list[key])
|
|
1881
2068
|
});
|
|
1882
2069
|
}
|
|
1883
2070
|
|
|
1884
2071
|
case 'visibility':
|
|
1885
2072
|
{
|
|
1886
|
-
return
|
|
2073
|
+
return Object.assign(Object.assign({}, list), parseVisibilityToObject(list[key]));
|
|
1887
2074
|
}
|
|
1888
2075
|
|
|
1889
2076
|
case 'weather':
|
|
1890
2077
|
{
|
|
1891
|
-
return
|
|
2078
|
+
return Object.assign(Object.assign({}, list), {
|
|
1892
2079
|
weather: parseWeatherToObject(list[key])
|
|
1893
2080
|
});
|
|
1894
2081
|
}
|
|
1895
2082
|
|
|
1896
2083
|
case 'cloud':
|
|
1897
2084
|
{
|
|
1898
|
-
return
|
|
2085
|
+
return Object.assign(Object.assign({}, list), {
|
|
1899
2086
|
cloud: parseCloudsToObject(list[key])
|
|
1900
2087
|
});
|
|
1901
2088
|
}
|
|
@@ -1904,7 +2091,7 @@ function reduceRowValues(row, tafStart, tafEnd) {
|
|
|
1904
2091
|
case 'change':
|
|
1905
2092
|
case 'probability':
|
|
1906
2093
|
{
|
|
1907
|
-
return
|
|
2094
|
+
return Object.assign(Object.assign({}, list), _defineProperty({}, key, (_a = list[key]) === null || _a === void 0 ? void 0 : _a.trim()));
|
|
1908
2095
|
}
|
|
1909
2096
|
|
|
1910
2097
|
default:
|
|
@@ -1915,9 +2102,7 @@ function reduceRowValues(row, tafStart, tafEnd) {
|
|
|
1915
2102
|
}, row);
|
|
1916
2103
|
}
|
|
1917
2104
|
|
|
1918
|
-
|
|
1919
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1920
|
-
row, tafStart, tafEnd) {
|
|
2105
|
+
function parseFormValues(row, tafStart, tafEnd) {
|
|
1921
2106
|
var reducedRow = reduceRowValues(row, tafStart, tafEnd);
|
|
1922
2107
|
return Object.keys(reducedRow).reduce(function (list, key) {
|
|
1923
2108
|
switch (key) {
|
|
@@ -1939,9 +2124,9 @@ row, tafStart, tafEnd) {
|
|
|
1939
2124
|
// If cloud is undefined or empty, remove it from the list
|
|
1940
2125
|
if (!reducedRow.cloud || Object.keys(reducedRow.cloud).length === 0) {
|
|
1941
2126
|
list.cloud;
|
|
1942
|
-
var
|
|
2127
|
+
var _rest = __rest(list, ["cloud"]);
|
|
1943
2128
|
|
|
1944
|
-
return
|
|
2129
|
+
return _rest;
|
|
1945
2130
|
}
|
|
1946
2131
|
|
|
1947
2132
|
return list;
|
|
@@ -1952,9 +2137,9 @@ row, tafStart, tafEnd) {
|
|
|
1952
2137
|
// If empty, remove it from the list
|
|
1953
2138
|
if (!reducedRow.weather.weather1) {
|
|
1954
2139
|
list.weather;
|
|
1955
|
-
var
|
|
2140
|
+
var _rest2 = __rest(list, ["weather"]);
|
|
1956
2141
|
|
|
1957
|
-
return
|
|
2142
|
+
return _rest2;
|
|
1958
2143
|
}
|
|
1959
2144
|
|
|
1960
2145
|
return list;
|
|
@@ -1963,11 +2148,11 @@ row, tafStart, tafEnd) {
|
|
|
1963
2148
|
case 'wind':
|
|
1964
2149
|
{
|
|
1965
2150
|
// If empty, remove it from the list
|
|
1966
|
-
if (!reducedRow.wind.direction && isNaN(reducedRow.wind.direction)) {
|
|
2151
|
+
if (!reducedRow.wind.direction && isNaN(Number(reducedRow.wind.direction))) {
|
|
1967
2152
|
list.wind;
|
|
1968
|
-
var
|
|
2153
|
+
var _rest3 = __rest(list, ["wind"]);
|
|
1969
2154
|
|
|
1970
|
-
return
|
|
2155
|
+
return _rest3;
|
|
1971
2156
|
}
|
|
1972
2157
|
|
|
1973
2158
|
return list;
|
|
@@ -1978,9 +2163,9 @@ row, tafStart, tafEnd) {
|
|
|
1978
2163
|
// If empty, remove it from the list
|
|
1979
2164
|
if (!reducedRow.visibility.range && isNaN(reducedRow.visibility.range)) {
|
|
1980
2165
|
list.visibility;
|
|
1981
|
-
var
|
|
2166
|
+
var _rest4 = __rest(list, ["visibility"]);
|
|
1982
2167
|
|
|
1983
|
-
return
|
|
2168
|
+
return _rest4;
|
|
1984
2169
|
}
|
|
1985
2170
|
|
|
1986
2171
|
return list;
|
|
@@ -1988,16 +2173,28 @@ row, tafStart, tafEnd) {
|
|
|
1988
2173
|
|
|
1989
2174
|
case 'change':
|
|
1990
2175
|
case 'probability':
|
|
2176
|
+
// If empty, remove it from the list
|
|
2177
|
+
if (!reducedRow[key]) {
|
|
2178
|
+
var _a = list,
|
|
2179
|
+
_b = key;
|
|
2180
|
+
_a[_b];
|
|
2181
|
+
var _rest5 = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
2182
|
+
|
|
2183
|
+
return _rest5;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
return list;
|
|
2187
|
+
|
|
1991
2188
|
case 'valid':
|
|
1992
2189
|
{
|
|
1993
2190
|
// If empty, remove it from the list
|
|
1994
2191
|
if (!reducedRow[key]) {
|
|
1995
|
-
var
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
var
|
|
2192
|
+
var _c = list,
|
|
2193
|
+
_d = key;
|
|
2194
|
+
_c[_d];
|
|
2195
|
+
var _rest6 = __rest(_c, [_typeof(_d) === "symbol" ? _d : _d + ""]);
|
|
1999
2196
|
|
|
2000
|
-
return
|
|
2197
|
+
return _rest6;
|
|
2001
2198
|
}
|
|
2002
2199
|
|
|
2003
2200
|
return list;
|
|
@@ -2009,9 +2206,7 @@ row, tafStart, tafEnd) {
|
|
|
2009
2206
|
}
|
|
2010
2207
|
}
|
|
2011
2208
|
}, reducedRow);
|
|
2012
|
-
}
|
|
2013
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2014
|
-
|
|
2209
|
+
}
|
|
2015
2210
|
var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
2016
2211
|
formData.IS_DRAFT;
|
|
2017
2212
|
var productToPost = __rest(formData, ["IS_DRAFT"]);
|
|
@@ -2025,12 +2220,10 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2025
2220
|
.filter(function (value) {
|
|
2026
2221
|
return Object.keys(value).length;
|
|
2027
2222
|
});
|
|
2028
|
-
|
|
2029
|
-
var parsedFormValues = __assign(__assign({}, productToPost), {
|
|
2223
|
+
var parsedFormValues = Object.assign(Object.assign({}, productToPost), {
|
|
2030
2224
|
baseForecast: parseFormValues(productToPost.baseForecast, tafStart, tafEnd),
|
|
2031
2225
|
changeGroups: parsedChangeGroups
|
|
2032
2226
|
});
|
|
2033
|
-
|
|
2034
2227
|
return Object.keys(parsedFormValues).reduce(function (list, key) {
|
|
2035
2228
|
switch (key) {
|
|
2036
2229
|
case 'changeGroups':
|
|
@@ -2056,9 +2249,9 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2056
2249
|
var _a = list,
|
|
2057
2250
|
_b = key;
|
|
2058
2251
|
_a[_b];
|
|
2059
|
-
var
|
|
2252
|
+
var _rest7 = __rest(_a, [_typeof(_b) === "symbol" ? _b : _b + ""]);
|
|
2060
2253
|
|
|
2061
|
-
return
|
|
2254
|
+
return _rest7;
|
|
2062
2255
|
}
|
|
2063
2256
|
|
|
2064
2257
|
return list;
|
|
@@ -2070,58 +2263,65 @@ var convertTafValuesToObject = function convertTafValuesToObject(formData) {
|
|
|
2070
2263
|
}
|
|
2071
2264
|
}
|
|
2072
2265
|
}, parsedFormValues);
|
|
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
|
|
2266
|
+
}; // 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
2267
|
|
|
2076
2268
|
var shouldRetrieveTAC = function shouldRetrieveTAC(product) {
|
|
2077
|
-
if (product && product.baseForecast && product.baseForecast.wind && product.baseForecast.wind
|
|
2269
|
+
if (product && product.baseForecast && product.baseForecast.wind && 'speed' in product.baseForecast.wind && product.baseForecast.wind.speed !== '' && (product.baseForecast.visibility && 'range' in product.baseForecast.visibility && product.baseForecast.visibility.range !== '' || product.baseForecast.cavOK)) {
|
|
2078
2270
|
return true;
|
|
2079
2271
|
}
|
|
2080
2272
|
|
|
2081
2273
|
return false;
|
|
2082
2274
|
};
|
|
2083
|
-
|
|
2084
2275
|
var getFieldNames = function getFieldNames(isChangeGroup, index) {
|
|
2085
|
-
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups["
|
|
2086
|
-
return
|
|
2276
|
+
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[".concat(index, "]");
|
|
2277
|
+
return Object.assign(Object.assign(Object.assign({}, !isChangeGroup && {
|
|
2087
2278
|
messageType: 'messageType',
|
|
2088
2279
|
location: 'location',
|
|
2089
2280
|
issueDate: 'issueDate'
|
|
2090
2281
|
}), isChangeGroup && {
|
|
2091
|
-
probability: namePrefix
|
|
2092
|
-
change: namePrefix
|
|
2282
|
+
probability: "".concat(namePrefix, ".probability"),
|
|
2283
|
+
change: "".concat(namePrefix, ".change")
|
|
2093
2284
|
}), {
|
|
2094
|
-
valid: namePrefix
|
|
2095
|
-
wind: namePrefix
|
|
2096
|
-
visibility: namePrefix
|
|
2097
|
-
weather1: namePrefix
|
|
2098
|
-
weather2: namePrefix
|
|
2099
|
-
weather3: namePrefix
|
|
2100
|
-
cloud1: namePrefix
|
|
2101
|
-
cloud2: namePrefix
|
|
2102
|
-
cloud3: namePrefix
|
|
2103
|
-
cloud4: namePrefix
|
|
2285
|
+
valid: "".concat(namePrefix, ".valid"),
|
|
2286
|
+
wind: "".concat(namePrefix, ".wind"),
|
|
2287
|
+
visibility: "".concat(namePrefix, ".visibility"),
|
|
2288
|
+
weather1: "".concat(namePrefix, ".weather.weather1"),
|
|
2289
|
+
weather2: "".concat(namePrefix, ".weather.weather2"),
|
|
2290
|
+
weather3: "".concat(namePrefix, ".weather.weather3"),
|
|
2291
|
+
cloud1: "".concat(namePrefix, ".cloud.cloud1"),
|
|
2292
|
+
cloud2: "".concat(namePrefix, ".cloud.cloud2"),
|
|
2293
|
+
cloud3: "".concat(namePrefix, ".cloud.cloud3"),
|
|
2294
|
+
cloud4: "".concat(namePrefix, ".cloud.cloud4")
|
|
2104
2295
|
});
|
|
2105
2296
|
};
|
|
2106
|
-
var
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2297
|
+
var TAC_MISSING_DATA = 'Missing data: no TAC can be generated';
|
|
2298
|
+
var TAC_NOT_AVAILABLE = 'No TAC available';
|
|
2299
|
+
var TAC_RETRIEVING_DATA = 'Retrieving TAC';
|
|
2300
|
+
var useTACGenerator = function useTACGenerator(taf, requestTAC) {
|
|
2301
|
+
var standardTAC = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
2110
2302
|
|
|
2111
|
-
var
|
|
2112
|
-
|
|
2113
|
-
|
|
2303
|
+
var _React$useState = React__default.useState(taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA),
|
|
2304
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2305
|
+
TAC = _React$useState2[0],
|
|
2306
|
+
setTAC = _React$useState2[1];
|
|
2307
|
+
|
|
2308
|
+
var _useIsMounted = useIsMounted(),
|
|
2309
|
+
isMounted = _useIsMounted.isMounted;
|
|
2114
2310
|
|
|
2115
2311
|
var retrieveTAC = function retrieveTAC(tafToPost) {
|
|
2116
2312
|
if (shouldRetrieveTAC(tafToPost)) {
|
|
2117
2313
|
requestTAC(tafToPost).then(function (result) {
|
|
2118
|
-
|
|
2314
|
+
if (isMounted.current) {
|
|
2315
|
+
setTAC(result.data);
|
|
2316
|
+
}
|
|
2119
2317
|
})["catch"](function () {
|
|
2120
|
-
|
|
2318
|
+
if (isMounted.current) {
|
|
2319
|
+
setTAC('Failed to retrieve TAC');
|
|
2320
|
+
}
|
|
2121
2321
|
});
|
|
2322
|
+
} else {
|
|
2323
|
+
setTAC(TAC_MISSING_DATA);
|
|
2122
2324
|
}
|
|
2123
|
-
|
|
2124
|
-
setTAC(noTAC);
|
|
2125
2325
|
};
|
|
2126
2326
|
|
|
2127
2327
|
React__default.useEffect(function () {
|
|
@@ -2137,69 +2337,57 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
|
|
|
2137
2337
|
}, [standardTAC]);
|
|
2138
2338
|
return [TAC, retrieveTAC];
|
|
2139
2339
|
};
|
|
2140
|
-
var
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
lastDragOrder = _b[0],
|
|
2155
|
-
onUpdatelastDragOrder = _b[1];
|
|
2156
|
-
|
|
2157
|
-
var onChangeOrder = function onChangeOrder(_a) {
|
|
2158
|
-
var oldIndex = _a.oldIndex,
|
|
2159
|
-
newIndex = _a.newIndex;
|
|
2340
|
+
var useDragOrder = function useDragOrder(trigger, move, onFormBlur) {
|
|
2341
|
+
var _React$useState3 = React__default.useState(null),
|
|
2342
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
2343
|
+
activeDraggingIndex = _React$useState4[0],
|
|
2344
|
+
setIsDragging = _React$useState4[1];
|
|
2345
|
+
|
|
2346
|
+
var _React$useState5 = React__default.useState([null, null]),
|
|
2347
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
2348
|
+
lastDragOrder = _React$useState6[0],
|
|
2349
|
+
onUpdatelastDragOrder = _React$useState6[1];
|
|
2350
|
+
|
|
2351
|
+
var onChangeOrder = function onChangeOrder(_ref) {
|
|
2352
|
+
var oldIndex = _ref.oldIndex,
|
|
2353
|
+
newIndex = _ref.newIndex;
|
|
2160
2354
|
if (oldIndex === undefined || newIndex === undefined) return;
|
|
2161
2355
|
move(oldIndex, newIndex);
|
|
2162
2356
|
onUpdatelastDragOrder([oldIndex, newIndex]);
|
|
2357
|
+
setIsDragging(false);
|
|
2163
2358
|
};
|
|
2164
2359
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
chosen: false
|
|
2171
|
-
};
|
|
2172
|
-
}));
|
|
2173
|
-
}, [fields]); // triggers validation AFTER render of new sorted elements
|
|
2360
|
+
var onStartDrag = function onStartDrag(_ref2) {
|
|
2361
|
+
var oldIndex = _ref2.oldIndex;
|
|
2362
|
+
return setIsDragging(oldIndex);
|
|
2363
|
+
}; // triggers validation AFTER render of new sorted elements
|
|
2364
|
+
|
|
2174
2365
|
|
|
2175
2366
|
React__default.useEffect(function () {
|
|
2176
|
-
var
|
|
2177
|
-
oldIndex =
|
|
2178
|
-
newIndex =
|
|
2367
|
+
var _lastDragOrder = _slicedToArray(lastDragOrder, 2),
|
|
2368
|
+
oldIndex = _lastDragOrder[0],
|
|
2369
|
+
newIndex = _lastDragOrder[1];
|
|
2179
2370
|
|
|
2180
2371
|
if (oldIndex !== null && newIndex !== null) {
|
|
2181
|
-
// trigger validation of
|
|
2182
|
-
|
|
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);
|
|
2372
|
+
// trigger validation of all fields
|
|
2373
|
+
trigger();
|
|
2197
2374
|
}
|
|
2198
|
-
}, [lastDragOrder, trigger]);
|
|
2375
|
+
}, [lastDragOrder, trigger]); // trigger onFormBlur AFTER render of new sorted elements so the TAC gets updated
|
|
2376
|
+
|
|
2377
|
+
React__default.useEffect(function () {
|
|
2378
|
+
var _lastDragOrder2 = _slicedToArray(lastDragOrder, 2),
|
|
2379
|
+
oldIndex = _lastDragOrder2[0],
|
|
2380
|
+
newIndex = _lastDragOrder2[1];
|
|
2381
|
+
|
|
2382
|
+
if (oldIndex !== null && newIndex !== null) {
|
|
2383
|
+
onFormBlur();
|
|
2384
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2385
|
+
|
|
2386
|
+
}, [lastDragOrder]);
|
|
2199
2387
|
return {
|
|
2200
2388
|
onChangeOrder: onChangeOrder,
|
|
2201
|
-
|
|
2202
|
-
|
|
2389
|
+
activeDraggingIndex: activeDraggingIndex,
|
|
2390
|
+
onStartDrag: onStartDrag
|
|
2203
2391
|
};
|
|
2204
2392
|
}; // dialog utils
|
|
2205
2393
|
|
|
@@ -2333,7 +2521,7 @@ var getDisplayValue = function getDisplayValue(value, disabled) {
|
|
|
2333
2521
|
};
|
|
2334
2522
|
var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
|
|
2335
2523
|
var classes = useStyles$9();
|
|
2336
|
-
return /*#__PURE__*/React__default.createElement(TextField,
|
|
2524
|
+
return /*#__PURE__*/React__default.createElement(TextField, Object.assign({
|
|
2337
2525
|
type: "text",
|
|
2338
2526
|
variant: "filled",
|
|
2339
2527
|
InputProps: {
|
|
@@ -2352,48 +2540,49 @@ var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
|
|
|
2352
2540
|
return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name;
|
|
2353
2541
|
});
|
|
2354
2542
|
|
|
2355
|
-
var TafFormTextField = function TafFormTextField(
|
|
2356
|
-
var label =
|
|
2357
|
-
|
|
2358
|
-
disabled =
|
|
2359
|
-
|
|
2360
|
-
name =
|
|
2361
|
-
|
|
2362
|
-
onChange =
|
|
2363
|
-
|
|
2364
|
-
onBlur =
|
|
2365
|
-
|
|
2366
|
-
defaultValue =
|
|
2367
|
-
|
|
2368
|
-
formatter =
|
|
2369
|
-
rules =
|
|
2370
|
-
|
|
2371
|
-
autoComplete =
|
|
2372
|
-
|
|
2373
|
-
autoFocus =
|
|
2543
|
+
var TafFormTextField = function TafFormTextField(_ref) {
|
|
2544
|
+
var label = _ref.label,
|
|
2545
|
+
_ref$disabled = _ref.disabled,
|
|
2546
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
2547
|
+
_ref$name = _ref.name,
|
|
2548
|
+
name = _ref$name === void 0 ? '' : _ref$name,
|
|
2549
|
+
_ref$onChange = _ref.onChange,
|
|
2550
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
2551
|
+
_ref$onBlur = _ref.onBlur,
|
|
2552
|
+
onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
|
|
2553
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
2554
|
+
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
2555
|
+
_ref$formatter = _ref.formatter,
|
|
2556
|
+
formatter = _ref$formatter === void 0 ? null : _ref$formatter,
|
|
2557
|
+
rules = _ref.rules,
|
|
2558
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
2559
|
+
autoComplete = _ref$autoComplete === void 0 ? [] : _ref$autoComplete,
|
|
2560
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
2561
|
+
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus;
|
|
2374
2562
|
var classes = useStyles$9();
|
|
2375
2563
|
|
|
2376
|
-
var
|
|
2377
|
-
control =
|
|
2378
|
-
getValues =
|
|
2379
|
-
setValue =
|
|
2380
|
-
errors =
|
|
2564
|
+
var _useFormContext = useFormContext(),
|
|
2565
|
+
control = _useFormContext.control,
|
|
2566
|
+
getValues = _useFormContext.getValues,
|
|
2567
|
+
setValue = _useFormContext.setValue,
|
|
2568
|
+
errors = _useFormContext.errors;
|
|
2381
2569
|
|
|
2382
2570
|
var inputRef = React__default.useRef(null);
|
|
2383
2571
|
var fieldErrors = getTafErrors(name, errors);
|
|
2384
2572
|
|
|
2385
|
-
var
|
|
2386
|
-
|
|
2387
|
-
|
|
2573
|
+
var _React$useState = React__default.useState(null),
|
|
2574
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2575
|
+
maxLength = _React$useState2[0],
|
|
2576
|
+
setMaxLength = _React$useState2[1];
|
|
2388
2577
|
|
|
2389
2578
|
var onKeyDown = React__default.useCallback(function (event) {
|
|
2390
2579
|
var currentValue = getValues(name).toString();
|
|
2391
2580
|
var textSelection = currentValue.substring(inputRef.current.selectionStart, inputRef.current.selectionEnd);
|
|
2392
2581
|
|
|
2393
2582
|
if (autoComplete && !currentValue.length || textSelection.length && currentValue.length && textSelection === currentValue) {
|
|
2394
|
-
var
|
|
2583
|
+
var pressedKey = event.key.toString().toUpperCase();
|
|
2395
2584
|
var foundValue = autoComplete.find(function (el) {
|
|
2396
|
-
return el.key ===
|
|
2585
|
+
return el.key === pressedKey;
|
|
2397
2586
|
}) || null;
|
|
2398
2587
|
|
|
2399
2588
|
if (foundValue) {
|
|
@@ -2480,7 +2669,7 @@ var TafFormTextField = function TafFormTextField(_a) {
|
|
|
2480
2669
|
* */
|
|
2481
2670
|
// messages
|
|
2482
2671
|
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
|
|
2672
|
+
var invalidChangeProbCombinationMessage = 'A probability is only allowed in combination with TEMPO or an empty Change input'; // validations
|
|
2484
2673
|
|
|
2485
2674
|
var validateChangeField = function validateChangeField(value) {
|
|
2486
2675
|
var trimmedValue = value.trim();
|
|
@@ -2532,48 +2721,57 @@ var getDefaultValue = function getDefaultValue(fieldName, data) {
|
|
|
2532
2721
|
};
|
|
2533
2722
|
|
|
2534
2723
|
var getRequiredCrossFields = function getRequiredCrossFields(fieldNames) {
|
|
2535
|
-
return [[fieldNames.valid, fieldNames.change
|
|
2724
|
+
return [[fieldNames.valid], [fieldNames.change, fieldNames.probability], [fieldNames.wind, fieldNames.visibility, fieldNames.weather1, fieldNames.cloud1] // sub fields
|
|
2725
|
+
];
|
|
2536
2726
|
};
|
|
2537
2727
|
|
|
2538
2728
|
var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
2539
|
-
var
|
|
2540
|
-
isChangeGroup =
|
|
2541
|
-
|
|
2542
|
-
disabled =
|
|
2543
|
-
|
|
2544
|
-
index =
|
|
2545
|
-
|
|
2546
|
-
lastRow =
|
|
2729
|
+
var _a$isChangeGroup = _a.isChangeGroup,
|
|
2730
|
+
isChangeGroup = _a$isChangeGroup === void 0 ? false : _a$isChangeGroup,
|
|
2731
|
+
_a$disabled = _a.disabled,
|
|
2732
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
2733
|
+
_a$index = _a.index,
|
|
2734
|
+
index = _a$index === void 0 ? -1 : _a$index,
|
|
2735
|
+
_a$lastRow = _a.lastRow,
|
|
2736
|
+
lastRow = _a$lastRow === void 0 ? false : _a$lastRow,
|
|
2547
2737
|
onRemoveChangeGroup = _a.onRemoveChangeGroup,
|
|
2548
|
-
|
|
2549
|
-
field =
|
|
2550
|
-
|
|
2551
|
-
dragHandle =
|
|
2738
|
+
_a$field = _a.field,
|
|
2739
|
+
field = _a$field === void 0 ? null : _a$field,
|
|
2740
|
+
_a$dragHandle = _a.dragHandle,
|
|
2741
|
+
dragHandle = _a$dragHandle === void 0 ? null : _a$dragHandle,
|
|
2552
2742
|
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "dragHandle"]);
|
|
2553
2743
|
|
|
2554
|
-
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups["
|
|
2744
|
+
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[".concat(index, "]");
|
|
2555
2745
|
var fieldNames = getFieldNames(isChangeGroup, index);
|
|
2556
2746
|
|
|
2557
|
-
var
|
|
2558
|
-
getValues =
|
|
2559
|
-
trigger =
|
|
2747
|
+
var _useFormContext = useFormContext(),
|
|
2748
|
+
getValues = _useFormContext.getValues,
|
|
2749
|
+
trigger = _useFormContext.trigger;
|
|
2750
|
+
|
|
2751
|
+
var _useDraftFormHelpers = useDraftFormHelpers(),
|
|
2752
|
+
isNotRequiredForAction = _useDraftFormHelpers.isRequired; // cross-field required validation
|
|
2560
2753
|
|
|
2561
|
-
var isNotRequiredForAction = useDraftFormHelpers().isRequired; // cross-field required validation
|
|
2562
2754
|
|
|
2563
|
-
var
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2755
|
+
var _getRequiredCrossFiel = getRequiredCrossFields(fieldNames),
|
|
2756
|
+
_getRequiredCrossFiel2 = _slicedToArray(_getRequiredCrossFiel, 3),
|
|
2757
|
+
mainFields = _getRequiredCrossFiel2[0],
|
|
2758
|
+
mainOptionalFields = _getRequiredCrossFiel2[1],
|
|
2759
|
+
subFields = _getRequiredCrossFiel2[2];
|
|
2567
2760
|
|
|
2568
2761
|
var hasFieldsValue = function hasFieldsValue(fields) {
|
|
2569
2762
|
return fields.map(getValues).find(function (field) {
|
|
2570
2763
|
return !!field;
|
|
2571
2764
|
});
|
|
2572
|
-
}; // Used to validate the
|
|
2765
|
+
}; // Used to validate the required field for change groups: Valid
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
var validateRequiredMain = function validateRequiredMain(value) {
|
|
2769
|
+
return isNotRequiredForAction(value) !== true && isChangeGroup && !value.length && (hasFieldsValue(subFields) || hasFieldsValue(mainFields) || hasFieldsValue(mainOptionalFields)) ? 'Valid is required' : true;
|
|
2770
|
+
}; // Used to ensure either probability or change is entered, or both
|
|
2573
2771
|
|
|
2574
2772
|
|
|
2575
|
-
var
|
|
2576
|
-
return isNotRequiredForAction(value) !== true && isChangeGroup &&
|
|
2773
|
+
var validateRequiredMainOptional = function validateRequiredMainOptional(value) {
|
|
2774
|
+
return isNotRequiredForAction(value) !== true && isChangeGroup && (hasFieldsValue(mainFields) || hasFieldsValue(subFields)) && !hasFieldsValue(mainOptionalFields) ? 'Probability or change is required' : true;
|
|
2577
2775
|
}; // Used to ensure one wind, visibility, weather or cloud is entered when start editing a changegroup and all of these are empty
|
|
2578
2776
|
|
|
2579
2777
|
|
|
@@ -2583,8 +2781,8 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2583
2781
|
|
|
2584
2782
|
|
|
2585
2783
|
var _validateRequiredMainFields = function validateRequiredMainFields(value, fieldName) {
|
|
2586
|
-
var changeField = getValues(namePrefix
|
|
2587
|
-
var visibilityField = getValues(namePrefix
|
|
2784
|
+
var changeField = getValues("".concat(namePrefix, ".change"));
|
|
2785
|
+
var visibilityField = getValues("".concat(namePrefix, ".visibility"));
|
|
2588
2786
|
var isFM = changeField && changeField.trim() === 'FM';
|
|
2589
2787
|
var isCAVOK = visibilityField && visibilityField.trim() === 'CAVOK';
|
|
2590
2788
|
|
|
@@ -2600,15 +2798,37 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2600
2798
|
return true;
|
|
2601
2799
|
}
|
|
2602
2800
|
|
|
2603
|
-
return fieldName
|
|
2801
|
+
return "".concat(fieldName, " is required");
|
|
2604
2802
|
}
|
|
2605
2803
|
}
|
|
2606
2804
|
|
|
2607
2805
|
return true;
|
|
2608
2806
|
};
|
|
2609
2807
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2808
|
+
var validatePreviousRow = React__default.useCallback(function () {
|
|
2809
|
+
if (isChangeGroup && index > 0) {
|
|
2810
|
+
var _getValues = getValues(),
|
|
2811
|
+
validDateEnd = _getValues.validDateEnd,
|
|
2812
|
+
validDateStart = _getValues.validDateStart,
|
|
2813
|
+
changeGroups = _getValues.changeGroups;
|
|
2814
|
+
|
|
2815
|
+
var currentChangeGroup = changeGroups[index];
|
|
2816
|
+
var previousChangeGroup = changeGroups[index - 1];
|
|
2817
|
+
return validatePreviousChangeGroup(currentChangeGroup, previousChangeGroup, validDateStart, validDateEnd);
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
return true;
|
|
2821
|
+
}, [index, isChangeGroup, getValues]);
|
|
2822
|
+
|
|
2823
|
+
var getFieldFromNextRow = function getFieldFromNextRow() {
|
|
2824
|
+
var fieldname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'valid';
|
|
2825
|
+
var nextValidFieldName = "changeGroups[".concat(index + 1, "].").concat(fieldname);
|
|
2826
|
+
var nextRowValidValue = getValues(nextValidFieldName);
|
|
2827
|
+
return nextRowValidValue ? [nextValidFieldName] : [];
|
|
2828
|
+
};
|
|
2829
|
+
|
|
2830
|
+
return /*#__PURE__*/React__default.createElement(Grid, Object.assign({
|
|
2831
|
+
"data-testid": "row-".concat(namePrefix),
|
|
2612
2832
|
container: true,
|
|
2613
2833
|
ref: ref
|
|
2614
2834
|
}, props), !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
@@ -2637,6 +2857,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2637
2857
|
defaultValue: getDefaultValue('probability', field),
|
|
2638
2858
|
rules: {
|
|
2639
2859
|
validate: {
|
|
2860
|
+
validateRequiredMainOptional: validateRequiredMainOptional,
|
|
2640
2861
|
validateProbabilityField: validateProbabilityField
|
|
2641
2862
|
}
|
|
2642
2863
|
},
|
|
@@ -2649,7 +2870,8 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2649
2870
|
}],
|
|
2650
2871
|
onBlur: function onBlur() {
|
|
2651
2872
|
if (isChangeGroup) {
|
|
2652
|
-
|
|
2873
|
+
var nextValidFieldName = getFieldFromNextRow();
|
|
2874
|
+
trigger([].concat(_toConsumableArray(subFields), _toConsumableArray(mainOptionalFields), _toConsumableArray(mainFields), _toConsumableArray(nextValidFieldName)));
|
|
2653
2875
|
}
|
|
2654
2876
|
}
|
|
2655
2877
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
@@ -2659,9 +2881,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2659
2881
|
defaultValue: getDefaultValue('change', field),
|
|
2660
2882
|
rules: {
|
|
2661
2883
|
validate: {
|
|
2662
|
-
|
|
2663
|
-
return _validateRequiredMain(value, 'Change');
|
|
2664
|
-
},
|
|
2884
|
+
validateRequiredMainOptional: validateRequiredMainOptional,
|
|
2665
2885
|
validateChangeField: validateChangeField,
|
|
2666
2886
|
validateChangeFieldInterField: function validateChangeFieldInterField$1(value) {
|
|
2667
2887
|
return validateChangeFieldInterField(value, getValues(fieldNames.probability));
|
|
@@ -2680,7 +2900,8 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2680
2900
|
}],
|
|
2681
2901
|
onBlur: function onBlur() {
|
|
2682
2902
|
if (isChangeGroup) {
|
|
2683
|
-
|
|
2903
|
+
var nextValidFieldName = getFieldFromNextRow();
|
|
2904
|
+
trigger([].concat(_toConsumableArray(subFields), _toConsumableArray(mainOptionalFields), _toConsumableArray(mainFields), _toConsumableArray(nextValidFieldName)));
|
|
2684
2905
|
}
|
|
2685
2906
|
}
|
|
2686
2907
|
})), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
@@ -2691,20 +2912,20 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2691
2912
|
defaultValue: getDefaultValue('valid', field),
|
|
2692
2913
|
rules: {
|
|
2693
2914
|
validate: {
|
|
2694
|
-
validateRequiredMain:
|
|
2695
|
-
return _validateRequiredMain(value, 'Valid');
|
|
2696
|
-
},
|
|
2915
|
+
validateRequiredMain: validateRequiredMain,
|
|
2697
2916
|
validateValidField: function validateValidField$1(value) {
|
|
2698
2917
|
return isChangeGroup ? validateValidField(value, getValues('validDateStart'), getValues('validDateEnd')) : true;
|
|
2699
2918
|
},
|
|
2700
2919
|
validateValidChangeGroupInterField: function validateValidChangeGroupInterField$1(value) {
|
|
2701
|
-
return isChangeGroup ? validateValidChangeGroupInterField(value, getValues(fieldNames.change)) : true;
|
|
2702
|
-
}
|
|
2920
|
+
return isChangeGroup ? validateValidChangeGroupInterField(value, getValues(fieldNames.change), getValues('validDateStart'), getValues('validDateEnd')) : true;
|
|
2921
|
+
},
|
|
2922
|
+
validatePreviousRow: validatePreviousRow
|
|
2703
2923
|
}
|
|
2704
2924
|
},
|
|
2705
2925
|
onBlur: function onBlur() {
|
|
2706
2926
|
if (isChangeGroup) {
|
|
2707
|
-
|
|
2927
|
+
var nextValidFieldName = getFieldFromNextRow();
|
|
2928
|
+
trigger([].concat(_toConsumableArray(subFields), _toConsumableArray(mainOptionalFields), _toConsumableArray(mainFields), _toConsumableArray(nextValidFieldName)));
|
|
2708
2929
|
}
|
|
2709
2930
|
}
|
|
2710
2931
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
@@ -2723,7 +2944,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2723
2944
|
},
|
|
2724
2945
|
onBlur: function onBlur() {
|
|
2725
2946
|
if (isChangeGroup) {
|
|
2726
|
-
trigger(
|
|
2947
|
+
trigger([].concat(_toConsumableArray(subFields), _toConsumableArray(mainFields)));
|
|
2727
2948
|
}
|
|
2728
2949
|
},
|
|
2729
2950
|
autoFocus: !isChangeGroup
|
|
@@ -2746,7 +2967,8 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2746
2967
|
value: 'CAVOK'
|
|
2747
2968
|
}],
|
|
2748
2969
|
onBlur: function onBlur() {
|
|
2749
|
-
|
|
2970
|
+
var fields = isChangeGroup ? [].concat(_toConsumableArray(subFields), _toConsumableArray(mainFields)) : subFields;
|
|
2971
|
+
trigger([].concat(_toConsumableArray(fields), [fieldNames.weather1, fieldNames.weather2, fieldNames.weather3]));
|
|
2750
2972
|
}
|
|
2751
2973
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2752
2974
|
label: "Weather",
|
|
@@ -2760,13 +2982,13 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2760
2982
|
},
|
|
2761
2983
|
validateRequiredSub: validateRequiredSub,
|
|
2762
2984
|
validateWeatherField: function validateWeatherField$1(value) {
|
|
2763
|
-
return validateWeatherField(value, !!isChangeGroup);
|
|
2985
|
+
return validateWeatherField(value, getValues(fieldNames.visibility), !!isChangeGroup);
|
|
2764
2986
|
}
|
|
2765
2987
|
}
|
|
2766
2988
|
},
|
|
2767
2989
|
onBlur: function onBlur() {
|
|
2768
|
-
var fields = isChangeGroup ?
|
|
2769
|
-
return trigger(
|
|
2990
|
+
var fields = isChangeGroup ? [].concat(_toConsumableArray(subFields), _toConsumableArray(mainFields)) : [];
|
|
2991
|
+
return trigger([].concat(_toConsumableArray(fields), [fieldNames.weather2, fieldNames.weather3]));
|
|
2770
2992
|
}
|
|
2771
2993
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2772
2994
|
label: "Weather",
|
|
@@ -2776,13 +2998,13 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2776
2998
|
rules: {
|
|
2777
2999
|
validate: {
|
|
2778
3000
|
validateSecondWeatherField: function validateSecondWeatherField$1(value) {
|
|
2779
|
-
return validateSecondWeatherField(getValues(fieldNames.weather1), value);
|
|
3001
|
+
return validateSecondWeatherField(getValues(fieldNames.weather1), value, getValues(fieldNames.visibility));
|
|
2780
3002
|
}
|
|
2781
3003
|
}
|
|
2782
3004
|
},
|
|
2783
3005
|
onBlur: function onBlur() {
|
|
2784
|
-
var fields = isChangeGroup ?
|
|
2785
|
-
return trigger(
|
|
3006
|
+
var fields = isChangeGroup ? [].concat(_toConsumableArray(subFields), _toConsumableArray(mainFields)) : [];
|
|
3007
|
+
return trigger([].concat(_toConsumableArray(fields), [fieldNames.weather3]));
|
|
2786
3008
|
}
|
|
2787
3009
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2788
3010
|
label: "Weather",
|
|
@@ -2792,7 +3014,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2792
3014
|
rules: {
|
|
2793
3015
|
validate: {
|
|
2794
3016
|
validateThirdWeatherField: function validateThirdWeatherField$1(value) {
|
|
2795
|
-
return validateThirdWeatherField(getValues(fieldNames.weather1), getValues(fieldNames.weather2), value);
|
|
3017
|
+
return validateThirdWeatherField(getValues(fieldNames.weather1), getValues(fieldNames.weather2), value, getValues(fieldNames.visibility));
|
|
2796
3018
|
}
|
|
2797
3019
|
}
|
|
2798
3020
|
}
|
|
@@ -2807,12 +3029,14 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2807
3029
|
return _validateRequiredMainFields(value, 'Clouds');
|
|
2808
3030
|
},
|
|
2809
3031
|
validateRequiredSub: validateRequiredSub,
|
|
2810
|
-
validateFirstCloud: validateFirstCloud
|
|
3032
|
+
validateFirstCloud: function validateFirstCloud$1(value) {
|
|
3033
|
+
return validateFirstCloud(value, getValues(fieldNames.visibility));
|
|
3034
|
+
}
|
|
2811
3035
|
}
|
|
2812
3036
|
},
|
|
2813
3037
|
onBlur: function onBlur() {
|
|
2814
|
-
var fields = isChangeGroup ?
|
|
2815
|
-
return trigger(
|
|
3038
|
+
var fields = isChangeGroup ? [].concat(_toConsumableArray(subFields), _toConsumableArray(mainFields)) : [];
|
|
3039
|
+
return trigger([].concat(_toConsumableArray(fields), [fieldNames.cloud2, fieldNames.cloud3, fieldNames.cloud4]));
|
|
2816
3040
|
}
|
|
2817
3041
|
}), /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2818
3042
|
label: "Cloud",
|
|
@@ -2822,7 +3046,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2822
3046
|
rules: {
|
|
2823
3047
|
validate: {
|
|
2824
3048
|
validateSecondCloud: function validateSecondCloud$1(value) {
|
|
2825
|
-
return validateSecondCloud(getValues(fieldNames.cloud1), value);
|
|
3049
|
+
return validateSecondCloud(getValues(fieldNames.cloud1), value, getValues(fieldNames.visibility));
|
|
2826
3050
|
}
|
|
2827
3051
|
}
|
|
2828
3052
|
},
|
|
@@ -2837,7 +3061,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2837
3061
|
rules: {
|
|
2838
3062
|
validate: {
|
|
2839
3063
|
validateThirdCloud: function validateThirdCloud$1(value) {
|
|
2840
|
-
return validateThirdCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), value);
|
|
3064
|
+
return validateThirdCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), value, getValues(fieldNames.visibility));
|
|
2841
3065
|
}
|
|
2842
3066
|
}
|
|
2843
3067
|
},
|
|
@@ -2852,7 +3076,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2852
3076
|
rules: {
|
|
2853
3077
|
validate: {
|
|
2854
3078
|
validateFourthCloud: function validateFourthCloud$1(value) {
|
|
2855
|
-
return validateFourthCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), getValues(fieldNames.cloud3), value);
|
|
3079
|
+
return validateFourthCloud(getValues(fieldNames.cloud1), getValues(fieldNames.cloud2), getValues(fieldNames.cloud3), value, getValues(fieldNames.visibility));
|
|
2856
3080
|
}
|
|
2857
3081
|
}
|
|
2858
3082
|
}
|
|
@@ -2862,7 +3086,7 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2862
3086
|
}), isChangeGroup && !disabled && /*#__PURE__*/React__default.createElement(Grid, {
|
|
2863
3087
|
item: true,
|
|
2864
3088
|
xs: true
|
|
2865
|
-
}, /*#__PURE__*/React__default.createElement(IconButton,
|
|
3089
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, Object.assign({
|
|
2866
3090
|
"aria-label": "delete",
|
|
2867
3091
|
"data-testid": "remove-changeGroup",
|
|
2868
3092
|
onClick: function onClick() {
|
|
@@ -2873,6 +3097,23 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
|
2873
3097
|
} : {}), /*#__PURE__*/React__default.createElement(Delete, null))));
|
|
2874
3098
|
});
|
|
2875
3099
|
|
|
3100
|
+
/* *
|
|
3101
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3102
|
+
* you may not use this file except in compliance with the License.
|
|
3103
|
+
* You may obtain a copy of the License at
|
|
3104
|
+
*
|
|
3105
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3106
|
+
*
|
|
3107
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3108
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3109
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3110
|
+
* See the License for the specific language governing permissions and
|
|
3111
|
+
* limitations under the License.
|
|
3112
|
+
*
|
|
3113
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3114
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3115
|
+
* */
|
|
3116
|
+
|
|
2876
3117
|
var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
|
|
2877
3118
|
switch (sumOfErrors) {
|
|
2878
3119
|
case 0:
|
|
@@ -2882,7 +3123,7 @@ var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
|
|
|
2882
3123
|
return '1 issue';
|
|
2883
3124
|
|
|
2884
3125
|
default:
|
|
2885
|
-
return sumOfErrors
|
|
3126
|
+
return "".concat(sumOfErrors, " issues");
|
|
2886
3127
|
}
|
|
2887
3128
|
};
|
|
2888
3129
|
|
|
@@ -2906,22 +3147,39 @@ var buttonStyle = function buttonStyle(color) {
|
|
|
2906
3147
|
};
|
|
2907
3148
|
};
|
|
2908
3149
|
|
|
2909
|
-
var IssuesButton = function IssuesButton(
|
|
2910
|
-
var togglePane =
|
|
2911
|
-
sumOfErrors =
|
|
3150
|
+
var IssuesButton = function IssuesButton(_ref) {
|
|
3151
|
+
var togglePane = _ref.togglePane,
|
|
3152
|
+
sumOfErrors = _ref.sumOfErrors;
|
|
2912
3153
|
var color = sumOfErrors > 0 ? 'red' : 'green';
|
|
2913
3154
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
2914
3155
|
title: "View details"
|
|
2915
3156
|
}, /*#__PURE__*/React.createElement(Chip, {
|
|
3157
|
+
"data-testid": "issuesButton",
|
|
2916
3158
|
size: "small",
|
|
2917
3159
|
label: getIssuesLabel(sumOfErrors),
|
|
2918
|
-
style:
|
|
3160
|
+
style: Object.assign({}, buttonStyle(color)),
|
|
2919
3161
|
onClick: togglePane
|
|
2920
3162
|
}));
|
|
2921
3163
|
};
|
|
2922
3164
|
|
|
3165
|
+
/* *
|
|
3166
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3167
|
+
* you may not use this file except in compliance with the License.
|
|
3168
|
+
* You may obtain a copy of the License at
|
|
3169
|
+
*
|
|
3170
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3171
|
+
*
|
|
3172
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3173
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3174
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3175
|
+
* See the License for the specific language governing permissions and
|
|
3176
|
+
* limitations under the License.
|
|
3177
|
+
*
|
|
3178
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3179
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3180
|
+
* */
|
|
2923
3181
|
var ThumbsUp = function ThumbsUp(props) {
|
|
2924
|
-
return /*#__PURE__*/React__default.createElement(SvgIcon,
|
|
3182
|
+
return /*#__PURE__*/React__default.createElement(SvgIcon, Object.assign({
|
|
2925
3183
|
fontSize: "inherit",
|
|
2926
3184
|
viewBox: "0 0 58 69"
|
|
2927
3185
|
}, props), /*#__PURE__*/React__default.createElement("title", null, "Thumbs up"), /*#__PURE__*/React__default.createElement("g", {
|
|
@@ -2958,32 +3216,9 @@ var ThumbsUp = function ThumbsUp(props) {
|
|
|
2958
3216
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2959
3217
|
* */
|
|
2960
3218
|
var useStyles$8 = makeStyles({
|
|
2961
|
-
issuesPane: {
|
|
2962
|
-
display: 'flex',
|
|
2963
|
-
flexDirection: 'column',
|
|
2964
|
-
overflow: 'hidden',
|
|
2965
|
-
width: '577px',
|
|
2966
|
-
height: '164px',
|
|
2967
|
-
marginTop: '16px'
|
|
2968
|
-
},
|
|
2969
|
-
paneHeader: {
|
|
2970
|
-
display: 'flex',
|
|
2971
|
-
justifyContent: 'space-between',
|
|
2972
|
-
alignItems: 'center',
|
|
2973
|
-
height: '24px'
|
|
2974
|
-
},
|
|
2975
|
-
paneTitle: {
|
|
2976
|
-
display: 'flex',
|
|
2977
|
-
justifyContent: 'space-between',
|
|
2978
|
-
alignItems: 'center',
|
|
2979
|
-
marginLeft: '32px',
|
|
2980
|
-
fontSize: '10px',
|
|
2981
|
-
fontWeight: 'bold'
|
|
2982
|
-
},
|
|
2983
3219
|
paneContent: {
|
|
2984
3220
|
marginTop: '16px',
|
|
2985
|
-
marginLeft: '
|
|
2986
|
-
overflowY: 'scroll'
|
|
3221
|
+
marginLeft: '24px'
|
|
2987
3222
|
},
|
|
2988
3223
|
image: {
|
|
2989
3224
|
fontSize: '4rem'
|
|
@@ -3017,10 +3252,10 @@ var getErrorDefaultMessage = function getErrorDefaultMessage(error) {
|
|
|
3017
3252
|
}
|
|
3018
3253
|
};
|
|
3019
3254
|
|
|
3020
|
-
var capitalizeWord = function capitalizeWord(
|
|
3021
|
-
var
|
|
3022
|
-
firstLetter =
|
|
3023
|
-
restOfWord =
|
|
3255
|
+
var capitalizeWord = function capitalizeWord(_ref) {
|
|
3256
|
+
var _ref2 = _toArray(_ref),
|
|
3257
|
+
firstLetter = _ref2[0],
|
|
3258
|
+
restOfWord = _ref2.slice(1);
|
|
3024
3259
|
|
|
3025
3260
|
return firstLetter.toUpperCase() + restOfWord.join('');
|
|
3026
3261
|
};
|
|
@@ -3028,19 +3263,20 @@ var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
|
|
|
3028
3263
|
var nameWithoutBrackets = nameAsString.replace(/[[\]']+/g, '');
|
|
3029
3264
|
var nameLowerCase = nameWithoutBrackets.toLowerCase();
|
|
3030
3265
|
|
|
3031
|
-
var
|
|
3266
|
+
var _nameLowerCase$split$ = nameLowerCase.split(/([0-9]+)/) // split numbers from field and build array
|
|
3032
3267
|
.filter(function (s) {
|
|
3033
3268
|
return s.length;
|
|
3034
|
-
}),
|
|
3035
|
-
|
|
3036
|
-
|
|
3269
|
+
}),
|
|
3270
|
+
_nameLowerCase$split$2 = _slicedToArray(_nameLowerCase$split$, 2),
|
|
3271
|
+
fieldName = _nameLowerCase$split$2[0],
|
|
3272
|
+
fieldNumberedValue = _nameLowerCase$split$2[1];
|
|
3037
3273
|
|
|
3038
3274
|
var nameCapitalized = capitalizeWord(fieldName);
|
|
3039
3275
|
|
|
3040
3276
|
if (fieldNumberedValue) {
|
|
3041
3277
|
// when name contains a number we assume it's a formgroup and we add a index +1 for human readability
|
|
3042
3278
|
var fieldNumber = parseInt(fieldNumberedValue, 10) + 1;
|
|
3043
|
-
return nameCapitalized
|
|
3279
|
+
return "".concat(nameCapitalized, " ").concat(fieldNumber);
|
|
3044
3280
|
}
|
|
3045
3281
|
|
|
3046
3282
|
return nameCapitalized;
|
|
@@ -3048,31 +3284,37 @@ var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
|
|
|
3048
3284
|
var getErrorMessage = function getErrorMessage(error, index) {
|
|
3049
3285
|
var name = error.ref.name;
|
|
3050
3286
|
|
|
3051
|
-
var
|
|
3052
|
-
|
|
3287
|
+
var _name$split = name.split('.'),
|
|
3288
|
+
_name$split2 = _slicedToArray(_name$split, 1),
|
|
3289
|
+
firstNamePart = _name$split2[0];
|
|
3053
3290
|
|
|
3054
3291
|
var fieldErrorTitle = humanizeErrorMessage(firstNamePart);
|
|
3055
|
-
return index + 1
|
|
3292
|
+
return "".concat(index + 1, ". ").concat(fieldErrorTitle, ": ").concat(getErrorDefaultMessage(error));
|
|
3056
3293
|
};
|
|
3057
3294
|
|
|
3058
|
-
var IssuesPane = function IssuesPane(
|
|
3059
|
-
var
|
|
3060
|
-
|
|
3061
|
-
errorList =
|
|
3295
|
+
var IssuesPane = function IssuesPane(_ref3) {
|
|
3296
|
+
var isOpen = _ref3.isOpen,
|
|
3297
|
+
handleClose = _ref3.handleClose,
|
|
3298
|
+
_ref3$errorList = _ref3.errorList,
|
|
3299
|
+
errorList = _ref3$errorList === void 0 ? [] : _ref3$errorList;
|
|
3062
3300
|
var classes = useStyles$8();
|
|
3063
|
-
return /*#__PURE__*/React.createElement(
|
|
3064
|
-
|
|
3065
|
-
|
|
3301
|
+
return /*#__PURE__*/React.createElement(ToolContainerDraggable, {
|
|
3302
|
+
startSize: {
|
|
3303
|
+
width: '577px',
|
|
3304
|
+
height: '200px'
|
|
3305
|
+
},
|
|
3306
|
+
startPosition: {
|
|
3307
|
+
left: 370,
|
|
3308
|
+
top: 570
|
|
3309
|
+
},
|
|
3310
|
+
minWidth: 300,
|
|
3311
|
+
onClose: handleClose,
|
|
3312
|
+
title: getPaneTitle(errorList.length),
|
|
3313
|
+
headerSize: "xs",
|
|
3314
|
+
isOpen: isOpen,
|
|
3315
|
+
"data-testid": "moveable-issues-pane",
|
|
3316
|
+
bounds: "body"
|
|
3066
3317
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3067
|
-
className: classes.paneHeader
|
|
3068
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
3069
|
-
"data-testid": "issuesPaneTitle",
|
|
3070
|
-
className: classes.paneTitle
|
|
3071
|
-
}, getPaneTitle(errorList.length)), /*#__PURE__*/React.createElement(IconButton, {
|
|
3072
|
-
"data-testid": "closeIssuesPane",
|
|
3073
|
-
size: "small",
|
|
3074
|
-
onClick: handleClose
|
|
3075
|
-
}, /*#__PURE__*/React.createElement(Close, null))), /*#__PURE__*/React.createElement("div", {
|
|
3076
3318
|
className: classes.paneContent
|
|
3077
3319
|
}, errorList.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
3078
3320
|
className: classes.image,
|
|
@@ -3081,7 +3323,7 @@ var IssuesPane = function IssuesPane(_a) {
|
|
|
3081
3323
|
return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
|
|
3082
3324
|
, {
|
|
3083
3325
|
// eslint-disable-next-line react/no-array-index-key
|
|
3084
|
-
key: "message-"
|
|
3326
|
+
key: "message-".concat(index),
|
|
3085
3327
|
variant: "body1",
|
|
3086
3328
|
"data-testid": "errorMessage"
|
|
3087
3329
|
}, getErrorMessage(error, index));
|
|
@@ -3093,7 +3335,7 @@ var getCustomError = function getCustomError(error) {
|
|
|
3093
3335
|
var isChangeGroup = name.includes('changeGroups');
|
|
3094
3336
|
var matchRowNumber = name.match(/\[(.*?)\]/);
|
|
3095
3337
|
var row = matchRowNumber ? parseInt(matchRowNumber[1], 10) : null;
|
|
3096
|
-
return
|
|
3338
|
+
return Object.assign(Object.assign({}, error), {
|
|
3097
3339
|
isChangeGroup: isChangeGroup,
|
|
3098
3340
|
row: row
|
|
3099
3341
|
});
|
|
@@ -3102,7 +3344,7 @@ var getCustomError = function getCustomError(error) {
|
|
|
3102
3344
|
var getErrorValues = function getErrorValues(fieldErrors) {
|
|
3103
3345
|
if (!fieldErrors) return [];
|
|
3104
3346
|
return Object.keys(fieldErrors).reduce(function (list, key) {
|
|
3105
|
-
var error =
|
|
3347
|
+
var error = Object.assign({}, fieldErrors[key]);
|
|
3106
3348
|
|
|
3107
3349
|
if (error.ref) {
|
|
3108
3350
|
return list.concat(getCustomError(error));
|
|
@@ -3120,7 +3362,7 @@ var getErrors = function getErrors(errors) {
|
|
|
3120
3362
|
var errorValues = errorValue.reduce(function (l, i) {
|
|
3121
3363
|
return l.concat(getErrorValues(i));
|
|
3122
3364
|
}, []);
|
|
3123
|
-
return list.concat.apply(list,
|
|
3365
|
+
return list.concat.apply(list, _toConsumableArray(errorValues));
|
|
3124
3366
|
}
|
|
3125
3367
|
|
|
3126
3368
|
return list.concat(getErrorValues(errorValue));
|
|
@@ -3130,7 +3372,7 @@ var getErrors = function getErrors(errors) {
|
|
|
3130
3372
|
|
|
3131
3373
|
var filterDuplicateErrors = function filterDuplicateErrors(errors) {
|
|
3132
3374
|
return errors.reduce(function (list, error) {
|
|
3133
|
-
//
|
|
3375
|
+
// check on type validateRequiredSub and validateRequiredMainOptional since these are giving 'duplicates'
|
|
3134
3376
|
if (error.type === 'validateRequiredSub') {
|
|
3135
3377
|
var exist = list.find(function (e) {
|
|
3136
3378
|
return e.type === 'validateRequiredSub' && e.row === error.row;
|
|
@@ -3138,20 +3380,32 @@ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
|
|
|
3138
3380
|
return exist ? list : list.concat(error);
|
|
3139
3381
|
}
|
|
3140
3382
|
|
|
3383
|
+
if (error.type === 'validateRequiredMainOptional') {
|
|
3384
|
+
var _exist = list.find(function (e) {
|
|
3385
|
+
return e.type === 'validateRequiredMainOptional' && e.row === error.row;
|
|
3386
|
+
});
|
|
3387
|
+
|
|
3388
|
+
return _exist ? list : list.concat(error);
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3141
3391
|
return list.concat(error);
|
|
3142
3392
|
}, []);
|
|
3143
3393
|
};
|
|
3144
3394
|
|
|
3145
|
-
var TafFormButtons = function TafFormButtons(
|
|
3146
|
-
var tafAction =
|
|
3147
|
-
onTafFormButtonPress =
|
|
3395
|
+
var TafFormButtons = function TafFormButtons(_ref) {
|
|
3396
|
+
var tafAction = _ref.tafAction,
|
|
3397
|
+
onTafFormButtonPress = _ref.onTafFormButtonPress;
|
|
3148
3398
|
var classes = useStyles$9();
|
|
3149
|
-
|
|
3399
|
+
|
|
3400
|
+
var _useFormContext = useFormContext(),
|
|
3401
|
+
errors = _useFormContext.errors;
|
|
3402
|
+
|
|
3150
3403
|
var errorList = filterDuplicateErrors(getErrors(errors));
|
|
3151
3404
|
|
|
3152
|
-
var
|
|
3153
|
-
|
|
3154
|
-
|
|
3405
|
+
var _React$useState = React__default.useState(false),
|
|
3406
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3407
|
+
isIssuesPaneOpen = _React$useState2[0],
|
|
3408
|
+
setIsIssuesPaneOpen = _React$useState2[1];
|
|
3155
3409
|
|
|
3156
3410
|
var toggleIssuesPane = function toggleIssuesPane() {
|
|
3157
3411
|
return setIsIssuesPaneOpen(!isIssuesPaneOpen);
|
|
@@ -3239,9 +3493,10 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3239
3493
|
break;
|
|
3240
3494
|
}
|
|
3241
3495
|
}
|
|
3242
|
-
}, "Publish"))),
|
|
3496
|
+
}, "Publish"))), /*#__PURE__*/React__default.createElement(IssuesPane, {
|
|
3243
3497
|
errorList: errorList,
|
|
3244
|
-
handleClose: toggleIssuesPane
|
|
3498
|
+
handleClose: toggleIssuesPane,
|
|
3499
|
+
isOpen: isIssuesPaneOpen
|
|
3245
3500
|
}));
|
|
3246
3501
|
};
|
|
3247
3502
|
|
|
@@ -3275,21 +3530,24 @@ var useStyles$7 = makeStyles(function () {
|
|
|
3275
3530
|
};
|
|
3276
3531
|
});
|
|
3277
3532
|
|
|
3278
|
-
var DragHandle = function DragHandle(
|
|
3279
|
-
var
|
|
3280
|
-
isSorting =
|
|
3281
|
-
|
|
3282
|
-
isDisabled =
|
|
3533
|
+
var DragHandle = function DragHandle(_ref) {
|
|
3534
|
+
var _ref$isSorting = _ref.isSorting,
|
|
3535
|
+
isSorting = _ref$isSorting === void 0 ? false : _ref$isSorting,
|
|
3536
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
3537
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
3538
|
+
index = _ref.index;
|
|
3283
3539
|
var classes = useStyles$7(isSorting);
|
|
3284
3540
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3285
|
-
className: classes.dragHandle
|
|
3286
|
-
"data-testid": "dragHandle",
|
|
3541
|
+
className: "".concat(classes.dragHandle, " handle"),
|
|
3542
|
+
"data-testid": "dragHandle-".concat(index),
|
|
3287
3543
|
disableRipple: true,
|
|
3288
3544
|
disabled: isDisabled
|
|
3289
3545
|
}, /*#__PURE__*/React__default.createElement(DragIndicator, null));
|
|
3290
3546
|
};
|
|
3291
3547
|
|
|
3292
|
-
var
|
|
3548
|
+
var noop = function noop() {};
|
|
3549
|
+
|
|
3550
|
+
var emptyChangegroup = {
|
|
3293
3551
|
valid: '',
|
|
3294
3552
|
wind: '',
|
|
3295
3553
|
visibility: '',
|
|
@@ -3308,73 +3566,71 @@ var emptyRow = {
|
|
|
3308
3566
|
probability: null
|
|
3309
3567
|
};
|
|
3310
3568
|
|
|
3311
|
-
var TafForm = function TafForm(
|
|
3312
|
-
var
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
onFormAction = _c === void 0 ? function () {
|
|
3569
|
+
var TafForm = function TafForm(_ref) {
|
|
3570
|
+
var isDisabled = _ref.isDisabled,
|
|
3571
|
+
tafAction = _ref.tafAction,
|
|
3572
|
+
_ref$staticTAC = _ref.staticTAC,
|
|
3573
|
+
staticTAC = _ref$staticTAC === void 0 ? '' : _ref$staticTAC,
|
|
3574
|
+
_ref$onFormAction = _ref.onFormAction,
|
|
3575
|
+
onFormAction = _ref$onFormAction === void 0 ? function () {
|
|
3319
3576
|
return null;
|
|
3320
|
-
} :
|
|
3577
|
+
} : _ref$onFormAction;
|
|
3321
3578
|
var classes = useStyles$9();
|
|
3322
3579
|
var confirmDialog = useConfirmationDialog();
|
|
3323
3580
|
|
|
3324
|
-
var
|
|
3325
|
-
toggleIsDraft =
|
|
3326
|
-
DraftFieldHelper =
|
|
3581
|
+
var _useDraftFormHelpers = useDraftFormHelpers(),
|
|
3582
|
+
toggleIsDraft = _useDraftFormHelpers.toggleIsDraft,
|
|
3583
|
+
DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
|
|
3327
3584
|
|
|
3328
|
-
var
|
|
3329
|
-
|
|
3585
|
+
var _useApiContext = useApiContext(),
|
|
3586
|
+
api = _useApiContext.api;
|
|
3330
3587
|
|
|
3331
|
-
var
|
|
3332
|
-
|
|
3333
|
-
handleSubmit = _e.handleSubmit,
|
|
3334
|
-
watch = _e.watch,
|
|
3335
|
-
getValues = _e.getValues,
|
|
3336
|
-
errors = _e.errors,
|
|
3337
|
-
trigger = _e.trigger;
|
|
3588
|
+
var _useIsMounted = useIsMounted(),
|
|
3589
|
+
isMounted = _useIsMounted.isMounted;
|
|
3338
3590
|
|
|
3339
|
-
var
|
|
3591
|
+
var _useFormContext = useFormContext(),
|
|
3592
|
+
control = _useFormContext.control,
|
|
3593
|
+
handleSubmit = _useFormContext.handleSubmit,
|
|
3594
|
+
watch = _useFormContext.watch,
|
|
3595
|
+
trigger = _useFormContext.trigger,
|
|
3596
|
+
formState = _useFormContext.formState,
|
|
3597
|
+
getValues = _useFormContext.getValues;
|
|
3340
3598
|
|
|
3341
|
-
var
|
|
3342
|
-
|
|
3343
|
-
|
|
3599
|
+
var isFormDirty = formState.isDirty,
|
|
3600
|
+
errors = formState.errors;
|
|
3601
|
+
usePreventBrowserClose(isFormDirty && !isDisabled);
|
|
3602
|
+
var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
|
|
3344
3603
|
|
|
3345
|
-
var
|
|
3346
|
-
|
|
3347
|
-
|
|
3604
|
+
var _React$useState = React__default.useState(watch()),
|
|
3605
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3606
|
+
delayedFormValues = _React$useState2[0],
|
|
3607
|
+
setDelayedFormValues = _React$useState2[1];
|
|
3348
3608
|
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3609
|
+
var _useTACGenerator = useTACGenerator(convertTafValuesToObject(delayedFormValues), api.getTAC, staticTAC),
|
|
3610
|
+
_useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
|
|
3611
|
+
TAC = _useTACGenerator2[0],
|
|
3612
|
+
updateTAC = _useTACGenerator2[1];
|
|
3353
3613
|
|
|
3354
|
-
|
|
3614
|
+
var hasErrors = Object.keys(errors).length;
|
|
3355
3615
|
|
|
3356
3616
|
var onFormBlur = function onFormBlur() {
|
|
3357
3617
|
setDelayedFormValues(getValues());
|
|
3358
3618
|
};
|
|
3359
3619
|
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
return !isFormDirty ? setFormDirty(true) : null;
|
|
3366
|
-
};
|
|
3620
|
+
React__default.useEffect(function () {
|
|
3621
|
+
if (staticTAC === '' && isMounted.current && isFormDirty) {
|
|
3622
|
+
var newTAC = hasErrors ? null : convertTafValuesToObject(delayedFormValues);
|
|
3623
|
+
updateTAC(newTAC);
|
|
3624
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3367
3625
|
|
|
3368
|
-
|
|
3626
|
+
}, [delayedFormValues]);
|
|
3627
|
+
React__default.useEffect(function () {
|
|
3628
|
+
// prevent updating an error while typing
|
|
3629
|
+
if (!hasErrors && isFormDirty && document.activeElement.tagName !== 'INPUT') {
|
|
3630
|
+
updateTAC(convertTafValuesToObject(delayedFormValues));
|
|
3631
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3369
3632
|
|
|
3370
|
-
|
|
3371
|
-
control: control,
|
|
3372
|
-
name: 'changeGroups'
|
|
3373
|
-
}),
|
|
3374
|
-
fields = _j.fields,
|
|
3375
|
-
append = _j.append,
|
|
3376
|
-
remove = _j.remove,
|
|
3377
|
-
move = _j.move;
|
|
3633
|
+
}, [hasErrors]);
|
|
3378
3634
|
|
|
3379
3635
|
var onSubmit = function onSubmit(data) {
|
|
3380
3636
|
// eslint-disable-next-line no-console
|
|
@@ -3428,38 +3684,39 @@ var TafForm = function TafForm(_a) {
|
|
|
3428
3684
|
}
|
|
3429
3685
|
};
|
|
3430
3686
|
|
|
3431
|
-
var
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
append(group, false);
|
|
3440
|
-
});
|
|
3441
|
-
} else if (!isDisabled) {
|
|
3442
|
-
append(emptyRow, false);
|
|
3443
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3687
|
+
var _useFieldArray = useFieldArray({
|
|
3688
|
+
control: control,
|
|
3689
|
+
name: 'changeGroups'
|
|
3690
|
+
}),
|
|
3691
|
+
fields = _useFieldArray.fields,
|
|
3692
|
+
append = _useFieldArray.append,
|
|
3693
|
+
remove = _useFieldArray.remove,
|
|
3694
|
+
move = _useFieldArray.move;
|
|
3444
3695
|
|
|
3445
|
-
|
|
3696
|
+
var lastTotalFields = usePrevious(fields.length);
|
|
3446
3697
|
|
|
3447
|
-
var
|
|
3448
|
-
onChangeOrder =
|
|
3449
|
-
|
|
3450
|
-
|
|
3698
|
+
var _useDragOrder = useDragOrder(trigger, move, onFormBlur),
|
|
3699
|
+
onChangeOrder = _useDragOrder.onChangeOrder,
|
|
3700
|
+
onStartDrag = _useDragOrder.onStartDrag,
|
|
3701
|
+
activeDraggingIndex = _useDragOrder.activeDraggingIndex;
|
|
3451
3702
|
|
|
3452
3703
|
var onRemoverow = function onRemoverow(index) {
|
|
3453
3704
|
remove(index);
|
|
3454
|
-
var newList = fields.length > 1 ? fields.filter(function (_, fieldIndex) {
|
|
3455
|
-
return fieldIndex === index;
|
|
3456
|
-
}) : [];
|
|
3457
|
-
setSortedFields(newList);
|
|
3458
3705
|
};
|
|
3459
3706
|
|
|
3707
|
+
var onAddRow = function onAddRow() {
|
|
3708
|
+
append(emptyChangegroup, true);
|
|
3709
|
+
};
|
|
3710
|
+
|
|
3711
|
+
React__default.useEffect(function () {
|
|
3712
|
+
if (isFormDirty && fields.length !== lastTotalFields) {
|
|
3713
|
+
onFormBlur();
|
|
3714
|
+
trigger(); // trigger all field validation,
|
|
3715
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3716
|
+
|
|
3717
|
+
}, [fields.length, isFormDirty]);
|
|
3460
3718
|
return /*#__PURE__*/React__default.createElement("form", {
|
|
3461
3719
|
onSubmit: handleSubmit(onSubmit),
|
|
3462
|
-
onChange: onFormChange,
|
|
3463
3720
|
onBlur: onFormBlur
|
|
3464
3721
|
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
3465
3722
|
className: classes.tacTitle
|
|
@@ -3476,20 +3733,19 @@ var TafForm = function TafForm(_a) {
|
|
|
3476
3733
|
disabled: isDisabled
|
|
3477
3734
|
}), /*#__PURE__*/React__default.createElement(ReactSortable, {
|
|
3478
3735
|
tag: "div",
|
|
3479
|
-
list:
|
|
3480
|
-
setList:
|
|
3736
|
+
list: fields,
|
|
3737
|
+
setList: noop,
|
|
3481
3738
|
animation: 200,
|
|
3482
3739
|
onSort: onChangeOrder,
|
|
3483
3740
|
handle: ".handle",
|
|
3484
3741
|
direction: "vertical",
|
|
3485
3742
|
// hover props
|
|
3486
3743
|
forceFallback: true,
|
|
3487
|
-
onStart: function onStart() {
|
|
3744
|
+
onStart: function onStart(event) {
|
|
3745
|
+
onStartDrag(event);
|
|
3488
3746
|
Sortable.ghost.style.opacity = '1';
|
|
3489
3747
|
}
|
|
3490
|
-
},
|
|
3491
|
-
var chosen = _a.chosen;
|
|
3492
|
-
var item = fields[index];
|
|
3748
|
+
}, fields.map(function (item, index) {
|
|
3493
3749
|
return /*#__PURE__*/React__default.createElement(TafFormRow, {
|
|
3494
3750
|
field: item,
|
|
3495
3751
|
className: classes.formRow,
|
|
@@ -3500,8 +3756,9 @@ var TafForm = function TafForm(_a) {
|
|
|
3500
3756
|
onRemoveChangeGroup: onRemoverow,
|
|
3501
3757
|
isChangeGroup: true,
|
|
3502
3758
|
dragHandle: /*#__PURE__*/React__default.createElement(DragHandle, {
|
|
3503
|
-
isDisabled:
|
|
3504
|
-
isSorting:
|
|
3759
|
+
isDisabled: fields.length === 1 || isDisabled,
|
|
3760
|
+
isSorting: activeDraggingIndex === index,
|
|
3761
|
+
index: index
|
|
3505
3762
|
})
|
|
3506
3763
|
});
|
|
3507
3764
|
})), !isDisabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
@@ -3525,6 +3782,22 @@ var TafForm = function TafForm(_a) {
|
|
|
3525
3782
|
}), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null));
|
|
3526
3783
|
};
|
|
3527
3784
|
|
|
3785
|
+
/* *
|
|
3786
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3787
|
+
* you may not use this file except in compliance with the License.
|
|
3788
|
+
* You may obtain a copy of the License at
|
|
3789
|
+
*
|
|
3790
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3791
|
+
*
|
|
3792
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3793
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3794
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3795
|
+
* See the License for the specific language governing permissions and
|
|
3796
|
+
* limitations under the License.
|
|
3797
|
+
*
|
|
3798
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3799
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3800
|
+
* */
|
|
3528
3801
|
var getMessageType = function getMessageType(taf, tafAction) {
|
|
3529
3802
|
if (tafAction === 'CORRECT') {
|
|
3530
3803
|
return 'COR';
|
|
@@ -3548,47 +3821,46 @@ var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafA
|
|
|
3548
3821
|
start: now,
|
|
3549
3822
|
end: taf.baseForecast.valid.end
|
|
3550
3823
|
};
|
|
3551
|
-
return
|
|
3824
|
+
return Object.assign(Object.assign({}, taf), {
|
|
3552
3825
|
previousValidDateStart: previousValidDateStart,
|
|
3553
3826
|
previousValidDateEnd: previousValidDateEnd,
|
|
3554
3827
|
validDateStart: now,
|
|
3555
|
-
baseForecast:
|
|
3828
|
+
baseForecast: Object.assign(Object.assign({}, taf.baseForecast), {
|
|
3556
3829
|
valid: validObj
|
|
3557
3830
|
})
|
|
3558
3831
|
});
|
|
3559
3832
|
}
|
|
3560
3833
|
|
|
3561
|
-
return
|
|
3834
|
+
return Object.assign(Object.assign({}, taf), {
|
|
3562
3835
|
previousValidDateStart: previousValidDateStart,
|
|
3563
3836
|
previousValidDateEnd: previousValidDateEnd
|
|
3564
3837
|
});
|
|
3565
3838
|
};
|
|
3566
3839
|
var prepareTafValues = function prepareTafValues(_taf, tafAction) {
|
|
3840
|
+
var addEmptyChangeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3567
3841
|
// If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
|
|
3568
3842
|
// If action is AMEND/DRAFT_AMEND - update validity start time to current time
|
|
3569
3843
|
var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
|
|
3570
|
-
return
|
|
3844
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
|
|
3571
3845
|
messageType: getMessageType(taf, tafAction),
|
|
3572
3846
|
baseForecast: formatFormValues(taf.baseForecast)
|
|
3573
3847
|
}), taf.changeGroups && {
|
|
3574
3848
|
changeGroups: taf.changeGroups.map(formatFormValues)
|
|
3849
|
+
}), addEmptyChangeGroup && {
|
|
3850
|
+
changeGroups: [emptyChangegroup]
|
|
3575
3851
|
});
|
|
3576
3852
|
};
|
|
3577
3853
|
|
|
3578
|
-
var TafFormWrapper = function TafFormWrapper(
|
|
3579
|
-
var tafFromBackend =
|
|
3580
|
-
mode =
|
|
3581
|
-
tafAction =
|
|
3582
|
-
|
|
3583
|
-
TAC =
|
|
3584
|
-
onFormAction =
|
|
3585
|
-
var taf = tafFromBackend.taf;
|
|
3586
|
-
|
|
3587
|
-
var
|
|
3588
|
-
_d = _c.changeGroups,
|
|
3589
|
-
changeGroups = _d === void 0 ? [] : _d,
|
|
3590
|
-
defaultValues = __rest(_c, ["changeGroups"]);
|
|
3591
|
-
|
|
3854
|
+
var TafFormWrapper = function TafFormWrapper(_ref) {
|
|
3855
|
+
var tafFromBackend = _ref.tafFromBackend,
|
|
3856
|
+
mode = _ref.mode,
|
|
3857
|
+
tafAction = _ref.tafAction,
|
|
3858
|
+
_ref$TAC = _ref.TAC,
|
|
3859
|
+
TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
|
|
3860
|
+
onFormAction = _ref.onFormAction;
|
|
3861
|
+
var taf = tafFromBackend.taf;
|
|
3862
|
+
var isDisabled = mode === 'view';
|
|
3863
|
+
var defaultValues = prepareTafValues(taf, tafAction, !isDisabled && !taf.changeGroups);
|
|
3592
3864
|
var options = {
|
|
3593
3865
|
defaultValues: defaultValues,
|
|
3594
3866
|
mode: 'onTouched',
|
|
@@ -3598,8 +3870,7 @@ var TafFormWrapper = function TafFormWrapper(_a) {
|
|
|
3598
3870
|
return /*#__PURE__*/React__default.createElement(ReactHookFormProvider, {
|
|
3599
3871
|
options: options
|
|
3600
3872
|
}, /*#__PURE__*/React__default.createElement(TafForm, {
|
|
3601
|
-
|
|
3602
|
-
changeGroups: changeGroups,
|
|
3873
|
+
isDisabled: isDisabled,
|
|
3603
3874
|
tafAction: tafAction,
|
|
3604
3875
|
staticTAC: TAC,
|
|
3605
3876
|
onFormAction: onFormAction
|
|
@@ -3636,20 +3907,25 @@ var ContentDialog = function ContentDialog(_a) {
|
|
|
3636
3907
|
var titleComponent = _a.titleComponent,
|
|
3637
3908
|
children = _a.children;
|
|
3638
3909
|
_a.onClose;
|
|
3639
|
-
var
|
|
3640
|
-
alertBanner =
|
|
3910
|
+
var _a$alertBanner = _a.alertBanner,
|
|
3911
|
+
alertBanner = _a$alertBanner === void 0 ? null : _a$alertBanner,
|
|
3641
3912
|
onFormAction = _a.onFormAction,
|
|
3642
3913
|
other = __rest(_a, ["open", "toggleDialogStatus", "titleComponent", "children", "onClose", "alertBanner", "onFormAction"]);
|
|
3643
3914
|
|
|
3644
3915
|
var classes = useStyles$6();
|
|
3645
|
-
return /*#__PURE__*/React.createElement(Dialog,
|
|
3916
|
+
return /*#__PURE__*/React.createElement(Dialog, Object.assign({
|
|
3646
3917
|
"data-testid": "contentDialog",
|
|
3647
3918
|
open: open,
|
|
3648
3919
|
onClose: function onClose() {
|
|
3649
3920
|
return onFormAction('CLOSE');
|
|
3650
3921
|
},
|
|
3651
3922
|
maxWidth: other.maxWidth ? other.maxWidth : 'lg',
|
|
3652
|
-
disableBackdropClick: true
|
|
3923
|
+
disableBackdropClick: true,
|
|
3924
|
+
PaperProps: {
|
|
3925
|
+
style: {
|
|
3926
|
+
position: 'inherit'
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3653
3929
|
}, other), /*#__PURE__*/React.createElement(DialogTitle, {
|
|
3654
3930
|
disableTypography: true,
|
|
3655
3931
|
className: classes.dialogHeader
|
|
@@ -3750,13 +4026,13 @@ var useStyles$5 = makeStyles({
|
|
|
3750
4026
|
}
|
|
3751
4027
|
});
|
|
3752
4028
|
|
|
3753
|
-
var TafListRow = function TafListRow(
|
|
3754
|
-
var taf =
|
|
3755
|
-
listType =
|
|
3756
|
-
|
|
3757
|
-
TAC =
|
|
3758
|
-
|
|
3759
|
-
showTac =
|
|
4029
|
+
var TafListRow = function TafListRow(_ref) {
|
|
4030
|
+
var taf = _ref.taf,
|
|
4031
|
+
listType = _ref.listType,
|
|
4032
|
+
_ref$TAC = _ref.TAC,
|
|
4033
|
+
TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
|
|
4034
|
+
_ref$showTac = _ref.showTac,
|
|
4035
|
+
showTac = _ref$showTac === void 0 ? false : _ref$showTac;
|
|
3760
4036
|
var classes = useStyles$5();
|
|
3761
4037
|
var validTimeDate = moment.utc(taf.validDateStart).format('DD MMM');
|
|
3762
4038
|
var baseTime = moment.utc(taf.baseTime).format('HH:mm');
|
|
@@ -3909,16 +4185,19 @@ var getListType = function getListType(taf, locationSettings) {
|
|
|
3909
4185
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3910
4186
|
* */
|
|
3911
4187
|
|
|
3912
|
-
var TafFormDialog = function TafFormDialog(
|
|
3913
|
-
var open =
|
|
3914
|
-
toggleFormDialog =
|
|
3915
|
-
tafFromBackend =
|
|
3916
|
-
children =
|
|
3917
|
-
|
|
3918
|
-
alertBanner =
|
|
3919
|
-
onFormAction =
|
|
4188
|
+
var TafFormDialog = function TafFormDialog(_ref) {
|
|
4189
|
+
var open = _ref.open,
|
|
4190
|
+
toggleFormDialog = _ref.toggleFormDialog,
|
|
4191
|
+
tafFromBackend = _ref.tafFromBackend,
|
|
4192
|
+
children = _ref.children,
|
|
4193
|
+
_ref$alertBanner = _ref.alertBanner,
|
|
4194
|
+
alertBanner = _ref$alertBanner === void 0 ? null : _ref$alertBanner,
|
|
4195
|
+
onFormAction = _ref.onFormAction;
|
|
3920
4196
|
var taf = tafFromBackend ? tafFromBackend.taf : null;
|
|
3921
|
-
|
|
4197
|
+
|
|
4198
|
+
var _useTafSettings = useTafSettings(tafConfig),
|
|
4199
|
+
locationSettings = _useTafSettings.locations;
|
|
4200
|
+
|
|
3922
4201
|
return /*#__PURE__*/React__default.createElement(ContentDialog, {
|
|
3923
4202
|
open: open,
|
|
3924
4203
|
toggleDialogStatus: toggleFormDialog,
|
|
@@ -3955,10 +4234,10 @@ var useStyles$4 = makeStyles({
|
|
|
3955
4234
|
}
|
|
3956
4235
|
});
|
|
3957
4236
|
|
|
3958
|
-
var TafListButtons = function TafListButtons(
|
|
3959
|
-
var uuid =
|
|
3960
|
-
canBe =
|
|
3961
|
-
onClickTafActionButton =
|
|
4237
|
+
var TafListButtons = function TafListButtons(_ref) {
|
|
4238
|
+
var uuid = _ref.uuid,
|
|
4239
|
+
canBe = _ref.canBe,
|
|
4240
|
+
onClickTafActionButton = _ref.onClickTafActionButton;
|
|
3962
4241
|
var classes = useStyles$4();
|
|
3963
4242
|
return !canBe.includes('CANCELLED') && !canBe.includes('CORRECTED') && !canBe.includes('AMENDED') ? null : /*#__PURE__*/React__default.createElement(Grid, {
|
|
3964
4243
|
container: true,
|
|
@@ -4022,19 +4301,22 @@ var fromStatusToAction = function fromStatusToAction(tafStatus) {
|
|
|
4022
4301
|
}
|
|
4023
4302
|
};
|
|
4024
4303
|
|
|
4025
|
-
var TafListAccordion = function TafListAccordion(
|
|
4026
|
-
var tafListItem =
|
|
4027
|
-
listType =
|
|
4028
|
-
|
|
4029
|
-
errorCancelTaf =
|
|
4030
|
-
onClickTafActionButton =
|
|
4304
|
+
var TafListAccordion = function TafListAccordion(_ref) {
|
|
4305
|
+
var tafListItem = _ref.tafListItem,
|
|
4306
|
+
listType = _ref.listType,
|
|
4307
|
+
_ref$errorCancelTaf = _ref.errorCancelTaf,
|
|
4308
|
+
errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
|
|
4309
|
+
onClickTafActionButton = _ref.onClickTafActionButton;
|
|
4031
4310
|
var classes = useStyles$3();
|
|
4032
4311
|
var status = tafListItem.taf.status;
|
|
4033
|
-
var api = useApiContext().api;
|
|
4034
4312
|
|
|
4035
|
-
var
|
|
4036
|
-
|
|
4037
|
-
|
|
4313
|
+
var _useApiContext = useApiContext(),
|
|
4314
|
+
api = _useApiContext.api;
|
|
4315
|
+
|
|
4316
|
+
var _useTACGenerator = useTACGenerator(tafListItem.taf, api.getTAC),
|
|
4317
|
+
_useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
|
|
4318
|
+
TAC = _useTACGenerator2[0],
|
|
4319
|
+
requestTAC = _useTACGenerator2[1];
|
|
4038
4320
|
|
|
4039
4321
|
React__default.useEffect(function () {
|
|
4040
4322
|
// only re-retrieve TAC if draft state
|
|
@@ -4044,7 +4326,7 @@ var TafListAccordion = function TafListAccordion(_a) {
|
|
|
4044
4326
|
|
|
4045
4327
|
}, [tafListItem.taf]);
|
|
4046
4328
|
var popOut = status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED';
|
|
4047
|
-
return /*#__PURE__*/React__default.createElement(Accordion,
|
|
4329
|
+
return /*#__PURE__*/React__default.createElement(Accordion, Object.assign({
|
|
4048
4330
|
"data-testid": "tafListItem",
|
|
4049
4331
|
className: classes.accordion
|
|
4050
4332
|
}, popOut ? {
|
|
@@ -4127,22 +4409,22 @@ var useStyles$2 = makeStyles({
|
|
|
4127
4409
|
}
|
|
4128
4410
|
});
|
|
4129
4411
|
|
|
4130
|
-
var TafListSection = function TafListSection(
|
|
4131
|
-
var tafList =
|
|
4132
|
-
title =
|
|
4133
|
-
listType =
|
|
4134
|
-
|
|
4135
|
-
errorCancelTaf =
|
|
4136
|
-
onClickTafActionButton =
|
|
4412
|
+
var TafListSection = function TafListSection(_ref) {
|
|
4413
|
+
var tafList = _ref.tafList,
|
|
4414
|
+
title = _ref.title,
|
|
4415
|
+
listType = _ref.listType,
|
|
4416
|
+
_ref$errorCancelTaf = _ref.errorCancelTaf,
|
|
4417
|
+
errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
|
|
4418
|
+
onClickTafActionButton = _ref.onClickTafActionButton;
|
|
4137
4419
|
var classes = useStyles$2();
|
|
4138
4420
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Typography, {
|
|
4139
4421
|
variant: "subtitle2",
|
|
4140
4422
|
className: classes.listHeaders
|
|
4141
4423
|
}, title), /*#__PURE__*/React__default.createElement("div", {
|
|
4142
|
-
"data-testid": "tafList"
|
|
4424
|
+
"data-testid": "tafList".concat(listType)
|
|
4143
4425
|
}, tafList.map(function (tafListItem) {
|
|
4144
4426
|
return /*#__PURE__*/React__default.createElement(TafListAccordion, {
|
|
4145
|
-
key: tafListItem.taf.uuid
|
|
4427
|
+
key: "".concat(tafListItem.taf.uuid, "-").concat(tafListItem.taf.status),
|
|
4146
4428
|
tafListItem: tafListItem,
|
|
4147
4429
|
listType: listType,
|
|
4148
4430
|
errorCancelTaf: errorCancelTaf,
|
|
@@ -4164,25 +4446,29 @@ var useStyles$1 = makeStyles({
|
|
|
4164
4446
|
}
|
|
4165
4447
|
});
|
|
4166
4448
|
|
|
4167
|
-
var TafList = function TafList(
|
|
4168
|
-
var
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
errorCancelTaf = _c === void 0 ? [] : _c,
|
|
4175
|
-
onClickTafActionButton = _a.onClickTafActionButton;
|
|
4449
|
+
var TafList = function TafList(_ref) {
|
|
4450
|
+
var tafList = _ref.tafList,
|
|
4451
|
+
isLoading = _ref.isLoading,
|
|
4452
|
+
error = _ref.error,
|
|
4453
|
+
_ref$errorCancelTaf = _ref.errorCancelTaf,
|
|
4454
|
+
errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
|
|
4455
|
+
onClickTafActionButton = _ref.onClickTafActionButton;
|
|
4176
4456
|
var classes = useStyles$1();
|
|
4177
|
-
|
|
4457
|
+
|
|
4458
|
+
var _useTafSettings = useTafSettings(tafConfig),
|
|
4459
|
+
locationSettings = _useTafSettings.locations;
|
|
4460
|
+
|
|
4178
4461
|
var upcomingTafs = [];
|
|
4179
4462
|
var currentTafs = [];
|
|
4180
4463
|
var expiredTafs = [];
|
|
4181
4464
|
|
|
4182
4465
|
if (tafList) {
|
|
4466
|
+
var _iterator = _createForOfIteratorHelper(tafList),
|
|
4467
|
+
_step;
|
|
4468
|
+
|
|
4183
4469
|
try {
|
|
4184
|
-
for (
|
|
4185
|
-
var taf =
|
|
4470
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4471
|
+
var taf = _step.value;
|
|
4186
4472
|
var now = moment.utc();
|
|
4187
4473
|
var baseTime = moment.utc(taf.taf.baseTime);
|
|
4188
4474
|
var activityPeriod = locationSettings[taf.taf.location].activity_period;
|
|
@@ -4196,16 +4482,10 @@ var TafList = function TafList(_a) {
|
|
|
4196
4482
|
upcomingTafs.push(taf);
|
|
4197
4483
|
}
|
|
4198
4484
|
}
|
|
4199
|
-
} catch (
|
|
4200
|
-
|
|
4201
|
-
error: e_1_1
|
|
4202
|
-
};
|
|
4485
|
+
} catch (err) {
|
|
4486
|
+
_iterator.e(err);
|
|
4203
4487
|
} finally {
|
|
4204
|
-
|
|
4205
|
-
if (tafList_1_1 && !tafList_1_1.done && (_b = tafList_1["return"])) _b.call(tafList_1);
|
|
4206
|
-
} finally {
|
|
4207
|
-
if (e_1) throw e_1.error;
|
|
4208
|
-
}
|
|
4488
|
+
_iterator.f();
|
|
4209
4489
|
}
|
|
4210
4490
|
}
|
|
4211
4491
|
|
|
@@ -4280,14 +4560,13 @@ var Spinner = function Spinner() {
|
|
|
4280
4560
|
}));
|
|
4281
4561
|
};
|
|
4282
4562
|
|
|
4283
|
-
var useTimeoutCancelError = function useTimeoutCancelError(
|
|
4284
|
-
|
|
4285
|
-
pollingInterval = 10000;
|
|
4286
|
-
}
|
|
4563
|
+
var useTimeoutCancelError = function useTimeoutCancelError() {
|
|
4564
|
+
var pollingInterval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10000;
|
|
4287
4565
|
|
|
4288
|
-
var
|
|
4289
|
-
|
|
4290
|
-
|
|
4566
|
+
var _React$useState = React__default.useState([]),
|
|
4567
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
4568
|
+
errorCancelTaf = _React$useState2[0],
|
|
4569
|
+
setErrorCancelTaf = _React$useState2[1];
|
|
4291
4570
|
|
|
4292
4571
|
React__default.useEffect(function () {
|
|
4293
4572
|
var cancelErrorMessageHandler = errorCancelTaf.length > 0 ? setTimeout(function () {
|
|
@@ -4311,44 +4590,53 @@ var getSelectedTaf = function getSelectedTaf(selectedTafId, tafList) {
|
|
|
4311
4590
|
};
|
|
4312
4591
|
|
|
4313
4592
|
var TafWrapper = function TafWrapper() {
|
|
4314
|
-
var
|
|
4593
|
+
var _useApiContext = useApiContext(),
|
|
4594
|
+
api = _useApiContext.api;
|
|
4595
|
+
|
|
4315
4596
|
var confirmDialog = useConfirmationDialog();
|
|
4316
4597
|
|
|
4317
|
-
var
|
|
4318
|
-
|
|
4319
|
-
|
|
4598
|
+
var _React$useState3 = React__default.useState(false),
|
|
4599
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
4600
|
+
isTafDialogOpen = _React$useState4[0],
|
|
4601
|
+
setTafDialogOpen = _React$useState4[1];
|
|
4320
4602
|
|
|
4321
|
-
var
|
|
4322
|
-
|
|
4323
|
-
|
|
4603
|
+
var _React$useState5 = React__default.useState(null),
|
|
4604
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
4605
|
+
selectedTafId = _React$useState6[0],
|
|
4606
|
+
setselectedTafId = _React$useState6[1];
|
|
4324
4607
|
|
|
4325
|
-
var
|
|
4326
|
-
|
|
4327
|
-
|
|
4608
|
+
var _React$useState7 = React__default.useState(null),
|
|
4609
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
4610
|
+
tafDialogAction = _React$useState8[0],
|
|
4611
|
+
setTafDialogAction = _React$useState8[1];
|
|
4328
4612
|
|
|
4329
|
-
var
|
|
4330
|
-
|
|
4331
|
-
|
|
4613
|
+
var _React$useState9 = React__default.useState(false),
|
|
4614
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
4615
|
+
errorPostMessage = _React$useState10[0],
|
|
4616
|
+
setErrorPostMessage = _React$useState10[1];
|
|
4332
4617
|
|
|
4333
|
-
var
|
|
4334
|
-
|
|
4335
|
-
|
|
4618
|
+
var _React$useState11 = React__default.useState(''),
|
|
4619
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
4620
|
+
errorPostMessageText = _React$useState12[0],
|
|
4621
|
+
setErrorPostMessageText = _React$useState12[1];
|
|
4336
4622
|
|
|
4337
|
-
var
|
|
4338
|
-
|
|
4339
|
-
|
|
4623
|
+
var _React$useState13 = React__default.useState(false),
|
|
4624
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
4625
|
+
showSpinner = _React$useState14[0],
|
|
4626
|
+
setSpinner = _React$useState14[1]; // clear error message for cancel after 10 seconds
|
|
4340
4627
|
|
|
4341
4628
|
|
|
4342
|
-
var
|
|
4343
|
-
|
|
4344
|
-
|
|
4629
|
+
var _useTimeoutCancelErro = useTimeoutCancelError(),
|
|
4630
|
+
_useTimeoutCancelErro2 = _slicedToArray(_useTimeoutCancelErro, 2),
|
|
4631
|
+
errorCancelTaf = _useTimeoutCancelErro2[0],
|
|
4632
|
+
setErrorCancelTaf = _useTimeoutCancelErro2[1]; // Retrieve list of tafs
|
|
4345
4633
|
|
|
4346
4634
|
|
|
4347
|
-
var
|
|
4348
|
-
errorList =
|
|
4349
|
-
isLoadingList =
|
|
4350
|
-
tafList =
|
|
4351
|
-
fetchNewTafList =
|
|
4635
|
+
var _useApi = useApi(api.getTafList),
|
|
4636
|
+
errorList = _useApi.error,
|
|
4637
|
+
isLoadingList = _useApi.isLoading,
|
|
4638
|
+
tafList = _useApi.result,
|
|
4639
|
+
fetchNewTafList = _useApi.fetchApiData;
|
|
4352
4640
|
|
|
4353
4641
|
var getNewTafList = function getNewTafList() {
|
|
4354
4642
|
fetchNewTafList({});
|
|
@@ -4379,7 +4667,9 @@ var TafWrapper = function TafWrapper() {
|
|
|
4379
4667
|
description: 'Are you sure you want to cancel this TAF?',
|
|
4380
4668
|
confirmLabel: 'Cancel'
|
|
4381
4669
|
}).then(function () {
|
|
4382
|
-
var
|
|
4670
|
+
var _getSelectedTaf = getSelectedTaf(tafUuid, tafList),
|
|
4671
|
+
taf = _getSelectedTaf.taf;
|
|
4672
|
+
|
|
4383
4673
|
postTaf({
|
|
4384
4674
|
taf: taf,
|
|
4385
4675
|
changeStatusTo: 'CANCELLED'
|
|
@@ -4395,59 +4685,49 @@ var TafWrapper = function TafWrapper() {
|
|
|
4395
4685
|
};
|
|
4396
4686
|
|
|
4397
4687
|
var postTaf = function postTaf(data) {
|
|
4398
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
setErrorCancelTaf(__spreadArray(__spreadArray([], __read(errorCancelTaf)), [data.taf.uuid]));
|
|
4431
|
-
} else {
|
|
4432
|
-
setErrorPostMessage(true);
|
|
4433
|
-
|
|
4434
|
-
if (isAxiosError(error_1)) {
|
|
4435
|
-
setErrorPostMessageText(getAxiosErrorMessage(error_1));
|
|
4688
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4689
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4690
|
+
while (1) {
|
|
4691
|
+
switch (_context.prev = _context.next) {
|
|
4692
|
+
case 0:
|
|
4693
|
+
setSpinner(true);
|
|
4694
|
+
_context.prev = 1;
|
|
4695
|
+
_context.next = 4;
|
|
4696
|
+
return api.postTaf(data);
|
|
4697
|
+
|
|
4698
|
+
case 4:
|
|
4699
|
+
if (isTafDialogOpen) toggleTafDialog();
|
|
4700
|
+
setSpinner(false); // fetch new taflist
|
|
4701
|
+
|
|
4702
|
+
getNewTafList(); // If a post has succeeded remove error message
|
|
4703
|
+
|
|
4704
|
+
setErrorCancelTaf([]);
|
|
4705
|
+
_context.next = 14;
|
|
4706
|
+
break;
|
|
4707
|
+
|
|
4708
|
+
case 10:
|
|
4709
|
+
_context.prev = 10;
|
|
4710
|
+
_context.t0 = _context["catch"](1);
|
|
4711
|
+
|
|
4712
|
+
if (data.changeStatusTo === 'CANCELLED') {
|
|
4713
|
+
setErrorCancelTaf([].concat(_toConsumableArray(errorCancelTaf), [data.taf.uuid]));
|
|
4714
|
+
} else {
|
|
4715
|
+
setErrorPostMessage(true);
|
|
4716
|
+
|
|
4717
|
+
if (isAxiosError(_context.t0)) {
|
|
4718
|
+
setErrorPostMessageText(getAxiosErrorMessage(_context.t0));
|
|
4719
|
+
}
|
|
4436
4720
|
}
|
|
4437
|
-
}
|
|
4438
4721
|
|
|
4439
|
-
|
|
4440
|
-
return [3
|
|
4441
|
-
/*break*/
|
|
4442
|
-
, 4];
|
|
4722
|
+
setSpinner(false);
|
|
4443
4723
|
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4724
|
+
case 14:
|
|
4725
|
+
case "end":
|
|
4726
|
+
return _context.stop();
|
|
4727
|
+
}
|
|
4448
4728
|
}
|
|
4449
|
-
});
|
|
4450
|
-
});
|
|
4729
|
+
}, _callee, null, [[1, 10]]);
|
|
4730
|
+
}));
|
|
4451
4731
|
};
|
|
4452
4732
|
|
|
4453
4733
|
var fromActionToStatus = function fromActionToStatus(tafAction) {
|
|
@@ -4543,18 +4823,34 @@ var ConfirmationWrapper = function ConfirmationWrapper() {
|
|
|
4543
4823
|
return /*#__PURE__*/React__default.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React__default.createElement(TafWrapper, null));
|
|
4544
4824
|
};
|
|
4545
4825
|
|
|
4546
|
-
|
|
4547
|
-
|
|
4826
|
+
/* *
|
|
4827
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4828
|
+
* you may not use this file except in compliance with the License.
|
|
4829
|
+
* You may obtain a copy of the License at
|
|
4830
|
+
*
|
|
4831
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4832
|
+
*
|
|
4833
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4834
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4835
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4836
|
+
* See the License for the specific language governing permissions and
|
|
4837
|
+
* limitations under the License.
|
|
4838
|
+
*
|
|
4839
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
4840
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
4841
|
+
* */
|
|
4842
|
+
var createApi = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
|
|
4843
|
+
var axiosInstance = createApiInstance(url, appUrl, auth, setAuth, authTokenUrl, authClientId);
|
|
4548
4844
|
return {
|
|
4549
4845
|
// api data
|
|
4550
4846
|
getTafList: function getTafList() {
|
|
4551
4847
|
return axiosInstance.get('/taflist');
|
|
4552
4848
|
},
|
|
4553
4849
|
postTaf: function postTaf(formData) {
|
|
4554
|
-
return axiosInstance.post('/taf',
|
|
4850
|
+
return axiosInstance.post('/taf', Object.assign({}, formData));
|
|
4555
4851
|
},
|
|
4556
4852
|
getTAC: function getTAC(tafData) {
|
|
4557
|
-
return axiosInstance.post('/taf2tac',
|
|
4853
|
+
return axiosInstance.post('/taf2tac', Object.assign({}, tafData));
|
|
4558
4854
|
}
|
|
4559
4855
|
};
|
|
4560
4856
|
};
|