@opengeoweb/taf 2.2.0 → 2.4.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 (95) hide show
  1. package/README.md +2 -2
  2. package/index.d.ts +1 -3
  3. package/index.esm.js +1661 -1359
  4. package/index.umd.js +1778 -1368
  5. package/lib/TafDemo.stories.d.ts +2 -2
  6. package/lib/components/IssuesPane/IssuesButton.d.ts +8 -2
  7. package/lib/components/IssuesPane/IssuesPane.d.ts +5 -0
  8. package/lib/components/IssuesPane/IssuesPane.stories.d.ts +12 -3
  9. package/lib/components/Spinner/Spinner.d.ts +2 -1
  10. package/lib/components/StatusIcon/StatusIcon.d.ts +8 -0
  11. package/lib/components/{ContentDialog/ContentDialog.spec.d.ts → StatusIcon/StatusIcon.spec.d.ts} +0 -0
  12. package/lib/components/TabPanel/TabPanel.d.ts +8 -0
  13. package/lib/components/{TafForm/TafFormDialog/TafFormDialog.spec.d.ts → TabPanel/TabPanel.spec.d.ts} +0 -0
  14. package/lib/components/TabPanel/index.d.ts +1 -0
  15. package/lib/components/TafForm/TafForm.d.ts +3 -20
  16. package/lib/components/TafForm/TafFormButtons/TafFormButtons.d.ts +5 -9
  17. package/lib/components/TafForm/TafFormButtons/TafFormOptionsButton.d.ts +11 -0
  18. package/lib/components/TafForm/{TafFormRow/change.spec.d.ts → TafFormButtons/TafFormOptionsButton.spec.d.ts} +0 -0
  19. package/lib/components/TafForm/TafFormRow/types.d.ts +3 -2
  20. package/lib/components/TafForm/TafFormRow/{change.d.ts → validations/change.d.ts} +0 -0
  21. package/lib/components/TafForm/TafFormRow/{clouds.spec.d.ts → validations/change.spec.d.ts} +0 -0
  22. package/lib/components/TafForm/TafFormRow/{clouds.d.ts → validations/clouds.d.ts} +1 -1
  23. package/lib/components/TafForm/TafFormRow/{probability.spec.d.ts → validations/clouds.spec.d.ts} +0 -0
  24. package/lib/components/TafForm/TafFormRow/{probability.d.ts → validations/probability.d.ts} +0 -0
  25. package/lib/components/TafForm/TafFormRow/{utils.spec.d.ts → validations/probability.spec.d.ts} +0 -0
  26. package/lib/components/TafForm/TafFormRow/{utils.d.ts → validations/utils.d.ts} +0 -0
  27. package/lib/components/{TafList → TafForm/TafFormRow/validations}/utils.spec.d.ts +0 -0
  28. package/lib/components/TafForm/TafFormRow/{validField.d.ts → validations/validField.d.ts} +1 -1
  29. package/lib/components/TafForm/TafFormRow/{validField.spec.d.ts → validations/validField.spec.d.ts} +0 -0
  30. package/lib/components/TafForm/TafFormRow/{visibility.d.ts → validations/visibility.d.ts} +1 -1
  31. package/lib/components/TafForm/TafFormRow/{visibility.spec.d.ts → validations/visibility.spec.d.ts} +0 -0
  32. package/lib/components/TafForm/TafFormRow/{weather.d.ts → validations/weather.d.ts} +1 -1
  33. package/lib/components/TafForm/TafFormRow/{weather.spec.d.ts → validations/weather.spec.d.ts} +0 -0
  34. package/lib/components/TafForm/TafFormRow/{wind.d.ts → validations/wind.d.ts} +1 -1
  35. package/lib/components/TafForm/TafFormRow/{wind.spec.d.ts → validations/wind.spec.d.ts} +0 -0
  36. package/lib/components/TafForm/TafFormWrapper.d.ts +3 -6
  37. package/lib/components/TafForm/TafFormWrapper.stories.d.ts +20 -0
  38. package/lib/components/TafForm/index.d.ts +0 -1
  39. package/lib/components/TafForm/utils.d.ts +25 -2
  40. package/lib/components/TafHeader/TafHeader.d.ts +6 -0
  41. package/lib/components/{TafList/TafList.spec.d.ts → TafHeader/TafHeader.spec.d.ts} +0 -0
  42. package/lib/components/TafLayout/LocationTabs/LocationTabs.d.ts +10 -0
  43. package/lib/components/{TafList/TafListAccordion.spec.d.ts → TafLayout/LocationTabs/LocationTabs.spec.d.ts} +0 -0
  44. package/lib/components/TafLayout/LocationTabs/LocationTabs.stories.d.ts +13 -0
  45. package/lib/components/TafLayout/LocationTabs/index.d.ts +1 -0
  46. package/lib/components/TafLayout/TacOverview/TacContainer.d.ts +8 -0
  47. package/lib/components/{TafList/TafListButtons.spec.d.ts → TafLayout/TacOverview/TacContainer.spec.d.ts} +0 -0
  48. package/lib/components/TafLayout/TacOverview/TacOverview.d.ts +11 -0
  49. package/lib/components/{TafList/TafListRow.spec.d.ts → TafLayout/TacOverview/TacOverview.spec.d.ts} +0 -0
  50. package/lib/components/TafLayout/TacOverview/TacOverview.stories.d.ts +15 -0
  51. package/lib/components/TafLayout/TacOverview/TacOverviewMobile.d.ts +11 -0
  52. package/lib/components/{TafList/TafListSection.spec.d.ts → TafLayout/TacOverview/TacOverviewMobile.spec.d.ts} +0 -0
  53. package/lib/components/TafLayout/TacOverview/TacOverviewMobile.stories.d.ts +23 -0
  54. package/lib/components/TafLayout/TacOverview/index.d.ts +2 -0
  55. package/lib/components/TafLayout/TafLayout.d.ts +8 -0
  56. package/lib/components/{TafWrapper/TafWrapper.spec.d.ts → TafLayout/TafLayout.spec.d.ts} +0 -0
  57. package/lib/components/TafLayout/TafLayout.stories.d.ts +7 -0
  58. package/lib/components/TafLayout/TafPanel/TafPanel.d.ts +10 -0
  59. package/lib/components/TafLayout/TafPanel/TafPanel.spec.d.ts +1 -0
  60. package/lib/components/TafLayout/TafPanel/index.d.ts +1 -0
  61. package/lib/components/TafLayout/TopTabs/TopTabs.d.ts +11 -0
  62. package/lib/components/TafLayout/TopTabs/TopTabs.spec.d.ts +1 -0
  63. package/lib/components/TafLayout/TopTabs/TopTabs.stories.d.ts +13 -0
  64. package/lib/components/TafLayout/TopTabs/index.d.ts +1 -0
  65. package/lib/components/TafLayout/utils.d.ts +18 -0
  66. package/lib/components/TafLayout/utils.spec.d.ts +1 -0
  67. package/lib/components/TafModule/TafModule.d.ts +3 -0
  68. package/lib/components/TafModule/TafModule.spec.d.ts +1 -0
  69. package/lib/components/TafModule/TafModule.stories.d.ts +9 -0
  70. package/lib/components/TafModule/index.d.ts +1 -0
  71. package/lib/types.d.ts +17 -1
  72. package/lib/utils/__mocks__/api.d.ts +1 -0
  73. package/lib/utils/fakeApi.d.ts +1 -1
  74. package/lib/utils/mockdata/fakeTafList.d.ts +1 -0
  75. package/lib/utils/testUtils.d.ts +4 -5
  76. package/package.json +7 -6
  77. package/lib/components/ContentDialog/ContentDialog.d.ts +0 -14
  78. package/lib/components/ContentDialog/ContentDialog.stories.d.ts +0 -7
  79. package/lib/components/ContentDialog/index.d.ts +0 -1
  80. package/lib/components/IssuesPane/IssuesPane.styles.d.ts +0 -1
  81. package/lib/components/TafForm/TafForm.styles.d.ts +0 -1
  82. package/lib/components/TafForm/TafFormDialog/TafFormDialog.d.ts +0 -12
  83. package/lib/components/TafForm/TafFormDialog/TafFormDialog.stories.d.ts +0 -9
  84. package/lib/components/TafList/TafList.d.ts +0 -11
  85. package/lib/components/TafList/TafList.stories.d.ts +0 -8
  86. package/lib/components/TafList/TafListAccordion.d.ts +0 -11
  87. package/lib/components/TafList/TafListButtons.d.ts +0 -9
  88. package/lib/components/TafList/TafListRow.d.ts +0 -12
  89. package/lib/components/TafList/TafListSection.d.ts +0 -12
  90. package/lib/components/TafList/TafListSection.stories.d.ts +0 -18
  91. package/lib/components/TafList/index.d.ts +0 -3
  92. package/lib/components/TafList/utils.d.ts +0 -4
  93. package/lib/components/TafWrapper/TafWrapper.d.ts +0 -13
  94. package/lib/components/TafWrapper/index.d.ts +0 -1
  95. package/lib/utils/utils.d.ts +0 -3
package/index.esm.js CHANGED
@@ -1,14 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { Grid, TextField, IconButton, Tooltip, Chip, SvgIcon, Typography, Button, Dialog, DialogTitle, DialogContent, Card, Accordion, AccordionSummary, AccordionDetails, Skeleton, Backdrop, CircularProgress } from '@mui/material';
4
- import makeStyles from '@mui/styles/makeStyles';
5
- import moment from 'moment';
6
- import { useIsMounted, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
7
- import { Add, Delete, DragIndicator, Close, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@mui/icons-material';
8
- import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
9
3
  import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
4
+ import { TextField, SvgIcon, Grid, Box, Button, IconButton, Typography, Tooltip, Chip, useTheme, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
10
5
  import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
11
6
  import { ReactSortable, Sortable } from 'react-sortablejs';
7
+ import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
8
+ import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, AlertBanner, getAxiosErrorMessage, ConfirmationServiceProvider, usePoller } from '@opengeoweb/shared';
9
+ import moment from 'moment';
10
+ import { isEqual } from 'lodash';
11
+ import makeStyles from '@mui/styles/makeStyles';
12
+ import { DragIndicator, Schedule, CheckCircle } from '@mui/icons-material';
13
+ import ReactDOM from 'react-dom';
14
+ import LinearProgress from '@mui/material/LinearProgress';
15
+ import DoDisturbIcon from '@mui/icons-material/DoDisturb';
16
+ import Box$1 from '@mui/material/Box';
12
17
 
13
18
  function _typeof(obj) {
14
19
  "@babel/helpers - typeof";
@@ -117,119 +122,6 @@ function _nonIterableRest() {
117
122
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
118
123
  }
119
124
 
120
- function _createForOfIteratorHelper(o, allowArrayLike) {
121
- var it;
122
-
123
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
124
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
125
- if (it) o = it;
126
- var i = 0;
127
-
128
- var F = function () {};
129
-
130
- return {
131
- s: F,
132
- n: function () {
133
- if (i >= o.length) return {
134
- done: true
135
- };
136
- return {
137
- done: false,
138
- value: o[i++]
139
- };
140
- },
141
- e: function (e) {
142
- throw e;
143
- },
144
- f: F
145
- };
146
- }
147
-
148
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
149
- }
150
-
151
- var normalCompletion = true,
152
- didErr = false,
153
- err;
154
- return {
155
- s: function () {
156
- it = o[Symbol.iterator]();
157
- },
158
- n: function () {
159
- var step = it.next();
160
- normalCompletion = step.done;
161
- return step;
162
- },
163
- e: function (e) {
164
- didErr = true;
165
- err = e;
166
- },
167
- f: function () {
168
- try {
169
- if (!normalCompletion && it.return != null) it.return();
170
- } finally {
171
- if (didErr) throw err;
172
- }
173
- }
174
- };
175
- }
176
-
177
- /* *
178
- * Licensed under the Apache License, Version 2.0 (the "License");
179
- * you may not use this file except in compliance with the License.
180
- * You may obtain a copy of the License at
181
- *
182
- * http://www.apache.org/licenses/LICENSE-2.0
183
- *
184
- * Unless required by applicable law or agreed to in writing, software
185
- * distributed under the License is distributed on an "AS IS" BASIS,
186
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187
- * See the License for the specific language governing permissions and
188
- * limitations under the License.
189
- *
190
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
191
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
192
- * */
193
- var useTafSettings = function useTafSettings( // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
194
- tafConfig) {
195
- var locations = tafConfig.locations;
196
- return {
197
- locations: locations
198
- };
199
- };
200
-
201
- var location_indicator_mwo = "EHDB";
202
- var locations = {
203
- EHAM: {
204
- validity_duration: 30,
205
- activity_period: 6
206
- },
207
- EHRD: {
208
- validity_duration: 30,
209
- activity_period: 6
210
- },
211
- EHGG: {
212
- validity_duration: 30,
213
- activity_period: 6
214
- },
215
- EHBK: {
216
- validity_duration: 30,
217
- activity_period: 6
218
- },
219
- EHLE: {
220
- validity_duration: 30,
221
- activity_period: 6
222
- },
223
- TNCB: {
224
- validity_duration: 30,
225
- activity_period: 6
226
- }
227
- };
228
- var tafConfig = {
229
- location_indicator_mwo: location_indicator_mwo,
230
- locations: locations
231
- };
232
-
233
125
  /*! *****************************************************************************
234
126
  Copyright (c) Microsoft Corporation.
235
127
 
@@ -2500,11 +2392,26 @@ var getConfirmationDialogTitle = function getConfirmationDialogTitle(action) {
2500
2392
  if (action === 'PUBLISH') return 'Publish';
2501
2393
  if (action === 'AMEND') return 'This TAF is an amendment';
2502
2394
  if (action === 'CORRECT') return 'This TAF is a correction';
2395
+ if (action === 'CANCEL') return 'Cancel TAF';
2503
2396
  return 'Cancel TAF';
2504
- };
2505
- var getConfirmationDialogContent = function getConfirmationDialogContent(action) {
2506
- var isFormDirty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2397
+ }; // Check if the amended/corrected TAF has been changed. Only compare the fields users are able to fill in
2398
+ // (i.e. exclude baseforecast valid time as that gets updated when doing an amendment automatically outside of the users influence)
2399
+
2400
+ var isTafAmendedCorrectedChanged = function isTafAmendedCorrectedChanged(isFormDirty, originalTaf, currentTaf) {
2401
+ var originalBaseF = originalTaf.baseForecast,
2402
+ originalChG = originalTaf.changeGroups;
2403
+ var currentBaseF = currentTaf.baseForecast,
2404
+ currentChG = currentTaf.changeGroups;
2507
2405
 
2406
+ originalBaseF.valid;
2407
+ var originalNoValid = __rest(originalBaseF, ["valid"]);
2408
+
2409
+ currentBaseF.valid;
2410
+ var currentNoValid = __rest(currentBaseF, ["valid"]);
2411
+
2412
+ return isFormDirty && (!isEqual(originalNoValid, currentNoValid) || !isEqual(originalChG, currentChG));
2413
+ };
2414
+ var getConfirmationDialogContent = function getConfirmationDialogContent(action, isFormDirty) {
2508
2415
  switch (action) {
2509
2416
  case 'DISCARD':
2510
2417
  return 'Are you sure you would like to discard this TAF? Any changes made will be lost';
@@ -2514,7 +2421,7 @@ var getConfirmationDialogContent = function getConfirmationDialogContent(action)
2514
2421
 
2515
2422
  case 'AMEND':
2516
2423
  case 'CORRECT':
2517
- return isFormDirty ? 'Do you want to publish it?' : 'Are you sure you want to publish the TAF? You did not make any changes!';
2424
+ return isFormDirty() ? 'Do you want to publish it?' : 'Are you sure you want to publish the TAF? You did not make any changes!';
2518
2425
 
2519
2426
  default:
2520
2427
  return 'Are you sure you want to cancel this TAF?';
@@ -2527,89 +2434,147 @@ var getConfirmationDialogButtonLabel = function getConfirmationDialogButtonLabel
2527
2434
  return 'Discard';
2528
2435
  }
2529
2436
 
2437
+ case 'CANCEL':
2438
+ return 'Cancel';
2439
+
2530
2440
  default:
2531
2441
  {
2532
2442
  return 'Publish';
2533
2443
  }
2534
2444
  }
2535
2445
  };
2446
+ var emptyChangegroup = {
2447
+ valid: '',
2448
+ wind: '',
2449
+ visibility: '',
2450
+ weather: {
2451
+ weather1: null,
2452
+ weather2: null,
2453
+ weather3: null
2454
+ },
2455
+ cloud: {
2456
+ cloud1: null,
2457
+ cloud2: null,
2458
+ cloud3: null,
2459
+ cloud4: null
2460
+ },
2461
+ change: null,
2462
+ probability: null
2463
+ };
2464
+ var getTafStatusLabel = function getTafStatusLabel(status) {
2465
+ switch (status) {
2466
+ case 'DRAFT_AMENDED':
2467
+ return 'draft amended';
2468
+
2469
+ case 'DRAFT_CORRECTED':
2470
+ return 'draft corrected';
2471
+
2472
+ default:
2473
+ return status.toLocaleLowerCase();
2474
+ }
2475
+ };
2476
+ var getMessageType = function getMessageType(taf, tafAction) {
2477
+ if (tafAction === 'CORRECT') {
2478
+ return 'COR';
2479
+ }
2480
+
2481
+ if (tafAction === 'AMEND') {
2482
+ return 'AMD';
2483
+ }
2484
+
2485
+ return taf.messageType;
2486
+ }; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
2487
+
2488
+ var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafAction) {
2489
+ var previousValidDateStart = taf.previousValidDateStart && tafAction !== 'AMEND' ? taf.previousValidDateStart : taf.validDateStart;
2490
+ var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== 'AMEND' ? taf.previousValidDateEnd : taf.validDateEnd; // For amendment change valid start time to current time
2491
+ // only do this if we're already within the validity period
2492
+
2493
+ if ((tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND') && moment.utc() >= moment.utc(taf.validDateStart)) {
2494
+ var now = moment.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
2495
+ var validObj = {
2496
+ start: now,
2497
+ end: taf.baseForecast.valid.end
2498
+ };
2499
+ return Object.assign(Object.assign({}, taf), {
2500
+ previousValidDateStart: previousValidDateStart,
2501
+ previousValidDateEnd: previousValidDateEnd,
2502
+ validDateStart: now,
2503
+ baseForecast: Object.assign(Object.assign({}, taf.baseForecast), {
2504
+ valid: validObj
2505
+ })
2506
+ });
2507
+ }
2508
+
2509
+ return Object.assign(Object.assign({}, taf), {
2510
+ previousValidDateStart: previousValidDateStart,
2511
+ previousValidDateEnd: previousValidDateEnd
2512
+ });
2513
+ };
2514
+ var prepareTafValues = function prepareTafValues(_taf, tafAction) {
2515
+ var addEmptyChangeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2516
+ // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
2517
+ // If action is AMEND/DRAFT_AMEND - update validity start time to current time
2518
+ var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
2519
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
2520
+ messageType: getMessageType(taf, tafAction),
2521
+ baseForecast: formatFormValues(taf.baseForecast)
2522
+ }), taf.changeGroups && {
2523
+ changeGroups: taf.changeGroups.map(formatFormValues)
2524
+ }), addEmptyChangeGroup && {
2525
+ changeGroups: [emptyChangegroup]
2526
+ });
2527
+ };
2536
2528
 
2537
- var useStyles$9 = makeStyles(function (theme) {
2529
+ var textFieldStyle = function textFieldStyle(theme) {
2538
2530
  return {
2539
- textFieldGridItem: {
2540
- marginRight: 4
2541
- },
2542
- textFieldRoot: {
2543
- '&.Mui-disabled::before': {
2544
- borderBottom: 'none'
2531
+ // input
2532
+ marginRight: '2px',
2533
+ marginBottom: '4px',
2534
+ width: 56,
2535
+ height: 46,
2536
+ input: {
2537
+ textAlign: 'center',
2538
+ fontSize: 10,
2539
+ fontWeight: 500,
2540
+ paddingLeft: 0,
2541
+ paddingRight: 0,
2542
+ '&.Mui-disabled': {
2543
+ color: 'geowebColors.typographyAndIcons.text',
2544
+ WebkitTextFillColor: theme.palette.geowebColors.typographyAndIcons.text
2545
2545
  },
2546
- '&:after': {
2547
- borderBottomColor: '#3f51b5'
2546
+ // TODO: https://gitlab.com/opengeoweb/opengeoweb/-/issues/1995 disables the default autofill styling, should be a better fix
2547
+ '&:-webkit-autofill': {
2548
+ WebkitTransitionDelay: '86400s' // 1 day delay
2549
+
2548
2550
  }
2549
2551
  },
2550
- textFieldInput: {
2551
- fontSize: '14px',
2552
- paddingLeft: 1,
2553
- paddingRight: 1,
2554
- color: '#051039',
2555
- WebkitTextFillColor: '#051039',
2552
+ label: {
2553
+ transformOrigin: 'center top',
2554
+ right: 0,
2555
+ textAlign: 'center',
2556
+ fontSize: '10px',
2556
2557
  '&.Mui-disabled': {
2557
- backgroundColor: 'white'
2558
- }
2559
- },
2560
- textFieldLabel: {
2561
- fontSize: '14px'
2562
- },
2563
- textFieldLabelShrink: {
2564
- transform: 'translate(2px, 10px) scale(0.75) !important'
2565
- },
2566
- formRow: {
2567
- marginTop: 8,
2568
- backgroundColor: theme.palette.common.white,
2569
- position: 'relative',
2570
- '&.sortable-chosen': {
2571
- boxShadow: theme.shadows[1]
2558
+ color: 'geowebColors.captions.captionStatus.rgba'
2572
2559
  },
2573
- '&.sortable-ghost': {
2574
- opacity: 0.5
2575
- }
2576
- },
2577
- tacTitle: {
2578
- fontSize: '20px',
2579
- fontWeight: 500
2580
- },
2581
- tacText: {
2582
- fontSize: '14px',
2583
- color: '#000000'
2560
+ whiteSpace: 'nowrap',
2561
+ maxWidth: '100%',
2562
+ transform: 'translate(0px, 16px) scale(1)'
2584
2563
  },
2585
- tacLine: {
2586
- margin: '0',
2587
- padding: '.1em .1em .1em 0.8em',
2588
- textIndent: '-0.7em',
2589
- borderRadius: '3px'
2564
+ // shrink
2565
+ ' .MuiInputLabel-shrink': {
2566
+ transform: 'translate(2px, 10px) scale(0.75) !important',
2567
+ letterSpacing: '0.33px',
2568
+ textAlign: 'left'
2590
2569
  },
2591
- addButton: {
2592
- marginRight: '48px'
2593
- },
2594
- lifecycleButtons: {
2595
- marginTop: '40px',
2596
- marginBottom: '16px'
2597
- },
2598
- actionButton: {
2599
- marginRight: '16px'
2600
- },
2601
- lastButton: {
2602
- marginRight: '90px'
2603
- },
2604
- backdrop: {
2605
- zIndex: 1500,
2606
- color: '#fff'
2607
- },
2608
- emptyButtonContainer: {
2609
- minWidth: 96
2570
+ // root
2571
+ '&': {
2572
+ '.Mui-disabled:before': {
2573
+ borderColor: 'transparent'
2574
+ }
2610
2575
  }
2611
2576
  };
2612
- });
2577
+ };
2613
2578
 
2614
2579
  var getTafErrors = function getTafErrors(name, errors) {
2615
2580
  var nameAsArray = name.split('.');
@@ -2632,25 +2597,13 @@ var getDisplayValue = function getDisplayValue(value, disabled) {
2632
2597
  return disabled && !value ? '-' : value;
2633
2598
  };
2634
2599
  var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
2635
- var classes = useStyles$9();
2636
2600
  return /*#__PURE__*/React__default.createElement(TextField, Object.assign({
2637
2601
  type: "text",
2638
2602
  variant: "filled",
2639
- InputProps: {
2640
- classes: {
2641
- input: classes.textFieldInput,
2642
- root: classes.textFieldRoot
2643
- }
2644
- },
2645
- InputLabelProps: {
2646
- classes: {
2647
- root: classes.textFieldLabel,
2648
- shrink: classes.textFieldLabelShrink
2649
- }
2650
- }
2603
+ sx: textFieldStyle
2651
2604
  }, props));
2652
2605
  }, function (prevProps, nextProps) {
2653
- return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name;
2606
+ return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name && prevProps.disabled === nextProps.disabled;
2654
2607
  });
