@opengeoweb/taf 2.13.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('@opengeoweb/form-fields'), require('@opengeoweb/shared'), require('lodash'), require('moment'), require('@opengeoweb/theme'), require('@mui/styles/makeStyles'), require('react-dom'), require('@opengeoweb/api'), require('@mui/material/LinearProgress'), require('@mui/material/Box')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', '@opengeoweb/form-fields', '@opengeoweb/shared', 'lodash', 'moment', '@opengeoweb/theme', '@mui/styles/makeStyles', 'react-dom', '@opengeoweb/api', '@mui/material/LinearProgress', '@mui/material/Box'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.formFields, global.shared, global.lodash, global.moment, global.theme, global.makeStyles, global.ReactDOM, global.api, global.LinearProgress, global.Box));
5
- })(this, (function (exports, React, material, reactHookForm, reactSortablejs, formFields, shared, lodash, moment, theme, makeStyles, ReactDOM, api, LinearProgress, Box) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('lodash'), require('@opengeoweb/authentication'), require('@opengeoweb/form-fields'), require('@opengeoweb/shared'), require('moment'), require('@opengeoweb/theme'), require('@mui/styles/makeStyles'), require('react-dom'), require('@opengeoweb/api'), require('@mui/material/LinearProgress'), require('@mui/material/Box')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', 'lodash', '@opengeoweb/authentication', '@opengeoweb/form-fields', '@opengeoweb/shared', 'moment', '@opengeoweb/theme', '@mui/styles/makeStyles', 'react-dom', '@opengeoweb/api', '@mui/material/LinearProgress', '@mui/material/Box'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.lodash, global.authentication, global.formFields, global.shared, global.moment, global.theme, global.makeStyles, global.ReactDOM, global.api, global.LinearProgress, global.Box));
5
+ })(this, (function (exports, React, material, reactHookForm, reactSortablejs, lodash, authentication, formFields, shared, moment, theme, makeStyles, ReactDOM, api, LinearProgress, Box) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -3825,7 +3825,12 @@
3825
3825
  fontSize: '4rem'
3826
3826
  },
3827
3827
  "data-testid": "zeroIssuesImage"
3828
- }, /*#__PURE__*/React__namespace.createElement(theme.ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3828
+ }, /*#__PURE__*/React__namespace.createElement(theme.ThumbsUp, {
3829
+ sx: {
3830
+ height: '69px',
3831
+ width: '58px'
3832
+ }
3833
+ })), errorList.length > 0 && errorList.map(function (error, index) {
3829
3834
  return /*#__PURE__*/React__namespace.createElement(material.Typography // eslint-disable-next-line react/no-array-index-key
3830
3835
  , {
3831
3836
  // eslint-disable-next-line react/no-array-index-key
@@ -3909,9 +3914,59 @@
3909
3914
  }, children);
3910
3915
  };
3911
3916
 
3917
+ var styles = {
3918
+ label: {
3919
+ color: 'geowebColors.buttons.tertiary.default.color',
3920
+ opacity: 1,
3921
+ fontSize: '12px',
3922
+ fontWeight: 500
3923
+ }
3924
+ };
3925
+
3926
+ var SwitchButton = function SwitchButton(props) {
3927
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3928
+ title: "Switch mode"
3929
+ }, /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement(material.FormLabel, {
3930
+ sx: styles.label
3931
+ }, "Viewer"), /*#__PURE__*/React__namespace.createElement(material.Switch, __assign({
3932
+ "data-testid": "switchMode"
3933
+ }, props)), /*#__PURE__*/React__namespace.createElement(material.FormLabel, {
3934
+ sx: styles.label
3935
+ }, "Editor")));
3936
+ };
3937
+
3938
+ /* *
3939
+ * Licensed under the Apache License, Version 2.0 (the "License");
3940
+ * you may not use this file except in compliance with the License.
3941
+ * You may obtain a copy of the License at
3942
+ *
3943
+ * http://www.apache.org/licenses/LICENSE-2.0
3944
+ *
3945
+ * Unless required by applicable law or agreed to in writing, software
3946
+ * distributed under the License is distributed on an "AS IS" BASIS,
3947
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3948
+ * See the License for the specific language governing permissions and
3949
+ * limitations under the License.
3950
+ *
3951
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3952
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3953
+ * */
3954
+
3955
+ var TafAvatar = function TafAvatar(_a) {
3956
+ var editor = _a.editor,
3957
+ _b = _a.tooltipPlacement,
3958
+ tooltipPlacement = _b === void 0 ? 'bottom' : _b;
3959
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3960
+ title: "Editor: " + editor,
3961
+ placement: tooltipPlacement
3962
+ }, /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement(shared.Avatar, {
3963
+ size: "small"
3964
+ }, shared.getInitials(editor))));
3965
+ };
3966
+
3912
3967
  var noop = function noop() {};
3913
3968
 
