@opengeoweb/warnings 9.35.0 → 9.36.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.
Files changed (32) hide show
  1. package/index.esm.js +793 -772
  2. package/package.json +2 -3
  3. package/src/lib/aviation-api/hooks.d.ts +2 -1
  4. package/src/lib/components/FilterList/ExpandableFilterChip.d.ts +2 -2
  5. package/src/lib/components/FilterList/{FilterChipWithOptions.stories.d.ts → ExpandableFilterChip.stories.d.ts} +2 -2
  6. package/src/lib/components/FilterList/FilterList.d.ts +0 -2
  7. package/src/lib/components/FilterList/filter-hooks.d.ts +5 -1
  8. package/src/lib/components/FilterList/filter-utils.d.ts +4 -0
  9. package/src/lib/components/PublicWarningList/NewWarningButton/NewWarningButton.d.ts +4 -1
  10. package/src/lib/components/PublicWarningList/PublicWarningList.d.ts +3 -4
  11. package/src/lib/components/PublicWarningList/PublicWarningList.stories.d.ts +20 -0
  12. package/src/lib/components/PublicWarningList/PublicWarningListConnect.aviation.integration.spec.d.ts +1 -0
  13. package/src/lib/components/PublicWarningList/WarningListItem.d.ts +1 -0
  14. package/src/lib/components/PublicWarningList/WarningListItem.spec.d.ts +1 -0
  15. package/src/lib/components/PublicWarningsForm/PublicWarningsForm.d.ts +7 -3
  16. package/src/lib/components/PublicWarningsForm/PublicWarningsForm.stories.d.ts +6 -8
  17. package/src/lib/components/PublicWarningsForm/PublicWarningsFormConnect.d.ts +3 -3
  18. package/src/lib/components/PublicWarningsFormDialog/PublicWarningsFormDialog.d.ts +2 -1
  19. package/src/lib/store/publicWarningForm/reducer.d.ts +3 -1
  20. package/src/lib/store/publicWarningForm/selectors.d.ts +5 -0
  21. package/src/lib/store/publicWarningForm/types.d.ts +2 -0
  22. package/src/lib/store/publicWarnings/reducer.d.ts +1 -9
  23. package/src/lib/store/publicWarnings/selectors.d.ts +2 -19
  24. package/src/lib/store/publicWarnings/types.d.ts +0 -22
  25. package/src/lib/storybookUtils/SimpleLinkMenu.d.ts +6 -0
  26. package/src/lib/utils/fakeApi/index.d.ts +4 -1
  27. package/src/lib/utils/sig-airmet-util.d.ts +2 -2
  28. package/src/lib/components/FilterList/FilterChipWithOptions.d.ts +0 -7
  29. package/src/lib/components/FilterList/FilterChipWithOptionsConnect.d.ts +0 -7
  30. package/src/lib/store/publicWarnings/utils.d.ts +0 -24
  31. /package/src/lib/components/FilterList/{FilterChipWithOptions.spec.d.ts → ExpandableFilterChip.spec.d.ts} +0 -0
  32. /package/src/lib/{store/publicWarnings/utils.spec.d.ts → components/FilterList/filter-utils.spec.d.ts} +0 -0
package/index.esm.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
- import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Close, Options, ChevronDown, ChevronUp, Copy, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
- import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData } from '@opengeoweb/store';
3
+ import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Options, Close, ChevronDown, ChevronUp, Copy, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
+ import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog, useUpdateSharedData } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, MapView, MapViewLayer, getFeatureExtent } from '@opengeoweb/webmap-react';
6
- import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, FilterLabel, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
6
+ import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
8
8
  import 'i18next';
9
9
  import { useTranslation } from 'react-i18next';
10
10
  import '@opengeoweb/core';
11
11
  import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
12
12
  import { LayerType, generateMapId, getWMJSMapById, getGeoCoordFromLatLong, WMBBOX } from '@opengeoweb/webmap';