2655
2608
 
2656
2609
  var TafFormTextField = function TafFormTextField(_ref) {
@@ -2672,7 +2625,6 @@ var TafFormTextField = function TafFormTextField(_ref) {
2672
2625
  autoComplete = _ref$autoComplete === void 0 ? [] : _ref$autoComplete,
2673
2626
  _ref$autoFocus = _ref.autoFocus,
2674
2627
  autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus;
2675
- var classes = useStyles$9();
2676
2628
 
2677
2629
  var _useFormContext = useFormContext(),
2678
2630
  control = _useFormContext.control,
@@ -2729,11 +2681,7 @@ var TafFormTextField = function TafFormTextField(_ref) {
2729
2681
  inputRef.current.disabled = false;
2730
2682
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
2731
2683
  }, []);
2732
- return /*#__PURE__*/React__default.createElement(Grid, {
2733
- item: true,
2734
- xs: true,
2735
- className: classes.textFieldGridItem
2736
- }, /*#__PURE__*/React__default.createElement(Controller, {
2684
+ return /*#__PURE__*/React__default.createElement(Controller, {
2737
2685
  render: function render(_props) {
2738
2686
  var displayValue = formatter ? formatter(_props.value) : getDisplayValue(_props.value, disabled);
2739
2687
  return /*#__PURE__*/React__default.createElement(BaseTextField, {
@@ -2761,7 +2709,7 @@ var TafFormTextField = function TafFormTextField(_ref) {
2761
2709
  defaultValue: defaultValue,
2762
2710
  rules: rules,
2763
2711
  onFocus: onFocusField
2764
- }));
2712
+ });
2765
2713
  };
2766
2714
 
2767
2715
  /* *
@@ -2825,6 +2773,71 @@ var validateProbabilityField = function validateProbabilityField(value) {
2825
2773
  return isValid ? true : invalidProbabilityMessage;
2826
2774
  };
2827
2775
 
2776
+ /* *
2777
+ * Licensed under the Apache License, Version 2.0 (the "License");
2778
+ * you may not use this file except in compliance with the License.
2779
+ * You may obtain a copy of the License at
2780
+ *
2781
+ * http://www.apache.org/licenses/LICENSE-2.0
2782
+ *
2783
+ * Unless required by applicable law or agreed to in writing, software
2784
+ * distributed under the License is distributed on an "AS IS" BASIS,
2785
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2786
+ * See the License for the specific language governing permissions and
2787
+ * limitations under the License.
2788
+ *
2789
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2790
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
2791
+ * */
2792
+ var AddIcon = /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
2793
+ d: "M10.647 10.647h6.82a1.276 1.276 0 1 0 0-2.552h-6.82v-6.82a1.276 1.276 0 1 0-2.552 0v6.82h-6.82a1.276 1.276 0 1 0 0 2.552h6.82v6.82a1.274 1.274 0 0 0 1.276 1.275c.705 0 1.276-.571 1.276-1.276v-6.82z"
2794
+ }));
2795
+ var DeleteIcon = /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
2796
+ d: "M17.504 8.228c.588 0 1.027.48.973 1.066l-.876 9.64A1.197 1.197 0 0 1 16.434 20H8.41c-.59 0-1.115-.48-1.167-1.066l-.877-9.64a.962.962 0 0 1 .973-1.066zm-2.115 1.228a.82.82 0 0 0-.819.82v7.674a.818.818 0 0 0 1.638 0v-7.675a.819.819 0 0 0-.819-.819zm-2.968 0a.819.819 0 0 0-.819.82v7.674a.818.818 0 1 0 1.638 0v-7.675a.82.82 0 0 0-.82-.819zm-2.968 0a.819.819 0 0 0-.818.82v7.674a.818.818 0 1 0 1.637 0v-7.675a.82.82 0 0 0-.82-.819zM13.432 4c.21 0 .404.168.436.376l.107.758 3.256-.01a1.606 1.606 0 0 1 1.61 1.6l.001.535-12.841.038L6 6.76a1.605 1.605 0 0 1 1.6-1.61l3.262-.008.103-.758a.454.454 0 0 1 .434-.38z"
2797
+ }));
2798
+ var CrossIcon = /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
2799
+ d: "m13.805 12 4.821-4.822a1.276 1.276 0 1 0-1.804-1.804L12 10.195 7.178 5.374a1.276 1.276 0 1 0-1.804 1.804L10.196 12l-4.822 4.822a1.276 1.276 0 1 0 1.804 1.805L12 13.805l4.822 4.822a1.274 1.274 0 0 0 1.804 0c.499-.5.499-1.306 0-1.805L13.805 12z"
2800
+ }));
2801
+
2802
+ var TafFormOptionsButton = function TafFormOptionsButton(_ref) {
2803
+ var isChangeGroup = _ref.isChangeGroup,
2804
+ addChangeGroupBelow = _ref.addChangeGroupBelow,
2805
+ addChangeGroupAbove = _ref.addChangeGroupAbove,
2806
+ removeChangeGroup = _ref.removeChangeGroup,
2807
+ clearRow = _ref.clearRow,
2808
+ index = _ref.index;
2809
+ var insertAbove = {
2810
+ text: 'Insert 1 row above',
2811
+ icon: AddIcon,
2812
+ action: addChangeGroupAbove
2813
+ };
2814
+ var insertBelow = {
2815
+ text: 'Insert 1 row below',
2816
+ icon: AddIcon,
2817
+ action: addChangeGroupBelow
2818
+ };
2819
+ var deleteRow = {
2820
+ text: 'Delete row',
2821
+ icon: DeleteIcon,
2822
+ action: removeChangeGroup
2823
+ };
2824
+ var clear = {
2825
+ text: 'Clear row',
2826
+ icon: CrossIcon,
2827
+ action: clearRow
2828
+ };
2829
+ var menuItemsBaseForecast = [insertBelow, clear];
2830
+ var menuItemsChangeGroup = [insertAbove, insertBelow, deleteRow, clear];
2831
+ return /*#__PURE__*/React.createElement(ToggleMenu, {
2832
+ buttonTestId: "tafFormOptions[".concat(index, "]"),
2833
+ buttonSx: {
2834
+ marginTop: '10px',
2835
+ marginLeft: '4px'
2836
+ },
2837
+ menuItems: isChangeGroup ? menuItemsChangeGroup : menuItemsBaseForecast
2838
+ });
2839
+ };
2840
+
2828
2841
  var getDefaultValue = function getDefaultValue(fieldName, data) {
2829
2842
  if (!data) {
2830
2843
  return '';
@@ -2845,17 +2858,16 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
2845
2858
  disabled = _a$disabled === void 0 ? false : _a$disabled,
2846
2859
  _a$index = _a.index,
2847
2860
  index = _a$index === void 0 ? -1 : _a$index,
2848
- _a$lastRow = _a.lastRow,
2849
- lastRow = _a$lastRow === void 0 ? false : _a$lastRow,
2850
2861
  onRemoveChangeGroup = _a.onRemoveChangeGroup,
2851
2862
  _a$field = _a.field,
2852
2863
  field = _a$field === void 0 ? null : _a$field,
2853
2864
  _a$dragHandle = _a.dragHandle,
2854
2865
  dragHandle = _a$dragHandle === void 0 ? null : _a$dragHandle,
2855
- onAddChangeGroup = _a.onAddChangeGroup,
2856
- props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "dragHandle", "onAddChangeGroup"]);
2866
+ onAddChangeGroupBelow = _a.onAddChangeGroupBelow,
2867
+ onAddChangeGroupAbove = _a.onAddChangeGroupAbove,
2868
+ onClearRow = _a.onClearRow,
2869
+ props = __rest(_a, ["isChangeGroup", "disabled", "index", "onRemoveChangeGroup", "field", "dragHandle", "onAddChangeGroupBelow", "onAddChangeGroupAbove", "onClearRow"]);
2857
2870
 
2858
- var classes = useStyles$9();
2859
2871
  var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[".concat(index, "]");
2860
2872
  var fieldNames = getFieldNames(isChangeGroup, index);
2861
2873
 
@@ -2971,14 +2983,39 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
2971
2983
  return validFields;
2972
2984
  };
2973
2985
 
2974
- var addChangeGroup = React__default.useCallback(function () {
2975
- onAddChangeGroup(index);
2976
- }, [onAddChangeGroup, index]);
2986
+ var addChangeGroupBelow = React__default.useCallback(function () {
2987
+ onAddChangeGroupBelow(index);
2988
+ }, [onAddChangeGroupBelow, index]);
2989
+ var addChangeGroupAbove = React__default.useCallback(function () {
2990
+ onAddChangeGroupAbove(index);
2991
+ }, [onAddChangeGroupAbove, index]);
2992
+ var clearRow = React__default.useCallback(function () {
2993
+ onClearRow(index);
2994
+ }, [onClearRow, index]);
2977
2995
  return /*#__PURE__*/React__default.createElement(Grid, Object.assign({
2996
+ sx: {
2997
+ marginTop: '8px',
2998
+ backgroundColor: 'geowebColors.cards.cardContainer',
2999
+ position: 'relative',
3000
+ '&.sortable-chosen': {
3001
+ boxShadow: 1
3002
+ },
3003
+ '&.sortable-ghost': {
3004
+ opacity: 0.5
3005
+ }
3006
+ },
3007
+ justifyContent: "flex-start",
2978
3008
  "data-testid": "row-".concat(namePrefix),
2979
3009
  container: true,
2980
- ref: ref
2981
- }, props), !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
3010
+ ref: ref,
3011
+ columns: 24
3012
+ }, props), /*#__PURE__*/React__default.createElement(Grid, {
3013
+ item: true,
3014
+ container: true,
3015
+ justifyContent: "flex-end",
3016
+ xs: 24,
3017
+ sm: 23
3018
+ }, !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
2982
3019
  label: "Type",
2983
3020
  name: fieldNames.messageType,
2984
3021
  disabled: true
@@ -2991,13 +3028,12 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
2991
3028
  label: "Issue time",
2992
3029
  name: "issueDate",
2993
3030
  disabled: true
2994
- })), isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
2995
- item: true,
2996
- xs: true,
2997
- style: {
2998
- display: 'flex'
3031
+ })), isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
3032
+ sx: {
3033
+ width: 56,
3034
+ marginRight: '2px'
2999
3035
  }
3000
- }, dragHandle), /*#__PURE__*/React__default.createElement(TafFormTextField, {
3036
+ }, !disabled && dragHandle), /*#__PURE__*/React__default.createElement(TafFormTextField, {
3001
3037
  label: "Prob",
3002
3038
  name: fieldNames.probability,
3003
3039
  disabled: disabled,
@@ -3235,33 +3271,26 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
3235
3271
  }
3236
3272
  }
3237
3273
  }
3238
- }), (!isChangeGroup || disabled) && /*#__PURE__*/React__default.createElement(Grid, {
3239
- className: classes.emptyButtonContainer,
3274
+ })), !disabled && /*#__PURE__*/React__default.createElement(Grid, {
3240
3275
  item: true,
3241
- xs: true
3242
- }, !disabled && /*#__PURE__*/React__default.createElement(IconButton, {
3243
- "aria-label": "add",
3244
- "data-testid": "add-changeGroup",
3245
- onClick: addChangeGroup,
3246
- size: "large"
3247
- }, /*#__PURE__*/React__default.createElement(Add, null))), isChangeGroup && !disabled && /*#__PURE__*/React__default.createElement(Grid, {
3248
- item: true
3249
- }, /*#__PURE__*/React__default.createElement(IconButton, {
3250
- "aria-label": "add",
3251
- "data-testid": "add-changeGroup",
3252
- onClick: addChangeGroup,
3253
- size: "large"
3254
- }, /*#__PURE__*/React__default.createElement(Add, null)), /*#__PURE__*/React__default.createElement(IconButton, Object.assign({
3255
- "aria-label": "delete",
3256
- "data-testid": "remove-changeGroup",
3257
- onClick: function onClick() {
3258
- return onRemoveChangeGroup(index);
3276
+ container: true,
3277
+ justifyContent: "flex-end",
3278
+ alignItems: "flex-end",
3279
+ xs: 24,
3280
+ sm: 1,
3281
+ sx: {
3282
+ marginBottom: '16px'
3259
3283
  }
3260
- }, lastRow ? {
3261
- tabIndex: -1
3262
- } : {}, {
3263
- size: "large"
3264
- }), /*#__PURE__*/React__default.createElement(Delete, null))));
3284
+ }, /*#__PURE__*/React__default.createElement(TafFormOptionsButton, {
3285
+ isChangeGroup: isChangeGroup,
3286
+ addChangeGroupBelow: addChangeGroupBelow,
3287
+ addChangeGroupAbove: addChangeGroupAbove,
3288
+ removeChangeGroup: function removeChangeGroup() {
3289
+ return onRemoveChangeGroup(index);
3290
+ },
3291
+ clearRow: clearRow,
3292
+ index: index
3293
+ })));
3265
3294
  });
3266
3295
 
3267
3296
  /* *
@@ -3280,55 +3309,184 @@ var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
3280
3309
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3281
3310
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
3282
3311
  * */