3914
- var TafForm = function TafForm(_a) {
3969
+ var TafForm = /*#__PURE__*/React__default["default"].memo(function (_a) {
3915
3970
  var tafFromBackend = _a.tafFromBackend,
3916
3971
  _b = _a.onFormAction,
3917
3972
  onFormAction = _b === void 0 ? function () {
@@ -3928,43 +3983,50 @@
3928
3983
  _f = _a.setIsDisabled,
3929
3984
  setIsDisabled = _f === void 0 ? function () {
3930
3985
  return null;
3931
- } : _f;
3932
- var originalTaf = tafFromBackend.taf;
3933
- var isDefaultDisabled = getIsFormDefaultDisabled(tafFromBackend.taf.status);
3986
+ } : _f,
3987
+ _g = _a.onSwitchEditor,
3988
+ onSwitchEditor = _g === void 0 ? function () {
3989
+ return null;
3990
+ } : _g;
3991
+ var originalTaf = tafFromBackend.taf,
3992
+ editor = tafFromBackend.editor;
3993
+ var auth = authentication.useAuthenticationContext().auth;
3994
+ var isEditor = editor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
3995
+ var isDefaultDisabled = getIsFormDefaultDisabled(originalTaf.status);
3934
3996
  var confirmDialog = shared.useConfirmationDialog();
3935
3997
 
3936
- var _g = shared.useDraftFormHelpers(true),
3937
- toggleIsDraft = _g.toggleIsDraft,
3938
- DraftFieldHelper = _g.DraftFieldHelper;
3998
+ var _h = shared.useDraftFormHelpers(true),
3999
+ toggleIsDraft = _h.toggleIsDraft,
4000
+ DraftFieldHelper = _h.DraftFieldHelper;
3939
4001
 
3940
- var _h = useTafModuleContext(),
3941
- registerValidateForm = _h.registerValidateForm,
3942
- tafAction = _h.tafAction,
3943
- setIsFormDirty = _h.setIsFormDirty,
3944
- setTafAction = _h.setTafAction,
3945
- TAC = _h.TAC,
3946
- updateTAC = _h.updateTAC,
3947
- setTAC = _h.setTAC;
4002
+ var _j = useTafModuleContext(),
4003
+ registerValidateForm = _j.registerValidateForm,
4004
+ tafAction = _j.tafAction,
4005
+ setIsFormDirty = _j.setIsFormDirty,
4006
+ setTafAction = _j.setTafAction,
4007
+ TAC = _j.TAC,
4008
+ updateTAC = _j.updateTAC,
4009
+ setTAC = _j.setTAC;
3948
4010
 
3949
4011
  var isMounted = shared.useIsMounted().isMounted;
3950
4012
 
3951
- var _j = reactHookForm.useFormContext(),
3952
- control = _j.control,
3953
- handleSubmit = _j.handleSubmit,
3954
- trigger = _j.trigger,
3955
- formState = _j.formState,
3956
- getValues = _j.getValues,
3957
- setValue = _j.setValue,
3958
- reset = _j.reset;
4013
+ var _k = reactHookForm.useFormContext(),
4014
+ control = _k.control,
4015
+ handleSubmit = _k.handleSubmit,
4016
+ trigger = _k.trigger,
4017
+ formState = _k.formState,
4018
+ getValues = _k.getValues,
4019
+ setValue = _k.setValue,
4020
+ reset = _k.reset;
3959
4021
 
3960
4022
  var isFormDirty = formState.isDirty,
3961
4023
  errors = formState.errors;
3962
4024
  shared.usePreventBrowserClose(isFormDirty && !isDisabled);
3963
4025
  var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
3964
4026
 
3965
- var _k = __read(React__default["default"].useState(getValues()), 2),
3966
- delayedFormValues = _k[0],
3967
- setDelayedFormValues = _k[1];
4027
+ var _l = __read(React__default["default"].useState(getValues()), 2),
4028
+ delayedFormValues = _l[0],
4029
+ setDelayedFormValues = _l[1];
3968
4030
 
3969
4031
  var hasErrors = Object.keys(errors).length;
3970
4032
 
@@ -4021,7 +4083,7 @@
4021
4083
  action = undefined;
4022
4084
  }
4023
4085
 
4024
- var newTaf = prepareTafValues(tafFromBackend.taf, action, shouldAddEmptyChangGroup);
4086
+ var newTaf = prepareTafValues(originalTaf, action, shouldAddEmptyChangGroup);
4025
4087
  reset(newTaf);
4026
4088
  };
4027
4089
 
@@ -4030,12 +4092,98 @@
4030
4092
  action = undefined;
4031
4093
  }
4032
4094
 
4033
- var shouldAddEmptyChangGroup = !(tafFromBackend.taf && tafFromBackend.taf.changeGroups) && !resetDisabled;
4095
+ var shouldAddEmptyChangGroup = !(originalTaf && originalTaf.changeGroups) && !resetDisabled;
4034
4096
  resetFormValues(action, shouldAddEmptyChangGroup);
4035
4097
  setIsDisabled(resetDisabled);
4036
4098
  setTafAction(action);
4037
4099
  };
4038
4100
 
