@opengeoweb/warnings 9.5.0 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +429 -166
- package/package.json +26 -2
- package/src/lib/components/PublicWarningList/PublicWarningList.d.ts +3 -1
- package/src/lib/components/PublicWarningList/PublicWarningListConnect.stories.d.ts +1 -0
- package/src/lib/components/PublicWarningsForm/PublicWarningsForm.d.ts +3 -2
- package/src/lib/components/PublicWarningsFormDialog/PublicWarningsFormDialog.stories.d.ts +8 -0
- package/src/lib/components/PublicWarningsFormDialog/PublicWarningsFormDialogConnect.d.ts +1 -0
- package/src/lib/store/publicWarningForm/reducer.d.ts +18 -4
- package/src/lib/store/publicWarningForm/sagas.d.ts +2 -0
- package/src/lib/store/publicWarningForm/selectors.d.ts +6 -1
- package/src/lib/store/publicWarningForm/types.d.ts +1 -1
- package/src/lib/store/publicWarnings/reducer.d.ts +1 -0
- package/src/lib/store/publicWarnings/sagas.d.ts +1 -0
- package/src/lib/store/publicWarnings/selectors.d.ts +5 -0
- package/src/lib/store/publicWarnings/types.d.ts +1 -0
- package/src/lib/utils/constants.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
4
4
|
import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, Wind, Fog, Lightning, Snow, Rain, TemperatureHigh, FunnelCloud, TemperatureLow, CoastalEvent, breakpoints, Options } from '@opengeoweb/theme';
|
|
5
5
|
import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog } from '@opengeoweb/store';
|
|
6
6
|
import { emptyGeoJSON, MapControlButton, getGeoJSONPropertyValue, getIcon, rewindGeometry, currentlySupportedDrawModes } from '@opengeoweb/webmap-react';
|
|
7
|
-
import { useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, StatusTag, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
|
|
7
|
+
import { useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, LastUpdateTime, StatusTag, ErrorBoundary, isAxiosError, pollingIntervalTimeout } from '@opengeoweb/shared';
|
|
8
8
|
import { createEntityAdapter, createSlice, createSelector } from '@reduxjs/toolkit';
|
|
9
9
|
import { snackbarActions } from '@opengeoweb/snackbar';
|
|
10
10
|
import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, FormControl, Card, CardContent, ListItemIcon, CircularProgress, List } from '@mui/material';
|
|
@@ -14,7 +14,8 @@ import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInsta
|
|
|
14
14
|
import { ReactHookFormProvider, defaultFormOptions, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isValidDate, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
|
|
15
15
|
import { useFormContext } from 'react-hook-form';
|
|
16
16
|
import { clamp } from 'lodash';
|
|
17
|
-
import {
|
|
17
|
+
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
18
|
+
import { takeLatest, put, call, select, delay } from 'redux-saga/effects';
|
|
18
19
|
import { isAxiosError as isAxiosError$1 } from 'axios';
|
|
19
20
|
|
|
20
21
|
function _iterableToArrayLimit(r, l) {
|
|
@@ -954,6 +955,7 @@ var DATE_FORMAT = 'dd/MM/yyyy HH:mm';
|
|
|
954
955
|
var DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
|
955
956
|
var DATE_FORMAT_HEADER = 'EEEE, MMMM dd';
|
|
956
957
|
var DATE_FORMAT_DATE_FIELDS = 'DD/MM/YYYY HH:mm'; // TODO: should be 'ddd DD MMM HH:mm' https://gitlab.com/opengeoweb/opengeoweb/-/issues/4484
|
|
958
|
+
var DATE_FORMAT_LASTUPDATEDTIME = 'HH:mm';
|
|
957
959
|
|
|
958
960
|
var DEFAULT_ADD_BUTTON_HEIGHT = 80;
|
|
959
961
|
var OBJECT_ITEM_SIZE = 50;
|
|
@@ -1526,9 +1528,62 @@ var publicWarningDialogType = uiTypes.DialogTypes.PublicWarnings;
|
|
|
1526
1528
|
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1527
1529
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
1528
1530
|
* */
|
|
1529
|
-
var
|
|
1531
|
+
var publicWarningsAdapter = createEntityAdapter({
|
|
1532
|
+
selectId: function selectId(warning) {
|
|
1533
|
+
return warning.id;
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
var initialState$1 = {
|
|
1537
|
+
warnings: publicWarningsAdapter.getInitialState(),
|
|
1538
|
+
isLoading: true,
|
|
1539
|
+
lastUpdatedTime: ''
|
|
1540
|
+
};
|
|
1530
1541
|
var slice$1 = createSlice({
|
|
1531
1542
|
initialState: initialState$1,
|
|
1543
|
+
name: 'publicWarnings',
|
|
1544
|
+
reducers: {
|
|
1545
|
+
fetchWarnings: function fetchWarnings(draft) {
|
|
1546
|
+
draft.isLoading = true;
|
|
1547
|
+
delete draft.error;
|
|
1548
|
+
},
|
|
1549
|
+
fetchWarningsSuccess: function fetchWarningsSuccess(draft, action) {
|
|
1550
|
+
var _action$payload = action.payload,
|
|
1551
|
+
warnings = _action$payload.warnings,
|
|
1552
|
+
lastUpdatedTime = _action$payload.lastUpdatedTime;
|
|
1553
|
+
draft.isLoading = false;
|
|
1554
|
+
draft.lastUpdatedTime = lastUpdatedTime;
|
|
1555
|
+
publicWarningsAdapter.setAll(draft.warnings, warnings);
|
|
1556
|
+
},
|
|
1557
|
+
fetchWarningsError: function fetchWarningsError(draft, action) {
|
|
1558
|
+
var error = action.payload.error;
|
|
1559
|
+
draft.isLoading = false;
|
|
1560
|
+
draft.error = error;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
var reducer$1 = slice$1.reducer;
|
|
1565
|
+
var publicWarningActions = slice$1.actions;
|
|
1566
|
+
|
|
1567
|
+
/* *
|
|
1568
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1569
|
+
* you may not use this file except in compliance with the License.
|
|
1570
|
+
* You may obtain a copy of the License at
|
|
1571
|
+
*
|
|
1572
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1573
|
+
*
|
|
1574
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1575
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1576
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1577
|
+
* See the License for the specific language governing permissions and
|
|
1578
|
+
* limitations under the License.
|
|
1579
|
+
*
|
|
1580
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1581
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
1582
|
+
* */
|
|
1583
|
+
var TAKEOVER_MESSAGE = 'You are no longer the editor of this warning';
|
|
1584
|
+
var initialState = {};
|
|
1585
|
+
var slice = createSlice({
|
|
1586
|
+
initialState: initialState,
|
|
1532
1587
|
name: 'publicWarningForm',
|
|
1533
1588
|
reducers: {
|
|
1534
1589
|
setFormValues: function setFormValues(draft, action) {
|
|
@@ -1557,12 +1612,26 @@ var slice$1 = createSlice({
|
|
|
1557
1612
|
draft.selectedPublicWarningId = publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.id;
|
|
1558
1613
|
draft.formState = formState;
|
|
1559
1614
|
},
|
|
1615
|
+
toggleEditorWarning: function toggleEditorWarning(draft,
|
|
1616
|
+
// eslint-disable-next-line no-unused-vars
|
|
1617
|
+
action) {
|
|
1618
|
+
delete draft.error;
|
|
1619
|
+
},
|
|
1620
|
+
toggleEditorWarningSuccess: function toggleEditorWarningSuccess(draft, action) {
|
|
1621
|
+
var _action$payload3 = action.payload,
|
|
1622
|
+
isEditor = _action$payload3.isEditor,
|
|
1623
|
+
username = _action$payload3.username;
|
|
1624
|
+
if (draft.publicWarning) {
|
|
1625
|
+
draft.publicWarning.editor = isEditor ? username : '';
|
|
1626
|
+
}
|
|
1627
|
+
draft.formState = isEditor ? '' : 'readonly';
|
|
1628
|
+
},
|
|
1560
1629
|
// publish warning
|
|
1561
1630
|
publishWarning: function publishWarning(draft,
|
|
1562
1631
|
// eslint-disable-next-line no-unused-vars
|
|
1563
1632
|
action) {
|
|
1564
1633
|
draft.formState = 'publishing';
|
|
1565
|
-
draft.error
|
|
1634
|
+
delete draft.error;
|
|
1566
1635
|
},
|
|
1567
1636
|
publishWarningSuccess: function publishWarningSuccess(draft, action) {
|
|
1568
1637
|
var publicWarning = action.payload.publicWarning;
|
|
@@ -1575,18 +1644,28 @@ var slice$1 = createSlice({
|
|
|
1575
1644
|
// eslint-disable-next-line no-unused-vars
|
|
1576
1645
|
action) {
|
|
1577
1646
|
draft.formState = 'saving';
|
|
1578
|
-
draft.error
|
|
1647
|
+
delete draft.error;
|
|
1579
1648
|
draft.publicWarning = action.payload.publicWarning;
|
|
1580
1649
|
},
|
|
1581
1650
|
saveWarningSuccess: function saveWarningSuccess(draft, action) {
|
|
1651
|
+
var _a;
|
|
1582
1652
|
var publicWarning = action.payload.publicWarning;
|
|
1583
1653
|
draft.publicWarning = publicWarning;
|
|
1654
|
+
if ((_a = publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.warningDetail) === null || _a === void 0 ? void 0 : _a.id) {
|
|
1655
|
+
draft.selectedPublicWarningId = publicWarning.warningDetail.id;
|
|
1656
|
+
}
|
|
1584
1657
|
draft.formState = '';
|
|
1585
1658
|
},
|
|
1586
1659
|
setFormError: function setFormError(draft, action) {
|
|
1587
|
-
var
|
|
1660
|
+
var _action$payload4 = action.payload,
|
|
1661
|
+
message = _action$payload4.message,
|
|
1662
|
+
_action$payload4$seve = _action$payload4.severity,
|
|
1663
|
+
severity = _action$payload4$seve === void 0 ? 'error' : _action$payload4$seve;
|
|
1588
1664
|
draft.formState = '';
|
|
1589
|
-
draft.error =
|
|
1665
|
+
draft.error = {
|
|
1666
|
+
severity: severity,
|
|
1667
|
+
message: message
|
|
1668
|
+
};
|
|
1590
1669
|
},
|
|
1591
1670
|
setFormDirty: function setFormDirty(draft, action) {
|
|
1592
1671
|
var isFormDirty = action.payload.isFormDirty;
|
|
@@ -1595,9 +1674,9 @@ var slice$1 = createSlice({
|
|
|
1595
1674
|
},
|
|
1596
1675
|
extraReducers: function extraReducers(builder) {
|
|
1597
1676
|
builder.addCase(uiActions.setToggleOpenDialog, function (draft, action) {
|
|
1598
|
-
var _action$
|
|
1599
|
-
type = _action$
|
|
1600
|
-
setOpen = _action$
|
|
1677
|
+
var _action$payload5 = action.payload,
|
|
1678
|
+
type = _action$payload5.type,
|
|
1679
|
+
setOpen = _action$payload5.setOpen;
|
|
1601
1680
|
if (type === publicWarningDialogType && setOpen === false) {
|
|
1602
1681
|
delete draft.object;
|
|
1603
1682
|
delete draft.publicWarning;
|
|
@@ -1606,11 +1685,29 @@ var slice$1 = createSlice({
|
|
|
1606
1685
|
delete draft.selectedPublicWarningId;
|
|
1607
1686
|
delete draft.isFormDirty;
|
|
1608
1687
|
}
|
|
1688
|
+
}).addCase(publicWarningActions.fetchWarningsSuccess, function (draft, action) {
|
|
1689
|
+
var _a;
|
|
1690
|
+
var warnings = action.payload.warnings;
|
|
1691
|
+
if (draft.selectedPublicWarningId) {
|
|
1692
|
+
var currentWarning = warnings.find(function (warning) {
|
|
1693
|
+
return warning.id === draft.selectedPublicWarningId;
|
|
1694
|
+
});
|
|
1695
|
+
if (((_a = draft.publicWarning) === null || _a === void 0 ? void 0 : _a.editor) !== (currentWarning === null || currentWarning === void 0 ? void 0 : currentWarning.editor)) {
|
|
1696
|
+
draft.publicWarning.editor = currentWarning === null || currentWarning === void 0 ? void 0 : currentWarning.editor;
|
|
1697
|
+
// if form is in edit mode show warning
|
|
1698
|
+
if (draft.formState === '') {
|
|
1699
|
+
draft.error = {
|
|
1700
|
+
severity: 'warning',
|
|
1701
|
+
message: TAKEOVER_MESSAGE
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1609
1706
|
});
|
|
1610
1707
|
}
|
|
1611
1708
|
});
|
|
1612
|
-
var reducer
|
|
1613
|
-
var publicWarningFormActions = slice
|
|
1709
|
+
var reducer = slice.reducer;
|
|
1710
|
+
var publicWarningFormActions = slice.actions;
|
|
1614
1711
|
|
|
1615
1712
|
var getDeleteSucces = function getDeleteSucces(objectName) {
|
|
1616
1713
|
return "".concat(objectName, " has been deleted");
|
|
@@ -1803,8 +1900,7 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
|
|
|
1803
1900
|
publicWarning: {
|
|
1804
1901
|
warningDetail: {
|
|
1805
1902
|
geoJSON: object.geoJSON
|
|
1806
|
-
}
|
|
1807
|
-
status: 'DRAFT'
|
|
1903
|
+
}
|
|
1808
1904
|
}
|
|
1809
1905
|
}));
|
|
1810
1906
|
};
|
|
@@ -4657,13 +4753,14 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
|
|
|
4657
4753
|
}, /*#__PURE__*/React.createElement(SwitchButton, {
|
|
4658
4754
|
checked: !isReadOnly,
|
|
4659
4755
|
onChange: onChangeMode
|
|
4660
|
-
})),
|
|
4756
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
4661
4757
|
sx: {
|
|
4662
4758
|
position: 'relative',
|
|
4663
4759
|
top: 3,
|
|
4664
|
-
right: '-2px'
|
|
4760
|
+
right: '-2px',
|
|
4761
|
+
width: '16px'
|
|
4665
4762
|
}
|
|
4666
|
-
}, /*#__PURE__*/React.createElement(WarningAvatar, {
|
|
4763
|
+
}, publicWarningEditor && ( /*#__PURE__*/React.createElement(WarningAvatar, {
|
|
4667
4764
|
editor: publicWarningEditor
|
|
4668
4765
|
})))))
|
|
4669
4766
|
}, {
|
|
@@ -5374,7 +5471,12 @@ var Form = function Form(_ref5) {
|
|
|
5374
5471
|
formAction = _ref5$formAction === void 0 ? '' : _ref5$formAction,
|
|
5375
5472
|
publicWarningDetails = _ref5.publicWarningDetails,
|
|
5376
5473
|
_ref5$error = _ref5.error,
|
|
5377
|
-
error = _ref5$error === void 0 ?
|
|
5474
|
+
error = _ref5$error === void 0 ? {
|
|
5475
|
+
severity: 'error',
|
|
5476
|
+
message: ''
|
|
5477
|
+
} : _ref5$error,
|
|
5478
|
+
_ref5$isReadOnly = _ref5.isReadOnly,
|
|
5479
|
+
isReadOnly = _ref5$isReadOnly === void 0 ? false : _ref5$isReadOnly,
|
|
5378
5480
|
_ref5$onFormDirty = _ref5.onFormDirty,
|
|
5379
5481
|
onFormDirty = _ref5$onFormDirty === void 0 ? function () {} : _ref5$onFormDirty;
|
|
5380
5482
|
var _useFormContext = useFormContext(),
|
|
@@ -5386,12 +5488,11 @@ var Form = function Form(_ref5) {
|
|
|
5386
5488
|
DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
|
|
5387
5489
|
var isPublishing = formAction === 'publishing';
|
|
5388
5490
|
var isSaving = formAction === 'saving';
|
|
5389
|
-
var isReadOnly = formAction === 'readonly';
|
|
5390
5491
|
var areFieldsDisabled = isPublishing || isSaving;
|
|
5391
5492
|
useFormDirty({
|
|
5392
5493
|
isDirty: isDirty,
|
|
5393
5494
|
isLoading: isPublishing || isSaving,
|
|
5394
|
-
error: error,
|
|
5495
|
+
error: error === null || error === void 0 ? void 0 : error.message,
|
|
5395
5496
|
onFormDirty: onFormDirty,
|
|
5396
5497
|
onSuccess: function onSuccess() {
|
|
5397
5498
|
// reset form dirty after successfull saving
|
|
@@ -5443,7 +5544,7 @@ var Form = function Form(_ref5) {
|
|
|
5443
5544
|
// sync redux with react-hook-form
|
|
5444
5545
|
reset(getFormData(publicWarningDetails, object));
|
|
5445
5546
|
}, [object, reset, publicWarningDetails]);
|
|
5446
|
-
var errors = getErrors(error);
|
|
5547
|
+
var errors = getErrors(error.message);
|
|
5447
5548
|
return /*#__PURE__*/React.createElement(ContainerWrapper, null, /*#__PURE__*/React.createElement(ContainerFormWrapper, {
|
|
5448
5549
|
isReadOnly: isReadOnly
|
|
5449
5550
|
}, /*#__PURE__*/React.createElement(ContainerGrid, null, errors && ( /*#__PURE__*/React.createElement(Box, {
|
|
@@ -5453,7 +5554,8 @@ var Form = function Form(_ref5) {
|
|
|
5453
5554
|
}, /*#__PURE__*/React.createElement(AlertBanner, {
|
|
5454
5555
|
title: errors.title,
|
|
5455
5556
|
info: errors.errors,
|
|
5456
|
-
shouldClose: true
|
|
5557
|
+
shouldClose: true,
|
|
5558
|
+
severity: error === null || error === void 0 ? void 0 : error.severity
|
|
5457
5559
|
}))), /*#__PURE__*/React.createElement(Grid, {
|
|
5458
5560
|
container: true,
|
|
5459
5561
|
rowSpacing: 2
|
|
@@ -5643,11 +5745,15 @@ var getPublicWarningStatus = createSelector(getPublicWarningStore, function (pub
|
|
|
5643
5745
|
var _a;
|
|
5644
5746
|
return (_a = publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.publicWarning) === null || _a === void 0 ? void 0 : _a.status;
|
|
5645
5747
|
});
|
|
5748
|
+
var getPublicWarningEditor = createSelector(getPublicWarningStore, function (publicWarningStore) {
|
|
5749
|
+
var _a;
|
|
5750
|
+
return (_a = publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.publicWarning) === null || _a === void 0 ? void 0 : _a.editor;
|
|
5751
|
+
});
|
|
5646
5752
|
var getPublicWarningFormState = createSelector(getPublicWarningStore, function (publicWarningStore) {
|
|
5647
5753
|
return (publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.formState) || '';
|
|
5648
5754
|
});
|
|
5649
5755
|
var getPublicWarningFormError = createSelector(getPublicWarningStore, function (publicWarningStore) {
|
|
5650
|
-
return
|
|
5756
|
+
return publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.error;
|
|
5651
5757
|
});
|
|
5652
5758
|
var getSelectedPublicWarningId = createSelector(getPublicWarningStore, function (publicWarningStore) {
|
|
5653
5759
|
return (publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.selectedPublicWarningId) || '';
|
|
@@ -5685,6 +5791,12 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
|
|
|
5685
5791
|
var publicWarningFormError = useSelector(function (store) {
|
|
5686
5792
|
return getPublicWarningFormError(store);
|
|
5687
5793
|
});
|
|
5794
|
+
var publicWarningEditor = useSelector(function (store) {
|
|
5795
|
+
return getPublicWarningEditor(store);
|
|
5796
|
+
});
|
|
5797
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
5798
|
+
auth = _useAuthenticationCon.auth;
|
|
5799
|
+
var isEditor = publicWarningEditor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
|
|
5688
5800
|
var dispatch = useDispatch();
|
|
5689
5801
|
var publishForm = function publishForm(newFormValues) {
|
|
5690
5802
|
dispatch(publicWarningFormActions.publishWarning({
|
|
@@ -5698,7 +5810,8 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
|
|
|
5698
5810
|
dispatch(publicWarningFormActions.saveWarning({
|
|
5699
5811
|
publicWarning: {
|
|
5700
5812
|
warningDetail: newFormValues,
|
|
5701
|
-
status: 'DRAFT'
|
|
5813
|
+
status: 'DRAFT',
|
|
5814
|
+
editor: auth === null || auth === void 0 ? void 0 : auth.username
|
|
5702
5815
|
}
|
|
5703
5816
|
}));
|
|
5704
5817
|
};
|
|
@@ -5707,12 +5820,15 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
|
|
|
5707
5820
|
isFormDirty: isFormDirty
|
|
5708
5821
|
}));
|
|
5709
5822
|
};
|
|
5823
|
+
// Readonly also in case you are not creating a new warning and you are not set as the editor
|
|
5824
|
+
var isReadOnly = publicWarningFormAction === 'readonly' || !isEditor && (publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.status) !== undefined;
|
|
5710
5825
|
return /*#__PURE__*/React.createElement(PublicWarningsForm, {
|
|
5711
5826
|
object: publicWarningObject,
|
|
5712
5827
|
publicWarningDetails: publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.warningDetail,
|
|
5713
5828
|
onPublishForm: publishForm,
|
|
5714
5829
|
onSaveForm: saveForm,
|
|
5715
5830
|
formAction: publicWarningFormAction,
|
|
5831
|
+
isReadOnly: isReadOnly,
|
|
5716
5832
|
error: publicWarningFormError,
|
|
5717
5833
|
onFormDirty: onFormDirty
|
|
5718
5834
|
});
|
|
@@ -5725,11 +5841,15 @@ var warningFormConfirmationOptions = {
|
|
|
5725
5841
|
confirmLabel: 'Close',
|
|
5726
5842
|
catchOnCancel: true
|
|
5727
5843
|
};
|
|
5844
|
+
var isAlreadyEdited = function isAlreadyEdited(publicWarningEditor, username) {
|
|
5845
|
+
return publicWarningEditor !== undefined && publicWarningEditor !== '' && publicWarningEditor !== null && publicWarningEditor !== username;
|
|
5846
|
+
};
|
|
5728
5847
|
var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_ref) {
|
|
5729
5848
|
var bounds = _ref.bounds,
|
|
5730
5849
|
_ref$source = _ref.source,
|
|
5731
5850
|
source = _ref$source === void 0 ? 'app' : _ref$source,
|
|
5732
5851
|
startPosition = _ref.startPosition;
|
|
5852
|
+
var warningsApi = getWarningsApi();
|
|
5733
5853
|
var _useSetupDialog = useSetupDialog(publicWarningDialogType, source),
|
|
5734
5854
|
dialogOrder = _useSetupDialog.dialogOrder,
|
|
5735
5855
|
setDialogOrder = _useSetupDialog.setDialogOrder,
|
|
@@ -5739,11 +5859,6 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
5739
5859
|
uiIsLoading = _useSetupDialog.uiIsLoading;
|
|
5740
5860
|
var dispatch = useDispatch();
|
|
5741
5861
|
var confirmDialog = useConfirmationDialog();
|
|
5742
|
-
var onChangeFormMode = function onChangeFormMode(isChecked) {
|
|
5743
|
-
dispatch(publicWarningFormActions.setFormValues({
|
|
5744
|
-
formState: !isChecked ? '' : 'readonly'
|
|
5745
|
-
}));
|
|
5746
|
-
};
|
|
5747
5862
|
var formAction = useSelector(function (store) {
|
|
5748
5863
|
return getPublicWarningFormState(store);
|
|
5749
5864
|
});
|
|
@@ -5753,43 +5868,157 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
5753
5868
|
var publicWarningStatus = useSelector(function (store) {
|
|
5754
5869
|
return getPublicWarningStatus(store);
|
|
5755
5870
|
});
|
|
5756
|
-
var
|
|
5871
|
+
var selectedWarningId = useSelector(function (store) {
|
|
5872
|
+
return getSelectedPublicWarningId(store);
|
|
5873
|
+
});
|
|
5874
|
+
var publicWarningEditor = useSelector(function (store) {
|
|
5875
|
+
return getPublicWarningEditor(store);
|
|
5876
|
+
});
|
|
5877
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
5878
|
+
auth = _useAuthenticationCon.auth;
|
|
5879
|
+
var isEditor = publicWarningEditor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
|
|
5880
|
+
var getLatestEditor = function getLatestEditor() {
|
|
5757
5881
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
5758
|
-
var
|
|
5882
|
+
var latestWarnings, latestWarning;
|
|
5759
5883
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
5760
5884
|
while (1) switch (_context.prev = _context.next) {
|
|
5885
|
+
case 0:
|
|
5886
|
+
_context.next = 2;
|
|
5887
|
+
return warningsApi.getWarnings();
|
|
5888
|
+
case 2:
|
|
5889
|
+
latestWarnings = _context.sent;
|
|
5890
|
+
latestWarning = latestWarnings.data.find(function (warning) {
|
|
5891
|
+
return warning.id === selectedWarningId;
|
|
5892
|
+
});
|
|
5893
|
+
return _context.abrupt("return", latestWarning.editor || '');
|
|
5894
|
+
case 5:
|
|
5895
|
+
case "end":
|
|
5896
|
+
return _context.stop();
|
|
5897
|
+
}
|
|
5898
|
+
}, _callee);
|
|
5899
|
+
}));
|
|
5900
|
+
};
|
|
5901
|
+
var setIsEditor = function setIsEditor(isReadOnly) {
|
|
5902
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
5903
|
+
var username, latestEditor;
|
|
5904
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
5905
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
5906
|
+
case 0:
|
|
5907
|
+
username = (auth === null || auth === void 0 ? void 0 : auth.username) || ''; // make sure to get the latest changes if you are editing an existing warning
|
|
5908
|
+
if (!selectedWarningId) {
|
|
5909
|
+
_context2.next = 7;
|
|
5910
|
+
break;
|
|
5911
|
+
}
|
|
5912
|
+
_context2.next = 4;
|
|
5913
|
+
return getLatestEditor();
|
|
5914
|
+
case 4:
|
|
5915
|
+
_context2.t0 = _context2.sent;
|
|
5916
|
+
_context2.next = 8;
|
|
5917
|
+
break;
|
|
5918
|
+
case 7:
|
|
5919
|
+
_context2.t0 = '';
|
|
5920
|
+
case 8:
|
|
5921
|
+
latestEditor = _context2.t0;
|
|
5922
|
+
if (!(!selectedWarningId || !isReadOnly && username === latestEditor || isReadOnly && latestEditor !== username)) {
|
|
5923
|
+
_context2.next = 12;
|
|
5924
|
+
break;
|
|
5925
|
+
}
|
|
5926
|
+
// currently editing a new warning or
|
|
5927
|
+
// correct editor is already set or
|
|
5928
|
+
// someone else is editor so only have to set to readonly mode
|
|
5929
|
+
// No need for a BE call
|
|
5930
|
+
dispatch(publicWarningFormActions.setFormValues({
|
|
5931
|
+
formState: isReadOnly ? 'readonly' : ''
|
|
5932
|
+
}));
|
|
5933
|
+
return _context2.abrupt("return", true);
|
|
5934
|
+
case 12:
|
|
5935
|
+
if (!(!isReadOnly && isAlreadyEdited(latestEditor, username))) {
|
|
5936
|
+
_context2.next = 15;
|
|
5937
|
+
break;
|
|
5938
|
+
}
|
|
5939
|
+
_context2.next = 15;
|
|
5940
|
+
return confirmDialog({
|
|
5941
|
+
title: 'Switch to edit mode',
|
|
5942
|
+
description: 'This warning is already in edit mode by another user and important information could get lost in the switching process.',
|
|
5943
|
+
confirmLabel: 'Edit mode'
|
|
5944
|
+
});
|
|
5945
|
+
case 15:
|
|
5946
|
+
dispatch(publicWarningFormActions.toggleEditorWarning({
|
|
5947
|
+
warningId: selectedWarningId,
|
|
5948
|
+
isEditor: !isReadOnly,
|
|
5949
|
+
username: username
|
|
5950
|
+
}));
|
|
5951
|
+
return _context2.abrupt("return", true);
|
|
5952
|
+
case 17:
|
|
5953
|
+
case "end":
|
|
5954
|
+
return _context2.stop();
|
|
5955
|
+
}
|
|
5956
|
+
}, _callee2);
|
|
5957
|
+
}));
|
|
5958
|
+
};
|
|
5959
|
+
var onChangeFormMode = function onChangeFormMode(isReadOnly) {
|
|
5960
|
+
if (isReadOnly && isFormDirty) {
|
|
5961
|
+
confirmDialog({
|
|
5962
|
+
title: 'Whoops',
|
|
5963
|
+
description: 'Are you sure you want to switch to view mode? Your unsaved changes will be lost.',
|
|
5964
|
+
confirmLabel: 'Switch mode'
|
|
5965
|
+
}).then(function () {
|
|
5966
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
5967
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
5968
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
5969
|
+
case 0:
|
|
5970
|
+
_context3.next = 2;
|
|
5971
|
+
return setIsEditor(isReadOnly);
|
|
5972
|
+
case 2:
|
|
5973
|
+
case "end":
|
|
5974
|
+
return _context3.stop();
|
|
5975
|
+
}
|
|
5976
|
+
}, _callee3);
|
|
5977
|
+
}));
|
|
5978
|
+
});
|
|
5979
|
+
} else {
|
|
5980
|
+
setIsEditor(isReadOnly);
|
|
5981
|
+
}
|
|
5982
|
+
};
|
|
5983
|
+
var closeDialog = function closeDialog() {
|
|
5984
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
5985
|
+
var mayProceed;
|
|
5986
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
5987
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
5761
5988
|
case 0:
|
|
5762
5989
|
if (!isFormDirty) {
|
|
5763
|
-
|
|
5990
|
+
_context4.next = 6;
|
|
5764
5991
|
break;
|
|
5765
5992
|
}
|
|
5766
|
-
|
|
5993
|
+
_context4.next = 3;
|
|
5767
5994
|
return confirmDialog(warningFormConfirmationOptions).then(function () {
|
|
5768
5995
|
return true;
|
|
5769
5996
|
})["catch"](function () {
|
|
5770
5997
|
return false;
|
|
5771
5998
|
});
|
|
5772
5999
|
case 3:
|
|
5773
|
-
mayProceed =
|
|
6000
|
+
mayProceed = _context4.sent;
|
|
5774
6001
|
if (mayProceed) {
|
|
5775
|
-
|
|
6002
|
+
_context4.next = 6;
|
|
5776
6003
|
break;
|
|
5777
6004
|
}
|
|
5778
|
-
return
|
|
6005
|
+
return _context4.abrupt("return");
|
|
5779
6006
|
case 6:
|
|
5780
6007
|
onCloseDialog();
|
|
5781
6008
|
case 7:
|
|
5782
6009
|
case "end":
|
|
5783
|
-
return
|
|
6010
|
+
return _context4.stop();
|
|
5784
6011
|
}
|
|
5785
|
-
},
|
|
6012
|
+
}, _callee4);
|
|
5786
6013
|
}));
|
|
5787
6014
|
};
|
|
5788
6015
|
if (!isDialogOpen) {
|
|
5789
6016
|
return null;
|
|
5790
6017
|
}
|
|
5791
|
-
|
|
5792
|
-
var
|
|
6018
|
+
// Readonly also in case you are not creating a new warning and you are not set as the editor
|
|
6019
|
+
var isReadOnly = formAction === 'readonly' || !isEditor && publicWarningStatus !== undefined;
|
|
6020
|
+
// Only show toggle if in draft status
|
|
6021
|
+
var shouldHideFormToggleMode = publicWarningStatus !== 'DRAFT';
|
|
5793
6022
|
return /*#__PURE__*/React__default.createElement(PublicWarningsFormDialog, {
|
|
5794
6023
|
isOpen: isDialogOpen,
|
|
5795
6024
|
onClose: closeDialog,
|
|
@@ -5801,7 +6030,8 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
5801
6030
|
isLoading: uiIsLoading,
|
|
5802
6031
|
isReadOnly: isReadOnly,
|
|
5803
6032
|
onChangeFormMode: onChangeFormMode,
|
|
5804
|
-
shouldHideFormMode: shouldHideFormToggleMode
|
|
6033
|
+
shouldHideFormMode: shouldHideFormToggleMode,
|
|
6034
|
+
publicWarningEditor: publicWarningEditor
|
|
5805
6035
|
}, /*#__PURE__*/React__default.createElement(PublicWarningsFormConnect, null));
|
|
5806
6036
|
};
|
|
5807
6037
|
|
|
@@ -6070,6 +6300,9 @@ var PublicWarningList = function PublicWarningList(_ref2) {
|
|
|
6070
6300
|
_ref2$isLoading = _ref2.isLoading,
|
|
6071
6301
|
isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading,
|
|
6072
6302
|
error = _ref2.error,
|
|
6303
|
+
_ref2$selectedPublicW = _ref2.selectedPublicWarningId,
|
|
6304
|
+
selectedPublicWarningId = _ref2$selectedPublicW === void 0 ? '' : _ref2$selectedPublicW,
|
|
6305
|
+
lastUpdatedTime = _ref2.lastUpdatedTime,
|
|
6073
6306
|
_ref2$onSelectWarning = _ref2.onSelectWarning,
|
|
6074
6307
|
onSelectWarning = _ref2$onSelectWarning === void 0 ? function () {} : _ref2$onSelectWarning,
|
|
6075
6308
|
_ref2$onEditWarning = _ref2.onEditWarning,
|
|
@@ -6078,8 +6311,8 @@ var PublicWarningList = function PublicWarningList(_ref2) {
|
|
|
6078
6311
|
onCreateWarning = _ref2$onCreateWarning === void 0 ? function () {} : _ref2$onCreateWarning,
|
|
6079
6312
|
_ref2$onDeleteWarning = _ref2.onDeleteWarning,
|
|
6080
6313
|
onDeleteWarning = _ref2$onDeleteWarning === void 0 ? function () {} : _ref2$onDeleteWarning,
|
|
6081
|
-
_ref2$
|
|
6082
|
-
|
|
6314
|
+
_ref2$onRefetchWarnin = _ref2.onRefetchWarnings,
|
|
6315
|
+
onRefetchWarnings = _ref2$onRefetchWarnin === void 0 ? function () {} : _ref2$onRefetchWarnin;
|
|
6083
6316
|
var sortedWarnings = warnings ? sortWarningsOnStatus(warnings) : null;
|
|
6084
6317
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
6085
6318
|
sx: {
|
|
@@ -6106,7 +6339,17 @@ var PublicWarningList = function PublicWarningList(_ref2) {
|
|
|
6106
6339
|
}), isLoading && ( /*#__PURE__*/React__default.createElement(LinearProgress, {
|
|
6107
6340
|
"data-testid": "loading-bar",
|
|
6108
6341
|
color: "secondary"
|
|
6109
|
-
})),
|
|
6342
|
+
})), lastUpdatedTime && ( /*#__PURE__*/React__default.createElement(Box, {
|
|
6343
|
+
sx: {
|
|
6344
|
+
marginBottom: -3.25,
|
|
6345
|
+
button: {
|
|
6346
|
+
marginRight: 0
|
|
6347
|
+
}
|
|
6348
|
+
}
|
|
6349
|
+
}, /*#__PURE__*/React__default.createElement(LastUpdateTime, {
|
|
6350
|
+
onPressRefresh: onRefetchWarnings,
|
|
6351
|
+
lastUpdateTime: lastUpdatedTime
|
|
6352
|
+
}))), sortedWarnings && !error && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningsOnStatus, {
|
|
6110
6353
|
status: "TODO",
|
|
6111
6354
|
warnings: sortedWarnings.todo,
|
|
6112
6355
|
onSelectWarning: onSelectWarning,
|
|
@@ -6137,54 +6380,6 @@ var PublicWarningList = function PublicWarningList(_ref2) {
|
|
|
6137
6380
|
}))));
|
|
6138
6381
|
};
|
|
6139
6382
|
|
|
6140
|
-
/* *
|
|
6141
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6142
|
-
* you may not use this file except in compliance with the License.
|
|
6143
|
-
* You may obtain a copy of the License at
|
|
6144
|
-
*
|
|
6145
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6146
|
-
*
|
|
6147
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
6148
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6149
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6150
|
-
* See the License for the specific language governing permissions and
|
|
6151
|
-
* limitations under the License.
|
|
6152
|
-
*
|
|
6153
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6154
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
6155
|
-
* */
|
|
6156
|
-
var publicWarningsAdapter = createEntityAdapter({
|
|
6157
|
-
selectId: function selectId(warning) {
|
|
6158
|
-
return warning.id;
|
|
6159
|
-
}
|
|
6160
|
-
});
|
|
6161
|
-
var initialState = {
|
|
6162
|
-
warnings: publicWarningsAdapter.getInitialState(),
|
|
6163
|
-
isLoading: true
|
|
6164
|
-
};
|
|
6165
|
-
var slice = createSlice({
|
|
6166
|
-
initialState: initialState,
|
|
6167
|
-
name: 'publicWarnings',
|
|
6168
|
-
reducers: {
|
|
6169
|
-
fetchWarnings: function fetchWarnings(draft) {
|
|
6170
|
-
draft.isLoading = true;
|
|
6171
|
-
delete draft.error;
|
|
6172
|
-
},
|
|
6173
|
-
fetchWarningsSuccess: function fetchWarningsSuccess(draft, action) {
|
|
6174
|
-
var warnings = action.payload.warnings;
|
|
6175
|
-
draft.isLoading = false;
|
|
6176
|
-
publicWarningsAdapter.setAll(draft.warnings, warnings);
|
|
6177
|
-
},
|
|
6178
|
-
fetchWarningsError: function fetchWarningsError(draft, action) {
|
|
6179
|
-
var error = action.payload.error;
|
|
6180
|
-
draft.isLoading = false;
|
|
6181
|
-
draft.error = error;
|
|
6182
|
-
}
|
|
6183
|
-
}
|
|
6184
|
-
});
|
|
6185
|
-
var reducer = slice.reducer;
|
|
6186
|
-
var publicWarningActions = slice.actions;
|
|
6187
|
-
|
|
6188
6383
|
/* *
|
|
6189
6384
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6190
6385
|
* you may not use this file except in compliance with the License.
|
|
@@ -6221,6 +6416,9 @@ var isPublicWarningsLoading = createSelector(getPublicWarningsStore, function (s
|
|
|
6221
6416
|
var getPublicWarningsError = createSelector(getPublicWarningsStore, function (store) {
|
|
6222
6417
|
return store === null || store === void 0 ? void 0 : store.error;
|
|
6223
6418
|
});
|
|
6419
|
+
var getPublicWarningsLastUpdatedTime = createSelector(getPublicWarningsStore, function (store) {
|
|
6420
|
+
return store === null || store === void 0 ? void 0 : store.lastUpdatedTime;
|
|
6421
|
+
});
|
|
6224
6422
|
|
|
6225
6423
|
var DELETE_TITLE = 'Delete warning';
|
|
6226
6424
|
var DELETE_CONFIRM = 'Delete';
|
|
@@ -6321,6 +6519,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
6321
6519
|
var isFormDirty = useSelector(function (store) {
|
|
6322
6520
|
return getSelectedPublicIsFormDirty(store);
|
|
6323
6521
|
});
|
|
6522
|
+
var lastUpdatedTime = useSelector(function (store) {
|
|
6523
|
+
return getPublicWarningsLastUpdatedTime(store);
|
|
6524
|
+
});
|
|
6324
6525
|
var openPublicWarningDialog = function openPublicWarningDialog(formAction, publicWarning) {
|
|
6325
6526
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6326
6527
|
var mayProceed;
|
|
@@ -6385,12 +6586,15 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
6385
6586
|
}));
|
|
6386
6587
|
}
|
|
6387
6588
|
openSnackbar(DELETE_WARNING_SUCCESS_MESSAGE);
|
|
6388
|
-
|
|
6589
|
+
fetchWarnings();
|
|
6389
6590
|
};
|
|
6390
|
-
React__default.
|
|
6391
|
-
// fetch warnings on mount
|
|
6591
|
+
var fetchWarnings = React__default.useCallback(function () {
|
|
6392
6592
|
dispatch(publicWarningActions.fetchWarnings());
|
|
6393
6593
|
}, [dispatch]);
|
|
6594
|
+
React__default.useEffect(function () {
|
|
6595
|
+
// fetch warnings on mount
|
|
6596
|
+
fetchWarnings();
|
|
6597
|
+
}, [fetchWarnings]);
|
|
6394
6598
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PublicWarningList, {
|
|
6395
6599
|
warnings: warnings,
|
|
6396
6600
|
isLoading: isLoading,
|
|
@@ -6399,7 +6603,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
6399
6603
|
onCreateWarning: createWarning,
|
|
6400
6604
|
onEditWarning: editWarning,
|
|
6401
6605
|
onDeleteWarning: deleteWarning,
|
|
6402
|
-
selectedPublicWarningId: selectedPublicWarningId
|
|
6606
|
+
selectedPublicWarningId: selectedPublicWarningId,
|
|
6607
|
+
lastUpdatedTime: lastUpdatedTime,
|
|
6608
|
+
onRefetchWarnings: fetchWarnings
|
|
6403
6609
|
}), confirmDeleteWarning && ( /*#__PURE__*/React__default.createElement(ConfirmDeleteWarningDialog, {
|
|
6404
6610
|
warningId: confirmDeleteWarning,
|
|
6405
6611
|
onDeleteSucces: onDeleteSuccess,
|
|
@@ -6605,43 +6811,53 @@ function saveOrUpdateWarning(publicWarning) {
|
|
|
6605
6811
|
}
|
|
6606
6812
|
}, _marked$1);
|
|
6607
6813
|
}
|
|
6608
|
-
function
|
|
6814
|
+
var getToggleEditorSuccessMessage = function getToggleEditorSuccessMessage(isEditor) {
|
|
6815
|
+
return "You are now ".concat(isEditor ? '' : 'no longer ', "the editor for this warning");
|
|
6816
|
+
};
|
|
6817
|
+
function toggleEditorWarningSaga(_ref) {
|
|
6609
6818
|
var payload = _ref.payload;
|
|
6610
6819
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6611
|
-
var
|
|
6820
|
+
var warningId, isEditor, username, warningsApi;
|
|
6612
6821
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
6613
6822
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6614
6823
|
case 0:
|
|
6615
6824
|
_context2.prev = 0;
|
|
6616
|
-
|
|
6825
|
+
warningId = payload.warningId, isEditor = payload.isEditor, username = payload.username;
|
|
6617
6826
|
_context2.next = 4;
|
|
6618
|
-
return call(
|
|
6827
|
+
return call(getWarningsApi);
|
|
6619
6828
|
case 4:
|
|
6620
|
-
|
|
6829
|
+
warningsApi = _context2.sent;
|
|
6621
6830
|
_context2.next = 7;
|
|
6622
|
-
return
|
|
6623
|
-
publicWarning: publishedWarning,
|
|
6624
|
-
message: PUBLISH_SUCCES
|
|
6625
|
-
}));
|
|
6831
|
+
return call(warningsApi.toggleEditorWarning, warningId, isEditor);
|
|
6626
6832
|
case 7:
|
|
6627
|
-
_context2.next =
|
|
6628
|
-
|
|
6833
|
+
_context2.next = 9;
|
|
6834
|
+
return put(publicWarningActions.fetchWarnings());
|
|
6629
6835
|
case 9:
|
|
6630
|
-
_context2.
|
|
6836
|
+
_context2.next = 11;
|
|
6837
|
+
return put(publicWarningFormActions.toggleEditorWarningSuccess({
|
|
6838
|
+
isEditor: isEditor,
|
|
6839
|
+
username: username,
|
|
6840
|
+
message: getToggleEditorSuccessMessage(isEditor)
|
|
6841
|
+
}));
|
|
6842
|
+
case 11:
|
|
6843
|
+
_context2.next = 17;
|
|
6844
|
+
break;
|
|
6845
|
+
case 13:
|
|
6846
|
+
_context2.prev = 13;
|
|
6631
6847
|
_context2.t0 = _context2["catch"](0);
|
|
6632
|
-
_context2.next =
|
|
6848
|
+
_context2.next = 17;
|
|
6633
6849
|
return call(errorSaga, getErrorMessage(_context2.t0));
|
|
6634
|
-
case
|
|
6850
|
+
case 17:
|
|
6635
6851
|
case "end":
|
|
6636
6852
|
return _context2.stop();
|
|
6637
6853
|
}
|
|
6638
|
-
}, _callee, null, [[0,
|
|
6854
|
+
}, _callee, null, [[0, 13]]);
|
|
6639
6855
|
})();
|
|
6640
6856
|
}
|
|
6641
|
-
function
|
|
6857
|
+
function publishWarningSaga(_ref2) {
|
|
6642
6858
|
var payload = _ref2.payload;
|
|
6643
6859
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
6644
|
-
var publicWarning,
|
|
6860
|
+
var publicWarning, publishedWarning;
|
|
6645
6861
|
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
6646
6862
|
while (1) switch (_context3.prev = _context3.next) {
|
|
6647
6863
|
case 0:
|
|
@@ -6650,11 +6866,11 @@ function saveWarningSaga(_ref2) {
|
|
|
6650
6866
|
_context3.next = 4;
|
|
6651
6867
|
return call(saveOrUpdateWarning, publicWarning);
|
|
6652
6868
|
case 4:
|
|
6653
|
-
|
|
6869
|
+
publishedWarning = _context3.sent;
|
|
6654
6870
|
_context3.next = 7;
|
|
6655
|
-
return put(publicWarningFormActions.
|
|
6656
|
-
publicWarning:
|
|
6657
|
-
message:
|
|
6871
|
+
return put(publicWarningFormActions.publishWarningSuccess({
|
|
6872
|
+
publicWarning: publishedWarning,
|
|
6873
|
+
message: PUBLISH_SUCCES
|
|
6658
6874
|
}));
|
|
6659
6875
|
case 7:
|
|
6660
6876
|
_context3.next = 13;
|
|
@@ -6671,105 +6887,141 @@ function saveWarningSaga(_ref2) {
|
|
|
6671
6887
|
}, _callee2, null, [[0, 9]]);
|
|
6672
6888
|
})();
|
|
6673
6889
|
}
|
|
6674
|
-
function
|
|
6890
|
+
function saveWarningSaga(_ref3) {
|
|
6675
6891
|
var payload = _ref3.payload;
|
|
6676
6892
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
6677
|
-
var
|
|
6893
|
+
var publicWarning, savedWarning;
|
|
6678
6894
|
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
6679
6895
|
while (1) switch (_context4.prev = _context4.next) {
|
|
6896
|
+
case 0:
|
|
6897
|
+
_context4.prev = 0;
|
|
6898
|
+
publicWarning = payload.publicWarning;
|
|
6899
|
+
_context4.next = 4;
|
|
6900
|
+
return call(saveOrUpdateWarning, publicWarning);
|
|
6901
|
+
case 4:
|
|
6902
|
+
savedWarning = _context4.sent;
|
|
6903
|
+
_context4.next = 7;
|
|
6904
|
+
return put(publicWarningFormActions.saveWarningSuccess({
|
|
6905
|
+
publicWarning: savedWarning,
|
|
6906
|
+
message: SAVE_SUCCES
|
|
6907
|
+
}));
|
|
6908
|
+
case 7:
|
|
6909
|
+
_context4.next = 13;
|
|
6910
|
+
break;
|
|
6911
|
+
case 9:
|
|
6912
|
+
_context4.prev = 9;
|
|
6913
|
+
_context4.t0 = _context4["catch"](0);
|
|
6914
|
+
_context4.next = 13;
|
|
6915
|
+
return call(errorSaga, getErrorMessage(_context4.t0));
|
|
6916
|
+
case 13:
|
|
6917
|
+
case "end":
|
|
6918
|
+
return _context4.stop();
|
|
6919
|
+
}
|
|
6920
|
+
}, _callee3, null, [[0, 9]]);
|
|
6921
|
+
})();
|
|
6922
|
+
}
|
|
6923
|
+
function successSaga(_ref4) {
|
|
6924
|
+
var payload = _ref4.payload;
|
|
6925
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
6926
|
+
var message;
|
|
6927
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
6928
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
6680
6929
|
case 0:
|
|
6681
6930
|
message = payload.message;
|
|
6682
|
-
|
|
6931
|
+
_context5.next = 3;
|
|
6683
6932
|
return put(snackbarActions.openSnackbar({
|
|
6684
6933
|
message: message
|
|
6685
6934
|
}));
|
|
6686
6935
|
case 3:
|
|
6687
|
-
|
|
6936
|
+
_context5.next = 5;
|
|
6688
6937
|
return call(toggleDialogLoadingSaga, false);
|
|
6689
6938
|
case 5:
|
|
6690
6939
|
case "end":
|
|
6691
|
-
return
|
|
6940
|
+
return _context5.stop();
|
|
6692
6941
|
}
|
|
6693
|
-
},
|
|
6942
|
+
}, _callee4);
|
|
6694
6943
|
})();
|
|
6695
6944
|
}
|
|
6696
6945
|
function errorSaga(message) {
|
|
6697
|
-
return _regeneratorRuntime().wrap(function errorSaga$(
|
|
6698
|
-
while (1) switch (
|
|
6946
|
+
return _regeneratorRuntime().wrap(function errorSaga$(_context6) {
|
|
6947
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
6699
6948
|
case 0:
|
|
6700
|
-
|
|
6949
|
+
_context6.next = 2;
|
|
6701
6950
|
return put(publicWarningFormActions.setFormError({
|
|
6702
|
-
|
|
6951
|
+
message: message
|
|
6703
6952
|
}));
|
|
6704
6953
|
case 2:
|
|
6705
|
-
|
|
6954
|
+
_context6.next = 4;
|
|
6706
6955
|
return call(toggleDialogLoadingSaga, false);
|
|
6707
6956
|
case 4:
|
|
6708
6957
|
case "end":
|
|
6709
|
-
return
|
|
6958
|
+
return _context6.stop();
|
|
6710
6959
|
}
|
|
6711
6960
|
}, _marked2$1);
|
|
6712
6961
|
}
|
|
6713
6962
|
function toggleDialogLoadingSaga(isLoading) {
|
|
6714
6963
|
var isDialogOpen;
|
|
6715
|
-
return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(
|
|
6716
|
-
while (1) switch (
|
|
6964
|
+
return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(_context7) {
|
|
6965
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
6717
6966
|
case 0:
|
|
6718
|
-
|
|
6967
|
+
_context7.next = 2;
|
|
6719
6968
|
return select(uiSelectors.getDialogDetailsByType, publicWarningDialogType);
|
|
6720
6969
|
case 2:
|
|
6721
|
-
isDialogOpen =
|
|
6970
|
+
isDialogOpen = _context7.sent;
|
|
6722
6971
|
if (!isDialogOpen) {
|
|
6723
|
-
|
|
6972
|
+
_context7.next = 6;
|
|
6724
6973
|
break;
|
|
6725
6974
|
}
|
|
6726
|
-
|
|
6975
|
+
_context7.next = 6;
|
|
6727
6976
|
return put(uiActions.toggleIsLoadingDialog({
|
|
6728
6977
|
isLoading: isLoading,
|
|
6729
6978
|
type: publicWarningDialogType
|
|
6730
6979
|
}));
|
|
6731
6980
|
case 6:
|
|
6732
6981
|
case "end":
|
|
6733
|
-
return
|
|
6982
|
+
return _context7.stop();
|
|
6734
6983
|
}
|
|
6735
6984
|
}, _marked3$1);
|
|
6736
6985
|
}
|
|
6737
6986
|
function openDialogSaga() {
|
|
6738
|
-
return _regeneratorRuntime().wrap(function openDialogSaga$(
|
|
6739
|
-
while (1) switch (
|
|
6987
|
+
return _regeneratorRuntime().wrap(function openDialogSaga$(_context8) {
|
|
6988
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
6740
6989
|
case 0:
|
|
6741
|
-
|
|
6990
|
+
_context8.next = 2;
|
|
6742
6991
|
return put(uiActions.setToggleOpenDialog({
|
|
6743
6992
|
setOpen: true,
|
|
6744
6993
|
type: publicWarningDialogType
|
|
6745
6994
|
}));
|
|
6746
6995
|
case 2:
|
|
6747
6996
|
case "end":
|
|
6748
|
-
return
|
|
6997
|
+
return _context8.stop();
|
|
6749
6998
|
}
|
|
6750
6999
|
}, _marked4);
|
|
6751
7000
|
}
|
|
6752
7001
|
function publicWarningRootSaga() {
|
|
6753
|
-
return _regeneratorRuntime().wrap(function publicWarningRootSaga$(
|
|
6754
|
-
while (1) switch (
|
|
7002
|
+
return _regeneratorRuntime().wrap(function publicWarningRootSaga$(_context9) {
|
|
7003
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
6755
7004
|
case 0:
|
|
6756
|
-
|
|
6757
|
-
return takeLatest(publicWarningFormActions.
|
|
7005
|
+
_context9.next = 2;
|
|
7006
|
+
return takeLatest(publicWarningFormActions.toggleEditorWarning, toggleEditorWarningSaga);
|
|
6758
7007
|
case 2:
|
|
6759
|
-
|
|
6760
|
-
return takeLatest(publicWarningFormActions.
|
|
7008
|
+
_context9.next = 4;
|
|
7009
|
+
return takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
|
|
6761
7010
|
case 4:
|
|
6762
|
-
|
|
6763
|
-
return takeLatest(
|
|
7011
|
+
_context9.next = 6;
|
|
7012
|
+
return takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
|
|
6764
7013
|
case 6:
|
|
6765
|
-
|
|
6766
|
-
return takeLatest([publicWarningFormActions.
|
|
7014
|
+
_context9.next = 8;
|
|
7015
|
+
return takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess, publicWarningFormActions.toggleEditorWarningSuccess], successSaga);
|
|
6767
7016
|
case 8:
|
|
6768
|
-
|
|
6769
|
-
return takeLatest(publicWarningFormActions.
|
|
7017
|
+
_context9.next = 10;
|
|
7018
|
+
return takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
|
|
6770
7019
|
case 10:
|
|
7020
|
+
_context9.next = 12;
|
|
7021
|
+
return takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
|
|
7022
|
+
case 12:
|
|
6771
7023
|
case "end":
|
|
6772
|
-
return
|
|
7024
|
+
return _context9.stop();
|
|
6773
7025
|
}
|
|
6774
7026
|
}, _marked5);
|
|
6775
7027
|
}
|
|
@@ -6777,8 +7029,11 @@ function publicWarningRootSaga() {
|
|
|
6777
7029
|
var _marked = /*#__PURE__*/_regeneratorRuntime().mark(fetchWarningsSaga),
|
|
6778
7030
|
_marked2 = /*#__PURE__*/_regeneratorRuntime().mark(refetchWarnings),
|
|
6779
7031
|
_marked3 = /*#__PURE__*/_regeneratorRuntime().mark(publicWarnings);
|
|
7032
|
+
var getLastUpdatedTimeFormatted = function getLastUpdatedTimeFormatted() {
|
|
7033
|
+
return dateUtils.dateToString(dateUtils.utc(), DATE_FORMAT_LASTUPDATEDTIME);
|
|
7034
|
+
};
|
|
6780
7035
|
function fetchWarningsSaga() {
|
|
6781
|
-
var warningsApi, _yield$call, warnings;
|
|
7036
|
+
var warningsApi, _yield$call, warnings, lastUpdatedTime;
|
|
6782
7037
|
return _regeneratorRuntime().wrap(function fetchWarningsSaga$(_context) {
|
|
6783
7038
|
while (1) switch (_context.prev = _context.next) {
|
|
6784
7039
|
case 0:
|
|
@@ -6792,28 +7047,36 @@ function fetchWarningsSaga() {
|
|
|
6792
7047
|
case 6:
|
|
6793
7048
|
_yield$call = _context.sent;
|
|
6794
7049
|
warnings = _yield$call.data;
|
|
6795
|
-
|
|
7050
|
+
lastUpdatedTime = getLastUpdatedTimeFormatted();
|
|
7051
|
+
_context.next = 11;
|
|
6796
7052
|
return put(publicWarningActions.fetchWarningsSuccess({
|
|
6797
|
-
warnings: warnings
|
|
7053
|
+
warnings: warnings,
|
|
7054
|
+
lastUpdatedTime: lastUpdatedTime
|
|
6798
7055
|
}));
|
|
6799
|
-
case
|
|
6800
|
-
_context.next =
|
|
7056
|
+
case 11:
|
|
7057
|
+
_context.next = 13;
|
|
7058
|
+
return delay(pollingIntervalTimeout);
|
|
7059
|
+
case 13:
|
|
7060
|
+
_context.next = 15;
|
|
7061
|
+
return put(publicWarningActions.fetchWarnings());
|
|
7062
|
+
case 15:
|
|
7063
|
+
_context.next = 21;
|
|
6801
7064
|
break;
|
|
6802
|
-
case
|
|
6803
|
-
_context.prev =
|
|
7065
|
+
case 17:
|
|
7066
|
+
_context.prev = 17;
|
|
6804
7067
|
_context.t0 = _context["catch"](0);
|
|
6805
|
-
_context.next =
|
|
7068
|
+
_context.next = 21;
|
|
6806
7069
|
return put(publicWarningActions.fetchWarningsError({
|
|
6807
7070
|
error: {
|
|
6808
7071
|
name: _context.t0.name,
|
|
6809
7072
|
message: _context.t0.message
|
|
6810
7073
|
}
|
|
6811
7074
|
}));
|
|
6812
|
-
case
|
|
7075
|
+
case 21:
|
|
6813
7076
|
case "end":
|
|
6814
7077
|
return _context.stop();
|
|
6815
7078
|
}
|
|
6816
|
-
}, _marked, null, [[0,
|
|
7079
|
+
}, _marked, null, [[0, 17]]);
|
|
6817
7080
|
}
|
|
6818
7081
|
function refetchWarnings() {
|
|
6819
7082
|
return _regeneratorRuntime().wrap(function refetchWarnings$(_context2) {
|
|
@@ -6863,10 +7126,10 @@ var drawingModuleConfig = {
|
|
|
6863
7126
|
id: 'drawing-module',
|
|
6864
7127
|
reducersMap: {
|
|
6865
7128
|
drawings: reducer$2,
|
|
6866
|
-
publicWarningForm: reducer
|
|
6867
|
-
publicWarnings: reducer
|
|
7129
|
+
publicWarningForm: reducer,
|
|
7130
|
+
publicWarnings: reducer$1
|
|
6868
7131
|
},
|
|
6869
7132
|
sagas: [drawingSaga, publicWarningRootSaga, publicWarnings]
|
|
6870
7133
|
};
|
|
6871
7134
|
|
|
6872
|
-
export { DIALOG_TITLE, DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, useObjectDrawDialogAction, warningFormConfirmationOptions };
|
|
7135
|
+
export { DIALOG_TITLE, DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, isAlreadyEdited, useObjectDrawDialogAction, warningFormConfirmationOptions };
|
package/package.json
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/warnings",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"description": "GeoWeb warinings library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git@gitlab.com:opengeoweb/opengeoweb.git"
|
|
9
9
|
},
|
|
10
|
-
"dependencies": {
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@opengeoweb/api": "*",
|
|
12
|
+
"@redux-eggs/redux-toolkit": "^2.2.0",
|
|
13
|
+
"@opengeoweb/shared": "*",
|
|
14
|
+
"@opengeoweb/store": "*",
|
|
15
|
+
"@opengeoweb/webmap-react": "*",
|
|
16
|
+
"react-redux": "^8.1.3",
|
|
17
|
+
"@mui/material": "5.12.0",
|
|
18
|
+
"@opengeoweb/theme": "*",
|
|
19
|
+
"@opengeoweb/form-fields": "*",
|
|
20
|
+
"react-hook-form": "7.47.0",
|
|
21
|
+
"lodash": "^4.17.21",
|
|
22
|
+
"redux-saga": "^1.2.3",
|
|
23
|
+
"@reduxjs/toolkit": "^1.9.7",
|
|
24
|
+
"@opengeoweb/snackbar": "*",
|
|
25
|
+
"react-window": "^1.8.10",
|
|
26
|
+
"react-virtualized-auto-sizer": "^1.0.20",
|
|
27
|
+
"axios": "1.5.0",
|
|
28
|
+
"@opengeoweb/core": "*",
|
|
29
|
+
"@opengeoweb/webmap": "*",
|
|
30
|
+
"@opengeoweb/authentication": "*"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "18"
|
|
34
|
+
},
|
|
11
35
|
"module": "./index.esm.js",
|
|
12
36
|
"type": "module",
|
|
13
37
|
"main": "./index.esm.js"
|
|
@@ -15,10 +15,12 @@ export declare const PublicWarningList: React.FC<{
|
|
|
15
15
|
warnings: PublicWarning[];
|
|
16
16
|
isLoading?: boolean;
|
|
17
17
|
error?: Error;
|
|
18
|
+
selectedPublicWarningId?: string;
|
|
19
|
+
lastUpdatedTime?: string;
|
|
18
20
|
onSelectWarning?: (warning: PublicWarning) => void;
|
|
19
21
|
onEditWarning?: (warning: PublicWarning) => void;
|
|
20
22
|
onCreateWarning?: () => void;
|
|
21
23
|
onDeleteWarning?: (warningId: string) => void;
|
|
22
|
-
|
|
24
|
+
onRefetchWarnings?: () => void;
|
|
23
25
|
}>;
|
|
24
26
|
export default PublicWarningList;
|
|
@@ -7,3 +7,4 @@ export declare const PublicWarningListLight: () => React.ReactElement;
|
|
|
7
7
|
export declare const PublicWarningListDark: () => React.ReactElement;
|
|
8
8
|
export declare const PublicWarningListError: () => React.ReactElement;
|
|
9
9
|
export declare const PublicWarningListErrorDeleteWarning: () => React.ReactElement;
|
|
10
|
+
export declare const PublicWarningListDifferentEditors: () => React.ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PublicWarningDetail } from '../../store/publicWarningForm/types';
|
|
3
3
|
import { BaseDrawingListItem, DrawingListItem } from '../../store/drawings/types';
|
|
4
|
-
import { FormAction } from '../../store/publicWarningForm/reducer';
|
|
4
|
+
import { FormAction, FormError } from '../../store/publicWarningForm/reducer';
|
|
5
5
|
export declare const getEmptyPublicWarning: () => PublicWarningDetail;
|
|
6
6
|
export declare const getFormData: (publicWarningsDetails: PublicWarningDetail | undefined, object?: DrawingListItem) => PublicWarningDetail;
|
|
7
7
|
export declare const LABEL_PROBABILITY = "Probability";
|
|
@@ -22,7 +22,8 @@ interface FormProps {
|
|
|
22
22
|
onPublishForm?: (formValues: PublicWarningDetail) => void;
|
|
23
23
|
object?: DrawingListItem;
|
|
24
24
|
publicWarningDetails?: PublicWarningDetail;
|
|
25
|
-
error?:
|
|
25
|
+
error?: FormError;
|
|
26
|
+
isReadOnly?: boolean;
|
|
26
27
|
onFormDirty?: (isFormDirty: boolean) => void;
|
|
27
28
|
}
|
|
28
29
|
export declare const PublicWarningsForm: React.FC<FormProps>;
|
|
@@ -47,3 +47,11 @@ export declare const PublicWarningsFormDialogDarkReadOnly: {
|
|
|
47
47
|
(): React.ReactElement;
|
|
48
48
|
storyName: string;
|
|
49
49
|
};
|
|
50
|
+
export declare const PublicWarningsFormDialogLightTakeoverWarning: {
|
|
51
|
+
(): React.ReactElement;
|
|
52
|
+
storyName: string;
|
|
53
|
+
};
|
|
54
|
+
export declare const PublicWarningsFormDialogDarkTakeoverWarning: {
|
|
55
|
+
(): React.ReactElement;
|
|
56
|
+
storyName: string;
|
|
57
|
+
};
|
|
@@ -8,6 +8,7 @@ export declare const warningFormConfirmationOptions: {
|
|
|
8
8
|
confirmLabel: string;
|
|
9
9
|
catchOnCancel: boolean;
|
|
10
10
|
};
|
|
11
|
+
export declare const isAlreadyEdited: (publicWarningEditor: string | undefined, username: string | undefined) => boolean;
|
|
11
12
|
export declare const PublicWarningsFormDialogConnect: React.FC<{
|
|
12
13
|
bounds?: string;
|
|
13
14
|
source?: uiTypes.Source;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { PayloadAction, Draft } from '@reduxjs/toolkit';
|
|
2
|
+
import { AlertColor } from '@mui/material';
|
|
2
3
|
import { DrawingListItem } from '../drawings/types';
|
|
3
4
|
import { PublicWarning } from './types';
|
|
4
5
|
export type FormAction = '' | 'saving' | 'publishing' | 'readonly';
|
|
6
|
+
export type FormError = {
|
|
7
|
+
severity?: AlertColor;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
5
10
|
export interface PublicWarningFormState {
|
|
6
11
|
object?: DrawingListItem;
|
|
7
12
|
publicWarning?: PublicWarning;
|
|
8
13
|
formState?: FormAction;
|
|
9
|
-
error?:
|
|
14
|
+
error?: FormError;
|
|
10
15
|
selectedPublicWarningId?: string;
|
|
11
16
|
isFormDirty?: boolean;
|
|
12
17
|
}
|
|
18
|
+
export declare const TAKEOVER_MESSAGE = "You are no longer the editor of this warning";
|
|
13
19
|
export declare const initialState: PublicWarningFormState;
|
|
14
20
|
export declare const reducer: import("redux").Reducer<PublicWarningFormState, import("redux").AnyAction>;
|
|
15
21
|
export declare const publicWarningFormActions: import("@reduxjs/toolkit").CaseReducerActions<{
|
|
@@ -23,6 +29,16 @@ export declare const publicWarningFormActions: import("@reduxjs/toolkit").CaseRe
|
|
|
23
29
|
formState?: FormAction;
|
|
24
30
|
publicWarning?: PublicWarning;
|
|
25
31
|
}>) => void;
|
|
32
|
+
toggleEditorWarning: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
|
|
33
|
+
warningId: string;
|
|
34
|
+
isEditor: boolean;
|
|
35
|
+
username: string;
|
|
36
|
+
}>) => void;
|
|
37
|
+
toggleEditorWarningSuccess: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
|
|
38
|
+
isEditor: boolean;
|
|
39
|
+
username: string;
|
|
40
|
+
message: string;
|
|
41
|
+
}>) => void;
|
|
26
42
|
publishWarning: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
|
|
27
43
|
publicWarning: PublicWarning;
|
|
28
44
|
}>) => void;
|
|
@@ -37,9 +53,7 @@ export declare const publicWarningFormActions: import("@reduxjs/toolkit").CaseRe
|
|
|
37
53
|
publicWarning: PublicWarning;
|
|
38
54
|
message: string;
|
|
39
55
|
}>) => void;
|
|
40
|
-
setFormError: (draft: Draft<PublicWarningFormState>, action: PayloadAction<
|
|
41
|
-
error: string;
|
|
42
|
-
}>) => void;
|
|
56
|
+
setFormError: (draft: Draft<PublicWarningFormState>, action: PayloadAction<FormError>) => void;
|
|
43
57
|
setFormDirty: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
|
|
44
58
|
isFormDirty: boolean;
|
|
45
59
|
}>) => void;
|
|
@@ -4,6 +4,8 @@ import { PublicWarning } from './types';
|
|
|
4
4
|
export declare const PUBLISH_SUCCES = "Public warning has succesfully been published!";
|
|
5
5
|
export declare const SAVE_SUCCES = "Public warning has succesfully been saved!";
|
|
6
6
|
export declare function saveOrUpdateWarning(publicWarning: PublicWarning): SagaIterator<PublicWarning>;
|
|
7
|
+
export declare const getToggleEditorSuccessMessage: (isEditor: boolean) => string;
|
|
8
|
+
export declare function toggleEditorWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.toggleEditorWarning>): SagaIterator;
|
|
7
9
|
export declare function publishWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.publishWarning>): SagaIterator;
|
|
8
10
|
export declare function saveWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.saveWarning>): SagaIterator;
|
|
9
11
|
export declare function successSaga({ payload, }: ReturnType<typeof publicWarningFormActions.publishWarningSuccess | typeof publicWarningFormActions.saveWarningSuccess>): SagaIterator;
|
|
@@ -16,12 +16,17 @@ export declare const getPublicWarningStatus: ((state: WarningModuleStore) => imp
|
|
|
16
16
|
}> & {
|
|
17
17
|
clearCache: () => void;
|
|
18
18
|
};
|
|
19
|
+
export declare const getPublicWarningEditor: ((state: WarningModuleStore) => string | undefined) & import("reselect").OutputSelectorFields<(args_0: PublicWarningFormState) => string | undefined, {
|
|
20
|
+
clearCache: () => void;
|
|
21
|
+
}> & {
|
|
22
|
+
clearCache: () => void;
|
|
23
|
+
};
|
|
19
24
|
export declare const getPublicWarningFormState: ((state: WarningModuleStore) => "" | "saving" | "publishing" | "readonly") & import("reselect").OutputSelectorFields<(args_0: PublicWarningFormState) => "" | "saving" | "publishing" | "readonly", {
|
|
20
25
|
clearCache: () => void;
|
|
21
26
|
}> & {
|
|
22
27
|
clearCache: () => void;
|
|
23
28
|
};
|
|
24
|
-
export declare const getPublicWarningFormError: ((state: WarningModuleStore) =>
|
|
29
|
+
export declare const getPublicWarningFormError: ((state: WarningModuleStore) => import("./reducer").FormError | undefined) & import("reselect").OutputSelectorFields<(args_0: PublicWarningFormState) => import("./reducer").FormError | undefined, {
|
|
25
30
|
clearCache: () => void;
|
|
26
31
|
}> & {
|
|
27
32
|
clearCache: () => void;
|
|
@@ -15,7 +15,7 @@ export type PublicWarningDetail = {
|
|
|
15
15
|
};
|
|
16
16
|
export type PublicWarningStatus = 'DRAFT' | 'PUBLISHED' | 'TODO' | 'EXPIRED';
|
|
17
17
|
export type PublicWarning = {
|
|
18
|
-
status
|
|
18
|
+
status?: PublicWarningStatus;
|
|
19
19
|
editor?: string;
|
|
20
20
|
warningDetail: PublicWarningDetail;
|
|
21
21
|
id?: string;
|
|
@@ -8,6 +8,7 @@ export declare const publicWarningActions: import("@reduxjs/toolkit").CaseReduce
|
|
|
8
8
|
fetchWarnings: (draft: Draft<PublicWarningsState>) => void;
|
|
9
9
|
fetchWarningsSuccess: (draft: Draft<PublicWarningsState>, action: PayloadAction<{
|
|
10
10
|
warnings: PublicWarning[];
|
|
11
|
+
lastUpdatedTime: string;
|
|
11
12
|
}>) => void;
|
|
12
13
|
fetchWarningsError: (draft: Draft<PublicWarningsState>, action: PayloadAction<{
|
|
13
14
|
error: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SagaIterator } from 'redux-saga';
|
|
2
|
+
export declare const getLastUpdatedTimeFormatted: () => string;
|
|
2
3
|
export declare function fetchWarningsSaga(): SagaIterator;
|
|
3
4
|
export declare function refetchWarnings(): SagaIterator;
|
|
4
5
|
declare function publicWarnings(): SagaIterator;
|
|
@@ -12,3 +12,8 @@ export declare const getPublicWarningsError: ((state: WarningModuleStore) => imp
|
|
|
12
12
|
}> & {
|
|
13
13
|
clearCache: () => void;
|
|
14
14
|
};
|
|
15
|
+
export declare const getPublicWarningsLastUpdatedTime: ((state: WarningModuleStore) => string) & import("reselect").OutputSelectorFields<(args_0: PublicWarningsState) => string, {
|
|
16
|
+
clearCache: () => void;
|
|
17
|
+
}> & {
|
|
18
|
+
clearCache: () => void;
|
|
19
|
+
};
|
|
@@ -2,3 +2,4 @@ export declare const DATE_FORMAT = "dd/MM/yyyy HH:mm";
|
|
|
2
2
|
export declare const DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
|
3
3
|
export declare const DATE_FORMAT_HEADER = "EEEE, MMMM dd";
|
|
4
4
|
export declare const DATE_FORMAT_DATE_FIELDS = "DD/MM/YYYY HH:mm";
|
|
5
|
+
export declare const DATE_FORMAT_LASTUPDATEDTIME = "HH:mm";
|