3283
-
3284
- var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3285
- switch (sumOfErrors) {
3286
- case 0:
3287
- return '0 issues';
3288
-
3289
- case 1:
3290
- return '1 issue';
3291
-
3292
- default:
3293
- return "".concat(sumOfErrors, " issues");
3312
+ var buttonsStyle = {
3313
+ button: {
3314
+ minWidth: {
3315
+ xs: '56px',
3316
+ sm: '64px'
3317
+ },
3318
+ width: {
3319
+ xs: '56px',
3320
+ sm: '64px'
3321
+ },
3322
+ marginLeft: {
3323
+ xs: 0.5,
3324
+ sm: 1
3325
+ },
3326
+ marginTop: 3,
3327
+ marginBottom: 3
3294
3328
  }
3295
3329
  };
3296
3330
 
3297
- var buttonColors = {
3298
- green: '#72bb23',
3299
- red: '#c00000'
3300
- };
3301
-
3302
- var buttonStyle = function buttonStyle(color) {
3303
- var buttonColor = buttonColors[color];
3304
- return {
3305
- width: '74px',
3306
- color: '#ffffff',
3307
- backgroundColor: buttonColor,
3308
- '&:hover': {
3309
- backgroundColor: buttonColor
3310
- },
3311
- '&:focus': {
3312
- backgroundColor: buttonColor
3331
+ var ViewModeButtons = function ViewModeButtons(_ref) {
3332
+ var canBe = _ref.canBe,
3333
+ onTafViewModeButtonPress = _ref.onTafViewModeButtonPress;
3334
+ return !canBe.includes('CANCELLED') && !canBe.includes('CORRECTED') && !canBe.includes('AMENDED') ? null : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, canBe.includes('CANCELLED') && /*#__PURE__*/React__default.createElement(Button, {
3335
+ "data-testid": "canceltaf",
3336
+ variant: "tertiary",
3337
+ onClick: function onClick() {
3338
+ return onTafViewModeButtonPress('CANCEL');
3313
3339
  }
3314
- };
3315
- };
3340
+ }, "Cancel"), canBe.includes('CORRECTED') && /*#__PURE__*/React__default.createElement(Button, {
3341
+ "data-testid": "correctaf",
3342
+ variant: "tertiary",
3343
+ onClick: function onClick() {
3344
+ return onTafViewModeButtonPress('CORRECT');
3345
+ }
3346
+ }, "Correct"), canBe.includes('AMENDED') && /*#__PURE__*/React__default.createElement(Button, {
3347
+ "data-testid": "amendtaf",
3348
+ variant: "tertiary",
3349
+ onClick: function onClick() {
3350
+ return onTafViewModeButtonPress('AMEND');
3351
+ }
3352
+ }, "Amend"));
3353
+ };
3316
3354
 
3317
- var IssuesButton = function IssuesButton(_ref) {
3318
- var togglePane = _ref.togglePane,
3319
- sumOfErrors = _ref.sumOfErrors;
3320
- var color = sumOfErrors > 0 ? 'red' : 'green';
3321
- return /*#__PURE__*/React.createElement(Tooltip, {
3322
- title: "View details"
3323
- }, /*#__PURE__*/React.createElement(Chip, {
3324
- "data-testid": "issuesButton",
3325
- size: "small",
3326
- label: getIssuesLabel(sumOfErrors),
3327
- style: Object.assign({}, buttonStyle(color)),
3328
- onClick: togglePane
3355
+ var TafFormButtons = function TafFormButtons(_ref2) {
3356
+ var _ref2$isFormDisabled = _ref2.isFormDisabled,
3357
+ isFormDisabled = _ref2$isFormDisabled === void 0 ? false : _ref2$isFormDisabled,
3358
+ tafAction = _ref2.tafAction,
3359
+ _ref2$canBe = _ref2.canBe,
3360
+ canBe = _ref2$canBe === void 0 ? [] : _ref2$canBe,
3361
+ onTafEditModeButtonPress = _ref2.onTafEditModeButtonPress,
3362
+ onTafViewModeButtonPress = _ref2.onTafViewModeButtonPress;
3363
+ return /*#__PURE__*/React__default.createElement(Grid, {
3364
+ container: true,
3365
+ justifyContent: "flex-end",
3366
+ sx: buttonsStyle,
3367
+ columns: 24
3368
+ }, /*#__PURE__*/React__default.createElement(Grid, {
3369
+ item: true,
3370
+ container: true,
3371
+ justifyContent: "flex-end",
3372
+ xs: 24,
3373
+ sm: 23
3374
+ }, isFormDisabled ? /*#__PURE__*/React__default.createElement(ViewModeButtons, {
3375
+ canBe: canBe,
3376
+ onTafViewModeButtonPress: onTafViewModeButtonPress
3377
+ }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
3378
+ "data-testid": "discardtaf",
3379
+ variant: "tertiary",
3380
+ onClick: function onClick() {
3381
+ // Simply discard the changes and close the dialog.
3382
+ onTafEditModeButtonPress('DISCARD');
3383
+ }
3384
+ }, "Discard"), /*#__PURE__*/React__default.createElement(Button, {
3385
+ "data-testid": "savedrafttaf",
3386
+ variant: "tertiary",
3387
+ onClick: function onClick() {
3388
+ /* Save the TAF as draft:
3389
+ if action NEW or DRAFT - new status will be DRAFT -- default
3390
+ if action AMEND - new status will be DRAFT_AMENDED
3391
+ if action CORRECT - new status will be DRAFT_CORRECTED
3392
+ if action DRAFT_AMEND - new status will be DRAFT_AMENDED
3393
+ if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
3394
+ */
3395
+ switch (tafAction) {
3396
+ case 'AMEND':
3397
+ case 'DRAFT_AMEND':
3398
+ onTafEditModeButtonPress('DRAFT_AMEND');
3399
+ break;
3400
+
3401
+ case 'CORRECT':
3402
+ case 'DRAFT_CORRECT':
3403
+ onTafEditModeButtonPress('DRAFT_CORRECT');
3404
+ break;
3405
+
3406
+ default:
3407
+ onTafEditModeButtonPress('DRAFT');
3408
+ break;
3409
+ }
3410
+ }
3411
+ }, "Save"), /*#__PURE__*/React__default.createElement(Button, {
3412
+ "data-testid": "publishtaf",
3413
+ variant: "tertiary",
3414
+ onClick: function onClick() {
3415
+ /* Publish the TAF:
3416
+ if action NEW or DRAFT - new status will be PUBLISHED -- default
3417
+ if action AMEND - new status will be AMENDED
3418
+ if action CORRECT - new status will be CORRECTED
3419
+ if action DRAFT_AMEND - new status will be AMENDED
3420
+ if action DRAFT_CORRECT - new status will be CORRECTED
3421
+ */
3422
+ switch (tafAction) {
3423
+ case 'AMEND':
3424
+ case 'DRAFT_AMEND':
3425
+ onTafEditModeButtonPress('AMEND');
3426
+ break;
3427
+
3428
+ case 'CORRECT':
3429
+ case 'DRAFT_CORRECT':
3430
+ onTafEditModeButtonPress('CORRECT');
3431
+ break;
3432
+
3433
+ default:
3434
+ onTafEditModeButtonPress('PUBLISH');
3435
+ break;
3436
+ }
3437
+ }
3438
+ }, "Publish"))), /*#__PURE__*/React__default.createElement(Grid, {
3439
+ item: true,
3440
+ sm: 1
3329
3441
  }));
3330
3442
  };
3331
3443
 
3444
+ /* *
3445
+ * Licensed under the Apache License, Version 2.0 (the "License");
3446
+ * you may not use this file except in compliance with the License.
3447
+ * You may obtain a copy of the License at
3448
+ *
3449
+ * http://www.apache.org/licenses/LICENSE-2.0
3450
+ *
3451
+ * Unless required by applicable law or agreed to in writing, software
3452
+ * distributed under the License is distributed on an "AS IS" BASIS,
3453
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3454
+ * See the License for the specific language governing permissions and
3455
+ * limitations under the License.
3456
+ *
3457
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3458
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
3459
+ * */
3460
+ var useStyles = makeStyles(function () {
3461
+ return {
3462
+ dragHandle: {
3463
+ backgroundColor: 'transparent',
3464
+ '&:hover': {
3465
+ backgroundColor: 'transparent'
3466
+ },
3467
+ cursor: function cursor(isSorting) {
3468
+ return isSorting ? 'grabbing' : 'grab';
3469
+ }
3470
+ }
3471
+ };
3472
+ });
3473
+
3474
+ var DragHandle = function DragHandle(_ref) {
3475
+ var _ref$isSorting = _ref.isSorting,
3476
+ isSorting = _ref$isSorting === void 0 ? false : _ref$isSorting,
3477
+ _ref$isDisabled = _ref.isDisabled,
3478
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
3479
+ index = _ref.index;
3480
+ var classes = useStyles(isSorting);
3481
+ return /*#__PURE__*/React__default.createElement(IconButton, {
3482
+ className: "".concat(classes.dragHandle, " handle"),
3483
+ "data-testid": "dragHandle-".concat(index),
3484
+ disableRipple: true,
3485
+ disabled: isDisabled,
3486
+ size: "large"
3487
+ }, /*#__PURE__*/React__default.createElement(DragIndicator, null));
3488
+ };
3489
+
3332
3490
  /* *
3333
3491
  * Licensed under the Apache License, Version 2.0 (the "License");
3334
3492
  * you may not use this file except in compliance with the License.
@@ -3366,32 +3524,6 @@ var ThumbsUp = function ThumbsUp(props) {
3366
3524
  })));
3367
3525
  };
3368
3526
 
3369
- /* *
3370
- * Licensed under the Apache License, Version 2.0 (the "License");
3371
- * you may not use this file except in compliance with the License.
3372
- * You may obtain a copy of the License at
3373
- *
3374
- * http://www.apache.org/licenses/LICENSE-2.0
3375
- *
3376
- * Unless required by applicable law or agreed to in writing, software
3377
- * distributed under the License is distributed on an "AS IS" BASIS,
3378
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3379
- * See the License for the specific language governing permissions and
3380
- * limitations under the License.
3381
- *
3382
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3383
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3384
- * */
3385
- var useStyles$8 = makeStyles({
3386
- paneContent: {
3387
- marginTop: '16px',
3388
- marginLeft: '24px'
3389
- },
3390
- image: {
3391
- fontSize: '4rem'
3392
- }
3393
- });
3394
-
3395
3527
  var getPaneTitle = function getPaneTitle(sumOfErrors) {
3396
3528
  switch (sumOfErrors) {
3397
3529
  case 0:
@@ -3430,7 +3562,7 @@ var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
3430
3562
  var nameWithoutBrackets = nameAsString.replace(/[[\]']+/g, '');
3431
3563
  var nameLowerCase = nameWithoutBrackets.toLowerCase();
3432
3564
 
3433
- var _nameLowerCase$split$ = nameLowerCase.split(/([0-9]+)/) // split numbers from field and build array
3565
+ var _nameLowerCase$split$ = nameLowerCase.split(/([0-9]+)/) // split num bers from field and build array
3434
3566
  .filter(function (s) {
3435
3567
  return s.length;
3436
3568
  }),
@@ -3458,33 +3590,43 @@ var getErrorMessage = function getErrorMessage(error, index) {
3458
3590
  var fieldErrorTitle = humanizeErrorMessage(firstNamePart);
3459
3591
  return "".concat(index + 1, ". ").concat(fieldErrorTitle, ": ").concat(getErrorDefaultMessage(error));
3460
3592
  };
3593
+ var MODAL_DIALOG_ELEMENT = 'modal-dialog';
3461
3594
 
3462
3595
  var IssuesPane = function IssuesPane(_ref3) {
3463
3596
  var isOpen = _ref3.isOpen,
3464
3597
  handleClose = _ref3.handleClose,
3465
3598
  _ref3$errorList = _ref3.errorList,
3466
- errorList = _ref3$errorList === void 0 ? [] : _ref3$errorList;
3467
- var classes = useStyles$8();
3468
- return /*#__PURE__*/React.createElement(ToolContainerDraggable, {
3599
+ errorList = _ref3$errorList === void 0 ? [] : _ref3$errorList,
3600
+ _ref3$startPosition = _ref3.startPosition,
3601
+ startPosition = _ref3$startPosition === void 0 ? {
3602
+ left: 20,
3603
+ top: 50
3604
+ } : _ref3$startPosition;
3605
+ var rootElement = document.getElementById(MODAL_DIALOG_ELEMENT) || document.body;
3606
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(ToolContainerDraggable, {
3469
3607
  startSize: {
3470
3608
  width: '577px',
3471
3609
  height: '200px'
3472
3610
  },
3473
- startPosition: {
3474
- left: 370,
3475
- top: 570
3476
- },
3611
+ startPosition: startPosition,
3477
3612
  minWidth: 300,
3478
3613
  onClose: handleClose,
3479
3614
  title: getPaneTitle(errorList.length),
3480
3615
  headerSize: "xs",
3481
3616
  isOpen: isOpen,
3482
3617
  "data-testid": "moveable-issues-pane",
3483
- bounds: "body"
3484
- }, /*#__PURE__*/React.createElement("div", {
3485
- className: classes.paneContent
3486
- }, errorList.length === 0 && /*#__PURE__*/React.createElement("div", {
3487
- className: classes.image,
3618
+ bounds: "parent"
3619
+ }, /*#__PURE__*/React.createElement(Box, {
3620
+ component: "div",
3621
+ sx: {
3622
+ marginTop: '16px',
3623
+ marginLeft: '24px'
3624
+ }
3625
+ }, errorList.length === 0 && /*#__PURE__*/React.createElement(Box, {
3626
+ component: "div",
3627
+ sx: {
3628
+ fontSize: '4rem'
3629
+ },
3488
3630
  "data-testid": "zeroIssuesImage"
3489
3631
  }, /*#__PURE__*/React.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3490
3632
  return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
@@ -3494,7 +3636,7 @@ var IssuesPane = function IssuesPane(_ref3) {
3494
3636
  variant: "body1",
3495
3637
  "data-testid": "errorMessage"
3496
3638
  }, getErrorMessage(error, index));
3497
- })));
3639
+ }))), rootElement);
3498
3640
  };
3499
3641
 
3500
3642
  var getCustomError = function getCustomError(error) {
@@ -3508,6 +3650,19 @@ var getCustomError = function getCustomError(error) {
3508
3650
  });
3509
3651
  };
3510
3652
 
3653
+ var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3654
+ switch (sumOfErrors) {
3655
+ case 0:
3656
+ return '0 issues';
3657
+
3658
+ case 1:
3659
+ return '1 issue';
3660
+
3661
+ default:
3662
+ return "".concat(sumOfErrors, " issues");
3663
+ }
3664
+ };
3665
+
3511
3666
  var getErrorValues = function getErrorValues(fieldErrors) {
3512
3667
  if (!fieldErrors) return [];
3513
3668
  return Object.keys(fieldErrors).reduce(function (list, key) {
@@ -3521,22 +3676,6 @@ var getErrorValues = function getErrorValues(fieldErrors) {
3521
3676
  }, []);
3522
3677
  };
3523
3678
 
3524
- var getErrors = function getErrors(errors) {
3525
- var errorList = Object.keys(errors).reduce(function (list, key) {
3526
- var errorValue = errors[key];
3527
-
3528
- if (Array.isArray(errorValue)) {
3529
- var errorValues = errorValue.reduce(function (l, i) {
3530
- return l.concat(getErrorValues(i));
3531
- }, []);
3532
- return list.concat.apply(list, _toConsumableArray(errorValues));
3533
- }
3534
-
3535
- return list.concat(getErrorValues(errorValue));
3536
- }, []);
3537
- return errorList;
3538
- };
3539
-
3540
3679
  var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3541
3680
  return errors.reduce(function (list, error) {
3542
3681
  // check on type validateRequiredSub and validateRequiredMainOptional since these are giving 'duplicates'
@@ -3559,17 +3698,31 @@ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3559
3698
  }, []);
3560
3699
  };
3561
3700
 
3562
- var TafFormButtons = function TafFormButtons(_ref) {
3563
- var tafAction = _ref.tafAction,
3564
- onTafFormButtonPress = _ref.onTafFormButtonPress;
3565
- var classes = useStyles$9();
3701
+ var getErrors = function getErrors(errors) {
3702
+ var errorList = Object.keys(errors).reduce(function (list, key) {
3703
+ var errorValue = errors[key];
3566
3704
 
3567
- var _useFormContext = useFormContext(),
3568
- errors = _useFormContext.errors;
3705
+ if (Array.isArray(errorValue)) {
3706
+ var errorValues = errorValue.reduce(function (l, i) {
3707
+ return l.concat(getErrorValues(i));
3708
+ }, []);
3709
+ return list.concat.apply(list, _toConsumableArray(errorValues));
3710
+ }
3711
+
3712
+ return list.concat(getErrorValues(errorValue));
3713
+ }, []);
3714
+ return errorList;
3715
+ };
3569
3716
 
3717
+ var IssuesButton = function IssuesButton(_ref) {
3718
+ var _ref$errors = _ref.errors,
3719
+ errors = _ref$errors === void 0 ? {} : _ref$errors;
3570
3720
  var errorList = filterDuplicateErrors(getErrors(errors));
3721
+ var totalErrors = errorList.length;
3722
+ var errorStatus = totalErrors > 0 ? 'error' : 'success';
3723
+ var buttonColor = "geowebColors.functional.".concat(errorStatus);
3571
3724
 
3572
- var _React$useState = React__default.useState(false),
3725
+ var _React$useState = React.useState(false),
3573
3726
  _React$useState2 = _slicedToArray(_React$useState, 2),
3574
3727
  isIssuesPaneOpen = _React$useState2[0],
3575
3728
  setIsIssuesPaneOpen = _React$useState2[1];
@@ -3578,172 +3731,85 @@ var TafFormButtons = function TafFormButtons(_ref) {
3578
3731
  return setIsIssuesPaneOpen(!isIssuesPaneOpen);
3579
3732
  };
3580
3733
 
3581
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
3582
- container: true,
3583
- justifyContent: "space-between",
3584
- alignItems: "center",
3585
- className: classes.lifecycleButtons
3586
- }, /*#__PURE__*/React__default.createElement(Grid, {
3587
- item: true
3588
- }, /*#__PURE__*/React__default.createElement(IssuesButton, {
3589
- sumOfErrors: errorList.length,
3590
- togglePane: toggleIssuesPane
3591
- })), /*#__PURE__*/React__default.createElement(Grid, {
3592
- item: true
3593
- }, /*#__PURE__*/React__default.createElement(Button, {
3594
- "data-testid": "discardtaf",
3595
- variant: "outlined",
3596
- color: "secondary",
3597
- type: "button",
3598
- className: classes.actionButton,
3599
- onClick: function onClick() {
3600
- // Simply discard the changes and close the dialog.
3601
- onTafFormButtonPress('DISCARD');
3602
- }
3603
- }, "Discard"), /*#__PURE__*/React__default.createElement(Button, {
3604
- "data-testid": "savedrafttaf",
3605
- variant: "outlined",
3606
- color: "secondary",
3607
- type: "button",
3608
- className: classes.actionButton,
3609
- onClick: function onClick() {
3610
- /* Save the TAF as draft:
3611
- if action NEW or DRAFT - new status will be DRAFT -- default
3612
- if action AMEND - new status will be DRAFT_AMENDED
3613
- if action CORRECT - new status will be DRAFT_CORRECTED
3614
- if action DRAFT_AMEND - new status will be DRAFT_AMENDED
3615
- if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
3616
- */
3617
- switch (tafAction) {
3618
- case 'AMEND':
3619
- case 'DRAFT_AMEND':
3620
- onTafFormButtonPress('DRAFT_AMEND');
3621
- break;
3622
-
3623
- case 'CORRECT':
3624
- case 'DRAFT_CORRECT':
3625
- onTafFormButtonPress('DRAFT_CORRECT');
3626
- break;
3734
+ var _React$useState3 = React.useState({
3735
+ left: 0,
3736
+ top: 0
3737
+ }),
3738
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
3739
+ startPosition = _React$useState4[0],
3740
+ setStartPosition = _React$useState4[1];
3627
3741
 
3628
- default:
3629
- onTafFormButtonPress('DRAFT');
3630
- break;
3631
- }
3632
- }
3633
- }, "Save"), /*#__PURE__*/React__default.createElement(Button, {
3634
- "data-testid": "publishtaf",
3635
- variant: "outlined",
3636
- color: "secondary",
3637
- type: "button",
3638
- className: classes.lastButton,
3639
- onClick: function onClick() {
3640
- /* Publish the TAF:
3641
- if action NEW or DRAFT - new status will be PUBLISHED -- default
3642
- if action AMEND - new status will be AMENDED
3643
- if action CORRECT - new status will be CORRECTED
3644
- if action DRAFT_AMEND - new status will be AMENDED
3645
- if action DRAFT_CORRECT - new status will be CORRECTED
3646
- */
3647
- switch (tafAction) {
3648
- case 'AMEND':
3649
- case 'DRAFT_AMEND':
3650
- onTafFormButtonPress('AMEND');
3651
- break;
3742
+ var onClickButton = function onClickButton(event) {
3743
+ var _a;
3652
3744
 
3653
- case 'CORRECT':
3654
- case 'DRAFT_CORRECT':
3655
- onTafFormButtonPress('CORRECT');
3656
- break;
3745
+ var _event$currentTarget$ = event.currentTarget.getBoundingClientRect(),
3746
+ left = _event$currentTarget$.left,
3747
+ top = _event$currentTarget$.top;
3657
3748
 
3658
- default:
3659
- onTafFormButtonPress('PUBLISH');
3660
- break;
3661
- }
3662
- }
3663
- }, "Publish"))), /*#__PURE__*/React__default.createElement(IssuesPane, {
3664
- errorList: errorList,
3665
- handleClose: toggleIssuesPane,
3666
- isOpen: isIssuesPaneOpen
3667
- }));
3668
- };
3749
+ var parentOffset = ((_a = document.getElementById('tafmodule')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
3750
+ top: 0,
3751
+ left: 0
3752
+ };
3753
+ var newPosition = {
3754
+ left: left - parentOffset.left + 100,
3755
+ top: top - parentOffset.top
3756
+ };
3757
+ setStartPosition(newPosition);
3758
+ toggleIssuesPane();
3759
+ };
3669
3760
 
3670
- /* *
3671
- * Licensed under the Apache License, Version 2.0 (the "License");
3672
- * you may not use this file except in compliance with the License.
3673
- * You may obtain a copy of the License at
3674
- *
3675
- * http://www.apache.org/licenses/LICENSE-2.0
3676
- *
3677
- * Unless required by applicable law or agreed to in writing, software
3678
- * distributed under the License is distributed on an "AS IS" BASIS,
3679
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3680
- * See the License for the specific language governing permissions and
3681
- * limitations under the License.
3682
- *
3683
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3684
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3685
- * */
3686
- var useStyles$7 = makeStyles(function () {
3687
- return {
3688
- dragHandle: {
3689
- backgroundColor: 'transparent',
3761
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
3762
+ title: "View details"
3763
+ }, /*#__PURE__*/React.createElement(Chip, {
3764
+ "data-testid": "issuesButton",
3765
+ className: "status-".concat(errorStatus),
3766
+ size: "small",
3767
+ label: getIssuesLabel(totalErrors),
3768
+ onClick: onClickButton,
3769
+ sx: {
3770
+ width: '74px',
3771
+ color: '#ffffff',
3772
+ backgroundColor: buttonColor,
3690
3773
  '&:hover': {
3691
- backgroundColor: 'transparent'
3774
+ backgroundColor: buttonColor
3692
3775
  },
3693
- cursor: function cursor(isSorting) {
3694
- return isSorting ? 'grabbing' : 'grab';
3695
- }
3776
+ '&:focus': {
3777
+ backgroundColor: buttonColor
3778
+ },
3779
+ fontSize: 12
3696
3780
  }
3697
- };
3698
- });
3699
-
3700
- var DragHandle = function DragHandle(_ref) {
3701
- var _ref$isSorting = _ref.isSorting,
3702
- isSorting = _ref$isSorting === void 0 ? false : _ref$isSorting,
3703
- _ref$isDisabled = _ref.isDisabled,
3704
- isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
3705
- index = _ref.index;
3706
- var classes = useStyles$7(isSorting);
3707
- return /*#__PURE__*/React__default.createElement(IconButton, {
3708
- className: "".concat(classes.dragHandle, " handle"),
3709
- "data-testid": "dragHandle-".concat(index),
3710
- disableRipple: true,
3711
- disabled: isDisabled,
3712
- size: "large"
3713
- }, /*#__PURE__*/React__default.createElement(DragIndicator, null));
3781
+ })), /*#__PURE__*/React.createElement(IssuesPane, {
3782
+ errorList: errorList,
3783
+ handleClose: toggleIssuesPane,
3784
+ isOpen: isIssuesPaneOpen,
3785
+ startPosition: startPosition
3786
+ }));
3714
3787
  };