4101
+ var setIsEditor = function setIsEditor(checked) {
4102
+ return __awaiter(void 0, void 0, void 0, function () {
4103
+ var editor, didSucceed;
4104
+ return __generator(this, function (_a) {
4105
+ switch (_a.label) {
4106
+ case 0:
4107
+ editor = checked ? auth === null || auth === void 0 ? void 0 : auth.username : '';
4108
+
4109
+ if (editor === tafFromBackend.editor) {
4110
+ // do nothing, correct editor is already set
4111
+ return [2
4112
+ /*return*/
4113
+ , true];
4114
+ }
4115
+
4116
+ if (!(tafFromBackend.editor !== '' && tafFromBackend.editor !== null && tafFromBackend.editor !== (auth === null || auth === void 0 ? void 0 : auth.username))) return [3
4117
+ /*break*/
4118
+ , 2];
4119
+ return [4
4120
+ /*yield*/
4121
+ , confirmDialog({
4122
+ title: 'Switch to editor mode',
4123
+ description: 'This TAF is already in edit mode and important information could get lost in the switching process.',
4124
+ confirmLabel: 'Edit mode'
4125
+ })];
4126
+
4127
+ case 1:
4128
+ _a.sent();
4129
+
4130
+ _a.label = 2;
4131
+
4132
+ case 2:
4133
+ return [4
4134
+ /*yield*/
4135
+ , onSwitchEditor(__assign(__assign({}, tafFromBackend), {
4136
+ editor: editor
4137
+ }))];
4138
+
4139
+ case 3:
4140
+ didSucceed = _a.sent();
4141
+ return [2
4142
+ /*return*/
4143
+ , didSucceed];
4144
+ }
4145
+ });
4146
+ });
4147
+ };
4148
+
4149
+ var onSwitchMode = function onSwitchMode(event) {
4150
+ var checked = event.target.checked;
4151
+
4152
+ if (!checked && isFormDirty) {
4153
+ confirmDialog({
4154
+ title: 'Whoops',
4155
+ description: 'Are you sure you want to switch to viewer mode? Your unsaved changes will be lost.',
4156
+ confirmLabel: 'Switch mode'
4157
+ }).then(function () {
4158
+ return __awaiter(void 0, void 0, void 0, function () {
4159
+ var didSucceed;
4160
+ return __generator(this, function (_a) {
4161
+ switch (_a.label) {
4162
+ case 0:
4163
+ return [4
4164
+ /*yield*/
4165
+ , setIsEditor(checked)];
4166
+
4167
+ case 1:
4168
+ didSucceed = _a.sent();
4169
+
4170
+ if (didSucceed) {
4171
+ resetForm(undefined, isDefaultDisabled);
4172
+ resetTAC();
4173
+ }
4174
+
4175
+ return [2
4176
+ /*return*/
4177
+ ];
4178
+ }
4179
+ });
4180
+ });
4181
+ });
4182
+ } else {
4183
+ setIsEditor(checked);
4184
+ }
4185
+ };
4186
+
4039
4187
  var onTafEditModeButtonPress = function onTafEditModeButtonPress(action) {
4040
4188
  switch (action) {
4041
4189
  case 'DRAFT':
@@ -4109,7 +4257,23 @@
4109
4257
  switch (action) {
4110
4258
  case 'CANCEL':
4111
4259
  showConfirmDialog(action).then(function () {
4112
- onFormAction(action, convertTafValuesToObject(prepareTafValues(tafFromBackend.taf, action)));
4260
+ return __awaiter(void 0, void 0, void 0, function () {
4261
+ return __generator(this, function (_a) {
4262
+ switch (_a.label) {
4263
+ case 0:
4264
+ return [4
4265
+ /*yield*/
4266
+ , onFormAction(action, convertTafValuesToObject(prepareTafValues(originalTaf, action)))];
4267
+
4268
+ case 1:
4269
+ _a.sent();
4270
+
4271
+ return [2
4272
+ /*return*/
4273
+ ];
4274
+ }
4275
+ });
4276
+ });
4113
4277
  });
4114
4278
  break;
4115
4279
 
@@ -4119,19 +4283,19 @@
4119
4283
  }
4120
4284
  };
4121
4285
 
4122
- var _l = reactHookForm.useFieldArray({
4286
+ var _m = reactHookForm.useFieldArray({
4123
4287
  control: control,
4124
4288
  name: 'changeGroups'
4125
4289
  }),
4126
- fields = _l.fields,
4127
- insert = _l.insert,
4128
- remove = _l.remove,
4129
- move = _l.move;
4290
+ fields = _m.fields,
4291
+ insert = _m.insert,
4292
+ remove = _m.remove,
4293
+ move = _m.move;
4130
4294
 
4131
- var _m = useDragOrder(trigger, move, onFormBlur),
4132
- onChangeOrder = _m.onChangeOrder,
4133
- onStartDrag = _m.onStartDrag,
4134
- activeDraggingIndex = _m.activeDraggingIndex;
4295
+ var _o = useDragOrder(trigger, move, onFormBlur),
4296
+ onChangeOrder = _o.onChangeOrder,
4297
+ onStartDrag = _o.onStartDrag,
4298
+ activeDraggingIndex = _o.activeDraggingIndex;
4135
4299
 
4136
4300
  var onRemoverow = function onRemoverow(index) {
4137
4301
  confirmDialog({
@@ -4212,13 +4376,13 @@
4212
4376
  });
4213
4377
  };
4214
4378
 
4215
- var _o = __read(React__default["default"].useState(false), 2),
4216
- shouldValidate = _o[0],
4217
- setShouldValidate = _o[1];
4379
+ var _p = __read(React__default["default"].useState(false), 2),
4380
+ shouldValidate = _p[0],
4381
+ setShouldValidate = _p[1];
4218
4382
 
4219
4383
  React__default["default"].useEffect(function () {
4220
- setIsDisabled(isDefaultDisabled);
4221
- var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
4384
+ setIsDisabled(!isEditor || isDefaultDisabled);
4385
+ var defaultValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled && !originalTaf.changeGroups); // set initial form values
4222
4386
 
4223
4387
  reset(defaultValues); // set validate flag to validate after the values have been set
4224
4388
 
@@ -4248,14 +4412,20 @@
4248
4412
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
4249
4413
  }, []);
4250
4414
  React__default["default"].useEffect(function () {
4251
- var newValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set new form values when tafFromBackend changed
4415
+ var newValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled && !originalTaf.changeGroups); // set new form values when taf values changed
4252
4416
 
4253
- reset(newValues); // eslint-disable-next-line react-hooks/exhaustive-deps
4254
- }, [tafFromBackend]);
4417
+ reset(newValues); // reset TAC when taf values changed
4418
+
4419
+ resetTAC(); // eslint-disable-next-line react-hooks/exhaustive-deps
4420
+ }, [originalTaf]);
4421
+ React__default["default"].useEffect(function () {
4422
+ // update disabled state when editor changed
4423
+ setIsDisabled(!isEditor || isDefaultDisabled); // eslint-disable-next-line react-hooks/exhaustive-deps
4424
+ }, [editor]);
4255
4425
  React__default["default"].useEffect(function () {
4256
4426
  if (shouldValidate && !isDisabled) {
4257
- // trigger validation on all changegroup validity times after initial load since they could be outside the new validity period
4258
- var _a = tafFromBackend.taf.changeGroups,
4427
+ // trigger validation on all changegroup validity times after form is enabled since they could be outside the new validity period
4428
+ var _a = originalTaf.changeGroups,
4259
4429
  changeGroups = _a === void 0 ? [] : _a;
4260
4430
  var validFields = changeGroups.map(function (_field, index) {
4261
4431
  return "changeGroups[" + index + "].valid";
@@ -4263,8 +4433,33 @@
4263
4433
  trigger(validFields);
4264
4434
  } // eslint-disable-next-line react-hooks/exhaustive-deps
4265
4435
 
4266
- }, [shouldValidate]);
4267
- return /*#__PURE__*/React__default["default"].createElement("form", {
4436
+ }, [shouldValidate, isDisabled]);
4437
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.Box, {
4438
+ sx: {
4439
+ display: 'flex',
4440
+ flexDirection: 'row',
4441
+ alignItems: 'center',
4442
+ position: 'absolute',
4443
+ top: {
4444
+ xs: '20px',
4445
+ sm: '0px'
4446
+ },
4447
+ right: {
4448
+ xs: 'calc(50% - 70px)',
4449
+ sm: '8px'
4450
+ }
4451
+ }
4452
+ }, /*#__PURE__*/React__default["default"].createElement(SwitchButton, {
4453
+ checked: isEditor,
4454
+ onChange: onSwitchMode
4455
+ }), /*#__PURE__*/React__default["default"].createElement(material.Box, {
4456
+ sx: {
4457
+ width: '16px',
4458
+ marginLeft: 1
4459
+ }
4460
+ }, editor && /*#__PURE__*/React__default["default"].createElement(TafAvatar, {
4461
+ editor: editor
4462
+ }))), /*#__PURE__*/React__default["default"].createElement("form", {
4268
4463
  "data-testid": "taf-form",
4269
4464
  onSubmit: handleSubmit(onSubmit),
4270
4465
  onBlur: onFormBlur
@@ -4330,7 +4525,7 @@
4330
4525
  index: index
4331
4526
  })
4332
4527
  });
4333
- })), !isDisabled && /*#__PURE__*/React__default["default"].createElement(material.Grid, {
4528
+ })), !isDisabled && isEditor && /*#__PURE__*/React__default["default"].createElement(material.Grid, {
4334
4529
  container: true,
4335
4530
  justifyContent: "space-between",
4336
4531
  alignItems: "center",
@@ -4344,7 +4539,7 @@
4344
4539
  errors: errors,
4345
4540
  isIssuesPaneOpen: isIssuesPaneOpen,
4346
4541
  setIsIssuesPaneOpen: setIsIssuesPaneOpen
4347
- }))), /*#__PURE__*/React__default["default"].createElement(TafFormButtons, {
4542
+ }))), isEditor && /*#__PURE__*/React__default["default"].createElement(TafFormButtons, {
4348
4543
  isFormDisabled: isDisabled,
4349
4544
  tafAction: tafAction,
4350
4545
  canBe: tafFromBackend.canbe,
@@ -4355,8 +4550,12 @@
4355
4550
  name: field,
4356
4551
  key: field
4357
4552
  });
4358
- }), /*#__PURE__*/React__default["default"].createElement(DraftFieldHelper, null));
4359
- };
4553
+ }), /*#__PURE__*/React__default["default"].createElement(DraftFieldHelper, null)));
4554
+ }, function (prevProps, nextProps) {
4555
+ // prevent re-render
4556
+ return !nextProps.isDisabled && prevProps.tafFromBackend !== nextProps.tafFromBackend && // if editor changed it should rerender
4557
+ prevProps.tafFromBackend.editor === nextProps.tafFromBackend.editor;
4558
+ });
4360
4559
 
