@opengeoweb/warnings 12.11.0 → 12.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +534 -114
- package/package.json +12 -12
- package/src/lib/api/warning-api/api.d.ts +2 -2
- package/src/lib/api/warning-api/hooks.d.ts +3 -2
- package/src/lib/components/MaritimeWarningsForm/AreaList/AreaList.d.ts +4 -2
- package/src/lib/components/MaritimeWarningsForm/AssignedAreas/AssignedAreas.d.ts +2 -0
- package/src/lib/components/MaritimeWarningsForm/AssignedAreas/AssignedAreas.spec.d.ts +1 -0
- package/src/lib/components/MaritimeWarningsForm/MaritimeWarningsAvatar.d.ts +8 -0
- package/src/lib/components/MaritimeWarningsForm/MaritimeWarningsForm.d.ts +4 -0
- package/src/lib/components/MaritimeWarningsForm/MaritimeWarningsForm.spec.d.ts +1 -2
- package/src/lib/components/MaritimeWarningsForm/MaritimeWarningsForm.stories.d.ts +7 -3
- package/src/lib/components/MaritimeWarningsForm/WarningList/WarningList.d.ts +2 -0
- package/src/lib/components/MaritimeWarningsForm/WarningList/WarningListItem.d.ts +3 -1
- package/src/lib/components/MaritimeWarningsForm/WarningList/WarningListSelect.d.ts +2 -2
- package/src/lib/components/MaritimeWarningsForm/WarningList/WindForceSelect.d.ts +4 -2
- package/src/lib/components/MaritimeWarningsForm/testUtils.d.ts +3 -0
- package/src/lib/components/MaritimeWarningsForm/useFilterChipSelect.d.ts +12 -0
- package/src/lib/components/MaritimeWarningsForm/useFilterChipSelect.spec.d.ts +1 -0
- package/src/lib/components/MaritimeWarningsForm/useMaritimeWarningsFormState.d.ts +8 -1
- package/src/lib/components/MaritimeWarningsForm/utils.d.ts +5 -1
- package/src/lib/store/publicWarningForm/types.d.ts +12 -2
package/index.esm.js
CHANGED
|
@@ -257,7 +257,12 @@ var en = {
|
|
|
257
257
|
"maritime-clear-dialog-description": "All warnings will be removed from the list",
|
|
258
258
|
"maritime-clear-success": "Warning list cleared successfully",
|
|
259
259
|
"maritime-warning-title-coastal": "Warning Maritime - Coastal Waters",
|
|
260
|
-
"maritime-warning-title-northsea": "Warning Maritime - North Sea Districts"
|
|
260
|
+
"maritime-warning-title-northsea": "Warning Maritime - North Sea Districts",
|
|
261
|
+
"maritime-domain-coastal": "Coastal Waters",
|
|
262
|
+
"maritime-domain-northsea": "North Sea Districts",
|
|
263
|
+
"maritime-editor-on": "You are now the editor of the Maritime Warnings for {{domain}}",
|
|
264
|
+
"maritime-editor-off": "You are now no longer the editor of the Maritime Warnings for {{domain}}",
|
|
265
|
+
"maritime-warning-post-success": "Warning published successfully"
|
|
261
266
|
};
|
|
262
267
|
var nl = {
|
|
263
268
|
"drawing-tool-form-tools": "Gereedschap",
|
|
@@ -452,7 +457,8 @@ var nl = {
|
|
|
452
457
|
"maritime-clear-dialog-description": "Alle waarschuwingen worden verwijderd",
|
|
453
458
|
"maritime-clear-success": "Alle waarchuwingen zijn verwijderd",
|
|
454
459
|
"maritime-warning-title-coastal": "Maritieme Waarschuwing - Kustgebieden",
|
|
455
|
-
"maritime-warning-title-northsea": "Maritieme Waarschuwing - Noordzee Districten"
|
|
460
|
+
"maritime-warning-title-northsea": "Maritieme Waarschuwing - Noordzee Districten",
|
|
461
|
+
"maritime-warning-post-success": "Waarschuwing succesvol gepubliceerd"
|
|
456
462
|
};
|
|
457
463
|
var fi = {
|
|
458
464
|
"drawing-tool-form-tools": "Työkalut",
|
|
@@ -604,7 +610,9 @@ var fi = {
|
|
|
604
610
|
"aviation-discard-success": "{{warningType}} er forkastet!",
|
|
605
611
|
"error-auth-login": "Tämän toiminnallisuuden käyttäminen vaatii tunnistautumista. Kirjaudu sisään jatkaaksesi",
|
|
606
612
|
"cancel-warningType": "Peruuta {{warningType}}",
|
|
607
|
-
cancelling: "Peruuttaminen"
|
|
613
|
+
cancelling: "Peruuttaminen",
|
|
614
|
+
"maritime-editor-off": "Et ole enää {{domain}} -merivaroitusten muokkaaja",
|
|
615
|
+
"maritime-warning-post-success": "Varoitus julkaistu onnistuneesti"
|
|
608
616
|
};
|
|
609
617
|
var no = {
|
|
610
618
|
"drawing-tool-form-tools": "Verktøy",
|
|
@@ -2019,7 +2027,7 @@ var updatePublicWarning = function updatePublicWarning(warningId, auth, data) {
|
|
|
2019
2027
|
body: JSON.stringify(data)
|
|
2020
2028
|
}).then(handleResponse);
|
|
2021
2029
|
};
|
|
2022
|
-
var
|
|
2030
|
+
var postWarning = function postWarning(auth, data) {
|
|
2023
2031
|
return fetch(publicWarningBaseUrl + "/warnings/", {
|
|
2024
2032
|
headers: getHeaders(auth),
|
|
2025
2033
|
method: 'POST',
|
|
@@ -2384,7 +2392,7 @@ var defaultDomainFilter = {
|
|
|
2384
2392
|
};
|
|
2385
2393
|
var domainLevels = {
|
|
2386
2394
|
aviation: [Level.airmet, Level.sigmet],
|
|
2387
|
-
maritime: [],
|
|
2395
|
+
maritime: [Level.extreme, Level.moderate, Level.severe],
|
|
2388
2396
|
"public": [Level.extreme, Level.moderate, Level.severe]
|
|
2389
2397
|
};
|
|
2390
2398
|
var defaultLevelFilter = (_defaultLevelFilter = {}, _defaultLevelFilter[emptyFilterId] = true, _defaultLevelFilter.extreme = true, _defaultLevelFilter.moderate = true, _defaultLevelFilter.severe = true, _defaultLevelFilter.AIR = true, _defaultLevelFilter.SIG = true, _defaultLevelFilter);
|
|
@@ -2394,9 +2402,9 @@ var makeFilterFromList = function makeFilterFromList(options, value) {
|
|
|
2394
2402
|
if (value === void 0) {
|
|
2395
2403
|
value = true;
|
|
2396
2404
|
}
|
|
2397
|
-
return options.reduce(function (acc,
|
|
2405
|
+
return options.reduce(function (acc, property) {
|
|
2398
2406
|
var _Object$assign;
|
|
2399
|
-
return
|
|
2407
|
+
return property ? Object.assign({}, acc, (_Object$assign = {}, _Object$assign[property] = value, _Object$assign)) : acc;
|
|
2400
2408
|
}, (_options$reduce = {}, _options$reduce[emptyFilterId] = value, _options$reduce));
|
|
2401
2409
|
};
|
|
2402
2410
|
var AllPhenomena = Object.assign({}, AirmetPhenomena, SigmetPhenomena, Phenomenon$1);
|
|
@@ -2405,7 +2413,7 @@ var AllPhenomenaKeys = Object.fromEntries(Object.keys(AllPhenomena).map(function
|
|
|
2405
2413
|
}));
|
|
2406
2414
|
var domainPhenomena = {
|
|
2407
2415
|
aviation: [].concat(Object.keys(SigmetPhenomena), Object.keys(AirmetPhenomena)),
|
|
2408
|
-
maritime: [],
|
|
2416
|
+
maritime: [Phenomenon$1.wind],
|
|
2409
2417
|
"public": [].concat(Object.keys(Phenomenon$1))
|
|
2410
2418
|
};
|
|
2411
2419
|
var defaultPhenomenonFilter = makeFilterFromList(Object.keys(AllPhenomenaKeys));
|
|
@@ -2420,8 +2428,8 @@ var getSelectedOptions = function getSelectedOptions(options) {
|
|
|
2420
2428
|
if (options === void 0) {
|
|
2421
2429
|
options = {};
|
|
2422
2430
|
}
|
|
2423
|
-
var selectedOptions = Object.keys(options).filter(function (
|
|
2424
|
-
return options[
|
|
2431
|
+
var selectedOptions = Object.keys(options).filter(function (key) {
|
|
2432
|
+
return options[key];
|
|
2425
2433
|
});
|
|
2426
2434
|
var allSelected = selectedOptions.length === Object.keys(options).length;
|
|
2427
2435
|
return {
|
|
@@ -2432,26 +2440,26 @@ var getSelectedOptions = function getSelectedOptions(options) {
|
|
|
2432
2440
|
var updateState = function updateState(state, optionKey, value, only) {
|
|
2433
2441
|
var _Object$assign4;
|
|
2434
2442
|
if (only) {
|
|
2435
|
-
return Object.keys(state).reduce(function (acc,
|
|
2443
|
+
return Object.keys(state).reduce(function (acc, key) {
|
|
2436
2444
|
var _Object$assign2;
|
|
2437
|
-
return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[
|
|
2445
|
+
return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[key] = key === optionKey, _Object$assign2));
|
|
2438
2446
|
}, {});
|
|
2439
2447
|
}
|
|
2440
2448
|
if (optionKey === 'ALL') {
|
|
2441
2449
|
if (Object.keys(state).length < 2) {
|
|
2442
2450
|
return state;
|
|
2443
2451
|
}
|
|
2444
|
-
return Object.keys(state).reduce(function (acc,
|
|
2452
|
+
return Object.keys(state).reduce(function (acc, key) {
|
|
2445
2453
|
var _Object$assign3;
|
|
2446
|
-
return Object.assign({}, acc, (_Object$assign3 = {}, _Object$assign3[
|
|
2454
|
+
return Object.assign({}, acc, (_Object$assign3 = {}, _Object$assign3[key] = value, _Object$assign3));
|
|
2447
2455
|
}, {});
|
|
2448
2456
|
}
|
|
2449
2457
|
return Object.assign({}, state, (_Object$assign4 = {}, _Object$assign4[optionKey] = value, _Object$assign4));
|
|
2450
2458
|
};
|
|
2451
2459
|
/** Make sure our value is in the filter */
|
|
2452
2460
|
var getValue = function getValue(values, value) {
|
|
2453
|
-
return Object.values(values).find(function (
|
|
2454
|
-
return
|
|
2461
|
+
return Object.values(values).find(function (existingValue) {
|
|
2462
|
+
return existingValue === value;
|
|
2455
2463
|
}) || emptyFilterId;
|
|
2456
2464
|
};
|
|
2457
2465
|
var getFiltersFromWarnings = function getFiltersFromWarnings(warnings, filterKey) {
|
|
@@ -3044,7 +3052,7 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
|
|
|
3044
3052
|
if (id) {
|
|
3045
3053
|
return updatePublicWarning(id, auth, data);
|
|
3046
3054
|
}
|
|
3047
|
-
return
|
|
3055
|
+
return postWarning(auth, data);
|
|
3048
3056
|
},
|
|
3049
3057
|
onError: function onError(error) {
|
|
3050
3058
|
void queryClient.invalidateQueries({
|
|
@@ -3303,6 +3311,45 @@ var useMutateDeleteDrawing = function useMutateDeleteDrawing() {
|
|
|
3303
3311
|
}
|
|
3304
3312
|
});
|
|
3305
3313
|
};
|
|
3314
|
+
var usePostMaritimeWarning = function usePostMaritimeWarning() {
|
|
3315
|
+
var _useAuthenticationCon6 = useAuthenticationContext(),
|
|
3316
|
+
auth = _useAuthenticationCon6.auth;
|
|
3317
|
+
var queryClient = useQueryClient();
|
|
3318
|
+
var dispatch = useDispatch();
|
|
3319
|
+
return useMutation({
|
|
3320
|
+
mutationFn: function mutationFn(data) {
|
|
3321
|
+
if (!auth) {
|
|
3322
|
+
throw new Error('Authentication context not found');
|
|
3323
|
+
}
|
|
3324
|
+
return postWarning(auth, data);
|
|
3325
|
+
},
|
|
3326
|
+
onSuccess: function () {
|
|
3327
|
+
var _onSuccess4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
3328
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
3329
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3330
|
+
case 0:
|
|
3331
|
+
_context6.next = 2;
|
|
3332
|
+
return queryClient.invalidateQueries({
|
|
3333
|
+
queryKey: ['public-warning-list']
|
|
3334
|
+
});
|
|
3335
|
+
case 2:
|
|
3336
|
+
dispatch(snackbarActions.openSnackbar({
|
|
3337
|
+
type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
|
|
3338
|
+
key: 'maritime-warning-post-success'
|
|
3339
|
+
}));
|
|
3340
|
+
case 3:
|
|
3341
|
+
case "end":
|
|
3342
|
+
return _context6.stop();
|
|
3343
|
+
}
|
|
3344
|
+
}, _callee6);
|
|
3345
|
+
}));
|
|
3346
|
+
function onSuccess() {
|
|
3347
|
+
return _onSuccess4.apply(this, arguments);
|
|
3348
|
+
}
|
|
3349
|
+
return onSuccess;
|
|
3350
|
+
}()
|
|
3351
|
+
});
|
|
3352
|
+
};
|
|
3306
3353
|
|
|
3307
3354
|
var getDeleteDescription = function getDeleteDescription(objectName, t) {
|
|
3308
3355
|
return t('delete-dialog-description') + " \"" + objectName + "\"?";
|
|
@@ -4410,15 +4457,15 @@ var getSigmetList = function getSigmetList(auth) {
|
|
|
4410
4457
|
var getAirmetConfig = function getAirmetConfig(auth) {
|
|
4411
4458
|
return fetch(airmetBaseUrl + "/airmet-config", {
|
|
4412
4459
|
headers: getHeaders(auth)
|
|
4413
|
-
}).then(function (
|
|
4414
|
-
return
|
|
4460
|
+
}).then(function (result) {
|
|
4461
|
+
return result.json();
|
|
4415
4462
|
});
|
|
4416
4463
|
};
|
|
4417
4464
|
var getSigmetConfig = function getSigmetConfig(auth) {
|
|
4418
4465
|
return fetch(sigmetBaseUrl + "/sigmet-config", {
|
|
4419
4466
|
headers: getHeaders(auth)
|
|
4420
|
-
}).then(function (
|
|
4421
|
-
return
|
|
4467
|
+
}).then(function (result) {
|
|
4468
|
+
return result.json();
|
|
4422
4469
|
});
|
|
4423
4470
|
};
|
|
4424
4471
|
var getAirmetTAC = function getAirmetTAC(auth, product) {
|
|
@@ -4427,24 +4474,24 @@ var getAirmetTAC = function getAirmetTAC(auth, product) {
|
|
|
4427
4474
|
method: 'POST',
|
|
4428
4475
|
headers: getHeaders(auth)
|
|
4429
4476
|
}).then(/*#__PURE__*/function () {
|
|
4430
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
|
4477
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(result) {
|
|
4431
4478
|
var textData;
|
|
4432
4479
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4433
4480
|
while (1) switch (_context.prev = _context.next) {
|
|
4434
4481
|
case 0:
|
|
4435
|
-
if (!(
|
|
4482
|
+
if (!(result.status === 200)) {
|
|
4436
4483
|
_context.next = 5;
|
|
4437
4484
|
break;
|
|
4438
4485
|
}
|
|
4439
4486
|
_context.next = 3;
|
|
4440
|
-
return
|
|
4487
|
+
return result.text();
|
|
4441
4488
|
case 3:
|
|
4442
4489
|
textData = _context.sent;
|
|
4443
4490
|
return _context.abrupt("return", {
|
|
4444
4491
|
data: textData
|
|
4445
4492
|
});
|
|
4446
4493
|
case 5:
|
|
4447
|
-
throw new Error("Failed to fetch TAC data: " +
|
|
4494
|
+
throw new Error("Failed to fetch TAC data: " + result.statusText);
|
|
4448
4495
|
case 6:
|
|
4449
4496
|
case "end":
|
|
4450
4497
|
return _context.stop();
|
|
@@ -4462,24 +4509,24 @@ var getSigmetTAC = function getSigmetTAC(auth, product) {
|
|
|
4462
4509
|
method: 'POST',
|
|
4463
4510
|
headers: getHeaders(auth)
|
|
4464
4511
|
}).then(/*#__PURE__*/function () {
|
|
4465
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
4512
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(result) {
|
|
4466
4513
|
var textData;
|
|
4467
4514
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4468
4515
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4469
4516
|
case 0:
|
|
4470
|
-
if (!(
|
|
4517
|
+
if (!(result.status === 200)) {
|
|
4471
4518
|
_context2.next = 5;
|
|
4472
4519
|
break;
|
|
4473
4520
|
}
|
|
4474
4521
|
_context2.next = 3;
|
|
4475
|
-
return
|
|
4522
|
+
return result.text();
|
|
4476
4523
|
case 3:
|
|
4477
4524
|
textData = _context2.sent;
|
|
4478
4525
|
return _context2.abrupt("return", {
|
|
4479
4526
|
data: textData
|
|
4480
4527
|
});
|
|
4481
4528
|
case 5:
|
|
4482
|
-
throw new Error("Failed to fetch TAC data: " +
|
|
4529
|
+
throw new Error("Failed to fetch TAC data: " + result.statusText);
|
|
4483
4530
|
case 6:
|
|
4484
4531
|
case "end":
|
|
4485
4532
|
return _context2.stop();
|
|
@@ -4703,12 +4750,12 @@ function isCancelSigmet(warningDetail) {
|
|
|
4703
4750
|
return warningDetail.cancelsSigmetSequenceId !== undefined;
|
|
4704
4751
|
}
|
|
4705
4752
|
var flattenPublicWarning = function flattenPublicWarning(publicWarning) {
|
|
4706
|
-
if (publicWarning.type === '
|
|
4707
|
-
|
|
4753
|
+
if (publicWarning.type === 'airmet' || publicWarning.type === 'sigmet') {
|
|
4754
|
+
var sigmetAirmetDetails = publicWarning.sigmetAirmetDetails,
|
|
4755
|
+
rest = _objectWithoutPropertiesLoose(publicWarning, _excluded$6);
|
|
4756
|
+
return Object.assign({}, rest, sigmetAirmetDetails);
|
|
4708
4757
|
}
|
|
4709
|
-
|
|
4710
|
-
rest = _objectWithoutPropertiesLoose(publicWarning, _excluded$6);
|
|
4711
|
-
return Object.assign({}, rest, sigmetAirmetDetails);
|
|
4758
|
+
return {};
|
|
4712
4759
|
};
|
|
4713
4760
|
var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(apiAirmet, productConfig) {
|
|
4714
4761
|
var airmet = apiAirmet.airmet;
|
|
@@ -5621,15 +5668,80 @@ var ValidUntil = function ValidUntil(_ref) {
|
|
|
5621
5668
|
});
|
|
5622
5669
|
};
|
|
5623
5670
|
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5671
|
+
/* *
|
|
5672
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5673
|
+
* you may not use this file except in compliance with the License.
|
|
5674
|
+
* You may obtain a copy of the License at
|
|
5675
|
+
*
|
|
5676
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5677
|
+
*
|
|
5678
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5679
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5680
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5681
|
+
* See the License for the specific language governing permissions and
|
|
5682
|
+
* limitations under the License.
|
|
5683
|
+
*
|
|
5684
|
+
* Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5685
|
+
* Copyright 2025 - Finnish Meteorological Institute (FMI)
|
|
5686
|
+
* Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
|
|
5687
|
+
* */
|
|
5688
|
+
function useFilterChipSelect(_ref) {
|
|
5689
|
+
var selectedIds = _ref.selectedIds,
|
|
5690
|
+
assignedIds = _ref.assignedIds,
|
|
5691
|
+
onToggleSelect = _ref.onToggleSelect,
|
|
5692
|
+
onSelectMultiple = _ref.onSelectMultiple;
|
|
5693
|
+
var lastSelectedByClick = React__default.useRef(null);
|
|
5694
|
+
// reset lastSelectedByClick when it disappears from ids list
|
|
5695
|
+
React__default.useEffect(function () {
|
|
5696
|
+
if (lastSelectedByClick.current && (!assignedIds.includes(lastSelectedByClick.current) || !selectedIds.includes(lastSelectedByClick.current))) {
|
|
5697
|
+
lastSelectedByClick.current = null;
|
|
5698
|
+
}
|
|
5699
|
+
}, [assignedIds, selectedIds]);
|
|
5700
|
+
return {
|
|
5701
|
+
handleChipClick: function handleChipClick(id, event) {
|
|
5702
|
+
if (event.shiftKey && lastSelectedByClick.current) {
|
|
5703
|
+
var assignedAreasIdsArray = Array.from(assignedIds);
|
|
5704
|
+
var lastClickedIndex = assignedAreasIdsArray.indexOf(lastSelectedByClick.current);
|
|
5705
|
+
var clickedIndex = assignedAreasIdsArray.indexOf(id);
|
|
5706
|
+
var firstIndex = Math.min(clickedIndex, lastClickedIndex);
|
|
5707
|
+
var secondIndex = Math.max(clickedIndex, lastClickedIndex);
|
|
5708
|
+
onSelectMultiple == null || onSelectMultiple(assignedAreasIdsArray.slice(firstIndex, secondIndex + 1));
|
|
5709
|
+
} else {
|
|
5710
|
+
var idIsSelected = selectedIds.includes(id);
|
|
5711
|
+
if (!idIsSelected) {
|
|
5712
|
+
lastSelectedByClick.current = id;
|
|
5713
|
+
} else {
|
|
5714
|
+
lastSelectedByClick.current = null;
|
|
5715
|
+
}
|
|
5716
|
+
onToggleSelect == null || onToggleSelect(id);
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
};
|
|
5720
|
+
}
|
|
5721
|
+
|
|
5722
|
+
var AreaList = /*#__PURE__*/React__default.memo(function (_ref2) {
|
|
5723
|
+
var areas = _ref2.areas,
|
|
5724
|
+
selected = _ref2.selected,
|
|
5725
|
+
disabled = _ref2.disabled,
|
|
5726
|
+
isReadOnly = _ref2.isReadOnly,
|
|
5727
|
+
onToggleSelectArea = _ref2.onToggleSelectArea,
|
|
5728
|
+
onSelectMultipleAreas = _ref2.onSelectMultipleAreas;
|
|
5729
|
+
var _useFilterChipSelect = useFilterChipSelect({
|
|
5730
|
+
selectedIds: selected,
|
|
5731
|
+
assignedIds: areas.map(function (area) {
|
|
5732
|
+
return area.id;
|
|
5733
|
+
}),
|
|
5734
|
+
onSelectMultiple: onSelectMultipleAreas,
|
|
5735
|
+
onToggleSelect: onToggleSelectArea
|
|
5736
|
+
}),
|
|
5737
|
+
handleChipClick = _useFilterChipSelect.handleChipClick;
|
|
5629
5738
|
return jsx(Stack, {
|
|
5630
5739
|
"data-testid": "arealist",
|
|
5631
5740
|
direction: "row",
|
|
5632
5741
|
spacing: 1,
|
|
5742
|
+
style: {
|
|
5743
|
+
pointerEvents: !isReadOnly ? 'auto' : 'none'
|
|
5744
|
+
},
|
|
5633
5745
|
sx: {
|
|
5634
5746
|
display: 'block',
|
|
5635
5747
|
'.MuiChip-root': {
|
|
@@ -5646,8 +5758,10 @@ var AreaList = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
|
5646
5758
|
label: area.label,
|
|
5647
5759
|
isSelected: isSelected,
|
|
5648
5760
|
isDisabled: isDisabled,
|
|
5649
|
-
onClick: function onClick() {
|
|
5650
|
-
|
|
5761
|
+
onClick: function onClick(_ref, event) {
|
|
5762
|
+
if (!isReadOnly) {
|
|
5763
|
+
handleChipClick == null || handleChipClick(area.id, event);
|
|
5764
|
+
}
|
|
5651
5765
|
},
|
|
5652
5766
|
size: "medium"
|
|
5653
5767
|
}, area.id);
|
|
@@ -5709,12 +5823,15 @@ var WarningListHeaderContent = function WarningListHeaderContent(_ref) {
|
|
|
5709
5823
|
};
|
|
5710
5824
|
|
|
5711
5825
|
var AssignedAreas = function AssignedAreas(_ref) {
|
|
5712
|
-
var _sx;
|
|
5826
|
+
var _sx, _sx2;
|
|
5713
5827
|
var assignedAreas = _ref.assignedAreas,
|
|
5714
5828
|
selectedAreaIds = _ref.selectedAreaIds,
|
|
5715
5829
|
onAddClick = _ref.onAddClick,
|
|
5716
5830
|
onDeleteClick = _ref.onDeleteClick,
|
|
5717
5831
|
onToggleSelectArea = _ref.onToggleSelectArea,
|
|
5832
|
+
onSelectMultipleAreas = _ref.onSelectMultipleAreas,
|
|
5833
|
+
_ref$isReadOnly = _ref.isReadOnly,
|
|
5834
|
+
isReadOnly = _ref$isReadOnly === void 0 ? false : _ref$isReadOnly,
|
|
5718
5835
|
_ref$shouldShowDistri = _ref.shouldShowDistricts,
|
|
5719
5836
|
shouldShowDistricts = _ref$shouldShowDistri === void 0 ? false : _ref$shouldShowDistri;
|
|
5720
5837
|
var _useWarningsTranslati = useWarningsTranslation(),
|
|
@@ -5726,21 +5843,32 @@ var AssignedAreas = function AssignedAreas(_ref) {
|
|
|
5726
5843
|
}, [assignedAreas]);
|
|
5727
5844
|
// can add the selected areas when they don't appear in the assigned area list
|
|
5728
5845
|
var canAddSelectedAreas = React__default.useMemo(function () {
|
|
5729
|
-
return selectedAreaIds.length > 0 && selectedAreaIds.
|
|
5846
|
+
return !isReadOnly && selectedAreaIds.length > 0 && selectedAreaIds.some(function (id) {
|
|
5730
5847
|
return !assignedAreaIds.has(id);
|
|
5731
5848
|
});
|
|
5732
|
-
}, [selectedAreaIds, assignedAreaIds]);
|
|
5849
|
+
}, [isReadOnly, selectedAreaIds, assignedAreaIds]);
|
|
5850
|
+
var assignedAreaIdsArray = React__default.useMemo(function () {
|
|
5851
|
+
return Array.from(assignedAreaIds);
|
|
5852
|
+
}, [assignedAreaIds]);
|
|
5853
|
+
var _useFilterChipSelect = useFilterChipSelect({
|
|
5854
|
+
selectedIds: selectedAreaIds,
|
|
5855
|
+
assignedIds: assignedAreaIdsArray,
|
|
5856
|
+
onSelectMultiple: onSelectMultipleAreas,
|
|
5857
|
+
onToggleSelect: onToggleSelectArea
|
|
5858
|
+
}),
|
|
5859
|
+
handleChipClick = _useFilterChipSelect.handleChipClick;
|
|
5733
5860
|
var theme = useTheme();
|
|
5734
5861
|
return jsxs(Box, {
|
|
5735
|
-
sx: {
|
|
5862
|
+
sx: (_sx = {
|
|
5736
5863
|
display: 'flex',
|
|
5737
5864
|
gridArea: 'areas',
|
|
5738
5865
|
gap: 1,
|
|
5739
5866
|
minHeight: 32,
|
|
5740
|
-
marginLeft: 1,
|
|
5741
5867
|
paddingInline: 0.5,
|
|
5742
5868
|
borderRadius: 1
|
|
5743
|
-
},
|
|
5869
|
+
}, _sx["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
5870
|
+
marginLeft: 1
|
|
5871
|
+
}, _sx),
|
|
5744
5872
|
style: {
|
|
5745
5873
|
backgroundColor: canAddSelectedAreas ? theme.palette.geowebColors.cards.cardContainerMouseOver : undefined
|
|
5746
5874
|
},
|
|
@@ -5752,17 +5880,20 @@ var AssignedAreas = function AssignedAreas(_ref) {
|
|
|
5752
5880
|
},
|
|
5753
5881
|
children: shouldShowDistricts ? t('maritime-no-district-selected') : t('maritime-no-area-selected')
|
|
5754
5882
|
}), jsx(Box, {
|
|
5755
|
-
sx: (
|
|
5883
|
+
sx: (_sx2 = {
|
|
5756
5884
|
flexGrow: 1,
|
|
5757
5885
|
display: 'flex',
|
|
5758
5886
|
flexDirection: 'column',
|
|
5759
5887
|
gap: 0.5,
|
|
5760
5888
|
paddingBlock: 0.5,
|
|
5761
5889
|
alignItems: 'flex-start'
|
|
5762
|
-
},
|
|
5890
|
+
}, _sx2["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
5763
5891
|
flexWrap: 'wrap',
|
|
5764
5892
|
flexDirection: 'row'
|
|
5765
|
-
},
|
|
5893
|
+
}, _sx2),
|
|
5894
|
+
style: {
|
|
5895
|
+
pointerEvents: !isReadOnly ? 'auto' : 'none'
|
|
5896
|
+
},
|
|
5766
5897
|
children: assignedAreas.map(function (area) {
|
|
5767
5898
|
var isSelected = selectedAreaIds.includes(area.id);
|
|
5768
5899
|
return jsx(FilterChip, {
|
|
@@ -5770,15 +5901,17 @@ var AssignedAreas = function AssignedAreas(_ref) {
|
|
|
5770
5901
|
id: area.id,
|
|
5771
5902
|
label: area.label,
|
|
5772
5903
|
isSelected: isSelected,
|
|
5773
|
-
onClick: function onClick() {
|
|
5774
|
-
|
|
5904
|
+
onClick: function onClick(_chipRef, event) {
|
|
5905
|
+
if (!isReadOnly) {
|
|
5906
|
+
handleChipClick(area.id, event);
|
|
5907
|
+
}
|
|
5775
5908
|
},
|
|
5776
|
-
onClickIcon: isSelected ? function () {
|
|
5777
|
-
|
|
5909
|
+
onClickIcon: isSelected && !isReadOnly ? function () {
|
|
5910
|
+
onDeleteClick(area.id);
|
|
5778
5911
|
} : undefined
|
|
5779
5912
|
}, area.id);
|
|
5780
5913
|
})
|
|
5781
|
-
}), jsx(AddButton, {
|
|
5914
|
+
}), !isReadOnly && jsx(AddButton, {
|
|
5782
5915
|
show: canAddSelectedAreas,
|
|
5783
5916
|
onClick: onAddClick
|
|
5784
5917
|
})]
|
|
@@ -5817,8 +5950,8 @@ var WarningListSelect = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
|
5817
5950
|
renderValue = _ref.renderValue,
|
|
5818
5951
|
gridArea = _ref.gridArea,
|
|
5819
5952
|
additionalStyling = _ref.additionalStyling,
|
|
5820
|
-
_ref$
|
|
5821
|
-
|
|
5953
|
+
_ref$isReadOnly = _ref.isReadOnly,
|
|
5954
|
+
isReadOnly = _ref$isReadOnly === void 0 ? false : _ref$isReadOnly;
|
|
5822
5955
|
var currentIndex = options.findIndex(function (option) {
|
|
5823
5956
|
return option.value === value;
|
|
5824
5957
|
});
|
|
@@ -5833,14 +5966,24 @@ var WarningListSelect = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
|
5833
5966
|
style: {
|
|
5834
5967
|
maxWidth: '100%'
|
|
5835
5968
|
},
|
|
5836
|
-
isEnabled: !
|
|
5837
|
-
disabled:
|
|
5969
|
+
isEnabled: !isReadOnly,
|
|
5970
|
+
disabled: isReadOnly,
|
|
5838
5971
|
value: value != null ? value : '',
|
|
5839
5972
|
SelectDisplayProps: {
|
|
5840
5973
|
'aria-label': label
|
|
5841
5974
|
},
|
|
5842
5975
|
list: options,
|
|
5843
|
-
additionalStyling:
|
|
5976
|
+
additionalStyling: Object.assign({
|
|
5977
|
+
'&.Mui-disabled .MuiSvgIcon-root': {
|
|
5978
|
+
display: 'none'
|
|
5979
|
+
},
|
|
5980
|
+
'&.Mui-disabled': {
|
|
5981
|
+
color: 'inherit',
|
|
5982
|
+
'& .MuiInput-input': {
|
|
5983
|
+
WebkitTextFillColor: 'inherit'
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
}, additionalStyling),
|
|
5844
5987
|
currentIndex: currentIndex > -1 ? currentIndex : undefined,
|
|
5845
5988
|
renderValue: renderValue,
|
|
5846
5989
|
onChange: function onChange(event) {
|
|
@@ -5899,7 +6042,8 @@ var WindForceSelect = function WindForceSelect(_ref) {
|
|
|
5899
6042
|
var onChange = _ref.onChange,
|
|
5900
6043
|
value = _ref.value,
|
|
5901
6044
|
gridArea = _ref.gridArea,
|
|
5902
|
-
options = _ref.options
|
|
6045
|
+
options = _ref.options,
|
|
6046
|
+
isReadOnly = _ref.isReadOnly;
|
|
5903
6047
|
var warningListOptions = React__default.useMemo(function () {
|
|
5904
6048
|
return options.map(function (option) {
|
|
5905
6049
|
return {
|
|
@@ -5968,6 +6112,7 @@ var WindForceSelect = function WindForceSelect(_ref) {
|
|
|
5968
6112
|
onChange: onChange,
|
|
5969
6113
|
renderOption: renderOption,
|
|
5970
6114
|
renderValue: renderValue,
|
|
6115
|
+
isReadOnly: isReadOnly,
|
|
5971
6116
|
additionalStyling: {
|
|
5972
6117
|
'& .MuiSvgIcon-root': {
|
|
5973
6118
|
fill: arrowColor
|
|
@@ -6123,7 +6268,9 @@ var WarningListItem$1 = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
|
6123
6268
|
onRemove = _ref.onRemove,
|
|
6124
6269
|
onChange = _ref.onChange,
|
|
6125
6270
|
onToggleSelectArea = _ref.onToggleSelectArea,
|
|
6271
|
+
onSelectMultipleAreas = _ref.onSelectMultipleAreas,
|
|
6126
6272
|
onRemoveArea = _ref.onRemoveArea,
|
|
6273
|
+
isReadOnly = _ref.isReadOnly,
|
|
6127
6274
|
_ref$shouldShowDistri = _ref.shouldShowDistricts,
|
|
6128
6275
|
shouldShowDistricts = _ref$shouldShowDistri === void 0 ? false : _ref$shouldShowDistri;
|
|
6129
6276
|
var areasById = React__default.useMemo(function () {
|
|
@@ -6168,41 +6315,46 @@ var WarningListItem$1 = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
|
6168
6315
|
var handleAddClick = React__default.useCallback(function () {
|
|
6169
6316
|
onAddClick(warning.id);
|
|
6170
6317
|
}, [warning.id, onAddClick]);
|
|
6171
|
-
var shouldDisableDirTo = warning.changeType === 'NO_CHANGE';
|
|
6318
|
+
var shouldDisableDirTo = warning.changeType === 'NO_CHANGE' || isReadOnly;
|
|
6172
6319
|
return jsxs(StyledItem, {
|
|
6173
6320
|
"data-testid": "maritime-warning",
|
|
6174
|
-
children: [jsx(WarningListDragHandle, {}), jsx(WarningListSelect, {
|
|
6321
|
+
children: [!isReadOnly && jsx(WarningListDragHandle, {}), jsx(WarningListSelect, {
|
|
6175
6322
|
gridArea: "dirFrom",
|
|
6176
6323
|
label: t('maritime-header-direction-from'),
|
|
6177
6324
|
options: windDirections,
|
|
6178
6325
|
onChange: handleChangeFromDirection,
|
|
6179
|
-
value: warning.windDirectionFrom
|
|
6326
|
+
value: warning.windDirectionFrom,
|
|
6327
|
+
isReadOnly: isReadOnly
|
|
6180
6328
|
}), jsx(WindForceSelect, {
|
|
6181
6329
|
gridArea: "windForce",
|
|
6182
6330
|
value: warning.windForce,
|
|
6183
6331
|
options: windForce,
|
|
6184
|
-
onChange: handleChangeWindForce
|
|
6332
|
+
onChange: handleChangeWindForce,
|
|
6333
|
+
isReadOnly: isReadOnly
|
|
6185
6334
|
}), jsx(AssignedAreas, {
|
|
6186
6335
|
assignedAreas: assignedAreas,
|
|
6187
6336
|
selectedAreaIds: selectedAreaIds,
|
|
6188
6337
|
onAddClick: handleAddClick,
|
|
6189
6338
|
onToggleSelectArea: onToggleSelectArea,
|
|
6339
|
+
onSelectMultipleAreas: onSelectMultipleAreas,
|
|
6190
6340
|
onDeleteClick: onRemoveArea,
|
|
6191
|
-
shouldShowDistricts: shouldShowDistricts
|
|
6341
|
+
shouldShowDistricts: shouldShowDistricts,
|
|
6342
|
+
isReadOnly: isReadOnly
|
|
6192
6343
|
}), jsx(WarningListSelect, {
|
|
6193
6344
|
gridArea: "changeType",
|
|
6194
6345
|
label: t('maritime-header-change'),
|
|
6195
6346
|
options: change,
|
|
6196
6347
|
onChange: handleChangeWindChangeType,
|
|
6197
|
-
value: warning.changeType
|
|
6348
|
+
value: warning.changeType,
|
|
6349
|
+
isReadOnly: isReadOnly
|
|
6198
6350
|
}), jsx(WarningListSelect, {
|
|
6199
6351
|
gridArea: "dirTo",
|
|
6200
6352
|
label: t('maritime-header-direction-to'),
|
|
6201
6353
|
options: windDirections,
|
|
6202
6354
|
onChange: handleChangeToDirection,
|
|
6203
6355
|
value: warning.windDirectionTo,
|
|
6204
|
-
|
|
6205
|
-
}), jsx(CustomIconButton, {
|
|
6356
|
+
isReadOnly: shouldDisableDirTo
|
|
6357
|
+
}), !isReadOnly && jsx(CustomIconButton, {
|
|
6206
6358
|
sx: {
|
|
6207
6359
|
gridArea: 'delete',
|
|
6208
6360
|
justifySelf: 'end',
|
|
@@ -6235,7 +6387,7 @@ var StyledItem = styled('div')(function (_ref2) {
|
|
|
6235
6387
|
paddingInline: theme.spacing(0.25),
|
|
6236
6388
|
// styling for small windows
|
|
6237
6389
|
gridTemplateAreas: "\n \"drag dirFrom dirFrom windForce delete\"\n \". areas areas areas .\"\n \". changeType dirTo dirTo .\" \n ",
|
|
6238
|
-
gridTemplateColumns: '
|
|
6390
|
+
gridTemplateColumns: '20px minmax(87px, 1fr) 1fr minmax(60px, 1fr) 20px'
|
|
6239
6391
|
}, _ref3["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
6240
6392
|
gridTemplateAreas: "\n \"drag dirFrom windForce areas changeType dirTo delete\" \n ",
|
|
6241
6393
|
gridTemplateColumns: 'var(--grid-columns)'
|
|
@@ -6252,7 +6404,9 @@ var WarningList = function WarningList(_ref) {
|
|
|
6252
6404
|
onRemoveArea = _ref.onRemoveArea,
|
|
6253
6405
|
onChangeWarning = _ref.onChangeWarning,
|
|
6254
6406
|
onToggleSelectArea = _ref.onToggleSelectArea,
|
|
6407
|
+
onSelectMultipleAreas = _ref.onSelectMultipleAreas,
|
|
6255
6408
|
onMoveWarning = _ref.onMoveWarning,
|
|
6409
|
+
isReadOnly = _ref.isReadOnly,
|
|
6256
6410
|
_ref$shouldShowDistri = _ref.shouldShowDistricts,
|
|
6257
6411
|
shouldShowDistricts = _ref$shouldShowDistri === void 0 ? false : _ref$shouldShowDistri;
|
|
6258
6412
|
var _useWarningsTranslati = useWarningsTranslation(),
|
|
@@ -6266,7 +6420,8 @@ var WarningList = function WarningList(_ref) {
|
|
|
6266
6420
|
display: 'flex',
|
|
6267
6421
|
flexDirection: 'column',
|
|
6268
6422
|
minHeight: 0,
|
|
6269
|
-
|
|
6423
|
+
marginBottom: 1,
|
|
6424
|
+
'--grid-columns': '30px 150px 60px 2fr 100px 150px 1fr'
|
|
6270
6425
|
},
|
|
6271
6426
|
children: [jsxs(Box, {
|
|
6272
6427
|
sx: (_sx = {
|
|
@@ -6307,7 +6462,9 @@ var WarningList = function WarningList(_ref) {
|
|
|
6307
6462
|
warning: warning,
|
|
6308
6463
|
areas: areas,
|
|
6309
6464
|
selectedAreaIds: selectedAreaIds,
|
|
6465
|
+
isReadOnly: isReadOnly,
|
|
6310
6466
|
onToggleSelectArea: onToggleSelectArea,
|
|
6467
|
+
onSelectMultipleAreas: onSelectMultipleAreas,
|
|
6311
6468
|
onAddClick: onAddSelectedAreas,
|
|
6312
6469
|
onRemove: onRemoveWarning,
|
|
6313
6470
|
onChange: onChangeWarning,
|
|
@@ -6379,6 +6536,16 @@ function reducer(state, action) {
|
|
|
6379
6536
|
selectedAreaIds: [].concat(state.selectedAreaIds, [action.id])
|
|
6380
6537
|
});
|
|
6381
6538
|
}
|
|
6539
|
+
case 'selectMultipleAreas':
|
|
6540
|
+
{
|
|
6541
|
+
var newSelectedAreaIds = new Set([].concat(state.selectedAreaIds, action.ids));
|
|
6542
|
+
if (newSelectedAreaIds.size === state.selectedAreaIds.length) {
|
|
6543
|
+
return state;
|
|
6544
|
+
}
|
|
6545
|
+
return Object.assign({}, state, {
|
|
6546
|
+
selectedAreaIds: Array.from(newSelectedAreaIds)
|
|
6547
|
+
});
|
|
6548
|
+
}
|
|
6382
6549
|
case 'removeArea':
|
|
6383
6550
|
{
|
|
6384
6551
|
return Object.assign({}, state, {
|
|
@@ -6464,6 +6631,32 @@ function reducer(state, action) {
|
|
|
6464
6631
|
modified: true
|
|
6465
6632
|
});
|
|
6466
6633
|
}
|
|
6634
|
+
case 'mergeWarnings':
|
|
6635
|
+
{
|
|
6636
|
+
var clonedWarnings = new Set();
|
|
6637
|
+
var mergedWarnings = state.warnings.reduce(function (acc, warning) {
|
|
6638
|
+
var relatedWarningIndex = acc.findLastIndex(function (otherWarning) {
|
|
6639
|
+
return warning.windDirectionFrom === otherWarning.windDirectionFrom && warning.windForce === otherWarning.windForce && warning.changeType === otherWarning.changeType && warning.windDirectionTo === otherWarning.windDirectionTo;
|
|
6640
|
+
});
|
|
6641
|
+
if (relatedWarningIndex > -1) {
|
|
6642
|
+
var relatedWarning = acc[relatedWarningIndex];
|
|
6643
|
+
// clone the warning to make sure React knows that it is a new warning
|
|
6644
|
+
if (!clonedWarnings.has(relatedWarningIndex)) {
|
|
6645
|
+
clonedWarnings.add(relatedWarningIndex);
|
|
6646
|
+
var clonedRelatedWarning = Object.assign({}, relatedWarning, {
|
|
6647
|
+
assignedAreaIds: [].concat(relatedWarning.assignedAreaIds, warning.assignedAreaIds)
|
|
6648
|
+
});
|
|
6649
|
+
return acc["with"](relatedWarningIndex, clonedRelatedWarning);
|
|
6650
|
+
}
|
|
6651
|
+
relatedWarning.assignedAreaIds = [].concat(relatedWarning.assignedAreaIds, warning.assignedAreaIds);
|
|
6652
|
+
return acc;
|
|
6653
|
+
}
|
|
6654
|
+
return [].concat(acc, [warning]);
|
|
6655
|
+
}, []);
|
|
6656
|
+
return Object.assign({}, state, {
|
|
6657
|
+
warnings: mergedWarnings
|
|
6658
|
+
});
|
|
6659
|
+
}
|
|
6467
6660
|
case 'initialize':
|
|
6468
6661
|
{
|
|
6469
6662
|
if (action.warnings.length === 0) {
|
|
@@ -6605,14 +6798,102 @@ var isWarningsValid = function isWarningsValid(warnings) {
|
|
|
6605
6798
|
return !isWarningEmpty(warning) && isWarningValid(warning);
|
|
6606
6799
|
});
|
|
6607
6800
|
};
|
|
6801
|
+
// FIXME: should be based on the config from BE
|
|
6802
|
+
var getLevelFromWindForce = function getLevelFromWindForce(windForce) {
|
|
6803
|
+
var force = parseInt(windForce, 10);
|
|
6804
|
+
if (isNaN(force)) {
|
|
6805
|
+
return '';
|
|
6806
|
+
}
|
|
6807
|
+
if (force < 8) {
|
|
6808
|
+
return 'moderate';
|
|
6809
|
+
}
|
|
6810
|
+
if (force < 10) {
|
|
6811
|
+
return 'severe';
|
|
6812
|
+
}
|
|
6813
|
+
return 'extreme';
|
|
6814
|
+
};
|
|
6815
|
+
var getType = function getType(domain) {
|
|
6816
|
+
switch (domain) {
|
|
6817
|
+
case 'coastalWaters':
|
|
6818
|
+
return 'maritimeWarningCoastal';
|
|
6819
|
+
case 'northSeaDistricts':
|
|
6820
|
+
default:
|
|
6821
|
+
return 'maritimeWarningNorthSea';
|
|
6822
|
+
}
|
|
6823
|
+
};
|
|
6824
|
+
var mapItemsToMaritimeWarnings = function mapItemsToMaritimeWarnings(warnings, domain, editor) {
|
|
6825
|
+
var type = getType(domain);
|
|
6826
|
+
return warnings.map(function (warning) {
|
|
6827
|
+
return {
|
|
6828
|
+
type: type,
|
|
6829
|
+
editor: editor,
|
|
6830
|
+
status: PublicWarningStatus.PUBLISHED,
|
|
6831
|
+
warningDetail: {
|
|
6832
|
+
phenomenon: 'wind',
|
|
6833
|
+
validFrom: new Date().toISOString(),
|
|
6834
|
+
validUntil: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
|
|
6835
|
+
level: getLevelFromWindForce(warning.windForce || ''),
|
|
6836
|
+
probability: 100,
|
|
6837
|
+
areas: warning.assignedAreaIds.map(function (areaId) {
|
|
6838
|
+
return {
|
|
6839
|
+
objectName: areaId,
|
|
6840
|
+
geoJSON: {
|
|
6841
|
+
type: 'FeatureCollection',
|
|
6842
|
+
features: []
|
|
6843
|
+
}
|
|
6844
|
+
};
|
|
6845
|
+
}),
|
|
6846
|
+
windDirectionFrom: warning.windDirectionFrom,
|
|
6847
|
+
windForce: warning.windForce,
|
|
6848
|
+
changeType: warning.changeType,
|
|
6849
|
+
windDirectionTo: warning.windDirectionTo,
|
|
6850
|
+
descriptionOriginal: '',
|
|
6851
|
+
descriptionTranslation: '',
|
|
6852
|
+
domain: type
|
|
6853
|
+
}
|
|
6854
|
+
};
|
|
6855
|
+
});
|
|
6856
|
+
};
|
|
6857
|
+
var mapMaritimeWarningsToItems = function mapMaritimeWarningsToItems(warnings) {
|
|
6858
|
+
return warnings.map(function (warning) {
|
|
6859
|
+
var _warning$warningDetai;
|
|
6860
|
+
return {
|
|
6861
|
+
id: warning.id || '',
|
|
6862
|
+
assignedAreaIds: ((_warning$warningDetai = warning.warningDetail.areas) == null ? void 0 : _warning$warningDetai.map(function (area) {
|
|
6863
|
+
return area.objectName;
|
|
6864
|
+
})) || [],
|
|
6865
|
+
windDirectionFrom: warning.warningDetail.windDirectionFrom,
|
|
6866
|
+
windDirectionTo: warning.warningDetail.windDirectionTo,
|
|
6867
|
+
windForce: warning.warningDetail.windForce,
|
|
6868
|
+
changeType: warning.warningDetail.changeType
|
|
6869
|
+
};
|
|
6870
|
+
});
|
|
6871
|
+
};
|
|
6872
|
+
|
|
6873
|
+
var MaritimeWarningAvatar = function MaritimeWarningAvatar(_ref) {
|
|
6874
|
+
var editor = _ref.editor,
|
|
6875
|
+
_ref$tooltipPlacement = _ref.tooltipPlacement,
|
|
6876
|
+
tooltipPlacement = _ref$tooltipPlacement === void 0 ? 'bottom' : _ref$tooltipPlacement;
|
|
6877
|
+
return jsx(CustomTooltip, {
|
|
6878
|
+
title: "Editor: " + editor,
|
|
6879
|
+
placement: tooltipPlacement,
|
|
6880
|
+
children: jsx("span", {
|
|
6881
|
+
children: jsx(Avatar, {
|
|
6882
|
+
size: "small",
|
|
6883
|
+
children: getInitials(editor)
|
|
6884
|
+
})
|
|
6885
|
+
})
|
|
6886
|
+
});
|
|
6887
|
+
};
|
|
6608
6888
|
|
|
6609
6889
|
var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
6610
|
-
var _sx, _sx2, _sx3;
|
|
6890
|
+
var _sx, _sx2, _sx3, _sx4;
|
|
6611
6891
|
var areas = _ref.areas,
|
|
6612
6892
|
selectedAreaIds = _ref.selectedAreaIds,
|
|
6613
6893
|
modified = _ref.modified,
|
|
6614
6894
|
warnings = _ref.warnings,
|
|
6615
6895
|
onToggleSelectArea = _ref.onToggleSelectArea,
|
|
6896
|
+
onSelectMultipleAreas = _ref.onSelectMultipleAreas,
|
|
6616
6897
|
onAddSelectedAreas = _ref.onAddSelectedAreas,
|
|
6617
6898
|
onRemoveWarning = _ref.onRemoveWarning,
|
|
6618
6899
|
onRemoveArea = _ref.onRemoveArea,
|
|
@@ -6621,10 +6902,14 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6621
6902
|
onSubmit = _ref.onSubmit,
|
|
6622
6903
|
onClear = _ref.onClear,
|
|
6623
6904
|
onMoveWarning = _ref.onMoveWarning,
|
|
6905
|
+
onToggleReadOnly = _ref.onToggleReadOnly,
|
|
6906
|
+
isReadOnly = _ref.isReadOnly,
|
|
6624
6907
|
_ref$shouldShowDistri = _ref.shouldShowDistricts,
|
|
6625
|
-
shouldShowDistricts = _ref$shouldShowDistri === void 0 ? false : _ref$shouldShowDistri
|
|
6908
|
+
shouldShowDistricts = _ref$shouldShowDistri === void 0 ? false : _ref$shouldShowDistri,
|
|
6909
|
+
editor = _ref.editor;
|
|
6626
6910
|
var _useWarningsTranslati = useWarningsTranslation(),
|
|
6627
6911
|
t = _useWarningsTranslati.t;
|
|
6912
|
+
var showConfirmDialog = useConfirmationDialog();
|
|
6628
6913
|
var disabledAreaIds = warnings.flatMap(function (warning) {
|
|
6629
6914
|
return warning.assignedAreaIds;
|
|
6630
6915
|
});
|
|
@@ -6634,7 +6919,6 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6634
6919
|
onRemoveWarning: onRemoveWarning
|
|
6635
6920
|
}),
|
|
6636
6921
|
onRemoveWarningWithConfirmation = _useConfirmRetractDia.onRemoveWarningWithConfirmation;
|
|
6637
|
-
var showConfirmDialog = useConfirmationDialog();
|
|
6638
6922
|
var onClearWithConfirmation = React__default.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6639
6923
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6640
6924
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -6655,22 +6939,82 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6655
6939
|
}, _callee);
|
|
6656
6940
|
})), [onClear, t, showConfirmDialog]);
|
|
6657
6941
|
var isValid = isWarningsValid(warnings);
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6942
|
+
var onSwitchMode = /*#__PURE__*/function () {
|
|
6943
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
6944
|
+
var checked, isReadOnly;
|
|
6945
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
6946
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
6947
|
+
case 0:
|
|
6948
|
+
checked = event.target.checked;
|
|
6949
|
+
isReadOnly = !checked;
|
|
6950
|
+
if (!(modified && isReadOnly)) {
|
|
6951
|
+
_context2.next = 5;
|
|
6952
|
+
break;
|
|
6953
|
+
}
|
|
6954
|
+
_context2.next = 5;
|
|
6955
|
+
return showConfirmDialog({
|
|
6956
|
+
title: t('warning-view-mode-title'),
|
|
6957
|
+
description: t('warning-view-mode-description'),
|
|
6958
|
+
confirmLabel: t('warning-view-mode-confirm'),
|
|
6959
|
+
cancelLabel: t('warning-dialog-cancel')
|
|
6960
|
+
});
|
|
6961
|
+
case 5:
|
|
6962
|
+
onToggleReadOnly(isReadOnly);
|
|
6963
|
+
case 6:
|
|
6964
|
+
case "end":
|
|
6965
|
+
return _context2.stop();
|
|
6966
|
+
}
|
|
6967
|
+
}, _callee2);
|
|
6968
|
+
}));
|
|
6969
|
+
return function onSwitchMode(_x) {
|
|
6970
|
+
return _ref3.apply(this, arguments);
|
|
6971
|
+
};
|
|
6972
|
+
}();
|
|
6973
|
+
return jsxs(Box, {
|
|
6661
6974
|
sx: (_sx = {
|
|
6975
|
+
display: 'flex',
|
|
6976
|
+
flexDirection: 'column',
|
|
6977
|
+
gap: 1,
|
|
6662
6978
|
height: '100%',
|
|
6663
6979
|
containerName: 'maritime',
|
|
6664
6980
|
containerType: 'inline-size',
|
|
6665
|
-
padding: 2
|
|
6981
|
+
padding: 2,
|
|
6982
|
+
// in a dialog there is an additional empty footer that messes up styling. This hack fixes that.
|
|
6983
|
+
'[role="dialog"] &': {
|
|
6984
|
+
paddingBottom: 0
|
|
6985
|
+
}
|
|
6666
6986
|
}, _sx["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
6667
6987
|
padding: 3
|
|
6668
6988
|
}, _sx),
|
|
6669
|
-
children: [
|
|
6989
|
+
children: [jsxs(Box, {
|
|
6990
|
+
sx: (_sx2 = {
|
|
6991
|
+
display: 'flex',
|
|
6992
|
+
gap: 1,
|
|
6993
|
+
alignItems: 'center'
|
|
6994
|
+
}, _sx2["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
6995
|
+
justifyContent: 'flex-end'
|
|
6996
|
+
}, _sx2),
|
|
6997
|
+
children: [jsx(SwitchButton, {
|
|
6998
|
+
inActiveLabel: t('warning-editor-user-viewer'),
|
|
6999
|
+
activeLabel: t('warning-editor-user-editor'),
|
|
7000
|
+
checked: !isReadOnly,
|
|
7001
|
+
onChange: onSwitchMode
|
|
7002
|
+
}), jsx(Box, {
|
|
7003
|
+
sx: {
|
|
7004
|
+
width: '16px',
|
|
7005
|
+
marginLeft: 1
|
|
7006
|
+
},
|
|
7007
|
+
children: editor && jsx(MaritimeWarningAvatar, {
|
|
7008
|
+
editor: editor
|
|
7009
|
+
})
|
|
7010
|
+
})]
|
|
7011
|
+
}), jsx(AreaList, {
|
|
6670
7012
|
areas: areas,
|
|
6671
7013
|
selected: selectedAreaIds,
|
|
6672
7014
|
disabled: disabledAreaIds,
|
|
6673
|
-
|
|
7015
|
+
isReadOnly: isReadOnly,
|
|
7016
|
+
onToggleSelectArea: onToggleSelectArea,
|
|
7017
|
+
onSelectMultipleAreas: onSelectMultipleAreas
|
|
6674
7018
|
}), jsx(WarningList, {
|
|
6675
7019
|
warnings: warnings,
|
|
6676
7020
|
areas: areas,
|
|
@@ -6679,10 +7023,12 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6679
7023
|
onRemoveWarning: onRemoveWarningWithConfirmation,
|
|
6680
7024
|
onChangeWarning: onChangeWarning,
|
|
6681
7025
|
onToggleSelectArea: onToggleSelectArea,
|
|
7026
|
+
onSelectMultipleAreas: onSelectMultipleAreas,
|
|
6682
7027
|
onRemoveArea: onRemoveArea,
|
|
6683
7028
|
onMoveWarning: onMoveWarning,
|
|
6684
|
-
shouldShowDistricts: shouldShowDistricts
|
|
6685
|
-
|
|
7029
|
+
shouldShowDistricts: shouldShowDistricts,
|
|
7030
|
+
isReadOnly: isReadOnly
|
|
7031
|
+
}), !isReadOnly && jsxs(Button, {
|
|
6686
7032
|
onClick: onAddWarning,
|
|
6687
7033
|
variant: "tertiary",
|
|
6688
7034
|
size: "small",
|
|
@@ -6691,15 +7037,20 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6691
7037
|
paddingInline: 2
|
|
6692
7038
|
},
|
|
6693
7039
|
children: [jsx(Add, {}), t('maritime-new-warning')]
|
|
6694
|
-
}), jsxs(Stack, {
|
|
7040
|
+
}), !isReadOnly && jsxs(Stack, {
|
|
6695
7041
|
spacing: 2,
|
|
6696
7042
|
direction: "row",
|
|
6697
|
-
sx: (
|
|
7043
|
+
sx: (_sx3 = {}, _sx3["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
6698
7044
|
position: 'absolute',
|
|
6699
7045
|
bottom: 0,
|
|
6700
7046
|
right: 0,
|
|
6701
|
-
|
|
6702
|
-
|
|
7047
|
+
paddingInline: 2,
|
|
7048
|
+
paddingBottom: 2,
|
|
7049
|
+
// in a dialog there is an additional empty footer that messes up styling. This hack fixes that.
|
|
7050
|
+
'[role="dialog"] &': {
|
|
7051
|
+
paddingBottom: 0
|
|
7052
|
+
}
|
|
7053
|
+
}, _sx3),
|
|
6703
7054
|
children: [jsx(Button, {
|
|
6704
7055
|
onClick: onClearWithConfirmation,
|
|
6705
7056
|
variant: "tertiary",
|
|
@@ -6711,11 +7062,11 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
|
|
|
6711
7062
|
}), jsx(Button, {
|
|
6712
7063
|
variant: "primary",
|
|
6713
7064
|
size: "small",
|
|
6714
|
-
sx: (
|
|
7065
|
+
sx: (_sx4 = {
|
|
6715
7066
|
width: '134px'
|
|
6716
|
-
},
|
|
7067
|
+
}, _sx4["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
|
|
6717
7068
|
marginLeft: '24px!important'
|
|
6718
|
-
},
|
|
7069
|
+
}, _sx4),
|
|
6719
7070
|
disabled: !modified || !isValid,
|
|
6720
7071
|
onClick: onSubmit,
|
|
6721
7072
|
children: t('warning-button-publish')
|
|
@@ -6780,16 +7131,35 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
|
|
|
6780
7131
|
onModifyForm = _ref.onModifyForm;
|
|
6781
7132
|
var areas = areasByDomain[domain];
|
|
6782
7133
|
var shouldShowDistricts = domain === 'northSeaDistricts';
|
|
7134
|
+
var _useWarningsTranslati = useWarningsTranslation(),
|
|
7135
|
+
t = _useWarningsTranslati.t;
|
|
7136
|
+
var _useAuthenticationCon = useAuthenticationContext$1(),
|
|
7137
|
+
auth = _useAuthenticationCon.auth;
|
|
7138
|
+
var maritimeWarningsType = getType(domain);
|
|
7139
|
+
// TODO this should be retrieved (and updated) from the api using a react-query
|
|
7140
|
+
var _React$useState = React__default.useState(auth == null ? void 0 : auth.username),
|
|
7141
|
+
editor = _React$useState[0],
|
|
7142
|
+
setEditor = _React$useState[1];
|
|
7143
|
+
var isReadOnly = editor !== undefined && editor !== (auth == null ? void 0 : auth.username);
|
|
6783
7144
|
var _useMaritimeWarningsF = useMaritimeWarningsFormState(),
|
|
6784
7145
|
state = _useMaritimeWarningsF[0],
|
|
6785
7146
|
dispatch = _useMaritimeWarningsF[1];
|
|
7147
|
+
var _usePublicWarnings = usePublicWarnings(),
|
|
7148
|
+
data = _usePublicWarnings.data;
|
|
7149
|
+
var warningsFromApi = React__default.useMemo(function () {
|
|
7150
|
+
return (data == null ? void 0 : data.filter(function (warning) {
|
|
7151
|
+
return warning.warningDetail.domain === maritimeWarningsType && warning.status === 'PUBLISHED';
|
|
7152
|
+
})) || [];
|
|
7153
|
+
}, [data, maritimeWarningsType]);
|
|
7154
|
+
var warningItemsFromApi = React__default.useMemo(function () {
|
|
7155
|
+
return mapMaritimeWarningsToItems(warningsFromApi || []);
|
|
7156
|
+
}, [warningsFromApi]);
|
|
6786
7157
|
React__default.useEffect(function () {
|
|
6787
|
-
// FIXME: replace this by warnings from api
|
|
6788
7158
|
dispatch({
|
|
6789
7159
|
type: 'initialize',
|
|
6790
|
-
warnings:
|
|
7160
|
+
warnings: warningItemsFromApi
|
|
6791
7161
|
});
|
|
6792
|
-
}, [dispatch,
|
|
7162
|
+
}, [dispatch, warningItemsFromApi]);
|
|
6793
7163
|
React__default.useEffect(function () {
|
|
6794
7164
|
onPreventCloseView == null || onPreventCloseView(state.modified);
|
|
6795
7165
|
if (onModifyForm) {
|
|
@@ -6810,6 +7180,14 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
|
|
|
6810
7180
|
});
|
|
6811
7181
|
});
|
|
6812
7182
|
}, [dispatch]);
|
|
7183
|
+
var onSelectMultipleAreas = React__default.useCallback(function (ids) {
|
|
7184
|
+
React__default.startTransition(function () {
|
|
7185
|
+
dispatch({
|
|
7186
|
+
type: 'selectMultipleAreas',
|
|
7187
|
+
ids: ids
|
|
7188
|
+
});
|
|
7189
|
+
});
|
|
7190
|
+
}, [dispatch]);
|
|
6813
7191
|
var onAddSelectedAreas = React__default.useCallback(function (id) {
|
|
6814
7192
|
React__default.startTransition(function () {
|
|
6815
7193
|
dispatch({
|
|
@@ -6872,26 +7250,57 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
|
|
|
6872
7250
|
newIndex: newIndex
|
|
6873
7251
|
});
|
|
6874
7252
|
}, [dispatch]);
|
|
7253
|
+
var _usePostMaritimeWarni = usePostMaritimeWarning(),
|
|
7254
|
+
postWarning = _usePostMaritimeWarni.mutate;
|
|
6875
7255
|
var onSubmit = React__default.useCallback(function () {
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
7256
|
+
dispatch({
|
|
7257
|
+
type: 'mergeWarnings'
|
|
7258
|
+
});
|
|
7259
|
+
var nextState = reducer(state, {
|
|
7260
|
+
type: 'mergeWarnings'
|
|
7261
|
+
});
|
|
7262
|
+
var maritimeWarnings = mapItemsToMaritimeWarnings(nextState.warnings, domain, auth == null ? void 0 : auth.username);
|
|
7263
|
+
maritimeWarnings.forEach(function (warning) {
|
|
7264
|
+
postWarning(warning);
|
|
7265
|
+
});
|
|
7266
|
+
}, [dispatch, state, domain, auth == null ? void 0 : auth.username, postWarning]);
|
|
7267
|
+
var onToggleReadOnly = React__default.useCallback(function (isReadOnly) {
|
|
7268
|
+
// FIXME: do a api call here
|
|
7269
|
+
if (isReadOnly) {
|
|
7270
|
+
setEditor('');
|
|
7271
|
+
} else {
|
|
7272
|
+
setEditor(auth == null ? void 0 : auth.username);
|
|
7273
|
+
}
|
|
7274
|
+
// FIXME: reset warnings to latest known api state
|
|
7275
|
+
var domainLabel = domain === 'coastalWaters' ? t('maritime-domain-coastal') : t('maritime-domain-northsea');
|
|
7276
|
+
showSnackbar({
|
|
7277
|
+
type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
|
|
7278
|
+
message: isReadOnly ? t('maritime-editor-off', {
|
|
7279
|
+
domain: domainLabel
|
|
7280
|
+
}) : t('maritime-editor-on', {
|
|
7281
|
+
domain: domainLabel
|
|
7282
|
+
})
|
|
7283
|
+
});
|
|
7284
|
+
}, [showSnackbar, t, domain, auth]);
|
|
6880
7285
|
return jsx(MaritimeWarningsForm, {
|
|
6881
7286
|
areas: areas,
|
|
6882
7287
|
selectedAreaIds: state.selectedAreaIds,
|
|
6883
7288
|
warnings: state.warnings,
|
|
6884
7289
|
modified: state.modified,
|
|
7290
|
+
isReadOnly: isReadOnly,
|
|
7291
|
+
shouldShowDistricts: shouldShowDistricts,
|
|
7292
|
+
editor: editor,
|
|
6885
7293
|
onToggleSelectArea: onToggleSelectArea,
|
|
7294
|
+
onSelectMultipleAreas: onSelectMultipleAreas,
|
|
6886
7295
|
onAddSelectedAreas: onAddSelectedAreas,
|
|
6887
7296
|
onRemoveWarning: onRemoveWarning,
|
|
6888
7297
|
onRemoveArea: onRemoveArea,
|
|
6889
7298
|
onAddWarning: onAddWarning,
|
|
6890
7299
|
onChangeWarning: onChangeWarning,
|
|
6891
7300
|
onMoveWarning: onMoveWarning,
|
|
7301
|
+
onToggleReadOnly: onToggleReadOnly,
|
|
6892
7302
|
onClear: onClear,
|
|
6893
|
-
onSubmit: onSubmit
|
|
6894
|
-
shouldShowDistricts: shouldShowDistricts
|
|
7303
|
+
onSubmit: onSubmit
|
|
6895
7304
|
});
|
|
6896
7305
|
};
|
|
6897
7306
|
|
|
@@ -7657,12 +8066,14 @@ var Form = function Form(_ref5) {
|
|
|
7657
8066
|
})
|
|
7658
8067
|
});
|
|
7659
8068
|
};
|
|
8069
|
+
if (isMaritimeWarning) {
|
|
8070
|
+
return getFormContent();
|
|
8071
|
+
}
|
|
7660
8072
|
return jsxs(ContainerWrapper, {
|
|
7661
8073
|
children: [jsxs(ContainerFormWrapper, {
|
|
7662
8074
|
isReadOnly: isReadOnly,
|
|
7663
8075
|
ref: ref,
|
|
7664
8076
|
"data-testid": "scroll-container",
|
|
7665
|
-
addPadding: !isMaritimeWarning,
|
|
7666
8077
|
children: [errors && jsx(Box, {
|
|
7667
8078
|
sx: {
|
|
7668
8079
|
marginBottom: 2
|
|
@@ -7676,7 +8087,7 @@ var Form = function Form(_ref5) {
|
|
|
7676
8087
|
}), getFormContent(), jsx(DraftFieldHelper, {}), jsx(ReactHookFormHiddenInput, {
|
|
7677
8088
|
name: "id"
|
|
7678
8089
|
})]
|
|
7679
|
-
}),
|
|
8090
|
+
}), formState !== 'cancel' && !isReadOnly && jsx(Box, {
|
|
7680
8091
|
sx: {
|
|
7681
8092
|
padding: '24px 10px 14px 10px',
|
|
7682
8093
|
position: 'absolute',
|
|
@@ -7761,7 +8172,7 @@ var Form = function Form(_ref5) {
|
|
|
7761
8172
|
})]
|
|
7762
8173
|
})
|
|
7763
8174
|
})
|
|
7764
|
-
}),
|
|
8175
|
+
}), formState === 'cancel' && jsx(Box, {
|
|
7765
8176
|
sx: {
|
|
7766
8177
|
padding: '24px 10px 14px 10px',
|
|
7767
8178
|
position: 'absolute',
|
|
@@ -8869,8 +9280,8 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
8869
9280
|
var selectedWarningId = useSelector(getSelectedWarningId);
|
|
8870
9281
|
var selectedWarningObject = useSelector(getPublicWarning);
|
|
8871
9282
|
var warningType = useSelector(getWarningType);
|
|
8872
|
-
var selectedWarning = combinedWarnings == null ? void 0 : combinedWarnings.find(function (
|
|
8873
|
-
return
|
|
9283
|
+
var selectedWarning = combinedWarnings == null ? void 0 : combinedWarnings.find(function (warning) {
|
|
9284
|
+
return warning.id === selectedWarningId;
|
|
8874
9285
|
});
|
|
8875
9286
|
var _useAuthenticationCon = useAuthenticationContext$1(),
|
|
8876
9287
|
auth = _useAuthenticationCon.auth;
|
|
@@ -9467,6 +9878,9 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
|
|
|
9467
9878
|
_ref$onActionAviation = _ref.onActionAviationWarning,
|
|
9468
9879
|
onActionAviationWarning = _ref$onActionAviation === void 0 ? function () {} : _ref$onActionAviation,
|
|
9469
9880
|
t = _ref.t;
|
|
9881
|
+
if (warning.warningDetail.domain === 'maritimeWarningCoastal' || warning.warningDetail.domain === 'maritimeWarningNorthSea') {
|
|
9882
|
+
return [];
|
|
9883
|
+
}
|
|
9470
9884
|
var duplicate = {
|
|
9471
9885
|
text: t('warning-list-button-duplicate'),
|
|
9472
9886
|
action: function action() {
|
|
@@ -9550,7 +9964,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
|
|
|
9550
9964
|
case ProductStatus.DRAFT:
|
|
9551
9965
|
return [aviationDuplicate, aviationDelete];
|
|
9552
9966
|
case ProductStatus.PUBLISHED:
|
|
9553
|
-
if (warning.type
|
|
9967
|
+
if ((warning.type === 'airmet' || warning.type === 'sigmet') && (isInstanceOfCancelSigmet(warning.sigmetAirmetDetails) || isInstanceOfCancelAirmet(warning.sigmetAirmetDetails))) {
|
|
9554
9968
|
return [];
|
|
9555
9969
|
}
|
|
9556
9970
|
return [{
|
|
@@ -9580,7 +9994,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
|
|
|
9580
9994
|
case ProductStatus.CANCELLED:
|
|
9581
9995
|
return [];
|
|
9582
9996
|
case ProductStatus.EXPIRED:
|
|
9583
|
-
if (warning.type
|
|
9997
|
+
if ((warning.type === 'airmet' || warning.type === 'sigmet') && (isInstanceOfCancelSigmet(warning.sigmetAirmetDetails) || isInstanceOfCancelAirmet(warning.sigmetAirmetDetails))) {
|
|
9584
9998
|
return [];
|
|
9585
9999
|
}
|
|
9586
10000
|
return [{
|
|
@@ -9635,10 +10049,10 @@ var renderStatusIcon = function renderStatusIcon(warning, status) {
|
|
|
9635
10049
|
icon: icon
|
|
9636
10050
|
});
|
|
9637
10051
|
};
|
|
9638
|
-
if (warning.productStatus === ProductStatus.PUBLISHED && warning.type
|
|
10052
|
+
if (warning.productStatus === ProductStatus.PUBLISHED && (warning.type === 'airmet' || warning.type === 'sigmet') && (isCancelAirmet(warning.sigmetAirmetDetails) || isCancelSigmet(warning.sigmetAirmetDetails))) {
|
|
9639
10053
|
return getStatusTag("Cnls " + (isCancelAirmet(warning.sigmetAirmetDetails) ? warning.sigmetAirmetDetails.cancelsAirmetSequenceId : warning.sigmetAirmetDetails.cancelsSigmetSequenceId), 'red');
|
|
9640
10054
|
}
|
|
9641
|
-
if (warning.productStatus === ProductStatus.CANCELLED && warning.type
|
|
10055
|
+
if (warning.productStatus === ProductStatus.CANCELLED && (warning.type === 'airmet' || warning.type === 'sigmet')) {
|
|
9642
10056
|
return getStatusTag('Cnld', 'red');
|
|
9643
10057
|
}
|
|
9644
10058
|
switch (status) {
|
|
@@ -9700,7 +10114,7 @@ var WarningListItem = function WarningListItem(_ref) {
|
|
|
9700
10114
|
t = _useWarningsTranslati.t;
|
|
9701
10115
|
var phenomenonDetails = allPhenomenaDict[warning.warningDetail.phenomenon];
|
|
9702
10116
|
var objectNameText = ((_warning$warningDetai = warning.warningDetail.areas) == null || (_warning$warningDetai = _warning$warningDetai[0]) == null ? void 0 : _warning$warningDetai.objectName) || '-';
|
|
9703
|
-
var objectHoverText = warning.type
|
|
10117
|
+
var objectHoverText = warning.type === 'airmet' || warning.type === 'sigmet' ? warning.sigmetAirmetDetails.firName : objectNameText;
|
|
9704
10118
|
var _useOverflowCheck = useOverflowCheck(objectNameText),
|
|
9705
10119
|
objectNameRef = _useOverflowCheck.ref;
|
|
9706
10120
|
var phenomenonText = phenomenonDetails != null && phenomenonDetails.translationKey ? t(phenomenonDetails.translationKey) : '-';
|
|
@@ -10057,9 +10471,9 @@ var NewWarningButton = function NewWarningButton(_ref) {
|
|
|
10057
10471
|
var groupWarningsOnStatus = function groupWarningsOnStatus(warnings, sortState) {
|
|
10058
10472
|
var key = sortState.key,
|
|
10059
10473
|
direction = sortState.direction;
|
|
10060
|
-
var sortedWarnings = warnings.sort(function (
|
|
10061
|
-
var dateStringA = key === 'lastUpdatedTime' ?
|
|
10062
|
-
var dateStringB = key === 'lastUpdatedTime' ?
|
|
10474
|
+
var sortedWarnings = warnings.sort(function (warningA, warningB) {
|
|
10475
|
+
var dateStringA = key === 'lastUpdatedTime' ? warningA[key] : warningA.warningDetail[key];
|
|
10476
|
+
var dateStringB = key === 'lastUpdatedTime' ? warningB[key] : warningB.warningDetail[key];
|
|
10063
10477
|
return (dateStringB == null ? void 0 : dateStringB.localeCompare(dateStringA || '')) || 0;
|
|
10064
10478
|
});
|
|
10065
10479
|
if (direction === 'asc') {
|
|
@@ -10637,9 +11051,15 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
|
|
|
10637
11051
|
}
|
|
10638
11052
|
};
|
|
10639
11053
|
var byFilterState = useCallback(function (warning) {
|
|
10640
|
-
var levelDomain =
|
|
10641
|
-
|
|
10642
|
-
|
|
11054
|
+
var levelDomain = function () {
|
|
11055
|
+
if (['SIG', 'AIR'].includes(warning.warningDetail.level)) {
|
|
11056
|
+
return Domain.aviation;
|
|
11057
|
+
}
|
|
11058
|
+
if (warning.warningDetail.domain === 'maritimeWarningCoastal' || warning.warningDetail.domain === 'maritimeWarningNorthSea') {
|
|
11059
|
+
return Domain.maritime;
|
|
11060
|
+
}
|
|
11061
|
+
return Domain["public"];
|
|
11062
|
+
}();
|
|
10643
11063
|
if (!savedDomainFilter[levelDomain]) {
|
|
10644
11064
|
return false;
|
|
10645
11065
|
}
|