3715
3788
 
3716
3789
  var noop = function noop() {};
3717
3790
 
3718
- var emptyChangegroup = {
3719
- valid: '',
3720
- wind: '',
3721
- visibility: '',
3722
- weather: {
3723
- weather1: null,
3724
- weather2: null,
3725
- weather3: null
3726
- },
3727
- cloud: {
3728
- cloud1: null,
3729
- cloud2: null,
3730
- cloud3: null,
3731
- cloud4: null
3732
- },
3733
- change: null,
3734
- probability: null
3735
- };
3736
-
3737
3791
  var TafForm = function TafForm(_ref) {
3738
- var isDisabled = _ref.isDisabled,
3739
- tafAction = _ref.tafAction,
3792
+ var defaultTafAction = _ref.tafAction,
3793
+ isDefaultDisabled = _ref.isDisabled,
3740
3794
  _ref$staticTAC = _ref.staticTAC,
3741
3795
  staticTAC = _ref$staticTAC === void 0 ? '' : _ref$staticTAC,
3796
+ tafFromBackend = _ref.tafFromBackend,
3742
3797
  _ref$onFormAction = _ref.onFormAction,
3743
3798
  onFormAction = _ref$onFormAction === void 0 ? function () {
3744
3799
  return null;
3745
3800
  } : _ref$onFormAction;
3746
- var classes = useStyles$9();
3801
+ var originalTaf = tafFromBackend.taf;
3802
+
3803
+ var _React$useState = React__default.useState(defaultTafAction),
3804
+ _React$useState2 = _slicedToArray(_React$useState, 2),
3805
+ tafAction = _React$useState2[0],
3806
+ setTafAction = _React$useState2[1];
3807
+
3808
+ var _React$useState3 = React__default.useState(isDefaultDisabled),
3809
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
3810
+ isDisabled = _React$useState4[0],
3811
+ setIsDisabled = _React$useState4[1];
3812
+
3747
3813
  var confirmDialog = useConfirmationDialog();
3748
3814
 
3749
3815
  var _useDraftFormHelpers = useDraftFormHelpers(),
@@ -3762,17 +3828,19 @@ var TafForm = function TafForm(_ref) {
3762
3828
  watch = _useFormContext.watch,
3763
3829
  trigger = _useFormContext.trigger,
3764
3830
  formState = _useFormContext.formState,
3765
- getValues = _useFormContext.getValues;
3831
+ getValues = _useFormContext.getValues,
3832
+ setValue = _useFormContext.setValue,
3833
+ reset = _useFormContext.reset;
3766
3834
 
3767
3835
  var isFormDirty = formState.isDirty,
3768
3836
  errors = formState.errors;
3769
3837
  usePreventBrowserClose(isFormDirty && !isDisabled);
3770
3838
  var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
3771
3839
 
3772
- var _React$useState = React__default.useState(watch()),
3773
- _React$useState2 = _slicedToArray(_React$useState, 2),
3774
- delayedFormValues = _React$useState2[0],
3775
- setDelayedFormValues = _React$useState2[1];
3840
+ var _React$useState5 = React__default.useState(watch()),
3841
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
3842
+ delayedFormValues = _React$useState6[0],
3843
+ setDelayedFormValues = _React$useState6[1];
3776
3844
 
3777
3845
  var _useTACGenerator = useTACGenerator(convertTafValuesToObject(delayedFormValues), api.getTAC, staticTAC),
3778
3846
  _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
@@ -3808,12 +3876,30 @@ var TafForm = function TafForm(_ref) {
3808
3876
  var showConfirmDialog = function showConfirmDialog(action) {
3809
3877
  return confirmDialog({
3810
3878
  title: getConfirmationDialogTitle(action),
3811
- description: getConfirmationDialogContent(action, isFormDirty),
3879
+ description: getConfirmationDialogContent(action, function () {
3880
+ return isTafAmendedCorrectedChanged(isFormDirty, originalTaf, convertTafValuesToObject(getValues()));
3881
+ }),
3812
3882
  confirmLabel: getConfirmationDialogButtonLabel(action)
3813
3883
  });
3814
3884
  };
3815
3885
 
3816
- var onTafButtonPress = function onTafButtonPress(action) {
3886
+ var resetFormValues = function resetFormValues() {
3887
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
3888
+ var shouldAddEmptyChangGroup = arguments.length > 1 ? arguments[1] : undefined;
3889
+ var newTaf = prepareTafValues(tafFromBackend.taf, action, shouldAddEmptyChangGroup);
3890
+ reset(newTaf);
3891
+ };
3892
+
3893
+ var resetForm = function resetForm() {
3894
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
3895
+ var resetDisabled = arguments.length > 1 ? arguments[1] : undefined;
3896
+ var shouldAddEmptyChangGroup = !(tafFromBackend.taf && tafFromBackend.taf.changeGroups) && !resetDisabled;
3897
+ resetFormValues(action, shouldAddEmptyChangGroup);
3898
+ setIsDisabled(resetDisabled);
3899
+ setTafAction(action);
3900
+ };
3901
+
3902
+ var onTafEditModeButtonPress = function onTafEditModeButtonPress(action) {
3817
3903
  switch (action) {
3818
3904
  case 'DRAFT':
3819
3905
  case 'DRAFT_AMEND':
@@ -3827,10 +3913,10 @@ var TafForm = function TafForm(_ref) {
3827
3913
  case 'DISCARD':
3828
3914
  if (isFormDirty) {
3829
3915
  showConfirmDialog(action).then(function () {
3830
- onFormAction(action);
3916
+ resetForm(undefined, isDefaultDisabled);
3831
3917
  });
3832
3918
  } else {
3833
- onFormAction(action);
3919
+ resetForm(undefined, isDefaultDisabled);
3834
3920
  }
3835
3921
 
3836
3922
  break;
@@ -3840,9 +3926,35 @@ var TafForm = function TafForm(_ref) {
3840
3926
  case 'PUBLISH':
3841
3927
  toggleIsDraft(false);
3842
3928
  handleSubmit(function (data) {
3843
- showConfirmDialog(action).then(function () {
3844
- onFormAction(action, convertTafValuesToObject(data));
3845
- });
3929
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3930
+ var didSucceed;
3931
+ return regeneratorRuntime.wrap(function _callee$(_context) {
3932
+ while (1) {
3933
+ switch (_context.prev = _context.next) {
3934
+ case 0:
3935
+ _context.next = 2;
3936
+ return showConfirmDialog(action);
3937
+
3938
+ case 2:
3939
+ _context.next = 4;
3940
+ return onFormAction(action, convertTafValuesToObject(data));
3941
+
3942
+ case 4:
3943
+ didSucceed = _context.sent;
3944
+
3945
+ if (didSucceed) {
3946
+ setIsDisabled(true);
3947
+ reset(prepareTafValues(convertTafValuesToObject(data), action, false));
3948
+ setTafAction(null);
3949
+ }
3950
+
3951
+ case 6:
3952
+ case "end":
3953
+ return _context.stop();
3954
+ }
3955
+ }
3956
+ }, _callee);
3957
+ }));
3846
3958
  })();
3847
3959
  break;
3848
3960
 
@@ -3852,6 +3964,20 @@ var TafForm = function TafForm(_ref) {
3852
3964
  }
3853
3965
  };
3854
3966
 
3967
+ var onTafViewModeButtonPress = function onTafViewModeButtonPress(action) {
3968
+ switch (action) {
3969
+ case 'CANCEL':
3970
+ showConfirmDialog(action).then(function () {
3971
+ onFormAction(action, tafFromBackend.taf);
3972
+ });
3973
+ break;
3974
+
3975
+ default:
3976
+ resetForm(action, false);
3977
+ break;
3978
+ }
3979
+ };
3980
+
3855
3981
  var _useFieldArray = useFieldArray({
3856
3982
  control: control,
3857
3983
  name: 'changeGroups'
@@ -3881,22 +4007,56 @@ var TafForm = function TafForm(_ref) {
3881
4007
 
3882
4008
 
3883
4009
  var focusFirstInput = function focusFirstInput(rowIndex) {
3884
- var nextRowFirstInput = document.querySelector("[name=\"changeGroups[".concat(rowIndex, "].probability\"]"));
4010
+ var selector = rowIndex === -1 ? "[name=\"baseForecast.wind\"]" : "[name=\"changeGroups[".concat(rowIndex, "].probability\"]");
4011
+ var nextRowFirstInput = document.querySelector(selector);
3885
4012
 
3886
4013
  if (nextRowFirstInput) {
3887
4014
  nextRowFirstInput.focus();
3888
4015
  }
4016
+ }; // adding rows and validation don't work well combined, with always skipping validation of fields of rows above the one the inserted row. A setTimeout prevents this issue
4017
+
4018
+
4019
+ var setFocusAndValidate = function setFocusAndValidate(rowIndex) {
4020
+ return setTimeout(function () {
4021
+ focusFirstInput(rowIndex);
4022
+ trigger(); // trigger all fields validation
4023
+ }, 0);
3889
4024
  };
3890
4025
 
3891
4026
  var onAddRow = function onAddRow() {
3892
4027
  var rowIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
3893
- var newRowIndex = rowIndex + 1;
3894
- insert(newRowIndex, emptyChangegroup, false); // adding rows and validation don't work well combined, with always skipping validation of fields of rows above the one the inserted row. A setTimeout prevents this issue
4028
+ var above = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4029
+ var newRowIndex = above ? rowIndex : rowIndex + 1;
4030
+ insert(newRowIndex, emptyChangegroup, false);
4031
+ setFocusAndValidate(newRowIndex);
4032
+ };
3895
4033
 
3896
- setTimeout(function () {
3897
- focusFirstInput(newRowIndex);
3898
- trigger(); // trigger all fields validation
3899
- }, 0);
4034
+ var _onClearRow = function onClearRow() {
4035
+ var rowIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
4036
+ var isChangeGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4037
+ confirmDialog({
4038
+ title: 'Clear row',
4039
+ description: 'Are you sure you want to clear this row?',
4040
+ confirmLabel: 'Yes'
4041
+ }).then(function () {
4042
+ if (isChangeGroup) {
4043
+ remove(rowIndex);
4044
+ insert(rowIndex, emptyChangegroup, false);
4045
+ } else {
4046
+ var baseForecastFields = getFieldNames(false, -1);
4047
+ setValue(baseForecastFields.wind, '');
4048
+ setValue(baseForecastFields.visibility, '');
4049
+ setValue(baseForecastFields.weather1, '');
4050
+ setValue(baseForecastFields.weather2, '');
4051
+ setValue(baseForecastFields.weather3, '');
4052
+ setValue(baseForecastFields.cloud1, '');
4053
+ setValue(baseForecastFields.cloud2, '');
4054
+ setValue(baseForecastFields.cloud3, '');
4055
+ setValue(baseForecastFields.cloud4, '');
4056
+ }
4057
+
4058
+ setFocusAndValidate(rowIndex);
4059
+ });
3900
4060
  };
3901
4061
 
3902
4062
  React__default.useEffect(function () {
@@ -3910,22 +4070,36 @@ var TafForm = function TafForm(_ref) {
3910
4070
 
3911
4071
  }, []);
3912
4072
  return /*#__PURE__*/React__default.createElement("form", {
4073
+ "data-testid": "taf-form",
3913
4074
  onSubmit: handleSubmit(onSubmit),
3914
4075
  onBlur: onFormBlur
3915
4076
  }, /*#__PURE__*/React__default.createElement(Typography, {
3916
- className: classes.tacTitle
4077
+ sx: {
4078
+ fontSize: '20px',
4079
+ fontWeight: 500,
4080
+ height: '24px'
4081
+ }
3917
4082
  }, "TAC"), /*#__PURE__*/React__default.createElement(Typography, {
3918
- "data-testid": "form-tac-message",
3919
- className: classes.tacText
4083
+ sx: {
4084
+ fontSize: '14px',
4085
+ margin: '8px 0px'
4086
+ },
4087
+ "data-testid": "form-tac-message"
3920
4088
  }, TAC.split('\n').map(function (line) {
3921
- return /*#__PURE__*/React__default.createElement("span", {
4089
+ return /*#__PURE__*/React__default.createElement(Box, {
4090
+ component: "span",
3922
4091
  key: line,
3923
- className: classes.tacLine,
3924
- "data-testid": "tafform-tac-message-line"
4092
+ "data-testid": "tafform-tac-message-line",
4093
+ sx: {
4094
+ textIndent: '-0.7em',
4095
+ borderRadius: '3px',
4096
+ paddingRight: '0.7em'
4097
+ }
3925
4098
  }, line);
3926
4099
  })), /*#__PURE__*/React__default.createElement(TafFormRow, {
3927
4100
  disabled: isDisabled,
3928
- onAddChangeGroup: onAddRow
4101
+ onAddChangeGroupBelow: onAddRow,
4102
+ onClearRow: _onClearRow
3929
4103
  }), /*#__PURE__*/React__default.createElement(ReactSortable, {
3930
4104
  tag: "div",
3931
4105
  list: fields,
@@ -3943,13 +4117,17 @@ var TafForm = function TafForm(_ref) {
3943
4117
  }, fields.map(function (item, index) {
3944
4118
  return /*#__PURE__*/React__default.createElement(TafFormRow, {
3945
4119
  field: item,
3946
- className: classes.formRow,
3947
4120
  key: item.id,
3948
4121
  index: index,
3949
- lastRow: fields.length === index + 1,
3950
4122
  disabled: isDisabled,
3951
4123
  onRemoveChangeGroup: onRemoverow,
3952
- onAddChangeGroup: onAddRow,
4124
+ onAddChangeGroupBelow: onAddRow,
4125
+ onAddChangeGroupAbove: function onAddChangeGroupAbove() {
4126
+ return onAddRow(index, true);
4127
+ },
4128
+ onClearRow: function onClearRow() {
4129
+ return _onClearRow(index, true);
4130
+ },
3953
4131
  isChangeGroup: true,
3954
4132
  dragHandle: /*#__PURE__*/React__default.createElement(DragHandle, {
3955
4133
  isDisabled: fields.length === 1 || isDisabled,
@@ -3957,9 +4135,24 @@ var TafForm = function TafForm(_ref) {
3957
4135
  index: index
3958
4136
  })
3959
4137
  });
3960
- })), !isDisabled && /*#__PURE__*/React__default.createElement(TafFormButtons, {
4138
+ })), !isDisabled && /*#__PURE__*/React__default.createElement(Grid, {
4139
+ container: true,
4140
+ justifyContent: "space-between",
4141
+ alignItems: "center",
4142
+ sx: {
4143
+ marginLeft: 1.5,
4144
+ marginTop: 1
4145
+ }
4146
+ }, /*#__PURE__*/React__default.createElement(Grid, {
4147
+ item: true
4148
+ }, /*#__PURE__*/React__default.createElement(IssuesButton, {
4149
+ errors: errors
4150
+ }))), /*#__PURE__*/React__default.createElement(TafFormButtons, {
4151
+ isFormDisabled: isDisabled,
3961
4152
  tafAction: tafAction,
3962
- onTafFormButtonPress: onTafButtonPress
4153
+ canBe: tafFromBackend.canbe,
4154
+ onTafEditModeButtonPress: onTafEditModeButtonPress,
4155
+ onTafViewModeButtonPress: onTafViewModeButtonPress
3963
4156
  }), hiddenInputFields.map(function (field) {
3964
4157
  return /*#__PURE__*/React__default.createElement(ReactHookFormHiddenInput, {
3965
4158
  name: field,
@@ -3984,69 +4177,17 @@ var TafForm = function TafForm(_ref) {
3984
4177
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3985
4178
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
3986
4179
  * */
3987
- var getMessageType = function getMessageType(taf, tafAction) {
3988
- if (tafAction === 'CORRECT') {
3989
- return 'COR';
3990
- }
3991
-
3992
- if (tafAction === 'AMEND') {
3993
- return 'AMD';
3994
- }
3995
-
3996
- return taf.messageType;
3997
- }; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
3998
-
3999
- var getAmendedCorrectedTafTimes = function getAmendedCorrectedTafTimes(taf, tafAction) {
4000
- var previousValidDateStart = taf.previousValidDateStart && tafAction !== 'AMEND' ? taf.previousValidDateStart : taf.validDateStart;
4001
- var previousValidDateEnd = taf.previousValidDateEnd && tafAction !== 'AMEND' ? taf.previousValidDateEnd : taf.validDateEnd; // For amendment change valid start time to current time
4002
- // only do this if we're already within the validity period
4003
-
4004
- if ((tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND') && moment.utc() >= moment.utc(taf.validDateStart)) {
4005
- var now = moment.utc().format('YYYY-MM-DDTHH:mm:ss[Z]');
4006
- var validObj = {
4007
- start: now,
4008
- end: taf.baseForecast.valid.end
4009
- };
4010
- return Object.assign(Object.assign({}, taf), {
4011
- previousValidDateStart: previousValidDateStart,
4012
- previousValidDateEnd: previousValidDateEnd,
4013
- validDateStart: now,
4014
- baseForecast: Object.assign(Object.assign({}, taf.baseForecast), {
4015
- valid: validObj
4016
- })
4017
- });
4018
- }
4019
-
4020
- return Object.assign(Object.assign({}, taf), {
4021
- previousValidDateStart: previousValidDateStart,
4022
- previousValidDateEnd: previousValidDateEnd
4023
- });
4024
- };
4025
- var prepareTafValues = function prepareTafValues(_taf, tafAction) {
4026
- var addEmptyChangeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4027
- // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
4028
- // If action is AMEND/DRAFT_AMEND - update validity start time to current time
4029
- var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
4030
- return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
4031
- messageType: getMessageType(taf, tafAction),
4032
- baseForecast: formatFormValues(taf.baseForecast)
4033
- }), taf.changeGroups && {
4034
- changeGroups: taf.changeGroups.map(formatFormValues)
4035
- }), addEmptyChangeGroup && {
4036
- changeGroups: [emptyChangegroup]
4037
- });
4038
- };
4039
4180
 
4040
4181
  var TafFormWrapper = function TafFormWrapper(_ref) {
4041
4182
  var tafFromBackend = _ref.tafFromBackend,
4042
4183
  mode = _ref.mode,
4043
- tafAction = _ref.tafAction,
4044
4184
  _ref$TAC = _ref.TAC,
4045
4185
  TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
4046
- onFormAction = _ref.onFormAction;
4186
+ onFormAction = _ref.onFormAction,
4187
+ tafAction = _ref.tafAction;
4047
4188
  var taf = tafFromBackend.taf;
4048
4189
  var isDisabled = mode === 'view';
4049
- var defaultValues = prepareTafValues(taf, tafAction, !isDisabled && !taf.changeGroups);
4190
+ var defaultValues = prepareTafValues(taf, undefined, !isDisabled && !taf.changeGroups);
4050
4191
  var options = {
4051
4192
  defaultValues: defaultValues,
4052
4193
  mode: 'onTouched',
@@ -4057,81 +4198,43 @@ var TafFormWrapper = function TafFormWrapper(_ref) {
4057
4198
  options: options
4058
4199
  }, /*#__PURE__*/React__default.createElement(TafForm, {
4059
4200
  isDisabled: isDisabled,
4060
- tafAction: tafAction,
4061
4201
  staticTAC: TAC,
4062
- onFormAction: onFormAction
4202
+ onFormAction: onFormAction,
4203
+ tafFromBackend: tafFromBackend,
4204
+ tafAction: tafAction
4063
4205
  }));
4064
4206
  };
4065
4207
 
4066
- var useStyles$6 = makeStyles({
4067
- dialogHeader: {
4068
- borderRadius: '3px',
4069
- border: 'solid 1px #f6f5f5',
4070
- zIndex: 1,
4071
- padding: '16px 20px'
4072
- },
4073
- dialogTitle: {
4074
- display: 'flex',
4075
- alignItems: 'center'
4076
- },
4077
- dialogCloseButton: {
4078
- display: 'flex',
4079
- justifyContent: 'flex-end'
4080
- },
4081
- dialogChildren: {
4082
- display: 'flex',
4083
- padding: 20,
4084
- minHeight: 200,
4085
- minWidth: 400,
4086
- height: '100%'
4087
- }
4088
- });
4208
+ /* *
4209
+ * Licensed under the Apache License, Version 2.0 (the "License");
4210
+ * you may not use this file except in compliance with the License.
4211
+ * You may obtain a copy of the License at
4212
+ *
4213
+ * http://www.apache.org/licenses/LICENSE-2.0
4214
+ *
4215
+ * Unless required by applicable law or agreed to in writing, software
4216
+ * distributed under the License is distributed on an "AS IS" BASIS,
4217
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4218
+ * See the License for the specific language governing permissions and
4219
+ * limitations under the License.
4220
+ *
4221
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4222
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4223
+ * */
4089
4224
 
4090
- var ContentDialog = function ContentDialog(_a) {
4091
- var open = _a.open;
4092
- _a.toggleDialogStatus;
4093
- var titleComponent = _a.titleComponent,
4094
- children = _a.children;
4095
- _a.onClose;
4096
- var _a$alertBanner = _a.alertBanner,
4097
- alertBanner = _a$alertBanner === void 0 ? null : _a$alertBanner,
4098
- onFormAction = _a.onFormAction,
4099
- other = __rest(_a, ["open", "toggleDialogStatus", "titleComponent", "children", "onClose", "alertBanner", "onFormAction"]);
4100
-
4101
- var classes = useStyles$6();
4102
- return /*#__PURE__*/React.createElement(Dialog, Object.assign({
4103
- "data-testid": "contentDialog",
4104
- open: open,
4105
- onClose: function onClose() {
4106
- return onFormAction('CLOSE');
4107
- },
4108
- maxWidth: other.maxWidth ? other.maxWidth : 'lg',
4109
- PaperProps: {
4110
- style: {
4111
- position: 'inherit'
4112
- }
4113
- }
4114
- }, other), /*#__PURE__*/React.createElement(DialogTitle, {
4115
- className: classes.dialogHeader
4116
- }, /*#__PURE__*/React.createElement(Grid, {
4117
- container: true
4118
- }, /*#__PURE__*/React.createElement(Grid, {
4119
- item: true,
4120
- xs: 11,
4121
- className: classes.dialogTitle
4122
- }, titleComponent), /*#__PURE__*/React.createElement(Grid, {
4123
- item: true,
4124
- xs: true,
4125
- className: classes.dialogCloseButton
4126
- }, /*#__PURE__*/React.createElement(IconButton, {
4127
- "data-testid": "closeDialog",
4128
- size: "small",
4129
- onClick: function onClick() {
4130
- return onFormAction('CLOSE');
4131
- }
4132
- }, /*#__PURE__*/React.createElement(Close, null))))), alertBanner !== null && alertBanner, /*#__PURE__*/React.createElement(DialogContent, {
4133
- className: classes.dialogChildren
4134
- }, children));
4225
+ var TabPanel = function TabPanel(_a) {
4226
+ var children = _a.children,
4227
+ value = _a.value,
4228
+ index = _a.index,
4229
+ other = __rest(_a, ["children", "value", "index"]);
4230
+
4231
+ return /*#__PURE__*/React__default.createElement(Box, Object.assign({
4232
+ role: "tabpanel",
4233
+ hidden: value !== index,
4234
+ id: "simple-tabpanel-".concat(index),
4235
+ "aria-labelledby": "simple-tab-".concat(index),
4236
+ "data-testid": "tab-panel-".concat(index)
4237
+ }, other), value === index && children);
4135
4238
  };
4136
4239
 
4137
4240
  /* *
@@ -4147,175 +4250,139 @@ var ContentDialog = function ContentDialog(_a) {
4147
4250
  * See the License for the specific language governing permissions and
4148
4251
  * limitations under the License.
4149
4252
  *
4150
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4151
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4253
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4254
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4152
4255
  * */
4153
4256
 
4154
- var getActiveStatus = function getActiveStatus(listType, className) {
4155
- return listType === 'ACTIVE' ? /*#__PURE__*/React__default.createElement(CheckCircle, {
4156
- "data-testid": "status-active",
4157
- className: className,
4158
- fontSize: "small"
4159
- }) : /*#__PURE__*/React__default.createElement(Schedule, {
4160
- "data-testid": "status-upcoming",
4161
- className: className,
4162
- fontSize: "small"
4163
- });
4257
+ var TafHeader = function TafHeader(_ref) {
4258
+ var title = _ref.title;
4259
+ return /*#__PURE__*/React__default.createElement(Typography, {
4260
+ sx: {
4261
+ textAlign: 'center',
4262
+ fontWeight: 500,
4263
+ paddingTop: '6px',
4264
+ textTransform: 'capitalize'
4265
+ }
4266
+ }, title);
4164
4267
  };
4165
4268
 
4166
- var getStatusTagList = function getStatusTagList(taf) {
4167
- // do not return anything if status = 'NEW'
4168
- if (taf.status === 'NEW') return null;
4269
+ var location_indicator_mwo = "EHDB";
4270
+ var locations = {
4271
+ EHAM: {
4272
+ validity_duration: 30,
4273
+ activity_period: 6,
4274
+ label: "Schiphol"
4275
+ },
4276
+ EHRD: {
4277
+ validity_duration: 30,
4278
+ activity_period: 6,
4279
+ label: "Rotterdam"
4280
+ },
4281
+ EHGG: {
4282
+ validity_duration: 30,
4283
+ activity_period: 6,
4284
+ label: "Eelde"
4285
+ },
4286
+ EHBK: {
4287
+ validity_duration: 30,
4288
+ activity_period: 6,
4289
+ label: "Maastricht"
4290
+ },
4291
+ EHLE: {
4292
+ validity_duration: 30,
4293
+ activity_period: 6,
4294
+ label: "Lelystad"
4295
+ },
4296
+ TNCB: {
4297
+ validity_duration: 30,
4298
+ activity_period: 6,
4299
+ label: "Bonaire"
4300
+ }
4301
+ };
4302
+ var locationOrder = [
4303
+ "EHAM",
4304
+ "EHRD",
4305
+ "EHLE",
4306
+ "EHGG",
4307
+ "EHBK",
4308
+ "TNCB"
4309
+ ];
4310
+ var tafConfig = {
4311
+ location_indicator_mwo: location_indicator_mwo,
4312
+ locations: locations,
4313
+ locationOrder: locationOrder
4314
+ };
4169
4315
 
4170
- if (taf.status === 'CANCELLED') {
4171
- return /*#__PURE__*/React__default.createElement(StatusTag, {
4172
- content: "cancelled",
4173
- color: "red"
4174
- });
4175
- }
4316
+ var getTafSettings = function getTafSettings() {
4317
+ return tafConfig;
4318
+ };
4176
4319
 
4177
- return /*#__PURE__*/React__default.createElement(StatusTag, {
4178
- content: taf.status.toLowerCase(),
4179
- color: taf.status === 'EXPIRED' ? 'grey' : 'green'
4320
+ var tafSettings = getTafSettings();
4321
+ var getLocationSetting = function getLocationSetting(location) {
4322
+ var locationSettings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : tafSettings.locations;
4323
+ return locationSettings[location];
4324
+ };
4325
+ var sortTafsOnLocation = function sortTafsOnLocation(tafList) {
4326
+ var locationOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : tafSettings.locationOrder;
4327
+ if (!tafList) return [];
4328
+ return _toConsumableArray(tafList).sort(function (_ref, _ref2) {
4329
+ var tafA = _ref.taf;
4330
+ var tafB = _ref2.taf;
4331
+ return locationOrder.indexOf(tafA.location) < locationOrder.indexOf(tafB.location) ? -1 : 1;
4180
4332
  });
4181
4333
  };
4334
+ var getBaseTime = function getBaseTime(baseTime, location) {
4335
+ var currentBaseTime = moment.utc(baseTime);
4336
+ var activityPeriod = getLocationSetting(location).activity_period;
4337
+ var nextBaseTime = moment.utc(baseTime).add(activityPeriod, 'hours');
4338
+ return {
4339
+ currentBaseTime: currentBaseTime,
4340
+ nextBaseTime: nextBaseTime
4341
+ };
4342
+ };
4343
+ var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status) {
4344
+ var now = moment.utc();
4345
+
4346
+ var _getBaseTime = getBaseTime(baseTime, location),
4347
+ currentBaseTime = _getBaseTime.currentBaseTime,
4348
+ nextBaseTime = _getBaseTime.nextBaseTime;
4182
4349
 
4183
- var getDraftTitle = function getDraftTitle(status) {
4184
- if (status === 'DRAFT_AMENDED') {
4185
- return 'Draft amendment';
4350
+ if (status === 'EXPIRED') {
4351
+ return 'EXPIRED';
4186
4352
  }
4187
4353
 
4188
- if (status === 'DRAFT_CORRECTED') {
4189
- return 'Draft correction';
4354
+ if (currentBaseTime < now && nextBaseTime > now) {
4355
+ return 'ACTIVE';
4190
4356
  }
4191
4357
 
4192
- return 'Draft';
4358
+ return 'UPCOMING';
4193
4359
  };
4194
- var useStyles$5 = makeStyles({
4195
- cardWrapper: {
4196
- width: '100%'
4197
- },
4198
- cardContent: {
4199
- width: '100%'
4200
- },
4201
- activeStatus: {
4202
- color: '#72bb23'
4203
- },
4204
- font: {
4205
- fontWeight: 'normal'
4206
- },
4207
- alignIcon: {
4208
- display: 'flex',
4209
- alignSelf: 'center'
4210
- }
4211
- });
4360
+ var sortTafTimeSlots = function sortTafTimeSlots(tafList) {
4361
+ var sortedListOnLocation = sortTafsOnLocation(tafList);
4362
+ return sortedListOnLocation.reduce(function (sortedTafList, tafFromBackend) {
4363
+ var taf = tafFromBackend.taf;
4364
+ var timeSlot = getTafTimeSlot(taf.baseTime, taf.location, taf.status);
4365
+
4366
+ if (timeSlot === 'EXPIRED') {
4367
+ sortedTafList.expired.push(tafFromBackend);
4368
+ } else if (timeSlot === 'ACTIVE') {
4369
+ sortedTafList.current.push(tafFromBackend);
4370
+ } else {
4371
+ sortedTafList.upcoming.push(tafFromBackend);
4372
+ }
4212
4373
 
4213
- var TafListRow = function TafListRow(_ref) {
4214
- var taf = _ref.taf,
4215
- listType = _ref.listType,
4216
- _ref$TAC = _ref.TAC,
4217
- TAC = _ref$TAC === void 0 ? '' : _ref$TAC,
4218
- _ref$showTac = _ref.showTac,
4219
- showTac = _ref$showTac === void 0 ? false : _ref$showTac;
4220
- var classes = useStyles$5();
4221
- var validTimeDate = moment.utc(taf.validDateStart).format('DD MMM');
4222
- var baseTime = moment.utc(taf.baseTime).format('HH:mm');
4223
- return /*#__PURE__*/React__default.createElement(Card, {
4224
- elevation: 0,
4225
- className: classes.cardWrapper
4226
- }, /*#__PURE__*/React__default.createElement(Grid, {
4227
- container: true,
4228
- alignItems: "center",
4229
- spacing: 1
4230
- }, /*#__PURE__*/React__default.createElement(Grid, {
4231
- item: true,
4232
- xs: 3,
4233
- sm: 2,
4234
- md: 1
4235
- }, /*#__PURE__*/React__default.createElement(Typography, {
4236
- variant: "subtitle2",
4237
- noWrap: true,
4238
- className: classes.font
4239
- }, taf.location)), /*#__PURE__*/React__default.createElement(Grid, {
4240
- item: true,
4241
- xs: 3,
4242
- sm: 3,
4243
- md: 1,
4244
- container: true
4245
- }, /*#__PURE__*/React__default.createElement(Grid, {
4246
- item: true,
4247
- xs: 3,
4248
- sm: 3,
4249
- md: 3,
4250
- className: classes.alignIcon
4251
- }, showTac && /*#__PURE__*/React__default.createElement(Tooltip, {
4252
- "data-testid": "taflistrow-tactooltip",
4253
- title: /*#__PURE__*/React__default.createElement("div", {
4254
- style: {
4255
- whiteSpace: 'pre-line'
4256
- }
4257
- }, TAC),
4258
- placement: "bottom-start"
4259
- }, /*#__PURE__*/React__default.createElement(InfoOutlined, {
4260
- "data-testid": "taflistrow-tacicon",
4261
- color: "secondary",
4262
- fontSize: "small"
4263
- }))), /*#__PURE__*/React__default.createElement(Grid, {
4264
- item: true,
4265
- xs: 9,
4266
- sm: 9,
4267
- md: 9
4268
- }, /*#__PURE__*/React__default.createElement(Typography, {
4269
- variant: "subtitle2",
4270
- className: classes.font,
4271
- "data-testid": "baseTime"
4272
- }, baseTime))), /*#__PURE__*/React__default.createElement(Grid, {
4273
- item: true,
4274
- xs: 3,
4275
- sm: 2,
4276
- md: 1
4277
- }, /*#__PURE__*/React__default.createElement(Typography, {
4278
- variant: "subtitle2",
4279
- className: classes.font,
4280
- "data-testid": "validTimeDate"
4281
- }, validTimeDate)), /*#__PURE__*/React__default.createElement(Grid, {
4282
- item: true,
4283
- xs: 3,
4284
- sm: 3,
4285
- md: 6
4286
- }, /*#__PURE__*/React__default.createElement(Typography, {
4287
- variant: "subtitle2",
4288
- className: classes.font,
4289
- "data-testid": "validTimeSlot"
4290
- }, formatValidToString({
4291
- start: taf.validDateStart,
4292
- end: taf.validDateEnd
4293
- }))), /*#__PURE__*/React__default.createElement(Grid, {
4294
- item: true,
4295
- xs: 12,
4296
- sm: 4,
4297
- md: 3
4298
- }, /*#__PURE__*/React__default.createElement(Grid, {
4299
- container: true,
4300
- justifyContent: "flex-start",
4301
- spacing: 2
4302
- }, /*#__PURE__*/React__default.createElement(Grid, {
4303
- item: true,
4304
- xs: 8,
4305
- container: true,
4306
- justifyContent: "flex-end"
4307
- }, taf.status === 'DRAFT' || taf.status === 'DRAFT_CORRECTED' || taf.status === 'DRAFT_AMENDED' ? /*#__PURE__*/React__default.createElement(Button, {
4308
- color: "secondary",
4309
- size: "small",
4310
- "data-testid": "tafRow-draft",
4311
- startIcon: /*#__PURE__*/React__default.createElement(Create, {
4312
- fontSize: "small",
4313
- color: "secondary"
4314
- })
4315
- }, getDraftTitle(taf.status)) : getStatusTagList(taf)), /*#__PURE__*/React__default.createElement(Grid, {
4316
- item: true,
4317
- className: classes.alignIcon
4318
- }, taf.status !== 'NEW' && taf.status !== 'DRAFT' && taf.status !== 'DRAFT_CORRECTED' && taf.status !== 'DRAFT_AMENDED' && taf.status !== 'CANCELLED' && listType !== 'EXPIRED' && getActiveStatus(listType, classes.activeStatus))))));
4374
+ return sortedTafList;
4375
+ }, {
4376
+ current: [],
4377
+ upcoming: [],
4378
+ expired: []
4379
+ });
4380
+ };
4381
+ var muiTabA11yProps = function muiTabA11yProps(index) {
4382
+ return {
4383
+ id: "simple-tab-".concat(index),
4384
+ 'aria-controls': "simple-tabpanel-".concat(index)
4385
+ };
4319
4386
  };
4320
4387
 
4321
4388
  /* *
@@ -4331,243 +4398,334 @@ var TafListRow = function TafListRow(_ref) {
4331
4398
  * See the License for the specific language governing permissions and
4332
4399
  * limitations under the License.
4333
4400
  *
4334
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4335
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4401
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4402
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4336
4403
  * */
4337
- var getListType = function getListType(taf, locationSettings) {
4338
- if (!taf) return null;
4339
- var now = moment.utc();
4340
- var baseTime = moment.utc(taf.baseTime);
4341
- var activityPeriod = locationSettings[taf.location].activity_period;
4342
- var nextBaseTime = moment.utc(taf.baseTime).add(activityPeriod, 'hours');
4343
4404
 
4344
- if (taf.status === 'EXPIRED') {
4345
- return 'EXPIRED';
4405
+ var EditIcon = function EditIcon(props) {
4406
+ var theme = useTheme();
4407
+ return /*#__PURE__*/React.createElement(SvgIcon, Object.assign({}, props), /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", {
4408
+ d: "m8.332 17.09-.005.001-2.652.604.956-2.542.001-.001.001-.001.857-.744 1.69 1.945-.848.738zm.71.815L20.932 7.577 17.823 4 5.933 14.329l-.01.008.005.005L4.173 19l4.857-1.09-.004-.02.019.02-.002-.005z",
4409
+ fillRule: "evenodd",
4410
+ fill: "".concat(theme.palette.geowebColors.buttons.tertiary["default"].color)
4411
+ })));
4412
+ };
4413
+
4414
+ var StatusIcon = function StatusIcon(_ref) {
4415
+ var timeSlot = _ref.timeSlot,
4416
+ status = _ref.status;
4417
+
4418
+ if (status === 'NEW') {
4419
+ return null;
4346
4420
  }
4347
4421
 
4348
- if (baseTime < now && nextBaseTime > now) {
4349
- return 'ACTIVE';
4422
+ if (status === 'EXPIRED') {
4423
+ return /*#__PURE__*/React.createElement(Schedule, {
4424
+ "data-testid": "status-expired",
4425
+ fontSize: "small",
4426
+ sx: {
4427
+ transform: 'scaleX(-1)',
4428
+ color: 'geowebColors.buttons.tertiary.disabled.color'
4429
+ }
4430
+ });
4350
4431
  }
4351
4432
 
4352
- return 'UPCOMING';
4353
- };
4433
+ if (status === 'CANCELLED') {
4434
+ return /*#__PURE__*/React.createElement(DoDisturbIcon, {
4435
+ "data-testid": "status-cancelled",
4436
+ fontSize: "small",
4437
+ sx: {
4438
+ color: 'geowebColors.captions.captionError.rgba'
4439
+ }
4440
+ });
4441
+ }
4354
4442
 
4355
- /* *
4356
- * Licensed under the Apache License, Version 2.0 (the "License");
4357
- * you may not use this file except in compliance with the License.
4358
- * You may obtain a copy of the License at
4359
- *
4360
- * http://www.apache.org/licenses/LICENSE-2.0
4361
- *
4362
- * Unless required by applicable law or agreed to in writing, software
4363
- * distributed under the License is distributed on an "AS IS" BASIS,
4364
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4365
- * See the License for the specific language governing permissions and
4366
- * limitations under the License.
4367
- *
4368
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4369
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4370
- * */
4443
+ if (status === 'DRAFT' || status === 'DRAFT_CORRECTED' || status === 'DRAFT_AMENDED') {
4444
+ return /*#__PURE__*/React.createElement(EditIcon, {
4445
+ "data-testid": "status-draft"
4446
+ });
4447
+ }
4371
4448
 
4372
- var TafFormDialog = function TafFormDialog(_ref) {
4373
- var open = _ref.open,
4374
- toggleFormDialog = _ref.toggleFormDialog,
4375
- tafFromBackend = _ref.tafFromBackend,
4376
- children = _ref.children,
4377
- _ref$alertBanner = _ref.alertBanner,
4378
- alertBanner = _ref$alertBanner === void 0 ? null : _ref$alertBanner,
4379
- onFormAction = _ref.onFormAction;
4380
- var taf = tafFromBackend ? tafFromBackend.taf : null;
4381
-
4382
- var _useTafSettings = useTafSettings(tafConfig),
4383
- locationSettings = _useTafSettings.locations;
4384
-
4385
- return /*#__PURE__*/React__default.createElement(ContentDialog, {
4386
- open: open,
4387
- toggleDialogStatus: toggleFormDialog,
4388
- titleComponent: /*#__PURE__*/React__default.createElement(TafListRow, {
4389
- taf: taf,
4390
- listType: getListType(taf, locationSettings)
4391
- }),
4392
- alertBanner: alertBanner,
4393
- onFormAction: onFormAction
4394
- }, children);
4449
+ return timeSlot === 'ACTIVE' ? /*#__PURE__*/React.createElement(CheckCircle, {
4450
+ "data-testid": "status-active",
4451
+ fontSize: "small",
4452
+ sx: {
4453
+ color: 'geowebColors.functional.success'
4454
+ }
4455
+ }) : /*#__PURE__*/React.createElement(Schedule, {
4456
+ "data-testid": "status-upcoming",
4457
+ fontSize: "small",
4458
+ sx: {
4459
+ color: 'geowebColors.functional.success'
4460
+ }
4461
+ });
4395
4462
  };
4396
4463
 
4397
- /* *
4398
- * Licensed under the Apache License, Version 2.0 (the "License");
4399
- * you may not use this file except in compliance with the License.
4400
- * You may obtain a copy of the License at
4401
- *
4402
- * http://www.apache.org/licenses/LICENSE-2.0
4403
- *
4404
- * Unless required by applicable law or agreed to in writing, software
4405
- * distributed under the License is distributed on an "AS IS" BASIS,
4406
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4407
- * See the License for the specific language governing permissions and
4408
- * limitations under the License.
4409
- *
4410
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4411
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4412
- * */
4413
- var useStyles$4 = makeStyles({
4414
- actionButtons: {
4415
- paddingRight: '98px',
4416
- paddingTop: '40px',
4417
- paddingBottom: '16px'
4418
- }
4419
- });
4464
+ var TacContainer = function TacContainer(_ref) {
4465
+ var taf = _ref.taf,
4466
+ _ref$isActive = _ref.isActive,
4467
+ isActive = _ref$isActive === void 0 ? false : _ref$isActive;
4420
4468
 
4421
- var TafListButtons = function TafListButtons(_ref) {
4422
- var uuid = _ref.uuid,
4423
- canBe = _ref.canBe,
4424
- onClickTafActionButton = _ref.onClickTafActionButton;
4425
- var classes = useStyles$4();
4426
- return !canBe.includes('CANCELLED') && !canBe.includes('CORRECTED') && !canBe.includes('AMENDED') ? null : /*#__PURE__*/React__default.createElement(Grid, {
4427
- container: true,
4428
- alignItems: "center",
4429
- justifyContent: "flex-end",
4430
- "data-testid": "taflist-canbebuttons",
4431
- spacing: 1,
4432
- className: classes.actionButtons
4433
- }, /*#__PURE__*/React__default.createElement(Grid, {
4434
- item: true
4435
- }, canBe.includes('CANCELLED') && /*#__PURE__*/React__default.createElement(Button, {
4436
- "data-testid": "canceltaf",
4437
- variant: "outlined",
4438
- color: "secondary",
4439
- onClick: function onClick() {
4440
- return onClickTafActionButton(uuid, 'CANCEL');
4469
+ var _useApiContext = useApiContext(),
4470
+ api = _useApiContext.api;
4471
+
4472
+ var _useTACGenerator = useTACGenerator(taf, api.getTAC),
4473
+ _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
4474
+ TAC = _useTACGenerator2[0],
4475
+ retrieveTAC = _useTACGenerator2[1];
4476
+
4477
+ var status = taf.status,
4478
+ location = taf.location,
4479
+ baseTime = taf.baseTime;
4480
+ var locationLabel = getLocationSetting(location).label;
4481
+ var timeSlot = getTafTimeSlot(baseTime, location, status);
4482
+ React__default.useEffect(function () {
4483
+ if (isActive) {
4484
+ retrieveTAC(taf);
4441
4485
  }
4442
- }, "Cancel")), /*#__PURE__*/React__default.createElement(Grid, {
4443
- item: true
4444
- }, canBe.includes('CORRECTED') && /*#__PURE__*/React__default.createElement(Button, {
4445
- "data-testid": "correctaf",
4446
- variant: "outlined",
4447
- color: "secondary",
4448
- onClick: function onClick() {
4449
- return onClickTafActionButton(uuid, 'CORRECT');
4486
+ }, [taf, isActive, retrieveTAC]);
4487
+ return /*#__PURE__*/React__default.createElement(Box, {
4488
+ sx: {
4489
+ marginBottom: '20px'
4490
+ },
4491
+ "data-location": location,
4492
+ className: isActive ? 'active' : null
4493
+ }, /*#__PURE__*/React__default.createElement(Box, {
4494
+ sx: {
4495
+ display: 'flex',
4496
+ alignItems: 'center',
4497
+ marginBottom: '2px'
4450
4498
  }
4451
- }, "Correct")), /*#__PURE__*/React__default.createElement(Grid, {
4452
- item: true
4453
- }, canBe.includes('AMENDED') && /*#__PURE__*/React__default.createElement(Button, {
4454
- "data-testid": "amendtaf",
4455
- variant: "outlined",
4456
- color: "secondary",
4457
- onClick: function onClick() {
4458
- return onClickTafActionButton(uuid, 'AMEND');
4499
+ }, /*#__PURE__*/React__default.createElement(Box, {
4500
+ sx: {
4501
+ width: 20,
4502
+ height: 20,
4503
+ display: 'flex',
4504
+ marginRight: '6px'
4505
+ }
4506
+ }, /*#__PURE__*/React__default.createElement(StatusIcon, {
4507
+ timeSlot: timeSlot,
4508
+ status: status
4509
+ })), /*#__PURE__*/React__default.createElement(Typography, {
4510
+ sx: Object.assign({
4511
+ lineHeight: 1
4512
+ }, isActive && {
4513
+ backgroundColor: 'geowebColors.functional.warningHighlight.rgba',
4514
+ padding: '0 2px',
4515
+ marginLeft: '-2px'
4516
+ })
4517
+ }, /*#__PURE__*/React__default.createElement(Typography, {
4518
+ sx: {
4519
+ fontSize: '12px',
4520
+ color: 'geowebColors.captions.captionInformation.rgba'
4521
+ },
4522
+ "data-testid": "tafLocation",
4523
+ component: "span"
4524
+ }, location), /*#__PURE__*/React__default.createElement(Typography, {
4525
+ sx: {
4526
+ fontSize: '12px',
4527
+ marginLeft: '10px'
4528
+ },
4529
+ "data-testid": "tafLocationLabel",
4530
+ component: "span"
4531
+ }, locationLabel))), /*#__PURE__*/React__default.createElement(Box, {
4532
+ sx: {
4533
+ fontSize: '12px',
4534
+ letterSpacing: '0.4px',
4535
+ color: 'geowebColors.captions.captionStatus.rgba'
4459
4536
  }
4460
- }, "Amend")));
4537
+ }, TAC.split('\n').map(function (line) {
4538
+ return /*#__PURE__*/React__default.createElement(Box, {
4539
+ component: "span",
4540
+ key: line,
4541
+ sx: {
4542
+ display: 'inline-block'
4543
+ }
4544
+ }, /*#__PURE__*/React__default.createElement(Box, {
4545
+ component: "span",
4546
+ sx: Object.assign({
4547
+ display: 'inline',
4548
+ boxDecorationBreak: 'clone',
4549
+ WebkitBoxDecorationBreak: 'clone'
4550
+ }, isActive && {
4551
+ backgroundColor: 'geowebColors.functional.warningHighlight.rgba'
4552
+ })
4553
+ }, line));
4554
+ })));
4461
4555
  };
4462
4556
 
4463
- var useStyles$3 = makeStyles({
4464
- accordion: {
4465
- marginBottom: '5px'
4466
- },
4467
- formPadding: {
4468
- padding: '8px'
4469
- },
4470
- expandIcon: {
4471
- color: '#0075a9'
4472
- }
4473
- });
4557
+ var TacOverview = function TacOverview(_ref) {
4558
+ var _ref$upcomingTafs = _ref.upcomingTafs,
4559
+ upcomingTafs = _ref$upcomingTafs === void 0 ? [] : _ref$upcomingTafs,
4560
+ _ref$currentTafs = _ref.currentTafs,
4561
+ currentTafs = _ref$currentTafs === void 0 ? [] : _ref$currentTafs,
4562
+ _ref$expiredTafs = _ref.expiredTafs,
4563
+ expiredTafs = _ref$expiredTafs === void 0 ? [] : _ref$expiredTafs,
4564
+ _ref$hideTitle = _ref.hideTitle,
4565
+ hideTitle = _ref$hideTitle === void 0 ? false : _ref$hideTitle,
4566
+ _ref$activeTaf = _ref.activeTaf,
4567
+ activeTaf = _ref$activeTaf === void 0 ? null : _ref$activeTaf;
4568
+
4569
+ var _React$useState = React__default.useState(0),
4570
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4571
+ activeTab = _React$useState2[0],
4572
+ setActiveTab = _React$useState2[1];
4474
4573
 
4475
- var fromStatusToAction = function fromStatusToAction(tafStatus) {
4476
- switch (tafStatus) {
4477
- case 'DRAFT':
4478
- return 'DRAFT';
4574
+ var scrollRef = React__default.useRef(null);
4575
+ var tabs = [{
4576
+ title: 'Upcoming',
4577
+ tafList: upcomingTafs
4578
+ }, {
4579
+ title: 'Current & Expired',
4580
+ tafList: sortTafsOnLocation([].concat(_toConsumableArray(currentTafs), _toConsumableArray(expiredTafs)))
4581
+ }];
4582
+ var activeLocation = (activeTaf === null || activeTaf === void 0 ? void 0 : activeTaf.taf.location) || null;
4479
4583
 
4480
- case 'DRAFT_AMENDED':
4481
- return 'DRAFT_AMEND';
4584
+ var isActiveLocation = function isActiveLocation(location) {
4585
+ return location === activeLocation;
4586
+ };
4482
4587
 
4483
- case 'DRAFT_CORRECTED':
4484
- return 'DRAFT_CORRECT';
4588
+ var scrollToPosition = React__default.useCallback(function () {
4589
+ if (!scrollRef.current) return;
4590
+ var containerTop = scrollRef.current.getBoundingClientRect().top;
4591
+ var firstLocation = scrollRef.current.querySelector("[data-location=\"".concat(activeLocation, "\"]"));
4592
+ var paddingTop = parseInt(getComputedStyle(scrollRef.current).paddingTop, 10);
4593
+ var newScrollPosition = (firstLocation === null || firstLocation === void 0 ? void 0 : firstLocation.getBoundingClientRect().top) - containerTop + scrollRef.current.scrollTop - paddingTop;
4594
+ scrollRef.current.scrollTo(newScrollPosition, newScrollPosition);
4595
+ }, [activeLocation]);
4596
+
4597
+ var resetScrollPosition = function resetScrollPosition() {
4598
+ return scrollRef.current.scrollTo(0, 0);
4599
+ };
4485
4600
 
4486
- default:
4487
- return 'NEW';
4488
- }
4601
+ var onChangeTab = function onChangeTab(_event, newValue) {
4602
+ setActiveTab(newValue);
4603
+ resetScrollPosition();
4604
+ };
4605
+
4606
+ React__default.useEffect(function () {
4607
+ if (activeLocation) {
4608
+ scrollToPosition();
4609
+ }
4610
+ }, [activeLocation, scrollToPosition]);
4611
+ React__default.useEffect(function () {
4612
+ var SCROLL_DELAY = 1000;
4613
+ var timer = setTimeout(function () {
4614
+ scrollToPosition();
4615
+ }, SCROLL_DELAY);
4616
+ return function () {
4617
+ clearTimeout(timer);
4618
+ };
4619
+ }, [activeTab, scrollToPosition]);
4620
+ return /*#__PURE__*/React__default.createElement(Card, {
4621
+ variant: "outlined",
4622
+ sx: {
4623
+ maxHeight: '100%',
4624
+ overflow: 'hidden',
4625
+ display: 'flex',
4626
+ flexDirection: 'column'
4627
+ }
4628
+ }, /*#__PURE__*/React__default.createElement(Box, {
4629
+ sx: {
4630
+ zIndex: 1
4631
+ }
4632
+ }, !hideTitle && /*#__PURE__*/React__default.createElement(TafHeader, {
4633
+ title: "TAC Overview"
4634
+ }), /*#__PURE__*/React__default.createElement(Tabs, {
4635
+ value: activeTab,
4636
+ onChange: onChangeTab,
4637
+ "aria-label": "tabs"
4638
+ }, tabs.map(function (tab, index) {
4639
+ return /*#__PURE__*/React__default.createElement(Tab, Object.assign({
4640
+ key: tab.title,
4641
+ sx: {
4642
+ flexGrow: 1
4643
+ },
4644
+ label: tab.title,
4645
+ "data-testid": "tab-".concat(index)
4646
+ }, muiTabA11yProps(index)));
4647
+ }))), /*#__PURE__*/React__default.createElement(Box, {
4648
+ ref: scrollRef,
4649
+ sx: {
4650
+ padding: '10px',
4651
+ maxHeight: '100%',
4652
+ overflow: 'auto'
4653
+ }
4654
+ }, tabs.map(function (tab, index) {
4655
+ return /*#__PURE__*/React__default.createElement(TabPanel, {
4656
+ key: tab.title,
4657
+ value: activeTab,
4658
+ index: index
4659
+ }, tab.tafList.map(function (_ref2) {
4660
+ var taf = _ref2.taf;
4661
+ return /*#__PURE__*/React__default.createElement(TacContainer, {
4662
+ key: taf.uuid,
4663
+ taf: taf,
4664
+ isActive: isActiveLocation(taf.location)
4665
+ });
4666
+ }));
4667
+ })));
4489
4668
  };
4490
4669
 
4491
- var TafListAccordion = function TafListAccordion(_ref) {
4492
- var tafListItem = _ref.tafListItem,
4493
- listType = _ref.listType,
4494
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4495
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4496
- onClickTafActionButton = _ref.onClickTafActionButton;
4497
- var classes = useStyles$3();
4498
- var status = tafListItem.taf.status;
4670
+ var TacOverviewIcon = /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
4671
+ d: "M3 3h4v4H3V3zm0 7h4v4H3v-4zm0 7h4v4H3v-4zm7-14h11v4H10V3zm0 7h11v4H10v-4zm0 7h11v4H10v-4z"
4672
+ }));
4499
4673
 
4500
- var _useApiContext = useApiContext(),
4501
- api = _useApiContext.api;
4674
+ var TacOverviewMobile = function TacOverviewMobile(_ref) {
4675
+ var upcomingTafs = _ref.upcomingTafs,
4676
+ currentTafs = _ref.currentTafs,
4677
+ expiredTafs = _ref.expiredTafs,
4678
+ activeTaf = _ref.activeTaf,
4679
+ _ref$defaultOpen = _ref.defaultOpen,
4680
+ defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen;
4502
4681
 
4503
- var _useTACGenerator = useTACGenerator(tafListItem.taf, api.getTAC),
4504
- _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
4505
- TAC = _useTACGenerator2[0],
4506
- requestTAC = _useTACGenerator2[1];
4682
+ var _React$useState = React.useState(defaultOpen),
4683
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4684
+ isOpen = _React$useState2[0],
4685
+ toggleOpen = _React$useState2[1];
4507
4686
 
4508
- React__default.useEffect(function () {
4509
- // only re-retrieve TAC if draft state
4510
- if (tafListItem.taf.status === 'DRAFT' || tafListItem.taf.status === 'DRAFT_AMENDED' || tafListItem.taf.status === 'DRAFT_CORRECTED') {
4511
- requestTAC(tafListItem.taf);
4512
- } // eslint-disable-next-line react-hooks/exhaustive-deps
4687
+ var onClose = function onClose() {
4688
+ return toggleOpen(false);
4689
+ };
4513
4690
 
4514
- }, [tafListItem.taf]);
4515
- var popOut = status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED';
4516
- return /*#__PURE__*/React__default.createElement(Accordion, Object.assign({
4517
- "data-testid": "tafListItem",
4518
- className: classes.accordion
4519
- }, popOut ? {
4520
- expanded: false
4521
- } : {}, {
4691
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolButton, {
4692
+ active: isOpen,
4522
4693
  onClick: function onClick() {
4523
- if (popOut) {
4524
- onClickTafActionButton(tafListItem.taf.uuid, fromStatusToAction(tafListItem.taf.status));
4525
- }
4694
+ return toggleOpen(true);
4526
4695
  },
4527
- TransitionProps: {
4528
- unmountOnExit: true
4696
+ "data-testid": "tac-overview-mobile-button",
4697
+ sx: {
4698
+ display: {
4699
+ xs: 'inline-flex',
4700
+ sm: 'none'
4701
+ },
4702
+ position: 'absolute',
4703
+ right: '8px',
4704
+ top: '30px'
4529
4705
  }
4530
- }), /*#__PURE__*/React__default.createElement(AccordionSummary, {
4531
- "data-testid": "tafListSectionAccordionSummary",
4532
- expandIcon: popOut ? /*#__PURE__*/React__default.createElement(Tooltip, {
4533
- title: "Popout to edit",
4534
- className: classes.expandIcon
4535
- }, /*#__PURE__*/React__default.createElement(OpenInNew, {
4536
- "data-testid": "popOutIcon",
4537
- fontSize: "small"
4538
- })) : /*#__PURE__*/React__default.createElement(ExpandMore, {
4539
- className: classes.expandIcon,
4540
- "data-testid": "expandIcon"
4541
- })
4542
- }, /*#__PURE__*/React__default.createElement(TafListRow, {
4543
- taf: tafListItem.taf,
4544
- listType: listType,
4545
- TAC: TAC,
4546
- showTac: true
4547
- })), /*#__PURE__*/React__default.createElement(AccordionDetails, null, /*#__PURE__*/React__default.createElement(Grid, {
4548
- container: true,
4549
- direction: "column"
4550
- }, errorCancelTaf.length > 0 && errorCancelTaf.find(function (uuid) {
4551
- return uuid === tafListItem.taf.uuid;
4552
- }) && /*#__PURE__*/React__default.createElement(AlertBanner, {
4553
- severity: "error",
4554
- title: "Cancelling this TAF failed, please try again",
4555
- dataTestId: "tafList-cancelAlert"
4556
- }), /*#__PURE__*/React__default.createElement("div", {
4557
- className: classes.formPadding
4558
- }, /*#__PURE__*/React__default.createElement(Grid, {
4559
- item: true
4560
- }, /*#__PURE__*/React__default.createElement(TafFormWrapper, {
4561
- tafFromBackend: tafListItem,
4562
- mode: "view",
4563
- TAC: TAC
4564
- })), /*#__PURE__*/React__default.createElement(Grid, {
4565
- item: true
4566
- }, /*#__PURE__*/React__default.createElement(TafListButtons, {
4567
- canBe: tafListItem.canbe,
4568
- uuid: tafListItem.taf.uuid,
4569
- onClickTafActionButton: onClickTafActionButton
4570
- }))))));
4706
+ }, TacOverviewIcon), /*#__PURE__*/React.createElement(Dialog, {
4707
+ open: isOpen,
4708
+ onClose: onClose,
4709
+ PaperProps: {
4710
+ sx: {
4711
+ margin: 2,
4712
+ width: '100%',
4713
+ height: '100%'
4714
+ }
4715
+ },
4716
+ "data-testid": "tac-overview-mobile"
4717
+ }, /*#__PURE__*/React.createElement(ToolHeader, {
4718
+ title: "TAC Overview",
4719
+ size: "small",
4720
+ isDraggable: false,
4721
+ onClose: onClose
4722
+ }), /*#__PURE__*/React.createElement(TacOverview, {
4723
+ upcomingTafs: upcomingTafs,
4724
+ currentTafs: currentTafs,
4725
+ expiredTafs: expiredTafs,
4726
+ activeTaf: activeTaf,
4727
+ hideTitle: true
4728
+ })));
4571
4729
  };
4572
4730
 
4573
4731
  /* *
@@ -4583,136 +4741,131 @@ var TafListAccordion = function TafListAccordion(_ref) {
4583
4741
  * See the License for the specific language governing permissions and
4584
4742
  * limitations under the License.
4585
4743
  *
4586
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4587
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4744
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4745
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4588
4746
  * */
4589
- var useStyles$2 = makeStyles({
4590
- listHeaders: {
4591
- color: '#9d9d9d'
4592
- },
4593
- formPadding: {
4594
- padding: '8px'
4595
- },
4596
- paperButton: {
4597
- width: '100%'
4598
- }
4599
- });
4600
-
4601
- var TafListSection = function TafListSection(_ref) {
4602
- var tafList = _ref.tafList,
4603
- title = _ref.title,
4604
- listType = _ref.listType,
4605
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4606
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4607
- onClickTafActionButton = _ref.onClickTafActionButton;
4608
- var classes = useStyles$2();
4609
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Typography, {
4610
- variant: "subtitle2",
4611
- className: classes.listHeaders
4612
- }, title), /*#__PURE__*/React__default.createElement("div", {
4613
- "data-testid": "tafList".concat(listType)
4614
- }, tafList.map(function (tafListItem) {
4615
- return /*#__PURE__*/React__default.createElement(TafListAccordion, {
4616
- key: "".concat(tafListItem.taf.uuid, "-").concat(tafListItem.taf.status),
4617
- tafListItem: tafListItem,
4618
- listType: listType,
4619
- errorCancelTaf: errorCancelTaf,
4620
- onClickTafActionButton: onClickTafActionButton
4621
- });
4622
- })));
4747
+ var formatBaseTime = function formatBaseTime(time) {
4748
+ return time.format('HH:mm DD MMM');
4623
4749
  };
4624
4750
 
4625
- var useStyles$1 = makeStyles({
4626
- accordion: {
4627
- marginBottom: '5px'
4628
- },
4629
- listHeaders: {
4630
- color: '#9d9d9d'
4631
- },
4632
- listBody: {
4633
- width: '100%',
4634
- minHeight: '600px'
4751
+ var TopTabs = function TopTabs(_ref) {
4752
+ var timeSlot = _ref.timeSlot,
4753
+ _ref$onChangeTimeSlot = _ref.onChangeTimeSlot,
4754
+ onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot,
4755
+ tafFromBackend = _ref.tafFromBackend;
4756
+
4757
+ if (!tafFromBackend) {
4758
+ return null;
4635
4759
  }
4636
- });
4637
4760
 
4638
- var TafList = function TafList(_ref) {
4639
- var tafList = _ref.tafList,
4640
- isLoading = _ref.isLoading,
4641
- error = _ref.error,
4642
- _ref$errorCancelTaf = _ref.errorCancelTaf,
4643
- errorCancelTaf = _ref$errorCancelTaf === void 0 ? [] : _ref$errorCancelTaf,
4644
- onClickTafActionButton = _ref.onClickTafActionButton;
4645
- var classes = useStyles$1();
4761
+ var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
4646
4762
 
4647
- var _useTafSettings = useTafSettings(tafConfig),
4648
- locationSettings = _useTafSettings.locations;
4763
+ var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
4764
+ currentBaseTime = _getBaseTime.currentBaseTime,
4765
+ nextBaseTime = _getBaseTime.nextBaseTime;
4649
4766
 
4650
- var upcomingTafs = [];
4651
- var currentTafs = [];
4652
- var expiredTafs = [];
4767
+ var tabs = [{
4768
+ title: "Upcoming ".concat(formatBaseTime(nextBaseTime)),
4769
+ timeSlot: 'UPCOMING'
4770
+ }, {
4771
+ title: "Current ".concat(formatBaseTime(currentBaseTime)),
4772
+ timeSlot: 'ACTIVE'
4773
+ }];
4653
4774
 
4654
- if (tafList) {
4655
- var _iterator = _createForOfIteratorHelper(tafList),
4656
- _step;
4775
+ var onChangeTab = function onChangeTab(_event, newValue) {
4776
+ onChangeTimeSlot(tabs[newValue].timeSlot);
4777
+ };
4657
4778
 
4658
- try {
4659
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
4660
- var taf = _step.value;
4661
- var now = moment.utc();
4662
- var baseTime = moment.utc(taf.taf.baseTime);
4663
- var activityPeriod = locationSettings[taf.taf.location].activity_period;
4664
- var nextBaseTime = moment.utc(taf.taf.baseTime).add(activityPeriod, 'hours');
4665
-
4666
- if (taf.taf.status === 'EXPIRED') {
4667
- expiredTafs.push(taf);
4668
- } else if (baseTime < now && nextBaseTime > now) {
4669
- currentTafs.push(taf);
4670
- } else {
4671
- upcomingTafs.push(taf);
4672
- }
4779
+ return /*#__PURE__*/React__default.createElement(Tabs, {
4780
+ value: activeTab,
4781
+ onChange: onChangeTab,
4782
+ "aria-label": "timeslot-tabs",
4783
+ variant: "fullWidth"
4784
+ }, tabs.map(function (tab, index) {
4785
+ return /*#__PURE__*/React__default.createElement(Tab, Object.assign({
4786
+ key: tab.title,
4787
+ label: tab.title,
4788
+ "data-testid": "tab-".concat(index),
4789
+ sx: {
4790
+ fontSize: 16
4673
4791
  }
4674
- } catch (err) {
4675
- _iterator.e(err);
4676
- } finally {
4677
- _iterator.f();
4678
- }
4679
- }
4792
+ }, muiTabA11yProps(index)));
4793
+ }));
4794
+ };
4680
4795
 
4681
- return /*#__PURE__*/React__default.createElement(Grid, {
4682
- container: true,
4683
- direction: "column",
4684
- alignItems: "stretch"
4685
- }, /*#__PURE__*/React__default.createElement(Grid, {
4686
- item: true,
4687
- className: classes.listBody
4688
- }, error && /*#__PURE__*/React__default.createElement(AlertBanner, {
4689
- severity: "error",
4690
- title: "An error has occurred while retrieving the list, please try again",
4691
- info: error.message ? error.message : '',
4692
- dataTestId: "tafList-alert"
4693
- }), tafList && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafListSection, {
4694
- title: "Upcoming",
4695
- listType: "UPCOMING",
4696
- tafList: upcomingTafs,
4697
- errorCancelTaf: errorCancelTaf,
4698
- onClickTafActionButton: onClickTafActionButton
4699
- }), /*#__PURE__*/React__default.createElement(TafListSection, {
4700
- title: "Current time slot",
4701
- listType: "ACTIVE",
4702
- tafList: currentTafs,
4703
- errorCancelTaf: errorCancelTaf,
4704
- onClickTafActionButton: onClickTafActionButton
4705
- }), /*#__PURE__*/React__default.createElement(TafListSection, {
4706
- title: "Expired",
4707
- listType: "EXPIRED",
4708
- tafList: expiredTafs,
4709
- errorCancelTaf: errorCancelTaf,
4710
- onClickTafActionButton: onClickTafActionButton
4711
- })), isLoading && /*#__PURE__*/React__default.createElement(Skeleton, {
4712
- "data-testid": "tafList-skeleton",
4713
- variant: "rectangular",
4714
- height: "660px"
4715
- })));
4796
+ /* *
4797
+ * Licensed under the Apache License, Version 2.0 (the "License");
4798
+ * you may not use this file except in compliance with the License.
4799
+ * You may obtain a copy of the License at
4800
+ *
4801
+ * http://www.apache.org/licenses/LICENSE-2.0
4802
+ *
4803
+ * Unless required by applicable law or agreed to in writing, software
4804
+ * distributed under the License is distributed on an "AS IS" BASIS,
4805
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4806
+ * See the License for the specific language governing permissions and
4807
+ * limitations under the License.
4808
+ *
4809
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4810
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4811
+ * */
4812
+
4813
+ var LocationTabs = function LocationTabs(_ref) {
4814
+ var tafList = _ref.tafList,
4815
+ _ref$activeIndex = _ref.activeIndex,
4816
+ activeIndex = _ref$activeIndex === void 0 ? 0 : _ref$activeIndex,
4817
+ _ref$onChangeTab = _ref.onChangeTab,
4818
+ onChangeTab = _ref$onChangeTab === void 0 ? function () {} : _ref$onChangeTab,
4819
+ timeSlot = _ref.timeSlot;
4820
+ return /*#__PURE__*/React.createElement(MenuList, {
4821
+ "data-testid": "location-tabs",
4822
+ sx: {
4823
+ paddingTop: '32px'
4824
+ }
4825
+ }, tafList.map(function (_ref2, index) {
4826
+ var taf = _ref2.taf;
4827
+ return /*#__PURE__*/React.createElement(MenuItem, {
4828
+ key: taf.uuid,
4829
+ selected: index === activeIndex,
4830
+ sx: {
4831
+ backgroundColor: 'geowebColors.cards.cardContainer',
4832
+ borderColor: 'geowebColors.cards.cardContainerBorder',
4833
+ borderWidth: '1px',
4834
+ borderStyle: 'solid',
4835
+ margin: '0 0 4px',
4836
+ height: '56px',
4837
+ justifyContent: 'center',
4838
+ ':after': {
4839
+ background: 'none!important'
4840
+ },
4841
+ '&.Mui-selected': {
4842
+ backgroundColor: 'geowebColors.cards.cardContainer',
4843
+ marginRight: '-17px',
4844
+ borderRight: '0px',
4845
+ zIndex: 1
4846
+ }
4847
+ },
4848
+ onClick: function onClick() {
4849
+ return onChangeTab(index);
4850
+ }
4851
+ }, /*#__PURE__*/React.createElement(Box$1, {
4852
+ component: "span",
4853
+ sx: {
4854
+ fontSize: '12px',
4855
+ fontWeight: '500',
4856
+ letterSpacing: '0.09px',
4857
+ '& + svg': {
4858
+ position: 'absolute',
4859
+ bottom: '1px',
4860
+ width: '20px',
4861
+ height: '20px'
4862
+ }
4863
+ }
4864
+ }, taf.location), /*#__PURE__*/React.createElement(StatusIcon, {
4865
+ timeSlot: timeSlot,
4866
+ status: taf.status
4867
+ }));
4868
+ }));
4716
4869
  };
4717
4870
 
4718
4871
  /* *
@@ -4731,285 +4884,434 @@ var TafList = function TafList(_ref) {
4731
4884
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4732
4885
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
4733
4886
  * */
4734
- var useStyles = makeStyles({
4735
- backdrop: {
4736
- zIndex: 1500,
4737
- color: '#fff'
4738
- }
4739
- });
4740
4887
 
4741
- var Spinner = function Spinner() {
4742
- var classes = useStyles();
4743
- return /*#__PURE__*/React__default.createElement(Backdrop, {
4744
- open: true,
4745
- className: classes.backdrop
4746
- }, /*#__PURE__*/React__default.createElement(CircularProgress, {
4888
+ var Spinner = function Spinner(props) {
4889
+ return /*#__PURE__*/React__default.createElement(Backdrop, Object.assign({
4890
+ open: true
4891
+ }, props), /*#__PURE__*/React__default.createElement(CircularProgress, {
4747
4892
  "data-testid": "spinner",
4748
4893
  color: "inherit"
4749
4894
  }));
4750
4895
  };
4751
4896
 
4752
- var useTimeoutCancelError = function useTimeoutCancelError() {
4753
- var pollingInterval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10000;
4754
-
4755
- var _React$useState = React__default.useState([]),
4756
- _React$useState2 = _slicedToArray(_React$useState, 2),
4757
- errorCancelTaf = _React$useState2[0],
4758
- setErrorCancelTaf = _React$useState2[1];
4759
-
4760
- React__default.useEffect(function () {
4761
- var cancelErrorMessageHandler = errorCancelTaf.length > 0 ? setTimeout(function () {
4762
- if (errorCancelTaf.length > 0) {
4763
- setErrorCancelTaf(errorCancelTaf.slice(1));
4764
- }
4765
- }, pollingInterval) : null;
4766
- return function () {
4767
- if (cancelErrorMessageHandler !== null) {
4768
- clearTimeout(cancelErrorMessageHandler);
4769
- }
4770
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
4771
- }, [errorCancelTaf]);
4772
- return [errorCancelTaf, setErrorCancelTaf];
4773
- };
4774
- var getSelectedTaf = function getSelectedTaf(selectedTafId, tafList) {
4775
- if (tafList === null) return undefined;
4776
- return tafList.find(function (element) {
4777
- return element.taf.uuid === selectedTafId;
4778
- });
4779
- };
4780
-
4781
- var TafWrapper = function TafWrapper() {
4782
- var _useApiContext = useApiContext(),
4783
- api = _useApiContext.api;
4784
-
4785
- var confirmDialog = useConfirmationDialog();
4786
-
4787
- var _React$useState3 = React__default.useState(false),
4788
- _React$useState4 = _slicedToArray(_React$useState3, 2),
4789
- isTafDialogOpen = _React$useState4[0],
4790
- setTafDialogOpen = _React$useState4[1];
4897
+ var fromActionToStatus = function fromActionToStatus(tafAction) {
4898
+ switch (tafAction) {
4899
+ case 'DRAFT':
4900
+ return 'DRAFT';
4791
4901
 
4792
- var _React$useState5 = React__default.useState(null),
4793
- _React$useState6 = _slicedToArray(_React$useState5, 2),
4794
- selectedTafId = _React$useState6[0],
4795
- setselectedTafId = _React$useState6[1];
4902
+ case 'DRAFT_AMEND':
4903
+ return 'DRAFT_AMENDED';
4796
4904
 
4797
- var _React$useState7 = React__default.useState(null),
4798
- _React$useState8 = _slicedToArray(_React$useState7, 2),
4799
- tafDialogAction = _React$useState8[0],
4800
- setTafDialogAction = _React$useState8[1];
4905
+ case 'DRAFT_CORRECT':
4906
+ return 'DRAFT_CORRECTED';
4801
4907
 
4802
- var _React$useState9 = React__default.useState(false),
4803
- _React$useState10 = _slicedToArray(_React$useState9, 2),
4804
- errorPostMessage = _React$useState10[0],
4805
- setErrorPostMessage = _React$useState10[1];
4806
-
4807
- var _React$useState11 = React__default.useState(''),
4808
- _React$useState12 = _slicedToArray(_React$useState11, 2),
4809
- errorPostMessageText = _React$useState12[0],
4810
- setErrorPostMessageText = _React$useState12[1];
4908
+ case 'PUBLISH':
4909
+ return 'PUBLISHED';
4811
4910
 
4812
- var _React$useState13 = React__default.useState(false),
4813
- _React$useState14 = _slicedToArray(_React$useState13, 2),
4814
- showSpinner = _React$useState14[0],
4815
- setSpinner = _React$useState14[1]; // clear error message for cancel after 10 seconds
4911
+ case 'AMEND':
4912
+ return 'AMENDED';
4816
4913
 
4914
+ case 'CORRECT':
4915
+ return 'CORRECTED';
4817
4916
 
4818
- var _useTimeoutCancelErro = useTimeoutCancelError(),
4819
- _useTimeoutCancelErro2 = _slicedToArray(_useTimeoutCancelErro, 2),
4820
- errorCancelTaf = _useTimeoutCancelErro2[0],
4821
- setErrorCancelTaf = _useTimeoutCancelErro2[1]; // Retrieve list of tafs
4917
+ case 'CANCEL':
4918
+ return 'CANCELLED';
4822
4919
 
4920
+ default:
4921
+ return 'NEW';
4922
+ }
4923
+ };
4823
4924
 
4824
- var _useApi = useApi(api.getTafList),
4825
- errorList = _useApi.error,
4826
- isLoadingList = _useApi.isLoading,
4827
- tafList = _useApi.result,
4828
- fetchNewTafList = _useApi.fetchApiData;
4925
+ var TafPanel = function TafPanel(_ref) {
4926
+ var tafFromBackend = _ref.tafFromBackend,
4927
+ activeTafIndex = _ref.activeTafIndex,
4928
+ index = _ref.index,
4929
+ _ref$onPostTaf = _ref.onPostTaf,
4930
+ onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
4829
4931
 
4830
- var getNewTafList = function getNewTafList() {
4831
- fetchNewTafList({});
4832
- };
4932
+ var _useApiContext = useApiContext(),
4933
+ api = _useApiContext.api;
4833
4934
 
4834
- usePoller([tafList, errorList], getNewTafList);
4935
+ var _React$useState = React__default.useState(false),
4936
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4937
+ isLoading = _React$useState2[0],
4938
+ setLoading = _React$useState2[1];
4835
4939
 
4836
- var toggleTafDialog = function toggleTafDialog() {
4837
- // Refresh list on closing dialog
4838
- if (isTafDialogOpen === true) getNewTafList(); // Set error message back to false
4940
+ var _React$useState3 = React__default.useState(null),
4941
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
4942
+ error = _React$useState4[0],
4943
+ setError = _React$useState4[1]; // removes cancelled error message
4839
4944
 
4840
- setErrorPostMessage(false);
4841
- setErrorPostMessageText('');
4842
- setTafDialogOpen(!isTafDialogOpen);
4843
- };
4844
4945
 
4845
4946
  React__default.useEffect(function () {
4846
- if (selectedTafId) {
4847
- toggleTafDialog();
4848
- } // eslint-disable-next-line react-hooks/exhaustive-deps
4849
-
4850
- }, [selectedTafId]);
4851
-
4852
- var onClickTafActionButton = function onClickTafActionButton(tafUuid, action) {
4853
- if (action === 'CANCEL') {
4854
- confirmDialog({
4855
- title: 'Cancel TAF',
4856
- description: 'Are you sure you want to cancel this TAF?',
4857
- confirmLabel: 'Cancel'
4858
- }).then(function () {
4859
- var _getSelectedTaf = getSelectedTaf(tafUuid, tafList),
4860
- taf = _getSelectedTaf.taf;
4861
-
4862
- postTaf({
4863
- taf: taf,
4864
- changeStatusTo: 'CANCELLED'
4865
- });
4866
- });
4867
- } else if (selectedTafId === tafUuid) {
4868
- setTafDialogAction(action);
4869
- toggleTafDialog();
4870
- } else {
4871
- setTafDialogAction(action);
4872
- setselectedTafId(tafUuid);
4873
- }
4874
- };
4947
+ var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
4948
+ setError(null);
4949
+ }, 10000) : null;
4950
+ return function () {
4951
+ if (cancelErrorTimeout !== null) {
4952
+ clearTimeout(cancelErrorTimeout);
4953
+ }
4954
+ };
4955
+ }, [error]);
4875
4956
 
4876
4957
  var postTaf = function postTaf(data) {
4877
4958
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4959
+ var newError;
4878
4960
  return regeneratorRuntime.wrap(function _callee$(_context) {
4879
4961
  while (1) {
4880
4962
  switch (_context.prev = _context.next) {
4881
4963
  case 0:
4882
- setSpinner(true);
4883
- _context.prev = 1;
4964
+ _context.prev = 0;
4965
+ setLoading(true);
4884
4966
  _context.next = 4;
4885
4967
  return api.postTaf(data);
4886
4968
 
4887
4969
  case 4:
4888
- if (isTafDialogOpen) toggleTafDialog();
4889
- setSpinner(false); // fetch new taflist
4970
+ setLoading(false);
4971
+ setError(null); // callback
4890
4972
 
4891
- getNewTafList(); // If a post has succeeded remove error message
4973
+ onPostTaf();
4974
+ _context.next = 15;
4975
+ break;
4892
4976
 
4893
- setErrorCancelTaf([]);
4894
- _context.next = 14;
4977
+ case 9:
4978
+ _context.prev = 9;
4979
+ _context.t0 = _context["catch"](0);
4980
+ newError = data.changeStatusTo === 'CANCELLED' ? {
4981
+ type: 'CANCELLED',
4982
+ title: 'Cancelling this TAF failed, please try again'
4983
+ } : {
4984
+ type: 'SERVER',
4985
+ title: 'An error has occurred while saving, please try again',
4986
+ message: getAxiosErrorMessage(_context.t0)
4987
+ };
4988
+ setError(newError);
4989
+ setLoading(false);
4990
+ throw _context.t0;
4991
+
4992
+ case 15:
4993
+ case "end":
4994
+ return _context.stop();
4995
+ }
4996
+ }
4997
+ }, _callee, null, [[0, 9]]);
4998
+ }));
4999
+ };
5000
+
5001
+ var getViewMode = function getViewMode(status) {
5002
+ return status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED' ? 'edit' : 'view';
5003
+ };
5004
+
5005
+ var onTafAction = function onTafAction(action, taf) {
5006
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
5007
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
5008
+ while (1) {
5009
+ switch (_context2.prev = _context2.next) {
5010
+ case 0:
5011
+ _context2.prev = 0;
5012
+ _context2.t0 = action;
5013
+ _context2.next = _context2.t0 === 'DRAFT' ? 4 : _context2.t0 === 'DRAFT_AMEND' ? 4 : _context2.t0 === 'DRAFT_CORRECT' ? 4 : _context2.t0 === 'PUBLISH' ? 4 : _context2.t0 === 'AMEND' ? 4 : _context2.t0 === 'CANCEL' ? 4 : _context2.t0 === 'CORRECT' ? 4 : 7;
4895
5014
  break;
4896
5015
 
4897
- case 10:
4898
- _context.prev = 10;
4899
- _context.t0 = _context["catch"](1);
5016
+ case 4:
5017
+ _context2.next = 6;
5018
+ return postTaf({
5019
+ taf: taf,
5020
+ changeStatusTo: fromActionToStatus(action)
5021
+ });
4900
5022
 
4901
- if (data.changeStatusTo === 'CANCELLED') {
4902
- setErrorCancelTaf([].concat(_toConsumableArray(errorCancelTaf), [data.taf.uuid]));
4903
- } else {
4904
- setErrorPostMessage(true);
5023
+ case 6:
5024
+ return _context2.abrupt("return", true);
4905
5025
 
4906
- if (isAxiosError(_context.t0)) {
4907
- setErrorPostMessageText(getAxiosErrorMessage(_context.t0));
4908
- }
4909
- }
5026
+ case 7:
5027
+ return _context2.abrupt("return", false);
4910
5028
 
4911
- setSpinner(false);
5029
+ case 8:
5030
+ _context2.next = 13;
5031
+ break;
5032
+
5033
+ case 10:
5034
+ _context2.prev = 10;
5035
+ _context2.t1 = _context2["catch"](0);
5036
+ return _context2.abrupt("return", false);
4912
5037
 
4913
- case 14:
5038
+ case 13:
4914
5039
  case "end":
4915
- return _context.stop();
5040
+ return _context2.stop();
4916
5041
  }
4917
5042
  }
4918
- }, _callee, null, [[1, 10]]);
5043
+ }, _callee2, null, [[0, 10]]);
4919
5044
  }));
4920
5045
  };
4921
5046
 
4922
- var fromActionToStatus = function fromActionToStatus(tafAction) {
4923
- switch (tafAction) {
4924
- case 'DRAFT':
4925
- return 'DRAFT';
5047
+ return /*#__PURE__*/React__default.createElement(TabPanel, {
5048
+ value: activeTafIndex,
5049
+ index: index,
5050
+ "data-testid": "taf-panel".concat(activeTafIndex === index ? '-active' : '')
5051
+ }, /*#__PURE__*/React__default.createElement(TafHeader, {
5052
+ title: getTafStatusLabel(tafFromBackend.taf.status)
5053
+ }), isLoading && /*#__PURE__*/React__default.createElement(Spinner, {
5054
+ "data-testid": "taf-loading",
5055
+ sx: {
5056
+ position: 'absolute',
5057
+ zIndex: 1,
5058
+ color: 'geowebColors.backdrops.white.fill'
5059
+ }
5060
+ }), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
5061
+ severity: "error",
5062
+ title: error.title,
5063
+ info: error.message,
5064
+ dataTestId: "taf-error"
5065
+ }), /*#__PURE__*/React__default.createElement(TafFormWrapper, {
5066
+ mode: getViewMode(tafFromBackend.taf.status),
5067
+ tafFromBackend: tafFromBackend,
5068
+ onFormAction: onTafAction
5069
+ }));
5070
+ };
4926
5071
 
4927
- case 'DRAFT_AMEND':
4928
- return 'DRAFT_AMENDED';
5072
+ var TafLayout = function TafLayout(_ref) {
5073
+ var _ref$tafList = _ref.tafList,
5074
+ tafList = _ref$tafList === void 0 ? [] : _ref$tafList,
5075
+ _ref$onPostTaf = _ref.onPostTaf,
5076
+ onPostTaf = _ref$onPostTaf === void 0 ? function () {} : _ref$onPostTaf;
4929
5077
 
4930
- case 'DRAFT_CORRECT':
4931
- return 'DRAFT_CORRECTED';
5078
+ var _React$useState = React__default.useState(sortTafTimeSlots(tafList)),
5079
+ _React$useState2 = _slicedToArray(_React$useState, 2),
5080
+ _React$useState2$ = _React$useState2[0],
5081
+ upcoming = _React$useState2$.upcoming,
5082
+ current = _React$useState2$.current,
5083
+ expired = _React$useState2$.expired,
5084
+ updateSortedTafs = _React$useState2[1];
4932
5085
 
4933
- case 'PUBLISH':
4934
- return 'PUBLISHED';
5086
+ var _upcoming$slice = upcoming.slice(-1),
5087
+ _upcoming$slice2 = _slicedToArray(_upcoming$slice, 1),
5088
+ lastUpcomingTaf = _upcoming$slice2[0];
4935
5089
 
4936
- case 'AMEND':
4937
- return 'AMENDED';
5090
+ var _React$useState3 = React__default.useState('UPCOMING'),
5091
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
5092
+ timeSlot = _React$useState4[0],
5093
+ setTimeSlot = _React$useState4[1];
4938
5094
 
4939
- case 'CORRECT':
4940
- return 'CORRECTED';
5095
+ var _React$useState5 = React__default.useState(upcoming),
5096
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
5097
+ locations = _React$useState6[0],
5098
+ setLocations = _React$useState6[1];
4941
5099
 
4942
- default:
4943
- return 'NEW';
4944
- }
5100
+ var _React$useState7 = React__default.useState(0),
5101
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
5102
+ activeTafIndex = _React$useState8[0],
5103
+ setActiveTafIndex = _React$useState8[1];
5104
+
5105
+ var onChangeTimeSlot = function onChangeTimeSlot(newTimeSlot) {
5106
+ setTimeSlot(newTimeSlot);
5107
+ setLocations(newTimeSlot === 'ACTIVE' ? current : upcoming);
5108
+ setActiveTafIndex(0);
4945
5109
  };
4946
5110
 
4947
- var onFormAction = function onFormAction(action, taf) {
4948
- // Add right actions and their follow up calls to the BE
4949
- switch (action) {
4950
- case 'CLOSE':
4951
- confirmDialog({
4952
- title: 'Closing TAF',
4953
- description: 'Are you sure you want to close this TAF? Any changes made will be lost.',
4954
- confirmLabel: 'Close'
4955
- }).then(function () {
4956
- toggleTafDialog();
4957
- });
4958
- break;
5111
+ React__default.useEffect(function () {
5112
+ var newSortedTafs = sortTafTimeSlots(tafList);
5113
+ var updatedLocations = timeSlot === 'ACTIVE' ? newSortedTafs.current : newSortedTafs.upcoming;
5114
+ updateSortedTafs(sortTafTimeSlots(tafList));
5115
+ setLocations(updatedLocations); // update active index
4959
5116
 
4960
- case 'DRAFT':
4961
- case 'DRAFT_AMEND':
4962
- case 'DRAFT_CORRECT':
4963
- case 'PUBLISH':
4964
- case 'AMEND':
4965
- case 'CORRECT':
4966
- postTaf({
4967
- taf: taf,
4968
- changeStatusTo: fromActionToStatus(action)
4969
- });
4970
- break;
5117
+ var newActiveIndex = updatedLocations.findIndex(function (location) {
5118
+ return location.taf.previousId === locations[activeTafIndex].taf.uuid;
5119
+ });
5120
+ var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
5121
+ setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5122
+ }, [tafList, setLocations]);
4971
5123
 
4972
- default:
4973
- toggleTafDialog();
4974
- break;
5124
+ if (!tafList) {
5125
+ return null;
5126
+ }
5127
+
5128
+ var activeTaf = locations[activeTafIndex];
5129
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
5130
+ id: MODAL_DIALOG_ELEMENT,
5131
+ component: "div",
5132
+ sx: {
5133
+ width: '100%',
5134
+ height: '100%',
5135
+ position: 'absolute',
5136
+ overflow: 'hidden',
5137
+ pointerEvents: 'none'
5138
+ }
5139
+ }), /*#__PURE__*/React__default.createElement(Box, {
5140
+ sx: {
5141
+ height: '100%',
5142
+ maxHeight: '100%'
5143
+ }
5144
+ }, /*#__PURE__*/React__default.createElement(Box, {
5145
+ sx: {
5146
+ minWidth: 320,
5147
+ maxWidth: 1272,
5148
+ margin: 'auto',
5149
+ height: '100%',
5150
+ display: 'flex',
5151
+ flexDirection: 'column'
5152
+ }
5153
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5154
+ container: true,
5155
+ spacing: 2,
5156
+ sx: {
5157
+ paddingLeft: 1,
5158
+ paddingRight: 1
5159
+ }
5160
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5161
+ item: true,
5162
+ xs: 12,
5163
+ sm: 9
5164
+ }, /*#__PURE__*/React__default.createElement(TopTabs, {
5165
+ tafFromBackend: lastUpcomingTaf,
5166
+ timeSlot: timeSlot,
5167
+ onChangeTimeSlot: onChangeTimeSlot
5168
+ }))), /*#__PURE__*/React__default.createElement(Grid, {
5169
+ container: true,
5170
+ flexGrow: 1,
5171
+ overflow: "hidden"
5172
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5173
+ container: true,
5174
+ spacing: 2,
5175
+ sx: {
5176
+ height: '100%',
5177
+ paddingLeft: 1,
5178
+ paddingRight: 1,
5179
+ paddingTop: 2,
5180
+ overflow: 'auto'
5181
+ }
5182
+ }, /*#__PURE__*/React__default.createElement(Grid, {
5183
+ item: true,
5184
+ xs: 3,
5185
+ sm: 1
5186
+ }, /*#__PURE__*/React__default.createElement(LocationTabs, {
5187
+ tafList: locations,
5188
+ activeIndex: activeTafIndex,
5189
+ onChangeTab: setActiveTafIndex,
5190
+ timeSlot: timeSlot
5191
+ })), /*#__PURE__*/React__default.createElement(Grid, {
5192
+ item: true,
5193
+ xs: true
5194
+ }, /*#__PURE__*/React__default.createElement(Card, {
5195
+ variant: "outlined",
5196
+ sx: {
5197
+ padding: 1,
5198
+ paddingTop: 0,
5199
+ marginBottom: '12px',
5200
+ position: 'relative'
5201
+ }
5202
+ }, /*#__PURE__*/React__default.createElement(TacOverviewMobile, {
5203
+ upcomingTafs: upcoming,
5204
+ currentTafs: current,
5205
+ expiredTafs: expired,
5206
+ activeTaf: activeTaf
5207
+ }), locations.map(function (tafFromBackend, index) {
5208
+ return /*#__PURE__*/React__default.createElement(TafPanel, {
5209
+ key: tafFromBackend.taf.uuid,
5210
+ activeTafIndex: activeTafIndex,
5211
+ index: index,
5212
+ tafFromBackend: tafFromBackend,
5213
+ onPostTaf: onPostTaf
5214
+ });
5215
+ }))), /*#__PURE__*/React__default.createElement(Grid, {
5216
+ item: true,
5217
+ xs: 3,
5218
+ sx: {
5219
+ height: '100%'
5220
+ },
5221
+ display: {
5222
+ xs: 'none',
5223
+ sm: 'block'
4975
5224
  }
5225
+ }, /*#__PURE__*/React__default.createElement(TacOverview, {
5226
+ upcomingTafs: upcoming,
5227
+ currentTafs: current,
5228
+ expiredTafs: expired,
5229
+ activeTaf: activeTaf
5230
+ })))))));
5231
+ };
5232
+
5233
+ var TafModule = function TafModule() {
5234
+ var _useApiContext = useApiContext(),
5235
+ api = _useApiContext.api;
5236
+
5237
+ var _React$useState = React.useState(false),
5238
+ _React$useState2 = _slicedToArray(_React$useState, 2),
5239
+ isLoading = _React$useState2[0],
5240
+ setLoading = _React$useState2[1];
5241
+
5242
+ var _useApi = useApi(api.getTafList),
5243
+ getTafListError = _useApi.error,
5244
+ isFetchingInitial = _useApi.isLoading,
5245
+ tafList = _useApi.result,
5246
+ fetchNewTafList = _useApi.fetchApiData;
5247
+
5248
+ usePoller([tafList, getTafListError], function () {
5249
+ return fetchNewTafList({});
5250
+ });
5251
+
5252
+ var reFetchNewTafList = function reFetchNewTafList() {
5253
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
5254
+ return regeneratorRuntime.wrap(function _callee$(_context) {
5255
+ while (1) {
5256
+ switch (_context.prev = _context.next) {
5257
+ case 0:
5258
+ _context.prev = 0;
5259
+ setLoading(true);
5260
+ _context.next = 4;
5261
+ return fetchNewTafList({});
5262
+
5263
+ case 4:
5264
+ setLoading(false);
5265
+ _context.next = 10;
5266
+ break;
5267
+
5268
+ case 7:
5269
+ _context.prev = 7;
5270
+ _context.t0 = _context["catch"](0);
5271
+ setLoading(false);
5272
+
5273
+ case 10:
5274
+ case "end":
5275
+ return _context.stop();
5276
+ }
5277
+ }
5278
+ }, _callee, null, [[0, 7]]);
5279
+ }));
4976
5280
  };
4977
5281
 
4978
- var selectedTaf = getSelectedTaf(selectedTafId, tafList);
4979
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafList, {
5282
+ var hasTafListError = getTafListError !== null;
5283
+
5284
+ if (isFetchingInitial) {
5285
+ return /*#__PURE__*/React.createElement(LinearProgress, {
5286
+ color: "secondary",
5287
+ "data-testid": "loading-bar"
5288
+ });
5289
+ }
5290
+
5291
+ return /*#__PURE__*/React.createElement(Box, {
5292
+ component: "div",
5293
+ id: "tafmodule",
5294
+ sx: {
5295
+ height: '100%'
5296
+ }
5297
+ }, isLoading && /*#__PURE__*/React.createElement(LinearProgress, {
5298
+ "data-testid": "loading-bar",
5299
+ color: "secondary",
5300
+ sx: {
5301
+ marginBottom: '-4px'
5302
+ }
5303
+ }), hasTafListError && /*#__PURE__*/React.createElement(AlertBanner, {
5304
+ severity: "error",
5305
+ title: "An error has occurred while retrieving the list",
5306
+ info: getTafListError.message
5307
+ }), /*#__PURE__*/React.createElement(TafLayout, {
4980
5308
  tafList: tafList,
4981
- isLoading: isLoadingList,
4982
- error: errorList,
4983
- onClickTafActionButton: onClickTafActionButton,
4984
- errorCancelTaf: errorCancelTaf
4985
- }), showSpinner && /*#__PURE__*/React__default.createElement(Spinner, null), selectedTaf !== undefined && /*#__PURE__*/React__default.createElement(TafFormDialog, {
4986
- open: isTafDialogOpen,
4987
- toggleFormDialog: toggleTafDialog,
4988
- tafFromBackend: selectedTaf,
4989
- alertBanner: errorPostMessage ? /*#__PURE__*/React__default.createElement(AlertBanner, {
4990
- severity: "error",
4991
- title: "An error has occurred while saving, please try again",
4992
- info: errorPostMessageText
4993
- }) : null,
4994
- onFormAction: onFormAction
4995
- }, /*#__PURE__*/React__default.createElement(TafFormWrapper, {
4996
- mode: "edit",
4997
- tafFromBackend: selectedTaf,
4998
- tafAction: tafDialogAction,
4999
- onFormAction: onFormAction
5000
- }), showSpinner && /*#__PURE__*/React__default.createElement(Spinner, null)));
5309
+ onPostTaf: reFetchNewTafList
5310
+ }));
5001
5311
  };
5002
- /**
5003
- * Shows the list of Tafs and allows to create, edit and view Tafs.
5004
- * Needs to be wrapped in the ApiProvider.
5005
- *
5006
- * @example
5007
- * ```<ApiProvider baseURL="http://test.com" appURL="http://app.com" auth={auth} onSetAuth={onSetAuth} createApi={createApi}> authTokenUrl="url/tokenrefresh"<TafWrapper /> </ApiProvider>```
5008
- */
5009
-
5010
5312
 
5011
- var ConfirmationWrapper = function ConfirmationWrapper() {
5012
- return /*#__PURE__*/React__default.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React__default.createElement(TafWrapper, null));
5313
+ var Wrapper = function Wrapper() {
5314
+ return /*#__PURE__*/React.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React.createElement(TafModule, null));
5013
5315
  };
5014
5316
 
5015
5317
  /* *
@@ -5044,4 +5346,4 @@ var createApi = function createApi(url, appUrl, auth, setAuth, authTokenUrl, aut
5044
5346
  };
5045
5347
  };
5046
5348
 
5047
- export { ContentDialog, TafFormDialog, TafFormWrapper, TafList, TafListRow, TafListSection, ConfirmationWrapper as TafWrapper, createApi };
5349
+ export { TafFormWrapper, Wrapper as TafModule, createApi };