4361
4560
  /* *
4362
4561
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4390,32 +4589,17 @@
4390
4589
  }, other), value === index && children);
4391
4590
  };
4392
4591
 
4393
- /* *
4394
- * Licensed under the Apache License, Version 2.0 (the "License");
4395
- * you may not use this file except in compliance with the License.
4396
- * You may obtain a copy of the License at
4397
- *
4398
- * http://www.apache.org/licenses/LICENSE-2.0
4399
- *
4400
- * Unless required by applicable law or agreed to in writing, software
4401
- * distributed under the License is distributed on an "AS IS" BASIS,
4402
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4403
- * See the License for the specific language governing permissions and
4404
- * limitations under the License.
4405
- *
4406
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4407
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
4408
- * */
4409
-
4410
4592
  var TafHeader = function TafHeader(_a) {
4411
- var title = _a.title;
4593
+ var title = _a.title,
4594
+ _b = _a.sx,
4595
+ sx = _b === void 0 ? {} : _b;
4412
4596
  return /*#__PURE__*/React__default["default"].createElement(material.Typography, {
4413
- sx: {
4597
+ sx: __assign({
4414
4598
  textAlign: 'center',
4415
4599
  fontWeight: 500,
4416
4600
  paddingTop: '6px',
4417
4601
  textTransform: 'capitalize'
4418
- }
4602
+ }, sx)
4419
4603
  }, title);
4420
4604
  };
4421
4605
 
@@ -4962,7 +5146,7 @@
4962
5146
  },
4963
5147
  position: 'absolute',
4964
5148
  right: '8px',
4965
- top: '30px'
5149
+ top: '48px'
4966
5150
  }
4967
5151
  }, /*#__PURE__*/React__namespace.createElement(theme.ListItem, null)), /*#__PURE__*/React__namespace.createElement(material.Dialog, {
4968
5152
  open: isOpen,
@@ -5075,7 +5259,8 @@
5075
5259
  paddingTop: '32px'
5076
5260
  }
5077
5261
  }, tafList.map(function (_a, index) {
5078
- var taf = _a.taf;
5262
+ var taf = _a.taf,
5263
+ editor = _a.editor;
5079
5264
  return /*#__PURE__*/React__namespace.createElement(material.MenuItem, {
5080
5265
  key: taf.uuid,
5081
5266
  selected: index === activeIndex,
@@ -5100,8 +5285,18 @@
5100
5285
  onClick: function onClick() {
5101
5286
  return onChangeTab(index);
5102
5287
  }
5103
- }, /*#__PURE__*/React__namespace.createElement(Box__default["default"], {
5288
+ }, editor && /*#__PURE__*/React__namespace.createElement(Box__default["default"], {
5289
+ sx: {
5290
+ position: 'absolute',
5291
+ top: '4px',
5292
+ left: '8px'
5293
+ }
5294
+ }, /*#__PURE__*/React__namespace.createElement(TafAvatar, {
5295
+ editor: editor,
5296
+ tooltipPlacement: "right"
5297
+ })), /*#__PURE__*/React__namespace.createElement(Box__default["default"], {
5104
5298
  component: "span",
5299
+ "data-testid": "taf-location",
5105
5300
  sx: {
5106
5301
  fontSize: '12px',
5107
5302
  fontWeight: '500',
@@ -5158,15 +5353,29 @@
5158
5353
  return 'NEW';
5159
5354
  }
5160
5355
  };
5356
+ var isWarning = function isWarning(error) {
5357
+ return (error === null || error === void 0 ? void 0 : error.type) === 'WARNING';
5358
+ };
5161
5359
 
5162
5360
  var parseErrorMessage = function parseErrorMessage(error, params) {
5361
+ var message = shared.getErrorMessage(error);
5362
+ var warningMessage = shared.getWarningMessage(error);
5363
+
5364
+ if (warningMessage) {
5365
+ return {
5366
+ type: 'WARNING',
5367
+ title: warningMessage
5368
+ };
5369
+ }
5370
+
5163
5371
  return params.changeStatusTo === 'CANCELLED' ? {
5164
5372
  type: 'CANCELLED',
5165
- title: 'Cancelling this TAF failed, please try again'
5373
+ title: 'Cancelling this TAF failed, please try again',
5374
+ message: message
5166
5375
  } : {
5167
5376
  type: 'SERVER',
5168
5377
  title: 'An error has occurred while saving, please try again',
5169
- message: shared.isAxiosError(error) ? shared.getAxiosErrorMessage(error) : error.message
5378
+ message: message
5170
5379
  };
5171
5380
  };
5172
5381
 
@@ -5251,19 +5460,24 @@
5251
5460
  postTaf = _c === void 0 ? function () {
5252
5461
  return null;
5253
5462
  } : _c,
5254
- _d = _a.isIssuesPaneOpen,
5255
- isIssuesPaneOpen = _d === void 0 ? false : _d,
5256
- _e = _a.setIsIssuesPaneOpen,
5257
- setIsIssuesPaneOpen = _e === void 0 ? function () {
5463
+ _d = _a.patchTaf,
5464
+ patchTaf = _d === void 0 ? function () {
5258
5465
  return null;
5259
- } : _e,
5260
- _f = _a.isFormDisabled,
5261
- isFormDisabled = _f === void 0 ? false : _f,
5262
- _g = _a.setIsFormDisabled,
5263
- setIsFormDisabled = _g === void 0 ? function () {
5466
+ } : _d,
5467
+ _e = _a.isIssuesPaneOpen,
5468
+ isIssuesPaneOpen = _e === void 0 ? false : _e,
5469
+ _f = _a.setIsIssuesPaneOpen,
5470
+ setIsIssuesPaneOpen = _f === void 0 ? function () {
5264
5471
  return null;
5265
- } : _g,
5472
+ } : _f,
5473
+ _g = _a.isFormDisabled,
5474
+ isFormDisabled = _g === void 0 ? false : _g,
5475
+ _h = _a.setIsFormDisabled,
5476
+ setIsFormDisabled = _h === void 0 ? function () {
5477
+ return null;
5478
+ } : _h,
5266
5479
  error = _a.error;
5480
+ var severity = isWarning(error) ? 'warning' : 'error';
5267
5481
 
5268
5482
  var onTafAction = function onTafAction(action, taf) {
5269
5483
  return __awaiter(void 0, void 0, void 0, function () {
@@ -5364,7 +5578,10 @@
5364
5578
  index: index,
5365
5579
  "data-testid": "taf-panel" + (activeTafIndex === index ? '-active' : '')
5366
5580
  }, /*#__PURE__*/React__default["default"].createElement(TafHeader, {
5367
- title: getTafStatusLabel(tafFromBackend.taf.status)
5581
+ title: getTafStatusLabel(tafFromBackend.taf.status),
5582
+ sx: {
5583
+ marginBottom: '4px'
5584
+ }
5368
5585
  }), isLoading && /*#__PURE__*/React__default["default"].createElement(Spinner, {
5369
5586
  "data-testid": "taf-loading",
5370
5587
  sx: {
@@ -5373,7 +5590,7 @@
5373
5590
  color: 'geowebColors.backdrops.white.fill'
5374
5591
  }
5375
5592
  }), error && /*#__PURE__*/React__default["default"].createElement(shared.AlertBanner, {
5376
- severity: "error",
5593
+ severity: severity,
5377
5594
  title: error.title,
5378
5595
  info: error.message,
5379
5596
  dataTestId: "taf-error",
@@ -5389,7 +5606,8 @@
5389
5606
  isIssuesPaneOpen: isIssuesPaneOpen,
5390
5607
  setIsIssuesPaneOpen: setIsIssuesPaneOpen,
5391
5608
  isDisabled: isFormDisabled,
5392
- setIsDisabled: setIsFormDisabled
5609
+ setIsDisabled: setIsFormDisabled,
5610
+ onSwitchEditor: patchTaf
5393
5611
  })));
5394
5612
  };
5395
5613
 
@@ -5401,6 +5619,57 @@
5401
5619
  }, props));
5402
5620
  };