13
+ import { SigmetForm, isInstanceOfCancelSigmet, AirmetForm, isInstanceOfCancelAirmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
13
14
  import { snackbarActions, snackbarTypes } from '@opengeoweb/snackbar';
14
15
  import * as React from 'react';
15
- import React__default, { useState, useEffect, useRef, useCallback } from 'react';
16
+ import React__default, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
16
17
  import { styled, Box, Typography, ListItem, Grid2, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, Card, CardContent, CircularProgress, Menu, DialogTitle, DialogContent, Switch, ListItemText } from '@mui/material';
17
18
  import { VariableSizeList } from 'react-window';
18
19
  import AutoSizer from 'react-virtualized-auto-sizer';
@@ -20,8 +21,6 @@ import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInsta
20
21
  import { useFormContext } from 'react-hook-form';
21
22
  import { isEqual, cloneDeep, clamp, groupBy, pick } from 'lodash';
22
23
  import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
23
- import { SigmetForm, isInstanceOfCancelSigmet, AirmetForm, isInstanceOfCancelAirmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
24
- import { produce } from 'immer';
25
24
  import { useQueryClient } from '@tanstack/react-query';
26
25
  import { isAxiosError } from 'axios';
27
26
 
@@ -57,7 +56,7 @@ var en = {
57
56
  "object-manager-object-selected": "object selected",
58
57
  "object-manager-share-menu": "Share object to",
59
58
  "public-warning-title": "Public Warning",
60
- "close-warning-dialog-title": "Close Public warning",
59
+ "close-warning-dialog-title": "Close warning",
61
60
  "warning-edit-mode-title": "Switch to edit mode",
62
61
  "warning-edit-mode-description": "This warning is already in edit mode by another user and important information could get lost in the switching process.",
63
62
  "warning-dialog-cancel": "Go back",
@@ -234,7 +233,7 @@ var nl = {
234
233
  "object-manager-object-selected": "object geselecteerd",
235
234
  "object-manager-share-menu": "Object delen naar",
236
235
  "public-warning-title": "Publieke Waarschuwing",
237
- "close-warning-dialog-title": "Publieke waarschuwing sluiten",
236
+ "close-warning-dialog-title": "Waarschuwing sluiten",
238
237
  "warning-edit-mode-title": "Wissel naar bewerken",
239
238
  "warning-edit-mode-description": "Deze waarschuwing wordt al bewerkt door een andere gebruiker en belangrijke informatie kan verloren gaan.",
240
239
  "warning-dialog-cancel": "Ga terug",
@@ -372,7 +371,7 @@ var fi = {
372
371
  "object-manager-object-selected": "objekti valittuna",
373
372
  "object-manager-share-menu": "Jaa objekti",
374
373
  "public-warning-title": "Julkiset varoitukset",
375
- "close-warning-dialog-title": "Sulje julkiset varoitukset",
374
+ "close-warning-dialog-title": "Sulje varoitukset",
376
375
  "warning-edit-mode-title": "Vaihda editointitilaan",
377
376
  "warning-edit-mode-description": "Tämä varoitus on jo editointitilassa toisen käyttäjän toimesta. Tärkeää tietoa saatetaan menettää, jos editointitilaa vaihdetaan.",
378
377
  "warning-dialog-cancel": "Palaa takaisin",
@@ -2084,137 +2083,6 @@ var ConfirmDeleteDialog = function ConfirmDeleteDialog(_ref) {
2084
2083
  * */
2085
2084
  var publicWarningDialogType = uiTypes.DialogTypes.PublicWarnings;
2086
2085
 
2087
- /* *
2088
- * Licensed under the Apache License, Version 2.0 (the "License");
2089
- * you may not use this file except in compliance with the License.
2090
- * You may obtain a copy of the License at
2091
- *
2092
- * http://www.apache.org/licenses/LICENSE-2.0
2093
- *
2094
- * Unless required by applicable law or agreed to in writing, software
2095
- * distributed under the License is distributed on an "AS IS" BASIS,
2096
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2097
- * See the License for the specific language governing permissions and
2098
- * limitations under the License.
2099
- *
2100
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2101
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
2102
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2103
- * */
2104
- var emptyFilter = {
2105
- id: 'unspecified',
2106
- name: '(not specified)',
2107
- checked: true
2108
- };
2109
- var defaultFilters = [{
2110
- key: 'incident',
2111
- translationKey: 'filter-incident'
2112
- }, {
2113
- key: 'warningProposalSource',
2114
- translationKey: 'filter-source'
2115
- }];
2116
- var getFiltersFromWarnings = function getFiltersFromWarnings(t, warnings) {
2117
- if (!warnings || !warnings.length) {
2118
- // return default list
2119
- return defaultFilters.map(function (_ref) {
2120
- var key = _ref.key,
2121
- translationKey = _ref.translationKey;
2122
- return {
2123
- id: key,
2124
- translationKey: translationKey,
2125
- filterList: []
2126
- };
2127
- });
2128
- }
2129
- var filledFilters = defaultFilters.map(function (_ref2) {
2130
- var key = _ref2.key,
2131
- translationKey = _ref2.translationKey,
2132
- translations = _ref2.translations;
2133
- var filterOptions = [];
2134
- warnings.forEach(function (warning) {
2135
- var id = warning.warningDetail[key];
2136
- if (id && filterOptions.findIndex(function (option) {
2137
- return option.filter.id === id;
2138
- }) === -1) {
2139
- var _translationKey = translations && translations[id];
2140
- var label = _translationKey ? t(_translationKey) : id;
2141
- var filter = {
2142
- id: id,
2143
- name: label,
2144
- checked: true
2145
- };
2146
- filterOptions.push({
2147
- filter: filter
2148
- });
2149
- }
2150
- });
2151
- // add option for empty
2152
- filterOptions.push({
2153
- filter: emptyFilter
2154
- });
2155
- // sort alphabetically
2156
- var filtersSorted = [].concat(filterOptions).sort(function (a, b) {
2157
- return a.filter.name.localeCompare(b.filter.name);
2158
- });
2159
- return {
2160
- id: key,
2161
- translationKey: translationKey,
2162
- filterList: filtersSorted
2163
- };
2164
- });
2165
- return filledFilters;
2166
- };
2167
- var isWarningMatchingFilter = function isWarningMatchingFilter(filters, filterId, warningDetailValue) {
2168
- return filters.some(function (filter) {
2169
- return filter.filterId === filterId && filter.optionId === warningDetailValue;
2170
- }) || !warningDetailValue && filters.some(function (filter) {
2171
- return filter.filterId === filterId && filter.optionId === emptyFilter.id;
2172
- });
2173
- };
2174
- var getUpdatedFilters = function getUpdatedFilters(filters, newFilters) {
2175
- return filters.ids.reduce(function (list, id) {
2176
- var _filters$entities$id;
2177
- var existingFilterList = (_filters$entities$id = filters.entities[id]) == null ? void 0 : _filters$entities$id.filterList;
2178
- var newFilter = newFilters.find(function (filter) {
2179
- return filter.id === id;
2180
- });
2181
- if (newFilter && existingFilterList) {
2182
- var updatedFilterList = getUpdatedFilterList(existingFilterList, newFilter.filterList);
2183
- list.push({
2184
- id: id,
2185
- changes: Object.assign({}, newFilter, {
2186
- filterList: updatedFilterList
2187
- })
2188
- });
2189
- }
2190
- return list;
2191
- }, []);
2192
- };
2193
- var getUpdatedFilterList = function getUpdatedFilterList(oldList, newList) {
2194
- var updatedList = [];
2195
- // if the item existed already, keep its state
2196
- oldList.forEach(function (oldListItem) {
2197
- if (newList.some(function (newListItem) {
2198
- return newListItem.filter.id === oldListItem.filter.id;
2199
- })) {
2200
- updatedList.push(oldListItem);
2201
- }
2202
- });
2203
- // if the item did not exist yet, add it
2204
- newList.forEach(function (newListItem) {
2205
- if (oldList.every(function (oldListItem) {
2206
- return oldListItem.filter.id !== newListItem.filter.id;
2207
- })) {
2208
- updatedList.push(newListItem);
2209
- }
2210
- });
2211
- // sort alphabetically
2212
- var sortedList = [].concat(updatedList).sort(function (a, b) {
2213
- return a.filter.name.localeCompare(b.filter.name);
2214
- });
2215
- return sortedList;
2216
- };
2217
-
2218
2086
  /* *
2219
2087
  * Licensed under the Apache License, Version 2.0 (the "License");
2220
2088
  * you may not use this file except in compliance with the License.
@@ -2237,12 +2105,10 @@ var publicWarningsAdapter = createEntityAdapter({
2237
2105
  return warning.id;
2238
2106
  }
2239
2107
  });
2240
- var warningListFilterAdapter = createEntityAdapter();
2241
2108
  var initialState$1 = {
2242
2109
  warnings: publicWarningsAdapter.getInitialState(),
2243
2110
  isLoading: true,
2244
- lastUpdatedTime: '',
2245
- filters: warningListFilterAdapter.getInitialState()
2111
+ lastUpdatedTime: ''
2246
2112
  };
2247
2113
  var slice$1 = createSlice({
2248
2114
  initialState: initialState$1,
@@ -2264,63 +2130,6 @@ var slice$1 = createSlice({
2264
2130
  var error = action.payload.error;
2265
2131
  draft.isLoading = false;
2266
2132
  draft.error = error;
2267
- },
2268
- setWarningListFilters: function setWarningListFilters(draft, action) {
2269
- var newFilters = action.payload.newFilters;
2270
- // Update existing filters
2271
- var updates = getUpdatedFilters(draft.filters, newFilters);
2272
- warningListFilterAdapter.updateMany(draft.filters, updates);
2273
- // Add any new filters that didn't exist before
2274
- var newFiltersToAdd = newFilters.filter(function (filter) {
2275
- return !draft.filters.ids.includes(filter.id);
2276
- });
2277
- warningListFilterAdapter.upsertMany(draft.filters, newFiltersToAdd);
2278
- },
2279
- toggleFilter: function toggleFilter(draft, action) {
2280
- var _action$payload2 = action.payload,
2281
- filterId = _action$payload2.filterId,
2282
- isChecked = _action$payload2.isChecked;
2283
- if (!draft.filters.entities[filterId]) {
2284
- return;
2285
- }
2286
- draft.filters.entities[filterId].filterList.forEach(function (_, index) {
2287
- draft.filters.entities[filterId].filterList[index].filter.checked = !isChecked;
2288
- });
2289
- },
2290
- toggleOption: function toggleOption(draft, action) {
2291
- var _action$payload3 = action.payload,
2292
- filterId = _action$payload3.filterId,
2293
- optionId = _action$payload3.optionId;
2294
- if (!draft.filters.entities[filterId]) {
2295
- return;
2296
- }
2297
- var index = draft.filters.entities[filterId].filterList.findIndex(function (option) {
2298
- return option.filter.id === optionId;
2299
- });
2300
- if (index === -1) {
2301
- return;
2302
- }
2303
- draft.filters.entities[filterId].filterList[index].filter.checked = !draft.filters.entities[filterId].filterList[index].filter.checked;
2304
- },
2305
- enableOnlyOneFilterOption: function enableOnlyOneFilterOption(draft, action) {
2306
- var _action$payload4 = action.payload,
2307
- filterId = _action$payload4.filterId,
2308
- optionId = _action$payload4.optionId;
2309
- if (!draft.filters.entities[filterId]) {
2310
- return;
2311
- }
2312
- draft.filters.entities[filterId].filterList.forEach(function (_, index) {
2313
- var newStatus = draft.filters.entities[filterId].filterList[index].filter.id === optionId;
2314
- draft.filters.entities[filterId].filterList[index].filter.checked = newStatus;
2315
- });
2316
- },
2317
- toggleAllFilters: function toggleAllFilters(draft, action) {
2318
- var isChecked = action.payload.isChecked;
2319
- draft.filters.ids.forEach(function (id) {
2320
- draft.filters.entities[id].filterList.forEach(function (_, index) {
2321
- draft.filters.entities[id].filterList[index].filter.checked = !isChecked;
2322
- });
2323
- });
2324
2133
  }
2325
2134
  }
2326
2135
  });
@@ -2393,11 +2202,14 @@ var slice = createSlice({
2393
2202
  object = _action$payload2.object,
2394
2203
  publicWarning = _action$payload2.publicWarning,
2395
2204
  _action$payload2$form = _action$payload2.formState,
2396
- formState = _action$payload2$form === void 0 ? '' : _action$payload2$form;
2205
+ formState = _action$payload2$form === void 0 ? '' : _action$payload2$form,
2206
+ _action$payload2$warn = _action$payload2.warningType,
2207
+ warningType = _action$payload2$warn === void 0 ? 'public' : _action$payload2$warn;
2397
2208
  draft.object = object;
2398
2209
  draft.publicWarning = publicWarning;
2399
2210
  draft.selectedPublicWarningId = publicWarning == null ? void 0 : publicWarning.id;
2400
2211
  draft.formState = formState;
2212
+ draft.warningType = warningType;
2401
2213
  },
2402
2214
  toggleEditorWarning: function toggleEditorWarning(draft,
2403
2215
  // eslint-disable-next-line no-unused-vars
@@ -2471,6 +2283,7 @@ var slice = createSlice({
2471
2283
  delete draft.error;
2472
2284
  delete draft.selectedPublicWarningId;
2473
2285
  delete draft.isFormDirty;
2286
+ delete draft.warningType;
2474
2287
  }
2475
2288
  }).addCase(publicWarningActions.fetchWarningsSuccess, function (draft, action) {
2476
2289
  var warnings = action.payload.warnings;
@@ -6950,6 +6763,7 @@ var warningListJSON = [
6950
6763
  lastUpdatedTime: "2023-12-05T16:47:43Z",
6951
6764
  status: "WITHDRAWN",
6952
6765
  warningDetail: {
6766
+ id: "3f756602-937d-11ee-a1bf-4k3k3k",
6953
6767
  phenomenon: "thunderstorm",
6954
6768
  areas: [
6955
6769
  {
@@ -7006,6 +6820,7 @@ var warningListJSON = [
7006
6820
  lastUpdatedTime: "2023-12-05T14:48:04Z",
7007
6821
  status: "EXPIRED",
7008
6822
  warningDetail: {
6823
+ id: "4b94edb8-937d-11ee-b619-0ab3cf8a98c1",
7009
6824
  phenomenon: "snowIce",
7010
6825
  areas: [
7011
6826
  {
@@ -7062,6 +6877,7 @@ var warningListJSON = [
7062
6877
  lastUpdatedTime: "2023-12-05T14:47:43Z",
7063
6878
  status: "EXPIRED",
7064
6879
  warningDetail: {
6880
+ id: "3f756602-937d-11ee-a1bf-0ab3cf8a98c1",
7065
6881
  phenomenon: "thunderstorm",
7066
6882
  areas: [
7067
6883
  {
@@ -7115,6 +6931,204 @@ var warningListJSON = [
7115
6931
  }
7116
6932
  ];
7117
6933
 
6934
+ var sigmetListJSON = [
6935
+ {
6936
+ id: "57eaf6c8-a247-11ef-ac05-12e0cc025418",
6937
+ lastUpdatedTime: "2024-11-14T05:14:37",
6938
+ productStatus: "DRAFT",
6939
+ warningDetail: {
6940
+ areas: [
6941
+ {
6942
+ geoJSON: {
6943
+ features: [
6944
+ {
6945
+ geometry: {
6946
+ type: "Polygon",
6947
+ coordinates: [
6948
+ [
6949
+ [
6950
+ 10,
6951
+ 20
6952
+ ],
6953
+ [
6954
+ 15,
6955
+ 25
6956
+ ],
6957
+ [
6958
+ 20,
6959
+ 20
6960
+ ],
6961
+ [
6962
+ 10,
6963
+ 20
6964
+ ]
6965
+ ]
6966
+ ]
6967
+ },
6968
+ properties: {
6969
+ selectionType: "fir",
6970
+ stroke: "#0075a9",
6971
+ "stroke-width": 1.5,
6972
+ "stroke-opacity": 1,
6973
+ fill: "#0075a9",
6974
+ "fill-opacity": 0.4
6975
+ },
6976
+ type: "Feature"
6977
+ }
6978
+ ],
6979
+ type: "FeatureCollection"
6980
+ },
6981
+ objectName: "ENOB"
6982
+ }
6983
+ ],
6984
+ descriptionOriginal: "",
6985
+ descriptionTranslation: "",
6986
+ firName: "BODOE OCEANIC FIR",
6987
+ incident: "-1",
6988
+ level: "SIG",
6989
+ phenomenon: "EMBD_TSGR",
6990
+ probability: "0",
6991
+ validFrom: "2024-11-14T05:30:14Z",
6992
+ validUntil: "2024-11-14T07:30:14Z"
6993
+ }
6994
+ },
6995
+ {
6996
+ id: "fc4c0002-8d32-11ef-888b-ee87a1644661",
6997
+ lastUpdatedTime: "2024-11-14T05:14:06",
6998
+ productStatus: "EXPIRED",
6999
+ warningDetail: {
7000
+ areas: [
7001
+ {
7002
+ geoJSON: null,
7003
+ objectName: "EFIN"
7004
+ }
7005
+ ],
7006
+ descriptionOriginal: "",
7007
+ descriptionTranslation: "",
7008
+ firName: "HELSINKI FIR",
7009
+ incident: "T01",
7010
+ level: "SIG",
7011
+ phenomenon: "OBSC_TS",
7012
+ probability: "0",
7013
+ validFrom: "2024-11-13T05:30:14Z",
7014
+ validUntil: "2024-11-13T07:30:14Z"
7015
+ }
7016
+ },
7017
+ {
7018
+ id: "fe4a14bc-8a90-11ef-9090-6c08d8abf452",
7019
+ lastUpdatedTime: "2024-10-08T08:10:30",
7020
+ productStatus: "PUBLISHED",
7021
+ warningDetail: {
7022
+ areas: [
7023
+ {
7024
+ geoJSON: null,
7025
+ objectName: "EHAA"
7026
+ }
7027
+ ],
7028
+ descriptionOriginal: "",
7029
+ descriptionTranslation: "",
7030
+ firName: "AMSTERDAM FIR",
7031
+ incident: "Z01",
7032
+ level: "SIG",
7033
+ phenomenon: "SEV_ICE",
7034
+ probability: "0",
7035
+ validFrom: "2024-10-08T05:30:14Z",
7036
+ validUntil: "2024-10-08T09:30:14Z"
7037
+ }
7038
+ }
7039
+ ];
7040
+
7041
+ var airmetListJSON = [
7042
+ {
7043
+ id: "02d3727a-b190-11ef-ba31-067f7750936d",
7044
+ lastUpdatedTime: "2024-12-03T16:02:35",
7045
+ productStatus: "DRAFT",
7046
+ warningDetail: {
7047
+ areas: [
7048
+ {
7049
+ geoJSON: null,
7050
+ objectName: "EHAA"
7051
+ }
7052
+ ],
7053
+ descriptionOriginal: "",
7054
+ descriptionTranslation: "",
7055
+ firName: "AMSTERDAM FIR",
7056
+ incident: "-1",
7057
+ level: "AIR",
7058
+ phenomenon: "SFC_WIND",
7059
+ probability: "0",
7060
+ validFrom: "2024-12-03T17:00:09Z",
7061
+ validUntil: "2024-12-03T21:00:09Z"
7062
+ }
7063
+ },
7064
+ {
7065
+ id: "1a868884-9076-11ef-8e82-5a063b90cdf6",
7066
+ lastUpdatedTime: "2024-10-22T13:03:56",
7067
+ productStatus: "DRAFT",
7068
+ warningDetail: {
7069
+ areas: [
7070
+ {
7071
+ geoJSON: null,
7072
+ objectName: "EHAA"
7073
+ }
7074
+ ],
7075
+ descriptionOriginal: "",
7076
+ descriptionTranslation: "",
7077
+ firName: "AMSTERDAM FIR",
7078
+ incident: "-1",
7079
+ level: "AIR",
7080
+ phenomenon: "MOD_TURB",
7081
+ probability: "0",
7082
+ validFrom: "2024-10-22T15:00:09Z",
7083
+ validUntil: "2024-10-22T18:00:09Z"
7084
+ }
7085
+ },
7086
+ {
7087
+ id: "4ac7fc94-c670-11ee-8ace-92491e683685",
7088
+ lastUpdatedTime: "2024-02-08T12:26:31.803468",
7089
+ productStatus: "EXPIRED",
7090
+ warningDetail: {
7091
+ areas: [
7092
+ {
7093
+ geoJSON: null,
7094
+ objectName: "ENOR"
7095
+ }
7096
+ ],
7097
+ descriptionOriginal: "",
7098
+ descriptionTranslation: "",
7099
+ firName: "POLARIS FIR",
7100
+ incident: "T01",
7101
+ level: "AIR",
7102
+ phenomenon: "OBSC_TS",
7103
+ probability: "0",
7104
+ validFrom: "2024-02-08T09:00:09Z",
7105
+ validUntil: "2024-02-08T11:00:09Z"
7106
+ }
7107
+ },
7108
+ {
7109
+ id: "9dbcd4c6-c4c0-11ee-a0e9-9e39e246af14",
7110
+ lastUpdatedTime: "2024-02-06T07:15:18.166785",
7111
+ productStatus: "PUBLISHED",
7112
+ warningDetail: {
7113
+ areas: [
7114
+ {
7115
+ geoJSON: null,
7116
+ objectName: "EHAA"
7117
+ }
7118
+ ],
7119
+ descriptionOriginal: "",
7120
+ descriptionTranslation: "",
7121
+ firName: "AMSTERDAM FIR",
7122
+ incident: "Z01",
7123
+ level: "AIR",
7124
+ phenomenon: "SEV_ICE",
7125
+ probability: "0",
7126
+ validFrom: "2024-02-06T08:00:09Z",
7127
+ validUntil: "2024-02-06T12:00:09Z"
7128
+ }
7129
+ }
7130
+ ];
7131
+
7118
7132
  /* *
7119
7133
  * Licensed under the Apache License, Version 2.0 (the "License");
7120
7134
  * you may not use this file except in compliance with the License.
@@ -7135,6 +7149,11 @@ var warningListJSON = [
7135
7149
  var drawingList = drawingListJSON;
7136
7150
  var drawingsListFullContent = drawingsListFullContentJSON;
7137
7151
  var warningList = warningListJSON;
7152
+ warningList.filter(function (warning) {
7153
+ return warning.status !== 'EXPIRED' && warning.status !== 'WITHDRAWN';
7154
+ }).length;
7155
+ var sigmetList = sigmetListJSON;
7156
+ var airmetList = airmetListJSON;
7138
7157
  var areaKeywordList = ['North Sea districts', 'Coastal Districts', 'KNMI Specific', 'Objects', 'Baltic areas', 'NL', 'FI', 'METNorway Specific', 'Provinces', 'FIR', 'Countries'];
7139
7158
 
7140
7159
  /* *
@@ -7235,7 +7254,7 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7235
7254
  getWarnings: function getWarnings() {
7236
7255
  return axiosInstance.get("/warnings/").then(function () {
7237
7256
  return {
7238
- data: warningList
7257
+ data: warningList.concat(sigmetList, airmetList)
7239
7258
  };
7240
7259
  });
7241
7260
  },
@@ -7979,7 +7998,8 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
7979
7998
  shouldHideFormMode = _ref$shouldHideFormMo === void 0 ? false : _ref$shouldHideFormMo,
7980
7999
  publicWarningEditor = _ref.publicWarningEditor,
7981
8000
  selectedAviationProduct = _ref.selectedAviationProduct,
7982
- warningType = _ref.warningType;
8001
+ _ref$warningType = _ref.warningType,
8002
+ warningType = _ref$warningType === void 0 ? 'public' : _ref$warningType;
7983
8003
  var _useWarningsTranslati = useWarningsTranslation(),
7984
8004
  t = _useWarningsTranslati.t;
7985
8005
  var minSize = selectedAviationProduct ? {
@@ -8364,6 +8384,109 @@ var AreaField = function AreaField(_ref) {
8364
8384
  });
8365
8385
  };
8366
8386
 
8387
+ var _defaultLevelFilter, _defaultEmptyFilter, _defaultPhenomenonFil;
8388
+ /* *
8389
+ * Licensed under the Apache License, Version 2.0 (the "License");
8390
+ * you may not use this file except in compliance with the License.
8391
+ * You may obtain a copy of the License at
8392
+ *
8393
+ * http://www.apache.org/licenses/LICENSE-2.0
8394
+ *
8395
+ * Unless required by applicable law or agreed to in writing, software
8396
+ * distributed under the License is distributed on an "AS IS" BASIS,
8397
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8398
+ * See the License for the specific language governing permissions and
8399
+ * limitations under the License.
8400
+ *
8401
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8402
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
8403
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
8404
+ * */
8405
+ var Domain;
8406
+ (function (Domain) {
8407
+ Domain["aviation"] = "aviation";
8408
+ Domain["maritime"] = "maritime";
8409
+ Domain["public"] = "public";
8410
+ })(Domain || (Domain = {}));
8411
+ var Level;
8412
+ (function (Level) {
8413
+ Level["extreme"] = "extreme";
8414
+ Level["moderate"] = "moderate";
8415
+ Level["severe"] = "severe";
8416
+ Level["airmet"] = "AIR";
8417
+ Level["sigmet"] = "SIG";
8418
+ })(Level || (Level = {}));
8419
+ var Phenomenon$1;
8420
+ (function (Phenomenon) {
8421
+ Phenomenon["wind"] = "wind";
8422
+ Phenomenon["fog"] = "fog";
8423
+ Phenomenon["thunderstorm"] = "thunderstorm";
8424
+ Phenomenon["snowIce"] = "snowIce";
8425
+ Phenomenon["rain"] = "rain";
8426
+ Phenomenon["highTemp"] = "highTemp";
8427
+ Phenomenon["lowTemp"] = "lowTemp";
8428
+ Phenomenon["coastalEvent"] = "coastalEvent";
8429
+ })(Phenomenon$1 || (Phenomenon$1 = {}));
8430
+ var emptyFilterId = 'unspecified';
8431
+ var defaultDomainFilter = {
8432
+ aviation: false,
8433
+ maritime: false,
8434
+ "public": true
8435
+ };
8436
+ var domainLevels = {
8437
+ aviation: [Level.airmet, Level.sigmet],
8438
+ maritime: [],
8439
+ "public": [Level.extreme, Level.moderate, Level.severe]
8440
+ };
8441
+ var defaultLevelFilter = (_defaultLevelFilter = {}, _defaultLevelFilter[emptyFilterId] = true, _defaultLevelFilter.extreme = true, _defaultLevelFilter.moderate = true, _defaultLevelFilter.severe = true, _defaultLevelFilter.AIR = true, _defaultLevelFilter.SIG = true, _defaultLevelFilter);
8442
+ (_defaultEmptyFilter = {}, _defaultEmptyFilter[emptyFilterId] = true, _defaultEmptyFilter);
8443
+ var defaultPhenomenonFilter = (_defaultPhenomenonFil = {}, _defaultPhenomenonFil[emptyFilterId] = true, _defaultPhenomenonFil.coastalEvent = true, _defaultPhenomenonFil.fog = true, _defaultPhenomenonFil.highTemp = true, _defaultPhenomenonFil.lowTemp = true, _defaultPhenomenonFil.rain = true, _defaultPhenomenonFil.snowIce = true, _defaultPhenomenonFil.thunderstorm = true, _defaultPhenomenonFil.wind = true, _defaultPhenomenonFil);
8444
+ var useSelectedOptions = function useSelectedOptions(options) {
8445
+ var selectedOptions = Object.keys(options).filter(function (k) {
8446
+ return options[k];
8447
+ });
8448
+ var allSelected = selectedOptions.length === Object.keys(options).length;
8449
+ return {
8450
+ noSelectedOptions: selectedOptions.length,
8451
+ allSelected: allSelected
8452
+ };
8453
+ };
8454
+ var updateState = function updateState(state, optionKey, value, only) {
8455
+ var _Object$assign3;
8456
+ if (only) {
8457
+ return Object.keys(state).reduce(function (acc, k) {
8458
+ var _Object$assign;
8459
+ return Object.assign({}, acc, (_Object$assign = {}, _Object$assign[k] = k === optionKey, _Object$assign));
8460
+ }, {});
8461
+ }
8462
+ return optionKey === 'ALL' ? Object.keys(state).reduce(function (acc, k) {
8463
+ var _Object$assign2;
8464
+ return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[k] = value, _Object$assign2));
8465
+ }, {}) : Object.assign({}, state, (_Object$assign3 = {}, _Object$assign3[optionKey] = value, _Object$assign3));
8466
+ };
8467
+ /** Make sure our value is in the filter */
8468
+ var getValue = function getValue(values, value) {
8469
+ return Object.values(values).find(function (v) {
8470
+ return v === value;
8471
+ }) || emptyFilterId;
8472
+ };
8473
+ var getFiltersFromWarnings = function getFiltersFromWarnings(warnings, filterKey) {
8474
+ var filterOptions = [emptyFilterId];
8475
+ if (!warnings || !warnings.length) {
8476
+ // return default list
8477
+ return filterOptions;
8478
+ }
8479
+ warnings.forEach(function (warning) {
8480
+ var id = warning.warningDetail[filterKey];
8481
+ if (id && filterOptions.findIndex(function (option) {
8482
+ return option === id;
8483
+ }) === -1) {
8484
+ filterOptions.push(id);
8485
+ }
8486
+ });
8487
+ return filterOptions;
8488
+ };
8489
+
8367
8490
  var getWarningPhenomenaIcon = function getWarningPhenomenaIcon(key) {
8368
8491
  switch (key) {
8369
8492
  case 'wind':
@@ -8424,7 +8547,7 @@ var getAviationPhenomenaIcon = function getAviationPhenomenaIcon(key) {
8424
8547
  };
8425
8548
  var warningPhenomena = [{
8426
8549
  translationKey: 'warning-unspecified',
8427
- key: 'unspecified',
8550
+ key: emptyFilterId,
8428
8551
  isAviation: false
8429
8552
  }, {
8430
8553
  translationKey: 'warning-phenomenon-wind',
@@ -8599,7 +8722,7 @@ var allPhenomenaDict = warningPhenomena.reduce(function (list, item) {
8599
8722
  var getPhenomenaIcon = function getPhenomenaIcon(key) {
8600
8723
  return getWarningPhenomenaIcon(key) || getAviationPhenomenaIcon(key);
8601
8724
  };
8602
- var Phenomenon$1 = function Phenomenon(_ref) {
8725
+ var Phenomenon = function Phenomenon(_ref) {
8603
8726
  var isDisabled = _ref.isDisabled,
8604
8727
  isReadOnly = _ref.isReadOnly;
8605
8728
  var _useWarningsTranslati = useWarningsTranslation(),
@@ -8608,7 +8731,7 @@ var Phenomenon$1 = function Phenomenon(_ref) {
8608
8731
  isRequired = _useDraftFormHelpers.isRequired;
8609
8732
  // These phenomena are sent to Public Warning Form
8610
8733
  var warningFormPhenomena = warningPhenomena.filter(function (phenomenon) {
8611
- return !phenomenon.isAviation && phenomenon.key !== 'unspecified';
8734
+ return !phenomenon.isAviation && phenomenon.key !== emptyFilterId;
8612
8735
  });
8613
8736
  return jsx(ReactHookFormSelect, {
8614
8737
  name: "phenomenon",
@@ -9189,15 +9312,6 @@ var getEmptyPublicWarning = function getEmptyPublicWarning() {
9189
9312
  areas: []
9190
9313
  };
9191
9314
  };
9192
- var getDefaultFeatureProperties = function getDefaultFeatureProperties(level) {
9193
- return {
9194
- fill: LevelColors[level].color,
9195
- stroke: LevelColors[level].color,
9196
- 'fill-opacity': 0.2,
9197
- 'stroke-width': 2,
9198
- 'stroke-opacity': 1
9199
- };
9200
- };
9201
9315
  var getFormData = function getFormData(publicWarningsDetails, object) {
9202
9316
  var data = Object.assign({
9203
9317
  IS_DRAFT: '',
@@ -9234,7 +9348,7 @@ var ContainerFormWrapper = styled('div')(function (_ref) {
9234
9348
  height: isReadOnly ? '100%' : "calc(100% - 206px)",
9235
9349
  overflowY: 'auto'
9236
9350
  }, _ref2[containerQueryBreakpoint] = {
9237
- height: 'calc(100% - 88px)'
9351
+ height: isReadOnly ? '100%' : 'calc(100% - 88px)'
9238
9352
  }, _ref2;
9239
9353
  });
9240
9354
  var sm6Width = 'calc(100% * 6 / var(--Grid-columns) - (var(--Grid-columns) - 6) * (var(--Grid-columnSpacing) / var(--Grid-columns)))';
@@ -9305,21 +9419,57 @@ var getErrors = function getErrors(errors) {
9305
9419
  errors: []
9306
9420
  }) : null;
9307
9421
  };
9308
- var getWarningGeoJSONWithColor = function getWarningGeoJSONWithColor(level, geoJSON) {
9309
- if (!geoJSON) {
9310
- return undefined;
9422
+ function warningLevelFeatureColors(level, geoJSON,
9423
+ // Allow undefined
9424
+ isAviationWarning) {
9425
+ if (isAviationWarning === void 0) {
9426
+ isAviationWarning = false;
9427
+ }
9428
+ if (!geoJSON || !geoJSON.features) {
9429
+ // Return an empty FeatureCollection if geoJSON is invalid
9430
+ return {
9431
+ type: 'FeatureCollection',
9432
+ features: []
9433
+ };
9311
9434
  }
9312
- return produce(geoJSON, function (draft) {
9313
- var draftFeature = draft == null ? void 0 : draft.features[0];
9314
- if (draftFeature) {
9315
- var defaultProps = getDefaultFeatureProperties(level);
9316
- if (!draftFeature.properties) {
9317
- draftFeature.properties = Object.assign({}, defaultProps);
9435
+ return Object.assign({}, geoJSON, {
9436
+ features: geoJSON.features.map(function (feature) {
9437
+ var _feature$properties2, _feature$properties3;
9438
+ var colors;
9439
+ if (isAviationWarning) {
9440
+ var _feature$properties$i, _feature$properties;
9441
+ var isStartGeometry = (_feature$properties$i = (_feature$properties = feature.properties) == null ? void 0 : _feature$properties.isStartGeometry) != null ? _feature$properties$i : false;
9442
+ colors = {
9443
+ color: isStartGeometry ? '#E27000' : '#800080',
9444
+ // Orange for start, purple for end
9445
+ borderColor: isStartGeometry ? '#FEAE02' : '#4B0082'
9446
+ };
9447
+ } else if (level) {
9448
+ // Public warning: use LevelColors if level is defined
9449
+ colors = LevelColors[level];
9450
+ } else {
9451
+ // Default to blue if level is undefined (public warning)
9452
+ colors = {
9453
+ color: '#0000FF',
9454
+ borderColor: '#0000A0'
9455
+ };
9318
9456
  }
9319
- Object.assign(draftFeature.properties, Object.assign({}, defaultProps, draftFeature.properties));
9320
- }
9457
+ var defaultProperties = {
9458
+ fill: colors.color,
9459
+ stroke: colors.color,
9460
+ 'fill-opacity': 0.2,
9461
+ 'stroke-width': 2,
9462
+ 'stroke-opacity': 1
9463
+ };
9464
+ return Object.assign({}, feature, {
9465
+ properties: Object.assign({}, defaultProperties, feature.properties, {
9466
+ fill: colors.color || ((_feature$properties2 = feature.properties) == null ? void 0 : _feature$properties2.fill),
9467
+ stroke: colors.color || ((_feature$properties3 = feature.properties) == null ? void 0 : _feature$properties3.stroke)
9468
+ })
9469
+ });
9470
+ })
9321
9471
  });
9322
- };
9472
+ }
9323
9473
  var Form = function Form(_ref5) {
9324
9474
  var _publicWarningDetails;
9325
9475
  var defaultMapPreset = _ref5.defaultMapPreset,
@@ -9345,7 +9495,8 @@ var Form = function Form(_ref5) {
9345
9495
  _ref5$onAddObject = _ref5.onAddObject,
9346
9496
  onAddObject = _ref5$onAddObject === void 0 ? function () {} : _ref5$onAddObject,
9347
9497
  selectedAviationProduct = _ref5.selectedAviationProduct,
9348
- isSigmetWarning = _ref5.isSigmetWarning,
9498
+ _ref5$warningType = _ref5.warningType,
9499
+ warningType = _ref5$warningType === void 0 ? 'public' : _ref5$warningType,
9349
9500
  mode = _ref5.mode;
9350
9501
  var _useTACApi = useTACApi(),
9351
9502
  fetchSigmetTAC = _useTACApi.fetchSigmetTAC,
@@ -9426,42 +9577,63 @@ var Form = function Form(_ref5) {
9426
9577
  };
9427
9578
  var publicWarningId = publicWarningDetails == null ? void 0 : publicWarningDetails.id;
9428
9579
  React.useEffect(function () {
9429
- if (!selectedAviationProduct) {
9430
- // sync redux with react-hook-form
9431
- reset(getFormData(publicWarningDetails, object));
9580
+ if (selectedAviationProduct) {
9581
+ return;
9432
9582
  }
9583
+ // sync redux with react-hook-form
9584
+ reset(getFormData(publicWarningDetails, object));
9433
9585
  // eslint-disable-next-line react-hooks/exhaustive-deps
9434
- }, [publicWarningId, selectedAviationProduct]);
9586
+ }, [publicWarningId]);
9435
9587
  var areas = publicWarningDetails == null ? void 0 : publicWarningDetails.areas;
9436
9588
  React.useEffect(function () {
9437
9589
  if (selectedAviationProduct) {
9438
9590
  return;
9439
9591
  }
9440
- // sync redux with react-hook-form
9441
9592
  if (areas) {
9593
+ // sync redux with react-hook-form
9442
9594
  setValue('areas', areas);
9443
9595
  }
9444
- }, [areas, setValue, selectedAviationProduct]);
9596
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9597
+ }, [areas, setValue]);
9445
9598
  React.useEffect(function () {
9446
9599
  if (selectedAviationProduct) {
9447
9600
  return;
9448
9601
  }
9449
9602
  // sync drawing on map with selected warning
9450
9603
  setWarningGeoJSONFeature(initialPublicWarningArea);
9451
- }, [initialPublicWarningArea, selectedAviationProduct]);
9604
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9605
+ }, [initialPublicWarningArea]);
9606
+ var aviationId = selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid;
9607
+ React.useEffect(function () {
9608
+ if (!selectedAviationProduct) {
9609
+ return;
9610
+ }
9611
+ // sync redux with react-hook-form
9612
+ reset(selectedAviationProduct);
9613
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9614
+ }, [aviationId, warningType]);
9452
9615
  var errors = getErrors(error.message);
9453
- var level = WarningLevel[publicWarningDetails == null ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
9454
- var geoJSONFeature = getWarningGeoJSONWithColor(level, warningGeoJSONFeature);
9616
+ var level = publicWarningDetails != null && publicWarningDetails.level ? WarningLevel[publicWarningDetails.level] : undefined;
9617
+ var geoJSONFeature = warningLevelFeatureColors(level, warningGeoJSONFeature);
9455
9618
  var ref = useScrollTopOnError(error);
9456
- var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
9457
9619
  var _useProductConfig = useProductConfig(warningType),
9458
9620
  aviationConfig = _useProductConfig.data;
9459
9621
  return jsxs(ContainerWrapper, {
9460
- children: [selectedAviationProduct ? jsx(ContainerFormWrapper, {
9622
+ children: [jsxs(ContainerFormWrapper, {
9461
9623
  isReadOnly: isReadOnly,
9462
9624
  ref: ref,
9463
9625
  "data-testid": "scroll-container",
9464
- children: jsx(Box, {
9626
+ children: [errors && jsx(Box, {
9627
+ sx: {
9628
+ marginBottom: 2
9629
+ },
9630
+ children: jsx(AlertBanner, {
9631
+ title: errors.title,
9632
+ info: errors.errors,
9633
+ shouldClose: true,
9634
+ severity: error == null ? void 0 : error.severity
9635
+ })
9636
+ }), selectedAviationProduct ? jsx(Box, {
9465
9637
  sx: {
9466
9638
  maxWidth: {
9467
9639
  xs: '550px',
@@ -9469,11 +9641,12 @@ var Form = function Form(_ref5) {
9469
9641
  },
9470
9642
  marginLeft: '-80px'
9471
9643
  },
9472
- children: isSigmetWarning ? jsx(SigmetForm, {
9644
+ children: warningType === 'sigmet' ? jsx(SigmetForm, {
9473
9645
  showMap: false,
9474
9646
  mode: mode,
9475
- initialSigmet: selectedAviationProduct !== null && !isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9476
- initialCancelSigmet: selectedAviationProduct !== null && isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9647
+ initialSigmet: selectedAviationProduct !== undefined && !isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9648
+ isCancelSigmet: selectedAviationProduct !== undefined && isInstanceOfCancelSigmet(selectedAviationProduct),
9649
+ initialCancelSigmet: selectedAviationProduct !== undefined && isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9477
9650
  productConfig: aviationConfig,
9478
9651
  product: selectedAviationProduct,
9479
9652
  getTAC: function getTAC(product) {
@@ -9482,32 +9655,17 @@ var Form = function Form(_ref5) {
9482
9655
  }) : jsx(AirmetForm, {
9483
9656
  showMap: false,
9484
9657
  mode: mode,
9485
- isCancelAirmet: selectedAviationProduct !== null && isInstanceOfCancelAirmet(selectedAviationProduct),
9486
- initialAirmet: selectedAviationProduct !== null && !isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9487
- initialCancelAirmet: selectedAviationProduct !== null && isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9658
+ isCancelAirmet: selectedAviationProduct !== undefined && isInstanceOfCancelAirmet(selectedAviationProduct),
9659
+ initialAirmet: selectedAviationProduct !== undefined && !isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9660
+ initialCancelAirmet: selectedAviationProduct !== undefined && isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9488
9661
  productConfig: aviationConfig,
9489
9662
  product: selectedAviationProduct,
9490
9663
  getTAC: function getTAC(product) {
9491
9664
  return fetchAirmetTAC(product);
9492
9665
  }
9493
9666
  })
9494
- })
9495
- }) : jsxs(ContainerFormWrapper, {
9496
- isReadOnly: isReadOnly,
9497
- ref: ref,
9498
- "data-testid": "scroll-container",
9499
- children: [jsxs(ContainerGrid, {
9500
- children: [errors && jsx(Box, {
9501
- sx: {
9502
- marginBottom: 2
9503
- },
9504
- children: jsx(AlertBanner, {
9505
- title: errors.title,
9506
- info: errors.errors,
9507
- shouldClose: true,
9508
- severity: error == null ? void 0 : error.severity
9509
- })
9510
- }), jsxs(Grid2, {
9667
+ }) : jsx(ContainerGrid, {
9668
+ children: jsxs(Grid2, {
9511
9669
  size: {
9512
9670
  xs: 12
9513
9671
  },
@@ -9518,7 +9676,7 @@ var Form = function Form(_ref5) {
9518
9676
  size: {
9519
9677
  xs: 12
9520
9678
  },
9521
- children: jsx(Phenomenon$1, {
9679
+ children: jsx(Phenomenon, {
9522
9680
  isDisabled: areFieldsDisabled,
9523
9681
  isReadOnly: isReadOnly
9524
9682
  })
@@ -9601,14 +9759,14 @@ var Form = function Form(_ref5) {
9601
9759
  })
9602
9760
  })
9603
9761
  })]
9604
- })]
9762
+ })
9605
9763
  }), jsx(DraftFieldHelper, {}), jsx(ReactHookFormHiddenInput, {
9606
9764
  name: "id"
9607
9765
  })]
9608
9766
  }), !isReadOnly && jsx(Box, {
9609
9767
  sx: {
9610
9768
  padding: '24px 10px 14px 10px',
9611
- position: selectedAviationProduct ? 'relative' : 'absolute',
9769
+ position: 'absolute',
9612
9770
  bottom: 0,
9613
9771
  width: '100%',
9614
9772
  backgroundColor: 'geowebColors.background.surfaceApp',
@@ -9697,8 +9855,7 @@ var PublicWarningsForm = function PublicWarningsForm(props) {
9697
9855
  return jsx(ReactHookFormProvider, {
9698
9856
  options: Object.assign({}, defaultFormOptions, {
9699
9857
  mode: 'onSubmit',
9700
- defaultValues: defaultValues,
9701
- values: selectedAviationProduct
9858
+ defaultValues: defaultValues
9702
9859
  }),
9703
9860
  children: jsx(Form, Object.assign({}, props))
9704
9861
  });
@@ -9761,6 +9918,9 @@ var getSelectedPublicWarningId = createSelector(getPublicWarningStore, function
9761
9918
  var getSelectedPublicIsFormDirty = createSelector(getPublicWarningStore, function (publicWarningStore) {
9762
9919
  return (publicWarningStore == null ? void 0 : publicWarningStore.isFormDirty) || false;
9763
9920
  });
9921
+ var getWarningType = createSelector(getPublicWarningStore, function (publicWarningStore) {
9922
+ return publicWarningStore == null ? void 0 : publicWarningStore.warningType;
9923
+ });
9764
9924
 
9765
9925
  /* *
9766
9926
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -9793,7 +9953,8 @@ var PublicWarningStatus;
9793
9953
  var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9794
9954
  var defaultMapPreset = _ref.defaultMapPreset,
9795
9955
  selectedAviationProduct = _ref.selectedAviationProduct,
9796
- isSigmetWarning = _ref.isSigmetWarning,
9956
+ _ref$warningType = _ref.warningType,
9957
+ warningType = _ref$warningType === void 0 ? 'public' : _ref$warningType,
9797
9958
  mode = _ref.mode;
9798
9959
  var publicWarning = useSelector(function (store) {
9799
9960
  return getPublicWarning(store);
@@ -9838,15 +9999,26 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9838
9999
  }));
9839
10000
  };
9840
10001
  var getIsReadOnly = function getIsReadOnly() {
9841
- if (publicWarningFormAction === 'readonly') {
9842
- return true;
10002
+ // public warning related
10003
+ if (warningType === 'public') {
10004
+ if (publicWarningFormAction === 'readonly') {
10005
+ return true;
10006
+ }
10007
+ if ((publicWarning == null ? void 0 : publicWarning.status) === 'TODO') {
10008
+ return false;
10009
+ }
10010
+ // Readonly in case you are not creating a new warning and you are not set as the editor
10011
+ return !isEditor && (publicWarning == null ? void 0 : publicWarning.status) !== undefined;
10012
+ }
10013
+ // aviation related
10014
+ if ((selectedAviationProduct == null ? void 0 : selectedAviationProduct.status) === 'DRAFT') {
10015
+ return false;
9843
10016
  }
9844
- if ((publicWarning == null ? void 0 : publicWarning.status) === 'TODO' && publicWarningFormAction === '') {
10017
+ if (mode === 'new') {
9845
10018
  return false;
9846
10019
  }
9847
- return !isEditor && (publicWarning == null ? void 0 : publicWarning.status) !== undefined;
10020
+ return true;
9848
10021
  };
9849
- // Readonly also in case you are not creating a new warning and you are not set as the editor
9850
10022
  var isReadOnly = getIsReadOnly();
9851
10023
  var onAddObject = function onAddObject() {
9852
10024
  dispatch(uiActions.setToggleOpenDialog({
@@ -9866,7 +10038,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9866
10038
  defaultMapPreset: defaultMapPreset,
9867
10039
  onAddObject: onAddObject,
9868
10040
  selectedAviationProduct: selectedAviationProduct,
9869
- isSigmetWarning: isSigmetWarning,
10041
+ warningType: warningType,
9870
10042
  mode: mode
9871
10043
  });
9872
10044
  };
@@ -10507,6 +10679,21 @@ var AreaObjectLoaderConnect = function AreaObjectLoaderConnect(_ref) {
10507
10679
  * */
10508
10680
  var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(apiAirmet) {
10509
10681
  var airmet = apiAirmet.airmet;
10682
+ var areas = [];
10683
+ if (airmet.startGeometry) {
10684
+ areas.push({
10685
+ geoJSON: Object.assign({}, airmet.startGeometry, {
10686
+ features: airmet.startGeometry.features.map(function (feature) {
10687
+ return Object.assign({}, feature, {
10688
+ properties: Object.assign({}, feature.properties, {
10689
+ isStartGeometry: true
10690
+ })
10691
+ });
10692
+ })
10693
+ }),
10694
+ objectName: airmet.locationIndicatorATSR
10695
+ });
10696
+ }
10510
10697
  return {
10511
10698
  id: apiAirmet.uuid,
10512
10699
  lastUpdatedTime: apiAirmet.lastUpdateDate,
@@ -10514,10 +10701,7 @@ var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(api
10514
10701
  warningDetail: {
10515
10702
  descriptionOriginal: '',
10516
10703
  descriptionTranslation: '',
10517
- areas: [{
10518
- geoJSON: airmet.startGeometry,
10519
- objectName: airmet.locationIndicatorATSR
10520
- }],
10704
+ areas: areas,
10521
10705
  phenomenon: airmet.phenomenon,
10522
10706
  validFrom: airmet.validDateStart,
10523
10707
  validUntil: airmet.validDateEnd,
@@ -10530,6 +10714,37 @@ var transformAirmetToWarningFormat = function transformAirmetToWarningFormat(api
10530
10714
  };
10531
10715
  var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(apiSigmet) {
10532
10716
  var sigmet = apiSigmet.sigmet;
10717
+ var areas = [];
10718
+ if (sigmet.startGeometry) {
10719
+ areas.push({
10720
+ areaId: sigmet.uuid + "-start",
10721
+ geoJSON: Object.assign({}, sigmet.startGeometry, {
10722
+ features: sigmet.startGeometry.features.map(function (feature) {
10723
+ return Object.assign({}, feature, {
10724
+ properties: Object.assign({}, feature.properties, {
10725
+ isStartGeometry: true
10726
+ })
10727
+ });
10728
+ })
10729
+ }),
10730
+ objectName: sigmet.locationIndicatorATSR
10731
+ });
10732
+ }
10733
+ if (sigmet.endGeometry) {
10734
+ areas.push({
10735
+ areaId: sigmet.uuid + "-end",
10736
+ geoJSON: Object.assign({}, sigmet.endGeometry, {
10737
+ features: sigmet.endGeometry.features.map(function (feature) {
10738
+ return Object.assign({}, feature, {
10739
+ properties: Object.assign({}, feature.properties, {
10740
+ isStartGeometry: false
10741
+ })
10742
+ });
10743
+ })
10744
+ }),
10745
+ objectName: sigmet.locationIndicatorATSR
10746
+ });
10747
+ }
10533
10748
  return {
10534
10749
  id: apiSigmet.uuid,
10535
10750
  lastUpdatedTime: apiSigmet.lastUpdateDate,
@@ -10537,10 +10752,7 @@ var transformSigmetToWarningFormat = function transformSigmetToWarningFormat(api
10537
10752
  warningDetail: {
10538
10753
  descriptionOriginal: '',
10539
10754
  descriptionTranslation: '',
10540
- areas: [{
10541
- geoJSON: sigmet.startGeometry,
10542
- objectName: sigmet.locationIndicatorATSR
10543
- }],
10755
+ areas: areas,
10544
10756
  phenomenon: sigmet.phenomenon,
10545
10757
  validFrom: sigmet.validDateStart,
10546
10758
  validUntil: sigmet.validDateEnd,
@@ -10659,13 +10871,81 @@ var transformAirmetToProductFormat = function transformAirmetToProductFormat(war
10659
10871
  cloudLevel: airmet.cloudLevel,
10660
10872
  cloudLowerLevel: airmet.cloudLowerLevel
10661
10873
  }, isInstanceOfCancelAirmet(airmet) && {
10662
- cancelsSigmetSequenceId: cancelAirmet.cancelsAirmetSequenceId
10663
- }, isInstanceOfCancelSigmet(airmet) && {
10874
+ cancelsAirmetSequenceId: cancelAirmet.cancelsAirmetSequenceId
10875
+ }, isInstanceOfCancelAirmet(airmet) && {
10664
10876
  validDateStartOfAirmetToCancel: cancelAirmet.validDateStartOfAirmetToCancel
10665
- }, isInstanceOfCancelSigmet(airmet) && {
10877
+ }, isInstanceOfCancelAirmet(airmet) && {
10666
10878
  validDateEndOfAirmetToCancel: cancelAirmet.validDateEndOfAirmetToCancel
10667
10879
  });
10668
10880
  };
10881
+ // For the Create and Clear buttons
10882
+ // The fields initialised to unknown will be set to their default values by ReactHookForm
10883
+ var getEmptySigmetWarning = function getEmptySigmetWarning() {
10884
+ var currentTime = new Date();
10885
+ var validFromTime = dateUtils.add(currentTime, {
10886
+ minutes: 15
10887
+ });
10888
+ var validUntilTime = dateUtils.add(currentTime, {
10889
+ hours: 4
10890
+ });
10891
+ return {
10892
+ type: undefined,
10893
+ phenomenon: '',
10894
+ status: '',
10895
+ isObservationOrForecast: '',
10896
+ issueDate: undefined,
10897
+ locationIndicatorATSR: undefined,
10898
+ locationIndicatorATSU: undefined,
10899
+ locationIndicatorMWO: undefined,
10900
+ change: '',
10901
+ // Default change
10902
+ sequence: undefined,
10903
+ validDateStart: dateUtils.dateToString(validFromTime),
10904
+ validDateEnd: dateUtils.dateToString(validUntilTime),
10905
+ level: '',
10906
+ levelInfoMode: '',
10907
+ movementType: '',
10908
+ firName: undefined
10909
+ };
10910
+ };
10911
+ // For the Create and Clear buttons
10912
+ // The fields initialised to unknown will be set to their default values by ReactHookForm
10913
+ var getEmptyAirmetWarning = function getEmptyAirmetWarning() {
10914
+ var currentTime = new Date();
10915
+ var validFromTime = dateUtils.add(currentTime, {
10916
+ minutes: 15
10917
+ });
10918
+ var validUntilTime = dateUtils.add(currentTime, {
10919
+ hours: 4
10920
+ });
10921
+ return {
10922
+ type: undefined,
10923
+ phenomenon: '',
10924
+ status: '',
10925
+ isObservationOrForecast: '',
10926
+ issueDate: undefined,
10927
+ locationIndicatorATSR: undefined,
10928
+ locationIndicatorATSU: undefined,
10929
+ locationIndicatorMWO: undefined,
10930
+ change: '',
10931
+ // Default change
10932
+ sequence: undefined,
10933
+ validDateStart: dateUtils.dateToString(validFromTime),
10934
+ validDateEnd: dateUtils.dateToString(validUntilTime),
10935
+ level: '',
10936
+ levelInfoMode: '',
10937
+ movementType: '',
10938
+ firName: undefined,
10939
+ startGeometry: {
10940
+ type: 'FeatureCollection',
10941
+ features: []
10942
+ },
10943
+ startGeometryIntersect: {
10944
+ type: 'FeatureCollection',
10945
+ features: []
10946
+ }
10947
+ };
10948
+ };
10669
10949
 
10670
10950
  var warningFormConfirmationOptions = function warningFormConfirmationOptions(t) {
10671
10951
  return {
@@ -10712,6 +10992,7 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10712
10992
  var publicWarningEditor = useSelector(function (store) {
10713
10993
  return getPublicWarningEditor(store);
10714
10994
  });
10995
+ var warningType = useSelector(getWarningType);
10715
10996
  var _useAuthenticationCon = useAuthenticationContext$1(),
10716
10997
  auth = _useAuthenticationCon.auth;
10717
10998
  var isEditor = publicWarningEditor === (auth == null ? void 0 : auth.username) || false;
@@ -10869,15 +11150,14 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10869
11150
  var selectedAirmet = airmetList == null ? void 0 : airmetList.find(function (airmet) {
10870
11151
  return airmet.uuid === selectedWarningId;
10871
11152
  });
10872
- var isSigmetWarning = Boolean(selectedSigmet);
10873
- var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
10874
- var _useProductConfig = useProductConfig(warningType, !isDialogOpen),
11153
+ var updatedWarningType = selectedSigmet ? 'sigmet' : selectedAirmet && 'airmet' || warningType;
11154
+ var _useProductConfig = useProductConfig(updatedWarningType, !isDialogOpen),
10875
11155
  aviationConfig = _useProductConfig.data;
10876
- var selectedSigmetProduct = selectedSigmet && aviationConfig ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : undefined;
10877
- var selectedAirmetProduct = selectedAirmet ? transformAirmetToProductFormat(selectedAirmet, aviationConfig) : undefined;
10878
- var selectedAviationProduct = isSigmetWarning ? selectedSigmetProduct : selectedAirmetProduct;
10879
- var productCanBe = selectedAviationProduct !== null ? (selectedSigmet == null ? void 0 : selectedSigmet.canbe) || (selectedAirmet == null ? void 0 : selectedAirmet.canbe) : ['DRAFTED', 'DISCARDED', 'PUBLISHED'];
10880
- var mode = getProductFormMode(productCanBe, selectedAviationProduct);
11156
+ var selectedSigmetProduct = selectedSigmet && aviationConfig ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : getEmptySigmetWarning();
11157
+ var selectedAirmetProduct = selectedAirmet && aviationConfig ? transformAirmetToProductFormat(selectedAirmet, aviationConfig) : getEmptyAirmetWarning();
11158
+ var selectedAviationProduct = updatedWarningType === 'sigmet' ? selectedSigmetProduct : updatedWarningType === 'airmet' && selectedAirmetProduct || undefined;
11159
+ var productCanBe = updatedWarningType === 'public' ? ['DRAFTED', 'DISCARDED', 'PUBLISHED'] : (selectedSigmet == null ? void 0 : selectedSigmet.canbe) || (selectedAirmet == null ? void 0 : selectedAirmet.canbe);
11160
+ var mode = getProductFormMode(productCanBe, !selectedWarningId ? null : selectedAviationProduct);
10881
11161
  // Readonly also in case you are not creating a new warning and you are not set as the editor
10882
11162
  var isReadOnly = formAction === 'readonly' || !isEditor && publicWarningStatus !== undefined;
10883
11163
  // Only show toggle if in draft status
@@ -10897,241 +11177,17 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10897
11177
  shouldHideFormMode: shouldHideFormToggleMode,
10898
11178
  publicWarningEditor: publicWarningEditor,
10899
11179
  selectedAviationProduct: selectedAviationProduct,
10900
- warningType: warningType,
11180
+ warningType: updatedWarningType,
10901
11181
  children: jsx(PublicWarningsFormConnect, {
10902
11182
  defaultMapPreset: defaultMapPreset,
10903
11183
  selectedAviationProduct: selectedAviationProduct,
10904
- isSigmetWarning: isSigmetWarning,
11184
+ warningType: updatedWarningType,
10905
11185
  mode: mode
10906
11186
  })
10907
11187
  }), jsx(AreaObjectLoaderConnect, {})]
10908
11188
  });
10909
11189
  };
10910
11190
 
10911
- var actionButton = function actionButton(amount) {
10912
- return jsxs(Grid2, {
10913
- container: true,
10914
- alignItems: "center",
10915
- style: {
10916
- marginRight: '8px',
10917
- minWidth: '36px'
10918
- },
10919
- children: [jsx(Options, {}), jsx(Typography, {
10920
- variant: "body2",
10921
- sx: {
10922
- paddingLeft: 0.5
10923
- },
10924
- children: amount > 0 && amount
10925
- })]
10926
- });
10927
- };
10928
- var FilterChipWithOptions = function FilterChipWithOptions(_ref) {
10929
- var id = _ref.id,
10930
- translationKey = _ref.translationKey,
10931
- handleClick = _ref.handleClick,
10932
- _ref$filterList = _ref.filterList,
10933
- filterList = _ref$filterList === void 0 ? [] : _ref$filterList;
10934
- var _useWarningsTranslati = useWarningsTranslation(),
10935
- t = _useWarningsTranslati.t;
10936
- var _React$useState = React.useState(undefined),
10937
- anchorEl = _React$useState[0],
10938
- setAnchorEl = _React$useState[1];
10939
- var _React$useState2 = React.useState(false),
10940
- isOpen = _React$useState2[0],
10941
- setIsOpen = _React$useState2[1];
10942
- var _getPosition = getPosition('bottom'),
10943
- anchorOrigin = _getPosition.anchorOrigin,
10944
- transformOrigin = _getPosition.transformOrigin;
10945
- var initialResult = {
10946
- isAllSelected: true,
10947
- selectedFiltersAmount: 0,
10948
- isDisabled: false
10949
- };
10950
- var _filterList$reduce = filterList.reduce(function (accumulatedResult, filterItem) {
10951
- var result = Object.assign({}, accumulatedResult);
10952
- var isEmptyFilter = filterItem.filter.id === emptyFilter.id;
10953
- var isOnlyFilter = filterList.length === 1 && isEmptyFilter;
10954
- if (!filterItem.filter.checked) {
10955
- result.isAllSelected = false;
10956
- if (isOnlyFilter) {
10957
- result.isDisabled = true;
10958
- }
10959
- } else if (isOnlyFilter) {
10960
- result.isDisabled = true;
10961
- } else {
10962
- result.selectedFiltersAmount += 1;
10963
- }
10964
- return result;
10965
- }, initialResult),
10966
- isAllSelected = _filterList$reduce.isAllSelected,
10967
- selectedFiltersAmount = _filterList$reduce.selectedFiltersAmount,
10968
- isDisabled = _filterList$reduce.isDisabled;
10969
- var isAnyFilterSelected = selectedFiltersAmount > 0;
10970
- var showDisabled = filterList.length === 0 || isDisabled;
10971
- var label = t(translationKey);
10972
- var onClickOptions = function onClickOptions() {
10973
- setIsOpen(!isOpen);
10974
- };
10975
- var onSelectAll = function onSelectAll() {
10976
- handleClick && handleClick(id, isAllSelected);
10977
- };
10978
- var handleClose = function handleClose(event) {
10979
- event.stopPropagation();
10980
- setIsOpen(false);
10981
- };
10982
- React.useEffect(function () {
10983
- setAnchorEl(document.getElementById(id));
10984
- }, [id]);
10985
- return jsxs(Fragment, {
10986
- children: [jsx(CustomTooltip, {
10987
- title: showDisabled ? t('filter-no-results') : t('filter-options'),
10988
- placement: "bottom",
10989
- children: jsx("span", {
10990
- style: {
10991
- margin: 0
10992
- },
10993
- children: jsx(FilterChip, {
10994
- id: id,
10995
- label: label,
10996
- actionIcon: actionButton(selectedFiltersAmount),
10997
- isSelected: isAnyFilterSelected,
10998
- handleClick: onClickOptions,
10999
- isDisabled: showDisabled,
11000
- size: "medium"
11001
- })
11002
- })
11003
- }), jsxs(Menu, {
11004
- title: label,
11005
- anchorEl: anchorEl,
11006
- open: isOpen,
11007
- onClose: handleClose,
11008
- anchorOrigin: anchorOrigin,
11009
- transformOrigin: transformOrigin,
11010
- BackdropProps: {
11011
- style: {
11012
- opacity: 0,
11013
- transition: 'none'
11014
- }
11015
- },
11016
- sx: {
11017
- padding: 3
11018
- },
11019
- children: [jsxs(DialogTitle, {
11020
- id: "dialog-title",
11021
- sx: {
11022
- zIndex: 1,
11023
- padding: '8px 18px 16px 24px',
11024
- display: 'flex',
11025
- justifyContent: 'space-between',
11026
- alignItems: 'center'
11027
- },
11028
- children: [jsx(Typography, {
11029
- sx: {
11030
- fontSize: '20px',
11031
- fontWeight: 500,
11032
- paddingRight: 1
11033
- },
11034
- "data-testid": "customDialog-title",
11035
- component: "span",
11036
- children: label
11037
- }), jsx(CustomIconButton, {
11038
- "aria-label": t('close-dialog-confirm'),
11039
- onClick: handleClose,
11040
- sx: {
11041
- '&.MuiIconButton-root': {
11042
- color: 'geowebColors.greys.accessible'
11043
- }
11044
- },
11045
- children: jsx(Close, {})
11046
- })]
11047
- }), jsxs(DialogContent, {
11048
- sx: {
11049
- padding: '0px 24px 16px 24px'
11050
- },
11051
- children: [jsxs(Grid2, {
11052
- container: true,
11053
- justifyContent: "space-between",
11054
- alignItems: "center",
11055
- children: [t('filter-select-all'), jsx(Switch, {
11056
- inputProps: {
11057
- 'aria-label': t('filter-select-all')
11058
- },
11059
- checked: isAllSelected,
11060
- onChange: onSelectAll,
11061
- sx: {
11062
- marginRight: '-12px'
11063
- }
11064
- })]
11065
- }), jsx(Box, {
11066
- sx: {
11067
- marginLeft: '-12px'
11068
- },
11069
- children: filterList.map(function (filterItem) {
11070
- switch (id) {
11071
- case 'phenomenon':
11072
- {
11073
- var icon = getWarningPhenomenaIcon(filterItem.filter.id);
11074
- return jsxs(FilterListItem, Object.assign({}, filterItem, {
11075
- children: [icon && jsx(Box, {
11076
- "data-testid": "icon-" + filterItem.filter.id,
11077
- sx: {
11078
- marginRight: 1
11079
- },
11080
- children: icon
11081
- }), jsx(FilterLabel, {
11082
- name: filterItem.filter.name
11083
- })]
11084
- }), filterItem.filter.id);
11085
- }
11086
- default:
11087
- {
11088
- return jsx(FilterListItem, Object.assign({}, filterItem), filterItem.filter.id);
11089
- }
11090
- }
11091
- })
11092
- })]
11093
- })]
11094
- })]
11095
- });
11096
- };
11097
-
11098
- var FilterChipWithOptionsConnect = function FilterChipWithOptionsConnect(_ref) {
11099
- var filter = _ref.filter;
11100
- var dispatch = useDispatch();
11101
- var toggleFilter = React.useCallback(function (filterId, isChecked) {
11102
- dispatch(publicWarningActions.toggleFilter({
11103
- filterId: filterId,
11104
- isChecked: isChecked
11105
- }));
11106
- }, [dispatch]);
11107
- var toggleOption = React.useCallback(function (filterId, optionId) {
11108
- dispatch(publicWarningActions.toggleOption({
11109
- filterId: filterId,
11110
- optionId: optionId
11111
- }));
11112
- }, [dispatch]);
11113
- var enableOnlyOneFilterOption = React.useCallback(function (filterId, optionId) {
11114
- dispatch(publicWarningActions.enableOnlyOneFilterOption({
11115
- filterId: filterId,
11116
- optionId: optionId
11117
- }));
11118
- }, [dispatch]);
11119
- var filterListWithActions = filter.filterList.map(function (option) {
11120
- return Object.assign({}, option, {
11121
- toggleFilter: function toggleFilter() {
11122
- return toggleOption(filter.id, option.filter.id);
11123
- },
11124
- enableOnlyOneFilter: function enableOnlyOneFilter() {
11125
- return enableOnlyOneFilterOption(filter.id, option.filter.id);
11126
- }
11127
- });
11128
- });
11129
- return jsx(FilterChipWithOptions, Object.assign({}, filter, {
11130
- handleClick: toggleFilter,
11131
- filterList: filterListWithActions
11132
- }));
11133
- };
11134
-
11135
11191
  /* *
11136
11192
  * Licensed under the Apache License, Version 2.0 (the "License");
11137
11193
  * you may not use this file except in compliance with the License.
@@ -11226,113 +11282,18 @@ function useOverflowCheck(text) {
11226
11282
  };
11227
11283
  }
11228
11284
  var getTranslationKey = function getTranslationKey(optionId, id) {
11285
+ if (id === 'source' || id === 'incident') {
11286
+ if (optionId === emptyFilterId) {
11287
+ return "warning-unspecified";
11288
+ }
11289
+ return optionId;
11290
+ }
11229
11291
  var phenomena = warningPhenomena.find(function (phenomenon) {
11230
11292
  return phenomenon.key === optionId;
11231
11293
  });
11232
11294
  return phenomena ? phenomena.translationKey : "warning-" + id + "-" + optionId;
11233
11295
  };
11234
11296
 
11235
- /* *
11236
- * Licensed under the Apache License, Version 2.0 (the "License");
11237
- * you may not use this file except in compliance with the License.
11238
- * You may obtain a copy of the License at
11239
- *
11240
- * http://www.apache.org/licenses/LICENSE-2.0
11241
- *
11242
- * Unless required by applicable law or agreed to in writing, software
11243
- * distributed under the License is distributed on an "AS IS" BASIS,
11244
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11245
- * See the License for the specific language governing permissions and
11246
- * limitations under the License.
11247
- *
11248
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11249
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
11250
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
11251
- * */
11252
- var Domain;
11253
- (function (Domain) {
11254
- Domain["aviation"] = "aviation";
11255
- Domain["maritime"] = "maritime";
11256
- Domain["public"] = "public";
11257
- })(Domain || (Domain = {}));
11258
- var Level;
11259
- (function (Level) {
11260
- Level["extreme"] = "extreme";
11261
- Level["moderate"] = "moderate";
11262
- Level["severe"] = "severe";
11263
- Level["airmet"] = "AIR";
11264
- Level["sigmet"] = "SIG";
11265
- })(Level || (Level = {}));
11266
- var Phenomenon;
11267
- (function (Phenomenon) {
11268
- Phenomenon["wind"] = "wind";
11269
- Phenomenon["fog"] = "fog";
11270
- Phenomenon["thunderstorm"] = "thunderstorm";
11271
- Phenomenon["snowIce"] = "snowIce";
11272
- Phenomenon["rain"] = "rain";
11273
- Phenomenon["highTemp"] = "highTemp";
11274
- Phenomenon["lowTemp"] = "lowTemp";
11275
- Phenomenon["coastalEvent"] = "coastalEvent";
11276
- })(Phenomenon || (Phenomenon = {}));
11277
- var defaultDomainFilter = {
11278
- aviation: false,
11279
- maritime: false,
11280
- "public": true
11281
- };
11282
- var domainLevels = {
11283
- aviation: [Level.airmet, Level.sigmet],
11284
- maritime: [],
11285
- "public": [Level.extreme, Level.moderate, Level.severe]
11286
- };
11287
- var defaultLevelFilter = {
11288
- unspecified: true,
11289
- extreme: true,
11290
- moderate: true,
11291
- severe: true,
11292
- AIR: true,
11293
- SIG: true
11294
- };
11295
- var defaultPhenomenonFilter = {
11296
- unspecified: true,
11297
- coastalEvent: true,
11298
- fog: true,
11299
- highTemp: true,
11300
- lowTemp: true,
11301
- rain: true,
11302
- snowIce: true,
11303
- thunderstorm: true,
11304
- wind: true
11305
- };
11306
- var useSelectedOptions = function useSelectedOptions(options) {
11307
- var selectedOptions = Object.keys(options).filter(function (k) {
11308
- return options[k];
11309
- });
11310
- var allSelected = selectedOptions.length === Object.keys(options).length;
11311
- return {
11312
- noSelectedOptions: selectedOptions.length,
11313
- allSelected: allSelected
11314
- };
11315
- };
11316
- var updateState = function updateState(state, optionKey, value, only) {
11317
- var _Object$assign3;
11318
- if (only) {
11319
- return Object.keys(state).reduce(function (acc, k) {
11320
- var _Object$assign;
11321
- return Object.assign({}, acc, (_Object$assign = {}, _Object$assign[k] = k === optionKey, _Object$assign));
11322
- }, {});
11323
- }
11324
- return optionKey === 'ALL' ? Object.keys(state).reduce(function (acc, k) {
11325
- var _Object$assign2;
11326
- return Object.assign({}, acc, (_Object$assign2 = {}, _Object$assign2[k] = value, _Object$assign2));
11327
- }, {}) : Object.assign({}, state, (_Object$assign3 = {}, _Object$assign3[optionKey] = value, _Object$assign3));
11328
- };
11329
- /** Make sure our value is in the filter */
11330
- var getValue = function getValue(values, value) {
11331
- return Object.values(values).find(function (v) {
11332
- return v === value;
11333
- }) || 'unspecified';
11334
- };
11335
-
11336
11297
  var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11337
11298
  var id = _ref.id,
11338
11299
  options = _ref.options,
@@ -11345,9 +11306,10 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11345
11306
  var _useSelectedOptions = useSelectedOptions(options),
11346
11307
  noSelectedOptions = _useSelectedOptions.noSelectedOptions,
11347
11308
  allSelected = _useSelectedOptions.allSelected;
11309
+ var isDisabled = Object.keys(options).length < 2;
11348
11310
  return jsxs(Fragment, {
11349
11311
  children: [jsx(CustomTooltip, {
11350
- title: t('filter-options'),
11312
+ title: isDisabled ? t('filter-no-results') : t('filter-options'),
11351
11313
  placement: "bottom",
11352
11314
  children: jsx("span", {
11353
11315
  style: {
@@ -11356,11 +11318,11 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11356
11318
  children: jsx(FilterChip, {
11357
11319
  id: id,
11358
11320
  label: t("filter-" + id),
11359
- isSelected: noSelectedOptions > 0,
11321
+ isSelected: !isDisabled && noSelectedOptions > 0,
11360
11322
  onClick: function onClick(ref) {
11361
11323
  return setAnchorEl(ref);
11362
11324
  },
11363
- isDisabled: false,
11325
+ isDisabled: isDisabled,
11364
11326
  size: "medium",
11365
11327
  actionIcon: jsxs(Grid2, {
11366
11328
  container: true,
@@ -11374,7 +11336,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11374
11336
  sx: {
11375
11337
  paddingLeft: 0.5
11376
11338
  },
11377
- children: noSelectedOptions > 0 && noSelectedOptions
11339
+ children: !isDisabled && noSelectedOptions > 0 && noSelectedOptions
11378
11340
  })]
11379
11341
  })
11380
11342
  })
@@ -11446,8 +11408,27 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11446
11408
  marginTop: '-6px'
11447
11409
  }
11448
11410
  })]
11449
- }), jsx(Box, {
11450
- children: Object.keys(options).map(function (optionId) {
11411
+ }), jsxs(Box, {
11412
+ children: [options[emptyFilterId] !== undefined && jsx(FilterOption, {
11413
+ optionId: emptyFilterId,
11414
+ checked: options[emptyFilterId],
11415
+ onClick: function onClick(checked, only) {
11416
+ return updateFilter(id, emptyFilterId, checked, only);
11417
+ },
11418
+ labelStyle: {
11419
+ width: 'fit-content',
11420
+ fontSize: '16px',
11421
+ display: 'flex',
11422
+ alignItems: 'center',
11423
+ gap: 1
11424
+ },
11425
+ label: jsx(Fragment, {
11426
+ children: t(getTranslationKey(emptyFilterId, id))
11427
+ })
11428
+ }, id + "-" + emptyFilterId), Object.keys(options).map(function (optionId) {
11429
+ if (optionId === emptyFilterId) {
11430
+ return null;
11431
+ }
11451
11432
  var warningColor = warningColors[optionId];
11452
11433
  return jsx(FilterOption, {
11453
11434
  optionId: optionId,
@@ -11466,7 +11447,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11466
11447
  children: [getWarningPhenomenaIcon(optionId), ' ', t(getTranslationKey(optionId, id))]
11467
11448
  })
11468
11449
  }, id + "-" + optionId);
11469
- })
11450
+ })]
11470
11451
  })]
11471
11452
  })]
11472
11453
  })]
@@ -11474,9 +11455,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
11474
11455
  };
11475
11456
 
11476
11457
  var FilterList = function FilterList(_ref) {
11477
- var _ref$filters = _ref.filters,
11478
- filters = _ref$filters === void 0 ? [] : _ref$filters,
11479
- _ref$onClickAll = _ref.onClickAll,
11458
+ var _ref$onClickAll = _ref.onClickAll,
11480
11459
  onClickAll = _ref$onClickAll === void 0 ? function () {} : _ref$onClickAll,
11481
11460
  _ref$isAllSelected = _ref.isAllSelected,
11482
11461
  isAllSelected = _ref$isAllSelected === void 0 ? true : _ref$isAllSelected,
@@ -11512,10 +11491,6 @@ var FilterList = function FilterList(_ref) {
11512
11491
  size: "medium"
11513
11492
  })
11514
11493
  })
11515
- }), filters.map(function (filter) {
11516
- return jsx(FilterChipWithOptionsConnect, {
11517
- filter: filter
11518
- }, filter.id);
11519
11494
  }), Object.keys(filterState).map(function (filterId) {
11520
11495
  return jsx(ExpandableFilterChip, {
11521
11496
  id: filterId,
@@ -11561,6 +11536,7 @@ var WarningListItemSeperator = function WarningListItemSeperator(_ref) {
11561
11536
  padding: 0
11562
11537
  },
11563
11538
  onClick: onClick,
11539
+ "data-testid": "warninglist-" + status,
11564
11540
  children: [isExpanded ? jsx(ChevronDown, {}) : jsx(ChevronUp, {}), jsx(Typography, {
11565
11541
  variant: "caption",
11566
11542
  sx: {
@@ -11694,7 +11670,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
11694
11670
  }
11695
11671
  };
11696
11672
 
11697
- var _excluded$2 = ["warning", "activeWarningId", "onSelectWarning", "onEditWarning", "onDeleteWarning", "onDeleteReviewWarning", "onExpireWarning", "onWithdrawWarning"];
11673
+ var _excluded$2 = ["warning", "activeWarningId", "highlightedItem", "onSelectWarning", "onEditWarning", "onDeleteWarning", "onDeleteReviewWarning", "onExpireWarning", "onWithdrawWarning"];
11698
11674
  var renderLevelText = function renderLevelText(levelString) {
11699
11675
  if (!levelString) {
11700
11676
  return null;
@@ -11768,6 +11744,7 @@ var WarningListItem = function WarningListItem(_ref) {
11768
11744
  var _warning$warningDetai, _sx, _sx2, _Object$assign;
11769
11745
  var warning = _ref.warning,
11770
11746
  activeWarningId = _ref.activeWarningId,
11747
+ highlightedItem = _ref.highlightedItem,
11771
11748
  _ref$onSelectWarning = _ref.onSelectWarning,
11772
11749
  onSelectWarning = _ref$onSelectWarning === void 0 ? function () {} : _ref$onSelectWarning,
11773
11750
  _ref$onEditWarning = _ref.onEditWarning,
@@ -11801,12 +11778,21 @@ var WarningListItem = function WarningListItem(_ref) {
11801
11778
  }
11802
11779
  return t(levelTranslation);
11803
11780
  }, [levelTranslation, t]);
11781
+ var backgroundColor = React__default.useMemo(function () {
11782
+ if (highlightedItem) {
11783
+ return 'geowebColors.cards.cardContainerMouseOver';
11784
+ }
11785
+ if (status === PublicWarningStatus.EXPIRED || status === PublicWarningStatus.WITHDRAWN) {
11786
+ return 'geowebColors.cards.cardContainerDisabled';
11787
+ }
11788
+ return 'geowebColors.cards.cardContainer';
11789
+ }, [highlightedItem, status]);
11804
11790
  return jsx(ListItem, Object.assign({
11805
11791
  sx: {
11806
11792
  marginBottom: 0.25,
11807
11793
  minHeight: '32px',
11808
11794
  padding: '0 0',
11809
- backgroundColor: status === PublicWarningStatus.EXPIRED || status === PublicWarningStatus.WITHDRAWN ? 'geowebColors.cards.cardContainerDisabled' : 'geowebColors.cards.cardContainer',
11795
+ backgroundColor: backgroundColor,
11810
11796
  borderColor: status === PublicWarningStatus.EXPIRED || status === PublicWarningStatus.WITHDRAWN ? 'geowebColors.cards.cardContainerDisabledBorder' : 'geowebColors.cards.cardContainerBorder',
11811
11797
  borderRadius: 1,
11812
11798
  borderWidth: activeWarningId === warning.id ? '1px' : '1px',
@@ -12022,6 +12008,10 @@ var NewWarningButton = function NewWarningButton(_ref) {
12022
12008
  event.stopPropagation();
12023
12009
  setAnchorEl(null);
12024
12010
  };
12011
+ var onCreateNewWarning = function onCreateNewWarning(warningType, event) {
12012
+ onCreateWarning(warningType);
12013
+ handleClose(event);
12014
+ };
12025
12015
  var buttonId = 'newWarningButton';
12026
12016
  React__default.useEffect(function () {
12027
12017
  if (isDefaultOpen) {
@@ -12082,19 +12072,22 @@ var NewWarningButton = function NewWarningButton(_ref) {
12082
12072
  },
12083
12073
  children: [jsx(MenuItem, {
12084
12074
  onClick: function onClick(event) {
12085
- onCreateWarning();
12086
- handleClose(event);
12075
+ onCreateNewWarning('public', event);
12087
12076
  },
12088
12077
  children: jsx(ListItemText, {
12089
12078
  children: t('public-warning-title').toUpperCase()
12090
12079
  })
12091
12080
  }, "Public"), jsx(MenuItem, {
12092
- disabled: true,
12081
+ onClick: function onClick(event) {
12082
+ onCreateNewWarning('airmet', event);
12083
+ },
12093
12084
  children: jsx(ListItemText, {
12094
12085
  children: BUTTON_AIRMET
12095
12086
  })
12096
12087
  }, "Airmet"), jsx(MenuItem, {
12097
- disabled: true,
12088
+ onClick: function onClick(event) {
12089
+ onCreateNewWarning('sigmet', event);
12090
+ },
12098
12091
  children: jsx(ListItemText, {
12099
12092
  children: BUTTON_SIGMET
12100
12093
  })
@@ -12195,7 +12188,6 @@ var PublicWarningList = function PublicWarningList(_ref) {
12195
12188
  var _sx, _sx2, _sx3;
12196
12189
  var _ref$warnings = _ref.warnings,
12197
12190
  warnings = _ref$warnings === void 0 ? [] : _ref$warnings,
12198
- filters = _ref.filters,
12199
12191
  filterHookState = _ref.filterHookState,
12200
12192
  _ref$isLoading = _ref.isLoading,
12201
12193
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
@@ -12219,10 +12211,9 @@ var PublicWarningList = function PublicWarningList(_ref) {
12219
12211
  onExpireWarning = _ref$onExpireWarning === void 0 ? function () {} : _ref$onExpireWarning,
12220
12212
  _ref$onWithdrawWarnin = _ref.onWithdrawWarning,
12221
12213
  onWithdrawWarning = _ref$onWithdrawWarnin === void 0 ? function () {} : _ref$onWithdrawWarnin,
12222
- _ref$onClickAllChip = _ref.onClickAllChip,
12223
- onClickAllChip = _ref$onClickAllChip === void 0 ? function () {} : _ref$onClickAllChip,
12224
- _ref$isAllChipSelecte = _ref.isAllChipSelected,
12225
- isAllChipSelected = _ref$isAllChipSelecte === void 0 ? true : _ref$isAllChipSelecte;
12214
+ hoveredFeatureId = _ref.hoveredFeatureId,
12215
+ expandedSections = _ref.expandedSections,
12216
+ setExpandedSections = _ref.setExpandedSections;
12226
12217
  var filterState = filterHookState.filterState,
12227
12218
  updateFilter = filterHookState.updateFilter,
12228
12219
  allSelected = filterHookState.allSelected;
@@ -12235,7 +12226,6 @@ var PublicWarningList = function PublicWarningList(_ref) {
12235
12226
  sortState = _React$useState[0],
12236
12227
  setSortState = _React$useState[1];
12237
12228
  var onClickAll = function onClickAll(isChecked) {
12238
- onClickAllChip(isChecked);
12239
12229
  updateFilter('ALL', 'ALL', !isChecked);
12240
12230
  };
12241
12231
  var sortedWarnings = React__default.useMemo(function () {
@@ -12249,32 +12239,26 @@ var PublicWarningList = function PublicWarningList(_ref) {
12249
12239
  };
12250
12240
  });
12251
12241
  };
12252
- var _React$useState2 = React__default.useState({
12253
- TODO: true,
12254
- DRAFT: true,
12255
- PUBLISHED: true,
12256
- EXPIRED: true
12257
- }),
12258
- expandedSections = _React$useState2[0],
12259
- setExpandedSections = _React$useState2[1];
12260
12242
  var toggleExpand = function toggleExpand(shouldToggle, status) {
12261
12243
  var _Object$assign;
12262
12244
  setExpandedSections(Object.assign({}, expandedSections, (_Object$assign = {}, _Object$assign[status] = shouldToggle, _Object$assign)));
12263
12245
  resetListIndex();
12264
12246
  };
12265
- var items = [{
12266
- status: PublicWarningStatus.TODO,
12267
- totalWarnings: sortedWarnings.todo.length
12268
- }].concat(expandedSections.TODO ? sortedWarnings.todo : [], [{
12269
- status: PublicWarningStatus.DRAFT,
12270
- totalWarnings: sortedWarnings.draft.length
12271
- }], expandedSections.DRAFT ? sortedWarnings.draft : [], [{
12272
- status: PublicWarningStatus.PUBLISHED,
12273
- totalWarnings: sortedWarnings.published.length
12274
- }], expandedSections.PUBLISHED ? sortedWarnings.published : [], [{
12275
- status: PublicWarningStatus.EXPIRED,
12276
- totalWarnings: sortedWarnings.expired.length
12277
- }], expandedSections.EXPIRED ? sortedWarnings.expired : []);
12247
+ var items = React__default.useMemo(function () {
12248
+ return [{
12249
+ status: PublicWarningStatus.TODO,
12250
+ totalWarnings: sortedWarnings.todo.length
12251
+ }].concat(expandedSections.TODO ? sortedWarnings.todo : [], [{
12252
+ status: PublicWarningStatus.DRAFT,
12253
+ totalWarnings: sortedWarnings.draft.length
12254
+ }], expandedSections.DRAFT ? sortedWarnings.draft : [], [{
12255
+ status: PublicWarningStatus.PUBLISHED,
12256
+ totalWarnings: sortedWarnings.published.length
12257
+ }], expandedSections.PUBLISHED ? sortedWarnings.published : [], [{
12258
+ status: PublicWarningStatus.EXPIRED,
12259
+ totalWarnings: sortedWarnings.expired.length
12260
+ }], expandedSections.EXPIRED ? sortedWarnings.expired : []);
12261
+ }, [sortedWarnings, expandedSections]);
12278
12262
  var getItemSize = function getItemSize(index, width) {
12279
12263
  var item = items[index];
12280
12264
  if (item.totalWarnings !== undefined) {
@@ -12307,6 +12291,15 @@ var PublicWarningList = function PublicWarningList(_ref) {
12307
12291
  }
12308
12292
  }, [warnings]);
12309
12293
  var filterHeight = useGetFilterHeight(filterRef);
12294
+ React__default.useEffect(function () {
12295
+ if (hoveredFeatureId) {
12296
+ var _listRef$current;
12297
+ var index = items.findIndex(function (item) {
12298
+ return item.id === hoveredFeatureId;
12299
+ });
12300
+ (_listRef$current = listRef.current) == null || _listRef$current.scrollToItem(index, 'smart');
12301
+ }
12302
+ }, [hoveredFeatureId, items]);
12310
12303
  return jsxs(Fragment, {
12311
12304
  children: [isLoading && jsx(LinearProgress, {
12312
12305
  "data-testid": "loading-bar",
@@ -12353,8 +12346,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
12353
12346
  md: 8
12354
12347
  },
12355
12348
  children: jsx(FilterList, {
12356
- filters: filters,
12357
- isAllSelected: allSelected && isAllChipSelected,
12349
+ isAllSelected: allSelected,
12358
12350
  onClickAll: onClickAll,
12359
12351
  filterState: filterState,
12360
12352
  updateFilter: updateFilter
@@ -12497,9 +12489,11 @@ var PublicWarningList = function PublicWarningList(_ref) {
12497
12489
  }, key);
12498
12490
  }
12499
12491
  var publicWarning = warning;
12492
+ var highlightedItem = hoveredFeatureId === publicWarning.id;
12500
12493
  return jsx(WarningListItem, {
12501
12494
  style: style,
12502
12495
  warning: publicWarning,
12496
+ highlightedItem: highlightedItem,
12503
12497
  onSelectWarning: onSelectWarning,
12504
12498
  onEditWarning: onEditWarning,
12505
12499
  onDeleteWarning: onDeleteWarning,
@@ -12557,49 +12551,6 @@ var getPublicWarningsError = createSelector(getPublicWarningsStore, function (st
12557
12551
  var getPublicWarningsLastUpdatedTime = createSelector(getPublicWarningsStore, function (store) {
12558
12552
  return store == null ? void 0 : store.lastUpdatedTime;
12559
12553
  });
12560
- var _warningListFilterAda = warningListFilterAdapter.getSelectors(function (state) {
12561
- var _state$publicWarnings3, _state$publicWarnings4;
12562
- return (_state$publicWarnings3 = state == null || (_state$publicWarnings4 = state.publicWarnings) == null ? void 0 : _state$publicWarnings4.filters) != null ? _state$publicWarnings3 : {
12563
- entities: {},
12564
- ids: []
12565
- };
12566
- }),
12567
- selectAllFilters = _warningListFilterAda.selectAll,
12568
- selectAllFilterIds = _warningListFilterAda.selectIds;
12569
- var getIsAllSelected = createSelector(selectAllFilters, function (filters) {
12570
- var result = filters.findIndex(function (filter) {
12571
- return filter.filterList.findIndex(function (option) {
12572
- return option.filter.checked === false;
12573
- }) !== -1;
12574
- }) === -1;
12575
- return result;
12576
- });
12577
- var getSelectedFilterOptions = createSelector(selectAllFilters, function (filters) {
12578
- var selectedOptions = [];
12579
- filters.forEach(function (filter) {
12580
- filter.filterList.forEach(function (option) {
12581
- if (option.filter.checked === true) {
12582
- selectedOptions.push({
12583
- filterId: filter.id,
12584
- optionId: option.filter.id
12585
- });
12586
- }
12587
- });
12588
- });
12589
- return selectedOptions;
12590
- }, selectorMemoizationOptions);
12591
- var getFilteredWarnings = createSelector(selectAllPublicWarnings, getIsAllSelected, getSelectedFilterOptions, selectAllFilterIds, function (warnings, isAllSelected, filters, filterIds) {
12592
- if (isAllSelected) {
12593
- return warnings;
12594
- }
12595
- var result = warnings.filter(function (_ref) {
12596
- var warningDetail = _ref.warningDetail;
12597
- return filterIds.every(function (key) {
12598
- return isWarningMatchingFilter(filters, key, warningDetail[key]);
12599
- });
12600
- });
12601
- return result;
12602
- }, selectorMemoizationOptions);
12603
12554
 
12604
12555
  var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
12605
12556
  var _ref$onClose = _ref.onClose,
@@ -12700,7 +12651,7 @@ var useFilter = function useFilter(defaultFilter, pickedOptions) {
12700
12651
  var _useState = useState(defaultFilter),
12701
12652
  filter = _useState[0],
12702
12653
  setFilter = _useState[1];
12703
- var pickedFilterOptions = pick(filter, ['unspecified'].concat(pickedOptions));
12654
+ var pickedFilterOptions = pick(filter, [emptyFilterId].concat(pickedOptions));
12704
12655
  var _useSelectedOptions = useSelectedOptions(pickedFilterOptions),
12705
12656
  allSelected = _useSelectedOptions.allSelected;
12706
12657
  return [pickedFilterOptions, setFilter, allSelected];
@@ -12716,7 +12667,7 @@ var useWarningFilters = function useWarningFilters(warnings) {
12716
12667
  pickedLevelFilter = _useFilter[0],
12717
12668
  setLevelFilter = _useFilter[1],
12718
12669
  allLevelsSelected = _useFilter[2];
12719
- var existingPhenomenon = Object.values(Phenomenon).filter(function (p) {
12670
+ var existingPhenomenon = Object.values(Phenomenon$1).filter(function (p) {
12720
12671
  return warnings.find(function (w) {
12721
12672
  return w.warningDetail.phenomenon === p;
12722
12673
  });
@@ -12725,9 +12676,53 @@ var useWarningFilters = function useWarningFilters(warnings) {
12725
12676
  pickedPhenomenonFilter = _useFilter2[0],
12726
12677
  setPhenomenonFilter = _useFilter2[1],
12727
12678
  allPhenomenonSelected = _useFilter2[2];
12679
+ var relevantSources = useMemo(function () {
12680
+ return getFiltersFromWarnings(warnings, 'warningProposalSource');
12681
+ }, [warnings]);
12682
+ var defaultSourceFilter = useMemo(function () {
12683
+ return Object.fromEntries(relevantSources.map(function (key) {
12684
+ return [key, true];
12685
+ }));
12686
+ }, [relevantSources]);
12687
+ var _useFilter3 = useFilter(defaultSourceFilter, relevantSources),
12688
+ pickedSourceFilter = _useFilter3[0],
12689
+ setSourceFilter = _useFilter3[1],
12690
+ allSourcesSelected = _useFilter3[2];
12691
+ useEffect(function () {
12692
+ setSourceFilter(function (prevFilter) {
12693
+ var newSourceFilter = Object.assign({}, defaultSourceFilter, prevFilter);
12694
+ // Only update state if the new filter differs from the current one
12695
+ if (JSON.stringify(newSourceFilter) !== JSON.stringify(prevFilter)) {
12696
+ return newSourceFilter;
12697
+ }
12698
+ return prevFilter;
12699
+ });
12700
+ }, [defaultSourceFilter, setSourceFilter]);
12701
+ var relevantIncidents = useMemo(function () {
12702
+ return getFiltersFromWarnings(warnings, 'incident');
12703
+ }, [warnings]);
12704
+ var defaultIncidentFilter = useMemo(function () {
12705
+ return Object.fromEntries(relevantIncidents.map(function (key) {
12706
+ return [key, true];
12707
+ }));
12708
+ }, [relevantIncidents]);
12709
+ var _useFilter4 = useFilter(defaultIncidentFilter, relevantIncidents),
12710
+ pickedIncidentFilter = _useFilter4[0],
12711
+ setIncidentFilter = _useFilter4[1],
12712
+ allIncidentsSelected = _useFilter4[2];
12713
+ useEffect(function () {
12714
+ setIncidentFilter(function (prevFilter) {
12715
+ var newIncidentFilter = Object.assign({}, defaultIncidentFilter, prevFilter);
12716
+ // Only update state if the new filter differs from the current one
12717
+ if (JSON.stringify(newIncidentFilter) !== JSON.stringify(prevFilter)) {
12718
+ return newIncidentFilter;
12719
+ }
12720
+ return prevFilter;
12721
+ });
12722
+ }, [defaultIncidentFilter, setIncidentFilter]);
12728
12723
  var _useSelectedOptions2 = useSelectedOptions(domainFilter),
12729
12724
  allDomainSelected = _useSelectedOptions2.allSelected;
12730
- var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected;
12725
+ var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected && allIncidentsSelected && allSourcesSelected;
12731
12726
  /**
12732
12727
  * @param filterKey - Name of the filter | "ALL" filters
12733
12728
  * @param optionKey - Name of the option | "ALL" options
@@ -12745,6 +12740,12 @@ var useWarningFilters = function useWarningFilters(warnings) {
12745
12740
  setPhenomenonFilter(function (state) {
12746
12741
  return updateState(state, 'ALL', value);
12747
12742
  });
12743
+ setSourceFilter(function (state) {
12744
+ return updateState(state, 'ALL', value);
12745
+ });
12746
+ setIncidentFilter(function (state) {
12747
+ return updateState(state, 'ALL', value);
12748
+ });
12748
12749
  } else if (filterKey === 'domain') {
12749
12750
  setDomainFilter(function (state) {
12750
12751
  return updateState(state, optionKey, value, only);
@@ -12757,6 +12758,14 @@ var useWarningFilters = function useWarningFilters(warnings) {
12757
12758
  setPhenomenonFilter(function (state) {
12758
12759
  return updateState(state, optionKey, value, only);
12759
12760
  });
12761
+ } else if (filterKey === 'source') {
12762
+ setSourceFilter(function (state) {
12763
+ return updateState(state, optionKey, value, only);
12764
+ });
12765
+ } else if (filterKey === 'incident') {
12766
+ setIncidentFilter(function (state) {
12767
+ return updateState(state, optionKey, value, only);
12768
+ });
12760
12769
  }
12761
12770
  };
12762
12771
  var byFilterState = useCallback(function (warning) {
@@ -12770,14 +12779,28 @@ var useWarningFilters = function useWarningFilters(warnings) {
12770
12779
  if (!pickedLevelFilter[level]) {
12771
12780
  return false;
12772
12781
  }
12773
- var phenomenon = getValue(Phenomenon, warning.warningDetail.phenomenon);
12782
+ var phenomenon = getValue(Phenomenon$1, warning.warningDetail.phenomenon);
12774
12783
  if (!pickedPhenomenonFilter[phenomenon]) {
12775
12784
  return false;
12776
12785
  }
12786
+ var source = relevantSources.find(function (source) {
12787
+ return source === warning.warningDetail.warningProposalSource;
12788
+ }) || emptyFilterId;
12789
+ if (!pickedSourceFilter[source]) {
12790
+ return false;
12791
+ }
12792
+ var incident = relevantIncidents.find(function (incident) {
12793
+ return incident === warning.warningDetail.incident;
12794
+ }) || emptyFilterId;
12795
+ if (!pickedIncidentFilter[incident]) {
12796
+ return false;
12797
+ }
12777
12798
  return true;
12778
- }, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter]);
12799
+ }, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter, relevantSources, pickedSourceFilter, relevantIncidents, pickedIncidentFilter]);
12779
12800
  return {
12780
12801
  filterState: {
12802
+ incident: pickedIncidentFilter,
12803
+ source: pickedSourceFilter,
12781
12804
  domain: domainFilter,
12782
12805
  phenomenon: pickedPhenomenonFilter,
12783
12806
  level: pickedLevelFilter
@@ -12807,10 +12830,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12807
12830
  var _React$useState = React__default.useState(undefined),
12808
12831
  confirmDialogOptions = _React$useState[0],
12809
12832
  setConfirmDialogOptions = _React$useState[1];
12810
- var filters = useSelector(selectAllFilters);
12811
- var isAllChipSelected = useSelector(getIsAllSelected);
12812
- var publicWarnings = useSelector(getFilteredWarnings);
12813
- var warnings = useSelector(selectAllPublicWarnings);
12833
+ var publicWarnings = useSelector(selectAllPublicWarnings);
12814
12834
  var selectedPublicWarningId = useSelector(getSelectedPublicWarningId);
12815
12835
  var isLoading = useSelector(isPublicWarningsLoading || isFetchingAirmet || isFetchingSigmet);
12816
12836
  var error = useSelector(getPublicWarningsError);
@@ -12818,7 +12838,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12818
12838
  var lastUpdatedTime = useSelector(getPublicWarningsLastUpdatedTime);
12819
12839
  var warningsApi = getWarningsApi();
12820
12840
  var openPublicWarningDialog = /*#__PURE__*/function () {
12821
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formAction, publicWarning) {
12841
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formAction, publicWarning, warningType) {
12822
12842
  var mayProceed;
12823
12843
  return _regeneratorRuntime().wrap(function _callee$(_context) {
12824
12844
  while (1) switch (_context.prev = _context.next) {
@@ -12844,7 +12864,8 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12844
12864
  dispatch(publicWarningFormActions.openPublicWarningFormDialog(Object.assign({}, publicWarning && {
12845
12865
  publicWarning: publicWarning
12846
12866
  }, {
12847
- formState: formAction
12867
+ formState: formAction,
12868
+ warningType: warningType
12848
12869
  })));
12849
12870
  case 7:
12850
12871
  case "end":
@@ -12852,15 +12873,15 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12852
12873
  }
12853
12874
  }, _callee);
12854
12875
  }));
12855
- return function openPublicWarningDialog(_x, _x2) {
12876
+ return function openPublicWarningDialog(_x, _x2, _x3) {
12856
12877
  return _ref2.apply(this, arguments);
12857
12878
  };
12858
12879
  }();
12859
12880
  var selectWarning = function selectWarning(publicWarning) {
12860
12881
  void openPublicWarningDialog('readonly', publicWarning);
12861
12882
  };
12862
- var createWarning = function createWarning() {
12863
- void openPublicWarningDialog('');
12883
+ var createWarning = function createWarning(warningType) {
12884
+ void openPublicWarningDialog('', undefined, warningType);
12864
12885
  };
12865
12886
  var editWarning = /*#__PURE__*/function () {
12866
12887
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(publicWarning) {
@@ -12868,32 +12889,30 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12868
12889
  while (1) switch (_context2.prev = _context2.next) {
12869
12890
  case 0:
12870
12891
  if (!(publicWarning.id && auth != null && auth.username && !publicWarning.editor)) {
12871
- _context2.next = 7;
12892
+ _context2.next = 6;
12872
12893
  break;
12873
12894
  }
12874
- _context2.next = 3;
12875
- return dispatch(publicWarningFormActions.toggleEditorWarning({
12895
+ dispatch(publicWarningFormActions.toggleEditorWarning({
12876
12896
  warningId: publicWarning.id,
12877
12897
  isEditor: true,
12878
12898
  username: auth == null ? void 0 : auth.username
12879
12899
  }));
12880
- case 3:
12881
- _context2.next = 5;
12900
+ _context2.next = 4;
12882
12901
  return openPublicWarningDialog('', Object.assign({}, publicWarning, {
12883
12902
  editor: auth == null ? void 0 : auth.username
12884
12903
  }));
12885
- case 5:
12886
- _context2.next = 8;
12904
+ case 4:
12905
+ _context2.next = 7;
12887
12906
  break;
12888
- case 7:
12907
+ case 6:
12889
12908
  void openPublicWarningDialog('', publicWarning);
12890
- case 8:
12909
+ case 7:
12891
12910
  case "end":
12892
12911
  return _context2.stop();
12893
12912
  }
12894
12913
  }, _callee2);
12895
12914
  }));
12896
- return function editWarning(_x3) {
12915
+ return function editWarning(_x4) {
12897
12916
  return _ref3.apply(this, arguments);
12898
12917
  };
12899
12918
  }();
@@ -12923,7 +12942,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12923
12942
  }
12924
12943
  }, _callee3);
12925
12944
  }));
12926
- return function expireWarning(_x4) {
12945
+ return function expireWarning(_x5) {
12927
12946
  return _ref4.apply(this, arguments);
12928
12947
  };
12929
12948
  }();
@@ -12953,7 +12972,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
12953
12972
  }
12954
12973
  }, _callee4);
12955
12974
  }));
12956
- return function withdrawWarning(_x5) {
12975
+ return function withdrawWarning(_x6) {
12957
12976
  return _ref5.apply(this, arguments);
12958
12977
  };
12959
12978
  }();
@@ -13012,23 +13031,10 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13012
13031
  void refetchSigmetList();
13013
13032
  dispatch(publicWarningActions.fetchWarnings());
13014
13033
  }, [dispatch, refetchAirmetList, refetchSigmetList]);
13015
- var onClickAllChip = React__default.useCallback(function (isChecked) {
13016
- dispatch(publicWarningActions.toggleAllFilters({
13017
- isChecked: isChecked
13018
- }));
13019
- }, [dispatch]);
13020
13034
  React__default.useEffect(function () {
13021
13035
  // fetch warnings on mount
13022
13036
  fetchWarnings();
13023
13037
  }, [fetchWarnings]);
13024
- // update filters when warnings change
13025
- React__default.useEffect(function () {
13026
- // Generate new filters based on the provided warnings
13027
- var newFilters = getFiltersFromWarnings(t, warnings);
13028
- dispatch(publicWarningActions.setWarningListFilters({
13029
- newFilters: newFilters
13030
- }));
13031
- }, [dispatch, t, warnings]);
13032
13038
  var combinedWarnings = React__default.useMemo(function () {
13033
13039
  var transformedSigmets = (sigmetList == null ? void 0 : sigmetList.map(transformSigmetToWarningFormat)) || [];
13034
13040
  var transformedAirmets = (airmetList == null ? void 0 : airmetList.map(transformAirmetToWarningFormat)) || [];
@@ -13038,29 +13044,46 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13038
13044
  var filteredWarnings = React__default.useMemo(function () {
13039
13045
  return combinedWarnings.filter(filterHookState.byFilterState);
13040
13046
  }, [combinedWarnings, filterHookState.byFilterState]);
13047
+ var _React$useState2 = React__default.useState({
13048
+ TODO: true,
13049
+ DRAFT: true,
13050
+ PUBLISHED: true,
13051
+ EXPIRED: false
13052
+ }),
13053
+ expandedSections = _React$useState2[0],
13054
+ setExpandedSections = _React$useState2[1];
13055
+ var filteredWarningsByExpandedSections = React__default.useMemo(function () {
13056
+ return filteredWarnings.filter(function (warning) {
13057
+ return warning.status && expandedSections[warning.status] || warning.productStatus && expandedSections[warning.productStatus];
13058
+ });
13059
+ }, [filteredWarnings, expandedSections]);
13041
13060
  var allFeatures = React__default.useMemo(function () {
13042
- return filteredWarnings.reduce(function (acc, warning) {
13061
+ return filteredWarningsByExpandedSections.flatMap(function (warning) {
13043
13062
  var _warning$warningDetai;
13044
- var features = warning == null || (_warning$warningDetai = warning.warningDetail.areas) == null ? void 0 : _warning$warningDetai.map(function (a) {
13063
+ return (warning == null ? void 0 : warning.id) && (warning == null || (_warning$warningDetai = warning.warningDetail) == null || (_warning$warningDetai = _warning$warningDetai.areas) == null ? void 0 : _warning$warningDetai.filter(function (area) {
13064
+ return area.geoJSON;
13065
+ }).map(function (area) {
13066
+ var isAviationWarning = warning.warningDetail.level === 'SIG' || warning.warningDetail.level === 'AIR';
13067
+ var styledGeoJSON = warningLevelFeatureColors(warning.warningDetail.level, area.geoJSON, isAviationWarning);
13045
13068
  return {
13046
- id: warning.id + a.objectName,
13047
- geoJSON: a.geoJSON
13069
+ id: warning.id + area.areaId,
13070
+ originalId: warning.id,
13071
+ geoJSON: styledGeoJSON
13048
13072
  };
13049
- }).filter(function (a) {
13050
- return a.geoJSON;
13051
- });
13052
- if ((features == null ? void 0 : features.length) > 0) {
13053
- return [].concat(acc, features);
13054
- }
13055
- return acc;
13056
- }, []);
13057
- }, [filteredWarnings]);
13058
- useUpdateSharedData({
13059
- features: allFeatures
13060
- }, panelId);
13073
+ })) || [];
13074
+ }).filter(function (feature) {
13075
+ return feature.id;
13076
+ });
13077
+ }, [filteredWarningsByExpandedSections]);
13078
+ var _useUpdateSharedData = useUpdateSharedData({
13079
+ features: allFeatures
13080
+ }, panelId),
13081
+ hoveredFeatureId = _useUpdateSharedData.hoverId;
13061
13082
  return jsxs(Fragment, {
13062
13083
  children: [jsx(PublicWarningList, {
13063
13084
  warnings: filteredWarnings,
13085
+ expandedSections: expandedSections,
13086
+ setExpandedSections: setExpandedSections,
13064
13087
  isLoading: isLoading,
13065
13088
  error: error,
13066
13089
  onSelectWarning: selectWarning,
@@ -13073,10 +13096,8 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13073
13096
  selectedPublicWarningId: selectedPublicWarningId,
13074
13097
  lastUpdatedTime: lastUpdatedTime,
13075
13098
  onRefetchWarnings: fetchWarnings,
13076
- filters: filters,
13077
13099
  filterHookState: filterHookState,
13078
- isAllChipSelected: isAllChipSelected,
13079
- onClickAllChip: onClickAllChip
13100
+ hoveredFeatureId: hoveredFeatureId
13080
13101
  }), confirmDialogOptions && jsx(ConfirmDeleteWarningDialog, {
13081
13102
  onClose: function onClose() {
13082
13103
  return setConfirmDialogOptions(undefined);