@opengeoweb/warnings 9.20.2 → 9.22.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 +51 -32
- package/package.json +4 -4
- package/src/index.d.ts +1 -0
- package/src/lib/utils/i18n.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createEntityAdapter, createSlice, createSelector, createListenerMiddlew
|
|
|
8
8
|
import i18n from 'i18next';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
10
|
import { defaultBbox } from '@opengeoweb/core';
|
|
11
|
+
import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
|
|
11
12
|
import { snackbarActions } from '@opengeoweb/snackbar';
|
|
12
13
|
import * as React from 'react';
|
|
13
14
|
import React__default, { useState, useEffect, useRef } from 'react';
|
|
@@ -15,12 +16,11 @@ import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack,
|
|
|
15
16
|
import { VariableSizeList } from 'react-window';
|
|
16
17
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
17
18
|
import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
|
|
18
|
-
import { ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
|
|
19
19
|
import { useFormContext } from 'react-hook-form';
|
|
20
20
|
import { isEqual, cloneDeep, clamp } from 'lodash';
|
|
21
21
|
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
22
22
|
import { produce } from 'immer';
|
|
23
|
-
import { generateMapId, LayerType, getWMJSMapById, WMBBOX } from '@opengeoweb/webmap';
|
|
23
|
+
import { generateMapId, LayerType, getWMJSMapById, getGeoCoordFromLatLong, WMBBOX } from '@opengeoweb/webmap';
|
|
24
24
|
import { isAxiosError } from 'axios';
|
|
25
25
|
|
|
26
26
|
var en = {
|
|
@@ -1712,10 +1712,11 @@ const {
|
|
|
1712
1712
|
const getWarningFormDirty = createSelector(selectDrawByInstanceId, drawing => (drawing === null || drawing === void 0 ? void 0 : drawing.isFormDirty) || false);
|
|
1713
1713
|
|
|
1714
1714
|
const WARN_NAMESPACE = 'warn';
|
|
1715
|
+
const ns = [WARN_NAMESPACE, FORM_FIELDS_NAMESPACE];
|
|
1715
1716
|
const translateKeyOutsideComponents = (key, params = undefined) => i18n.t(key, Object.assign({
|
|
1716
|
-
ns
|
|
1717
|
+
ns
|
|
1717
1718
|
}, params));
|
|
1718
|
-
const useWarningsTranslation = () => useTranslation(
|
|
1719
|
+
const useWarningsTranslation = () => useTranslation(ns);
|
|
1719
1720
|
|
|
1720
1721
|
/* *
|
|
1721
1722
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -7877,7 +7878,7 @@ const levelOptions = t => [Object.assign({
|
|
|
7877
7878
|
}, LevelColors[WarningLevel.severe]), Object.assign({
|
|
7878
7879
|
title: t('warning-level-extreme'),
|
|
7879
7880
|
key: WarningLevel.extreme
|
|
7880
|
-
}, LevelColors[
|
|
7881
|
+
}, LevelColors[WarningLevel.extreme])];
|
|
7881
7882
|
const LevelField = ({
|
|
7882
7883
|
isDisabled: _isDisabled = false,
|
|
7883
7884
|
isReadOnly: _isReadOnly = false
|
|
@@ -8049,11 +8050,11 @@ const zoomToFeature = (mapId, geojsonFeature) => {
|
|
|
8049
8050
|
return;
|
|
8050
8051
|
}
|
|
8051
8052
|
const bboxGeoJSON = getFeatureExtent(geojsonFeature);
|
|
8052
|
-
const projectedCoordinateBoxBottomLeft =
|
|
8053
|
+
const projectedCoordinateBoxBottomLeft = getGeoCoordFromLatLong(webmapjs, {
|
|
8053
8054
|
x: bboxGeoJSON.left,
|
|
8054
8055
|
y: bboxGeoJSON.bottom
|
|
8055
8056
|
});
|
|
8056
|
-
const projectedCoordinateBoxTopRight =
|
|
8057
|
+
const projectedCoordinateBoxTopRight = getGeoCoordFromLatLong(webmapjs, {
|
|
8057
8058
|
x: bboxGeoJSON.right,
|
|
8058
8059
|
y: bboxGeoJSON.top
|
|
8059
8060
|
});
|
|
@@ -8095,6 +8096,9 @@ const WarningsMapView = ({
|
|
|
8095
8096
|
showScaleBar: false,
|
|
8096
8097
|
onWMJSMount: mapId => {
|
|
8097
8098
|
const webmapjs = getWMJSMapById(mapId);
|
|
8099
|
+
if (!webmapjs) {
|
|
8100
|
+
return;
|
|
8101
|
+
}
|
|
8098
8102
|
webmapjs.hideMouseCursorProperties();
|
|
8099
8103
|
if (!geojsonFeature) {
|
|
8100
8104
|
return;
|
|
@@ -8286,6 +8290,16 @@ const getErrors = errors => errors ? errors === null || errors === void 0 ? void
|
|
|
8286
8290
|
title: '',
|
|
8287
8291
|
errors: []
|
|
8288
8292
|
}) : null;
|
|
8293
|
+
const getWarningGeoJSONWithColor = (level, geoJSON) => produce(geoJSON, draft => {
|
|
8294
|
+
const draftFeature = draft === null || draft === void 0 ? void 0 : draft.features[0];
|
|
8295
|
+
if (draftFeature) {
|
|
8296
|
+
const defaultProps = getDefaultFeatureProperties(level);
|
|
8297
|
+
if (!draftFeature.properties) {
|
|
8298
|
+
draftFeature.properties = Object.assign({}, defaultProps);
|
|
8299
|
+
}
|
|
8300
|
+
Object.assign(draftFeature.properties, Object.assign(Object.assign({}, defaultProps), draftFeature.properties));
|
|
8301
|
+
}
|
|
8302
|
+
});
|
|
8289
8303
|
const Form = ({
|
|
8290
8304
|
defaultBbox,
|
|
8291
8305
|
onSaveForm: _onSaveForm = () => {},
|
|
@@ -8301,6 +8315,7 @@ const Form = ({
|
|
|
8301
8315
|
onFormDirty: _onFormDirty = () => {},
|
|
8302
8316
|
isSnapshot: _isSnapshot = false
|
|
8303
8317
|
}) => {
|
|
8318
|
+
const [warningGeoJSONFeature, setWarningGeoJSONFeature] = React.useState(publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.geoJSON);
|
|
8304
8319
|
const {
|
|
8305
8320
|
t
|
|
8306
8321
|
} = useWarningsTranslation();
|
|
@@ -8347,26 +8362,19 @@ const Form = ({
|
|
|
8347
8362
|
};
|
|
8348
8363
|
const onPressClear = () => {
|
|
8349
8364
|
reset(getEmptyPublicWarning());
|
|
8365
|
+
setWarningGeoJSONFeature(undefined);
|
|
8350
8366
|
};
|
|
8351
8367
|
React.useEffect(() => {
|
|
8352
8368
|
// sync redux with react-hook-form
|
|
8353
8369
|
reset(getFormData(publicWarningDetails, object));
|
|
8354
8370
|
}, [object, reset, publicWarningDetails]);
|
|
8371
|
+
React.useEffect(() => {
|
|
8372
|
+
// sync drawing on map with selected warning
|
|
8373
|
+
setWarningGeoJSONFeature(publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.geoJSON);
|
|
8374
|
+
}, [publicWarningDetails]);
|
|
8355
8375
|
const errors = getErrors(_error.message);
|
|
8356
|
-
|
|
8357
|
-
const
|
|
8358
|
-
// Add colors, if not defined
|
|
8359
|
-
const warningGeoJSONFeatureWithFillProps = produce(warningGeoJSONFeature, draft => {
|
|
8360
|
-
const draftFeature = draft === null || draft === void 0 ? void 0 : draft.features[0];
|
|
8361
|
-
if (draftFeature) {
|
|
8362
|
-
const level = WarningLevel[publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
|
|
8363
|
-
const defaultProps = getDefaultFeatureProperties(level);
|
|
8364
|
-
if (!draftFeature.properties) {
|
|
8365
|
-
draftFeature.properties = Object.assign({}, defaultProps);
|
|
8366
|
-
}
|
|
8367
|
-
Object.assign(draftFeature.properties, Object.assign(Object.assign({}, defaultProps), draftFeature.properties));
|
|
8368
|
-
}
|
|
8369
|
-
});
|
|
8376
|
+
const level = WarningLevel[publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
|
|
8377
|
+
const geoJSONFeature = getWarningGeoJSONWithColor(level, warningGeoJSONFeature);
|
|
8370
8378
|
return jsxs(ContainerWrapper, {
|
|
8371
8379
|
children: [jsxs(ContainerFormWrapper, Object.assign({
|
|
8372
8380
|
isReadOnly: _isReadOnly2
|
|
@@ -8421,7 +8429,7 @@ const Form = ({
|
|
|
8421
8429
|
xs: 12
|
|
8422
8430
|
}, {
|
|
8423
8431
|
children: jsx(WarningsMapView, {
|
|
8424
|
-
geojsonFeature:
|
|
8432
|
+
geojsonFeature: geoJSONFeature,
|
|
8425
8433
|
defaultBbox: defaultBbox,
|
|
8426
8434
|
isSnapshot: _isSnapshot
|
|
8427
8435
|
})
|
|
@@ -9551,12 +9559,12 @@ const PublicWarningListConnect = () => {
|
|
|
9551
9559
|
auth
|
|
9552
9560
|
} = useAuthenticationContext();
|
|
9553
9561
|
const [confirmDialogOptions, setConfirmDialogOptions] = React__default.useState(undefined);
|
|
9554
|
-
const warnings = useSelector(
|
|
9555
|
-
const selectedPublicWarningId = useSelector(
|
|
9556
|
-
const isLoading = useSelector(
|
|
9557
|
-
const error = useSelector(
|
|
9558
|
-
const isFormDirty = useSelector(
|
|
9559
|
-
const lastUpdatedTime = useSelector(
|
|
9562
|
+
const warnings = useSelector(selectAllPublicWarnings);
|
|
9563
|
+
const selectedPublicWarningId = useSelector(getSelectedPublicWarningId);
|
|
9564
|
+
const isLoading = useSelector(isPublicWarningsLoading);
|
|
9565
|
+
const error = useSelector(getPublicWarningsError);
|
|
9566
|
+
const isFormDirty = useSelector(getSelectedPublicIsFormDirty);
|
|
9567
|
+
const lastUpdatedTime = useSelector(getPublicWarningsLastUpdatedTime);
|
|
9560
9568
|
const openPublicWarningDialog = (formAction, publicWarning) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9561
9569
|
if (isFormDirty) {
|
|
9562
9570
|
const mayProceed = yield confirmDialog(warningFormConfirmationOptions(t)).then(() => true).catch(() => false);
|
|
@@ -9576,9 +9584,20 @@ const PublicWarningListConnect = () => {
|
|
|
9576
9584
|
const createWarning = () => {
|
|
9577
9585
|
openPublicWarningDialog('');
|
|
9578
9586
|
};
|
|
9579
|
-
const editWarning = publicWarning => {
|
|
9580
|
-
|
|
9581
|
-
|
|
9587
|
+
const editWarning = publicWarning => __awaiter(void 0, void 0, void 0, function* () {
|
|
9588
|
+
if (publicWarning.id && (auth === null || auth === void 0 ? void 0 : auth.username) && !publicWarning.editor) {
|
|
9589
|
+
yield dispatch(publicWarningFormActions.toggleEditorWarning({
|
|
9590
|
+
warningId: publicWarning.id,
|
|
9591
|
+
isEditor: true,
|
|
9592
|
+
username: auth === null || auth === void 0 ? void 0 : auth.username
|
|
9593
|
+
}));
|
|
9594
|
+
yield openPublicWarningDialog('', Object.assign(Object.assign({}, publicWarning), {
|
|
9595
|
+
editor: auth === null || auth === void 0 ? void 0 : auth.username
|
|
9596
|
+
}));
|
|
9597
|
+
} else {
|
|
9598
|
+
openPublicWarningDialog('', publicWarning);
|
|
9599
|
+
}
|
|
9600
|
+
});
|
|
9582
9601
|
const openSnackbar = message => {
|
|
9583
9602
|
dispatch(snackbarActions.openSnackbar({
|
|
9584
9603
|
message
|
|
@@ -10005,4 +10024,4 @@ const drawingModuleConfig = {
|
|
|
10005
10024
|
middlewares: [drawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware]
|
|
10006
10025
|
};
|
|
10007
10026
|
|
|
10008
|
-
export { DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, isAlreadyEdited, useObjectDrawDialogAction, warningFormConfirmationOptions, warningsTranslations };
|
|
10027
|
+
export { DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WARN_NAMESPACE, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, isAlreadyEdited, useObjectDrawDialogAction, warningFormConfirmationOptions, warningsTranslations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/warnings",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.22.0",
|
|
4
4
|
"description": "GeoWeb warinings library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@opengeoweb/store": "*",
|
|
14
14
|
"@opengeoweb/webmap-react": "*",
|
|
15
15
|
"react-redux": "^8.1.3",
|
|
16
|
-
"@mui/material": "
|
|
16
|
+
"@mui/material": "^5.16.0",
|
|
17
17
|
"@opengeoweb/theme": "*",
|
|
18
18
|
"@opengeoweb/form-fields": "*",
|
|
19
19
|
"react-hook-form": "^7.50.1",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@opengeoweb/core": "*",
|
|
27
27
|
"@opengeoweb/webmap": "*",
|
|
28
28
|
"@opengeoweb/authentication": "*",
|
|
29
|
-
"react-i18next": "^
|
|
30
|
-
"i18next": "^23.
|
|
29
|
+
"react-i18next": "^14.1.2",
|
|
30
|
+
"i18next": "^23.11.5",
|
|
31
31
|
"immer": "^10.0.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * from './lib/components/DrawingToolForm';
|
|
|
6
6
|
export * from './lib/components/PublicWarningsFormDialog';
|
|
7
7
|
export * from './lib/components/ComponentsLookUp';
|
|
8
8
|
export * from './lib/store/config';
|
|
9
|
+
export { WARN_NAMESPACE } from './lib/utils/i18n';
|
|
9
10
|
export { warningsTranslations };
|
package/src/lib/utils/i18n.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare const WARN_NAMESPACE = "warn";
|
|
|
4
4
|
export declare const initWarnI18n: () => void;
|
|
5
5
|
export declare const translateKeyOutsideComponents: (key: string, params?: Record<string, string | number> | undefined) => string;
|
|
6
6
|
export declare const useWarningsTranslation: () => UseTranslationResponse<typeof WARN_NAMESPACE, typeof i18n>;
|
|
7
|
+
export { i18n };
|