5403
5621
 
5622
+ /* *
5623
+ * Licensed under the Apache License, Version 2.0 (the "License");
5624
+ * you may not use this file except in compliance with the License.
5625
+ * You may obtain a copy of the License at
5626
+ *
5627
+ * http://www.apache.org/licenses/LICENSE-2.0
5628
+ *
5629
+ * Unless required by applicable law or agreed to in writing, software
5630
+ * distributed under the License is distributed on an "AS IS" BASIS,
5631
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5632
+ * See the License for the specific language governing permissions and
5633
+ * limitations under the License.
5634
+ *
5635
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5636
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
5637
+ * */
5638
+ var getLastUpdateTitle = function getLastUpdateTitle(time) {
5639
+ return "Last updated " + time;
5640
+ };
5641
+
5642
+ var LastUpdateTime = function LastUpdateTime(_a) {
5643
+ var _b = _a.onUpdateTaf,
5644
+ onUpdateTaf = _b === void 0 ? function () {} : _b,
5645
+ lastUpdateTime = _a.lastUpdateTime;
5646
+ return /*#__PURE__*/React__default["default"].createElement(material.Box, {
5647
+ sx: {
5648
+ display: 'flex',
5649
+ alignItems: 'center',
5650
+ height: '100%',
5651
+ justifyContent: 'flex-end'
5652
+ }
5653
+ }, /*#__PURE__*/React__default["default"].createElement(material.Typography, {
5654
+ sx: {
5655
+ color: 'geowebColors.captions.captionStatus.rgba',
5656
+ fontSize: '10px',
5657
+ lineHeight: '1.6',
5658
+ letterSpacing: '0.33px'
5659
+ },
5660
+ "data-testid": "lastupdated-time"
5661
+ }, getLastUpdateTitle(lastUpdateTime)), /*#__PURE__*/React__default["default"].createElement(material.Tooltip, {
5662
+ title: "Click to refresh"
5663
+ }, /*#__PURE__*/React__default["default"].createElement(shared.ToolButton, {
5664
+ "data-testid": "updateTafBtn",
5665
+ onClick: onUpdateTaf,
5666
+ sx: {
5667
+ marginRight: 1,
5668
+ marginLeft: 1
5669
+ }
5670
+ }, /*#__PURE__*/React__default["default"].createElement(theme.Cached, null))));
5671
+ };
5672
+
5404
5673
  var CONFIRM_DIALOG_OPTIONS = {
5405
5674
  title: 'Whoops',
5406
5675
  description: "It's not possible to autosave this TAF due to the presence of issue(s). Are you sure you want to close this TAF? Any changes made will be lost.",
@@ -5410,8 +5679,9 @@
5410
5679
  var TafLayout = function TafLayout(_a) {
5411
5680
  var _b = _a.tafList,
5412
5681
  tafList = _b === void 0 ? [] : _b,
5413
- _c = _a.onPostTaf,
5414
- onPostTaf = _c === void 0 ? function () {} : _c;
5682
+ _c = _a.onUpdateTaf,
5683
+ onUpdateTaf = _c === void 0 ? function () {} : _c,
5684
+ lastUpdateTime = _a.lastUpdateTime;
5415
5685
  var api$1 = api.useApiContext().api;
5416
5686
  var confirmDialog = shared.useConfirmationDialog();
5417
5687
 
@@ -5424,45 +5694,56 @@
5424
5694
  var _e = usePostTafRequest(api$1.postTaf),
5425
5695
  isLoading = _e.isLoading,
5426
5696
  postTafRequest = _e.doRequest,
5427
- error = _e.error,
5428
- setError = _e.setError;
5697
+ postError = _e.error;
5429
5698
 
5430
- var _f = useTafModuleContext(),
5431
- onValidateForm = _f.onValidateForm,
5432
- tafAction = _f.tafAction,
5433
- isFormDirty = _f.isFormDirty;
5699
+ var _f = usePostTafRequest(api$1.patchTaf),
5700
+ patchTafRequest = _f.doRequest,
5701
+ patchError = _f.error;
5434
5702
 
5435
- var _g = __read(React__default["default"].useState(sortTafTimeSlots(tafList)), 2),
5436
- _h = _g[0],
5437
- upcoming = _h.upcoming,
5438
- current = _h.current,
5439
- expired = _h.expired,
5440
- updateSortedTafs = _g[1];
5703
+ var _g = useTafModuleContext(),
5704
+ onValidateForm = _g.onValidateForm,
5705
+ tafAction = _g.tafAction,
5706
+ isFormDirty = _g.isFormDirty;
5441
5707
 
5442
- var _j = __read(current.slice(-1), 1),
5443
- lastCurrentTaf = _j[0];
5708
+ var _h = __read(React__default["default"].useState(sortTafTimeSlots(tafList)), 2),
5709
+ _j = _h[0],
5710
+ upcoming = _j.upcoming,
5711
+ current = _j.current,
5712
+ expired = _j.expired,
5713
+ updateSortedTafs = _h[1];
5444
5714
 
5445
- var _k = __read(React__default["default"].useState('UPCOMING'), 2),
5446
- timeSlot = _k[0],
5447
- setTimeSlot = _k[1];
5715
+ var _k = __read(current.slice(-1), 1),
5716
+ lastCurrentTaf = _k[0];
5448
5717
 
5449
- var _l = __read(React__default["default"].useState(upcoming), 2),
5450
- locations = _l[0],
5451
- setLocations = _l[1];
5718
+ var _l = __read(React__default["default"].useState('UPCOMING'), 2),
5719
+ timeSlot = _l[0],
5720
+ setTimeSlot = _l[1];
5452
5721
 
5453
- var _m = __read(React__default["default"].useState(0), 2),
5454
- activeTafIndex = _m[0],
5455
- setActiveTafIndex = _m[1];
5722
+ var _m = __read(React__default["default"].useState(upcoming), 2),
5723
+ locations = _m[0],
5724
+ setLocations = _m[1];
5456
5725
 
5457
- var _o = __read(React__default["default"].useState(false), 2),
5458
- isFormDisabled = _o[0],
5459
- setIsFormDisabled = _o[1];
5726
+ var _o = __read(React__default["default"].useState(0), 2),
5727
+ activeTafIndex = _o[0],
5728
+ setActiveTafIndex = _o[1];
5729
+
5730
+ var _p = __read(React__default["default"].useState(false), 2),
5731
+ isFormDisabled = _p[0],
5732
+ setIsFormDisabled = _p[1];
5733
+
5734
+ var _q = __read(React__default["default"].useState(), 2),
5735
+ error = _q[0],
5736
+ setError = _q[1];
5460
5737
 
5461
5738
  var postTaf = function postTaf(data) {
5462
5739
  return __awaiter(void 0, void 0, void 0, function () {
5740
+ var error_1;
5463
5741
  return __generator(this, function (_a) {
5464
5742
  switch (_a.label) {
5465
5743
  case 0:
5744
+ _a.trys.push([0, 2,, 3]);
5745
+
5746
+ setError(null);
5466
5747
  return [4
5467
5748
  /*yield*/
5468
5749
  , postTafRequest(data)];
@@ -5471,7 +5752,57 @@
5471
5752
  _a.sent(); // callback
5472
5753
 
5473
5754
 
5474
- onPostTaf();
5755
+ onUpdateTaf();
5756
+ return [3
5757
+ /*break*/
5758
+ , 3];
5759
+
5760
+ case 2:
5761
+ error_1 = _a.sent();
5762
+
5763
+ if (isWarning(error_1)) {
5764
+ onUpdateTaf();
5765
+ }
5766
+
5767
+ throw error_1;
5768
+
5769
+ case 3:
5770
+ return [2
5771
+ /*return*/
5772
+ ];
5773
+ }
5774
+ });
5775
+ });
5776
+ };
5777
+
5778
+ var patchTaf = function patchTaf(data) {
5779
+ return __awaiter(void 0, void 0, void 0, function () {
5780
+ return __generator(this, function (_a) {
5781
+ switch (_a.label) {
5782
+ case 0:
5783
+ _a.trys.push([0, 2,, 3]);
5784
+
5785
+ setError(null);
5786
+ return [4
5787
+ /*yield*/
5788
+ , patchTafRequest(data)];
5789
+
5790
+ case 1:
5791
+ _a.sent(); // callback
5792
+
5793
+
5794
+ onUpdateTaf();
5795
+ return [2
5796
+ /*return*/
5797
+ , true];
5798
+
5799
+ case 2:
5800
+ _a.sent();
5801
+ return [2
5802
+ /*return*/
5803
+ , false];
5804
+
5805
+ case 3:
5475
5806
  return [2
5476
5807
  /*return*/
5477
5808
  ];
@@ -5573,7 +5904,8 @@
5573
5904
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5574
5905
  }, [tafList, setLocations]);
5575
5906
  React__default["default"].useEffect(function () {
5576
- var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
5907
+ setError(postError);
5908
+ var cancelErrorTimeout = postError && postError.type === 'CANCELLED' ? setTimeout(function () {
5577
5909
  setError(null);
5578
5910
  }, 10000) : null;
5579
5911
  return function () {
@@ -5581,7 +5913,10 @@
5581
5913
  clearTimeout(cancelErrorTimeout);
5582
5914
  }
5583
5915
  };
5584
- }, [error, setError]);
5916
+ }, [postError]);
5917
+ React__default["default"].useEffect(function () {
5918
+ setError(patchError);
5919
+ }, [patchError]);
5585
5920
 
5586
5921
  if (!tafList) {
5587
5922
  return null;
@@ -5627,6 +5962,13 @@
5627
5962
  tafFromBackend: lastCurrentTaf,
5628
5963
  timeSlot: timeSlot,
5629
5964
  onChangeTimeSlot: onChangeTimeSlot
5965
+ })), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5966
+ item: true,
5967
+ xs: 12,
5968
+ sm: 3
5969
+ }, lastUpdateTime && /*#__PURE__*/React__default["default"].createElement(LastUpdateTime, {
5970
+ lastUpdateTime: lastUpdateTime,
5971
+ onUpdateTaf: onUpdateTaf
5630
5972
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5631
5973
  container: true,
5632
5974
  flexGrow: 1,
@@ -5676,6 +6018,7 @@
5676
6018
  isFormDisabled: isFormDisabled,
5677
6019
  setIsFormDisabled: setIsFormDisabled,
5678
6020
  postTaf: postTaf,
6021
+ patchTaf: patchTaf,
5679
6022
  isLoading: isLoading,
5680
6023
  error: error
5681
6024
  });
@@ -5717,23 +6060,80 @@
5717
6060
  }, children)));
5718
6061
  };
5719
6062
 
6063
+ var getCurrentDate = function getCurrentDate() {
6064
+ return moment__default["default"].utc().format('HH:mm');
6065
+ };
6066
+
5720
6067
  var TafModule = function TafModule() {
5721
6068
  var api$1 = api.useApiContext().api;
5722
6069
 
5723
- var _a = api.useApi(api$1.getTafList),
5724
- getTafListError = _a.error,
5725
- isLoading = _a.isLoading,
5726
- tafList = _a.result,
5727
- fetchNewTafList = _a.fetchApiData;
6070
+ var _a = __read(React__namespace.useState([]), 2),
6071
+ tafList = _a[0],
6072
+ setTafList = _a[1];
5728
6073
 
5729
- shared.usePoller([tafList, getTafListError], function () {
5730
- return fetchNewTafList({});
5731
- });
6074
+ var _b = __read(React__namespace.useState(true), 2),
6075
+ isLoading = _b[0],
6076
+ setIsLoading = _b[1];
6077
+
6078
+ var _c = __read(React__namespace.useState(null), 2),
6079
+ getTafListError = _c[0],
6080
+ setError = _c[1];
6081
+
6082
+ var _d = __read(React__namespace.useState(), 2),
6083
+ lastUpdateTime = _d[0],
6084
+ setLastUpdateTime = _d[1];
6085
+
6086
+ var fetchNewTafList = function fetchNewTafList() {
6087
+ return __awaiter(void 0, void 0, void 0, function () {
6088
+ var result, error_1;
6089
+ return __generator(this, function (_a) {
6090
+ switch (_a.label) {
6091
+ case 0:
6092
+ setIsLoading(true);
6093
+ setError(null);
6094
+ _a.label = 1;
6095
+
6096
+ case 1:
6097
+ _a.trys.push([1, 3,, 4]);
6098
+
6099
+ return [4
6100
+ /*yield*/
6101
+ , api$1.getTafList()];
6102
+
6103
+ case 2:
6104
+ result = _a.sent();
6105
+ setTafList(result.data);
6106
+ setIsLoading(false);
6107
+ setLastUpdateTime(getCurrentDate());
6108
+ return [3
6109
+ /*break*/
6110
+ , 4];
6111
+
6112
+ case 3:
6113
+ error_1 = _a.sent();
6114
+ setError(error_1);
6115
+ setIsLoading(false);
6116
+ return [3
6117
+ /*break*/
6118
+ , 4];
6119
+
6120
+ case 4:
6121
+ return [2
6122
+ /*return*/
6123
+ ];
6124
+ }
6125
+ });
6126
+ });
6127
+ };
5732
6128
 
5733
- var onPostTaf = function onPostTaf() {
5734
- fetchNewTafList({});
6129
+ var onUpdateTaf = function onUpdateTaf() {
6130
+ fetchNewTafList();
5735
6131
  };
5736
6132
 
6133
+ React__namespace.useEffect(function () {
6134
+ fetchNewTafList(); // eslint-disable-next-line react-hooks/exhaustive-deps
6135
+ }, []);
6136
+ shared.usePoller([tafList, getTafListError], fetchNewTafList);
5737
6137
  var hasTafListError = getTafListError !== null;
5738
6138
  return /*#__PURE__*/React__namespace.createElement(material.Box, {
5739
6139
  component: "div",
@@ -5758,7 +6158,8 @@
5758
6158
  }
5759
6159
  }), /*#__PURE__*/React__namespace.createElement(TafLayout, {
5760
6160
  tafList: tafList,
5761
- onPostTaf: onPostTaf
6161
+ onUpdateTaf: onUpdateTaf,
6162
+ lastUpdateTime: lastUpdateTime
5762
6163
  }));
5763
6164
  };
5764
6165
 
@@ -5780,10 +6181,32 @@
5780
6181
  return axiosInstance.post.apply(axiosInstance, __spreadArray(['/taf2tac'], __read(__spreadArray([__assign({}, tafData)], __read(signal ? [{
5781
6182
  signal: signal
5782
6183
  }] : [])))));
6184
+ },
6185
+ patchTaf: function patchTaf(formData) {
6186
+ return axiosInstance.patch('/taf', __assign({}, formData));
5783
6187
  }
5784
6188
  };
5785
6189
  };
5786
6190
 
6191
+ /* *
6192
+ * Licensed under the Apache License, Version 2.0 (the "License");
6193
+ * you may not use this file except in compliance with the License.
6194
+ * You may obtain a copy of the License at
6195
+ *
6196
+ * http://www.apache.org/licenses/LICENSE-2.0
6197
+ *
6198
+ * Unless required by applicable law or agreed to in writing, software
6199
+ * distributed under the License is distributed on an "AS IS" BASIS,
6200
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6201
+ * See the License for the specific language governing permissions and
6202
+ * limitations under the License.
6203
+ *
6204
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
6205
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
6206
+ * */
6207
+
6208
+ var MOCK_USERNAME = 'user.name';
6209
+
5787
6210
  var currentDate = moment__default["default"].utc().format('YYYY-MM-DD');
5788
6211
  var tomorrowDate = moment__default["default"].utc().add(1, 'day').format('YYYY-MM-DD');
5789
6212
  var airportPeriod = 6;
@@ -5819,6 +6242,7 @@
5819
6242
  var fakeTafList = [{
5820
6243
  creationDate: upcomingValidDateStart,
5821
6244
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6245
+ editor: MOCK_USERNAME,
5822
6246
  taf: {
5823
6247
  uuid: '5f9583fjdf0f337925',
5824
6248
  baseTime: upcomingValidDateStart,
@@ -5838,6 +6262,7 @@
5838
6262
  }, {
5839
6263
  creationDate: upcomingValidDateStart,
5840
6264
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6265
+ editor: null,
5841
6266
  taf: {
5842
6267
  uuid: '5f9583fjd111137925',
5843
6268
  baseTime: upcomingValidDateStart,
@@ -5863,6 +6288,7 @@
5863
6288
  }, {
5864
6289
  creationDate: upcomingValidDateStart,
5865
6290
  canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
6291
+ editor: null,
5866
6292
  taf: {
5867
6293
  uuid: '754905485',
5868
6294
  baseTime: upcomingValidDateStart,
@@ -5920,6 +6346,7 @@
5920
6346
  }, {
5921
6347
  creationDate: upcomingValidDateStart,
5922
6348
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6349
+ editor: MOCK_USERNAME,
5923
6350
  taf: {
5924
6351
  uuid: '43545345345',
5925
6352
  issueDate: upcomingValidDateStart,
@@ -5990,6 +6417,7 @@
5990
6417
  }, {
5991
6418
  creationDate: upcomingValidDateStart,
5992
6419
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6420
+ editor: null,
5993
6421
  taf: {
5994
6422
  uuid: '5f9583fjdf45ff4330f337925',
5995
6423
  issueDate: upcomingValidDateStart,
@@ -6045,6 +6473,7 @@
6045
6473
  }, {
6046
6474
  creationDate: upcomingValidDateStart,
6047
6475
  canbe: ['AMENDED'],
6476
+ editor: null,
6048
6477
  taf: {
6049
6478
  uuid: '5464565464',
6050
6479
  previousId: '5445fghrfg3546456',
@@ -6086,6 +6515,7 @@
6086
6515
  }, {
6087
6516
  creationDate: upcomingValidDateStart,
6088
6517
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6518
+ editor: 'max.jansen',
6089
6519
  taf: {
6090
6520
  uuid: 'gh56734fghfgh',
6091
6521
  previousId: '8574jnf93475',
@@ -6127,6 +6557,7 @@
6127
6557
  }, {
6128
6558
  creationDate: currentValidDateStart,
6129
6559
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6560
+ editor: null,
6130
6561
  taf: {
6131
6562
  uuid: 'giskdj09845872039',
6132
6563
  issueDate: currentValidDateStart,
@@ -6166,6 +6597,7 @@
6166
6597
  }, {
6167
6598
  creationDate: currentValidDateStart,
6168
6599
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6600
+ editor: null,
6169
6601
  taf: {
6170
6602
  uuid: 'ghskdj09845872039',
6171
6603
  baseTime: currentValidDateStart,
@@ -6185,6 +6617,7 @@
6185
6617
  }, {
6186
6618
  creationDate: currentValidDateStart,
6187
6619
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6620
+ editor: null,
6188
6621
  taf: {
6189
6622
  uuid: 'ghskdj09845872040',
6190
6623
  issueDate: currentValidDateStart,
@@ -6205,6 +6638,7 @@
6205
6638
  }, {
6206
6639
  creationDate: currentDate + "T06:00:00Z",
6207
6640
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6641
+ editor: null,
6208
6642
  taf: {
6209
6643
  uuid: 'ghskdj09845872041',
6210
6644
  issueDate: currentValidDateStart,
@@ -6225,6 +6659,7 @@
6225
6659
  }, {
6226
6660
  creationDate: currentDate + "T06:00:00Z",
6227
6661
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6662
+ editor: null,
6228
6663
  taf: {
6229
6664
  uuid: 'ghskdj09845872042',
6230
6665
  issueDate: currentValidDateStart,
@@ -6245,6 +6680,7 @@
6245
6680
  }, {
6246
6681
  creationDate: currentDate + "T06:00:00Z",
6247
6682
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6683
+ editor: null,
6248
6684
  taf: {
6249
6685
  uuid: 'ghskdj09845872043',
6250
6686
  issueDate: currentValidDateStart,
@@ -6265,6 +6701,7 @@
6265
6701
  }, {
6266
6702
  creationDate: expiredValidDateStart,
6267
6703
  canbe: [],
6704
+ editor: null,
6268
6705
  taf: {
6269
6706
  uuid: 'sdkjhsdf90845890',
6270
6707
  issueDate: expiredValidDateStart,
@@ -6329,6 +6766,7 @@
6329
6766
  var fakeNewTaf = {
6330
6767
  creationDate: currentDate + "T12:00:00Z",
6331
6768
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6769
+ editor: null,
6332
6770
  taf: {
6333
6771
  type: 'NORMAL',
6334
6772
  messageType: 'ORG',
@@ -6349,6 +6787,7 @@
6349
6787
  ({
6350
6788
  creationDate: "2022-01-06T12:00:00Z",
6351
6789
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6790
+ editor: MOCK_USERNAME,
6352
6791
  taf: __assign(__assign({}, fakeNewTaf.taf), {
6353
6792
  baseTime: "2022-01-06T12:00:00Z",
6354
6793
  validDateStart: "2022-01-06T12:00:00Z",
@@ -6364,6 +6803,7 @@
6364
6803
  var fakePublishedTaf = {
6365
6804
  creationDate: currentDate + "T12:00:00Z",
6366
6805
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6806
+ editor: null,
6367
6807
  taf: {
6368
6808
  uuid: 'slsdkjg-023895',
6369
6809
  issueDate: currentDate + "T12:00:00Z",
@@ -6439,7 +6879,9 @@
6439
6879
  ({
6440
6880
  creationDate: "2022-01-06T12:00:00Z",
6441
6881
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6882
+ editor: MOCK_USERNAME,
6442
6883
  taf: __assign(__assign({}, fakePublishedTaf.taf), {
6884
+ uuid: 'sowi3u4o-lsdjflsk',
6443
6885
  location: 'EHGG',
6444
6886
  baseTime: "2022-01-06T12:00:00Z",
6445
6887
  issueDate: "2022-01-06T12:00:00Z",
@@ -6504,6 +6946,7 @@
6504
6946
  var fakeDraftTaf = {
6505
6947
  creationDate: currentDate + "T18:00:00Z",
6506
6948
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6949
+ editor: null,
6507
6950
  taf: {
6508
6951
  uuid: '5f9583fjdf0f337925',
6509
6952
  baseTime: currentDate + "T18:00:00Z",
@@ -6542,6 +6985,7 @@
6542
6985
  ({
6543
6986
  creationDate: "2022-01-06T18:00:00Z",
6544
6987
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6988
+ editor: MOCK_USERNAME,
6545
6989
  taf: __assign(__assign({}, fakeDraftTaf.taf), {
6546
6990
  baseTime: "2022-01-06T18:00:00Z",
6547
6991
  validDateStart: "2022-01-06T18:00:00Z",
@@ -6557,6 +7001,7 @@
6557
7001
  var fakeDraftAmendmentTaf = {
6558
7002
  creationDate: currentDate + "T14:00:00Z",
6559
7003
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7004
+ editor: null,
6560
7005
  taf: {
6561
7006
  uuid: '954905487',
6562
7007
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6617,6 +7062,7 @@
6617
7062
  ({
6618
7063
  creationDate: "2022-01-06T14:00:00Z",
6619
7064
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7065
+ editor: null,
6620
7066
  taf: __assign(__assign({}, fakeDraftAmendmentTaf.taf), {
6621
7067
  location: 'EHRD',
6622
7068
  issueDate: "2022-01-06T14:00:00Z",
@@ -6637,6 +7083,7 @@
6637
7083
  var fakeAmendmentTaf = {
6638
7084
  creationDate: currentDate + "T14:00:00Z",
6639
7085
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7086
+ editor: null,
6640
7087
  taf: {
6641
7088
  uuid: '754905486',
6642
7089
  previousId: '5f9583fjdf45ff4330f337925',
@@ -6680,6 +7127,7 @@
6680
7127
  ({
6681
7128
  creationDate: "2022-01-06T14:00:00Z",
6682
7129
  canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
7130
+ editor: MOCK_USERNAME,
6683
7131
  taf: __assign(__assign({}, fakeAmendmentTaf.taf), {
6684
7132
  uuid: '7549058980',
6685
7133
  issueDate: "2022-01-06T14:00:00Z",
@@ -6717,6 +7165,14 @@
6717
7165
  });
6718
7166
  };
6719
7167
 
7168
+ var fakeUpdatedTafList = __spreadArray([], __read(fakeTafList));
7169
+
7170
+ var setFakeUpdatedList = function setFakeUpdatedList(newList) {
7171
+ fakeUpdatedTafList = newList;
7172
+ };
7173
+ var getFakeUpdatedList = function getFakeUpdatedList() {
7174
+ return fakeUpdatedTafList;
7175
+ };
6720
7176
  var fakeAxiosInstance = {
6721
7177
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6722
7178
  get: function get(_url, _params) {
@@ -6725,6 +7181,10 @@
6725
7181
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6726
7182
  post: function post(_url, _params, _signal) {
6727
7183
  return fakePromise(false, _signal);
7184
+ },
7185
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
7186
+ patch: function patch(_url, _params, _signal) {
7187
+ return fakePromise(false, _signal);
6728
7188
  }
6729
7189
  };
6730
7190
  var createApi = function createApi() {
@@ -6734,7 +7194,7 @@
6734
7194
  console.log('Retrieving new TAF list');
6735
7195
  return fakeAxiosInstance.get('/taflist').then(function () {
6736
7196
  return {
6737
- data: __spreadArray([], __read(fakeTafList))
7197
+ data: getFakeUpdatedList()
6738
7198
  };
6739
7199
  });
6740
7200
  },
@@ -6753,6 +7213,21 @@
6753
7213
  data: fakeTafTac
6754
7214
  };
6755
7215
  });
7216
+ },
7217
+ patchTaf: function patchTaf(_patchTaf) {
7218
+ var updatedList = getFakeUpdatedList().map(function (tafFromBackend) {
7219
+ if (tafFromBackend.taf.uuid === _patchTaf.taf.uuid) {
7220
+ return __assign(__assign({}, tafFromBackend), {
7221
+ editor: _patchTaf.editor
7222
+ });
7223
+ }
7224
+
7225
+ return tafFromBackend;
7226
+ });
7227
+ setFakeUpdatedList(updatedList); // eslint-disable-next-line no-console
7228
+
7229
+ console.log("The new editor of the taf will be " + (_patchTaf.editor || 'empty'));
7230
+ return fakeAxiosInstance.patch('/taf', _patchTaf);
6756
7231
  }
6757
7232
  };
6758
7233
  };