@opengeoweb/layer-select 9.10.2 → 9.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.esm.js +16 -11
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -16,7 +16,7 @@ import Typography$1 from '@mui/material/Typography';
16
16
  import Grid$1 from '@mui/material/Grid';
17
17
  import { LegendLayout } from '@opengeoweb/webmap-react';
18
18
  import { FixedSizeList } from 'react-window';
19
- import { webmapUtils, LayerType, getCapabilities, WMGetServiceFromStore, clearImageCache } from '@opengeoweb/webmap';
19
+ import { webmapUtils, LayerType, getCapabilities, WMGetServiceFromStore, clearImageCacheForAllMaps } from '@opengeoweb/webmap';
20
20
  import { snackbarActions } from '@opengeoweb/snackbar';
21
21
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormTextField } from '@opengeoweb/form-fields';
22
22
  import { useFormContext } from 'react-hook-form';
@@ -5025,7 +5025,7 @@ const ServiceOptionsDialogConnect = ({
5025
5025
  scope: service && service.scope || 'user',
5026
5026
  isUpdating: true
5027
5027
  });
5028
- clearImageCache();
5028
+ clearImageCacheForAllMaps();
5029
5029
  const serviceTitle = service && service.serviceName || layersForService.name;
5030
5030
  showSnackbar(getServiceSuccesUpdateMessage(serviceTitle));
5031
5031
  } catch (error) {
@@ -5252,16 +5252,18 @@ const ServicePopupUnwrapped = ({
5252
5252
  setValue
5253
5253
  } = useFormContext();
5254
5254
  const [isLoading, setIsLoading] = React.useState(false);
5255
+ const [shouldForceReload, setShouldForceReload] = React.useState(false);
5255
5256
  const fetchServiceData = newServiceUrl => __awaiter(void 0, void 0, void 0, function* () {
5256
5257
  try {
5257
5258
  setIsLoading(true);
5258
- yield getCapabilities.getLayersFromService(newServiceUrl);
5259
- const service = WMGetServiceFromStore(newServiceUrl);
5260
- setValue(fields.serviceName.name, service.title);
5259
+ const service = yield loadWMSService(newServiceUrl, true);
5260
+ setValue(fields.serviceName.name, service.name);
5261
5261
  setValue(fields.serviceAbstracts.name, service.abstract);
5262
5262
  setIsLoading(false);
5263
+ setShouldForceReload(false);
5263
5264
  } catch (error) {
5264
5265
  setIsLoading(false);
5266
+ setShouldForceReload(true);
5265
5267
  setError(fields.serviceUrl.name, {
5266
5268
  message: VALIDATIONS_REQUEST_FAILED,
5267
5269
  type: 'SYSTEM'
@@ -5272,13 +5274,13 @@ const ServicePopupUnwrapped = ({
5272
5274
  clearErrors(fields.serviceUrl.name);
5273
5275
  setIsLoading(true);
5274
5276
  try {
5275
- const layersForService = yield loadWMSService(formValues.serviceUrl, true);
5277
+ const service = yield loadWMSService(formValues.serviceUrl, shouldForceReload);
5276
5278
  serviceSetLayers({
5277
- id: layersForService.id,
5279
+ id: service.id,
5278
5280
  name: formValues.serviceName,
5279
5281
  serviceUrl: formValues.serviceUrl,
5280
5282
  abstract: formValues.serviceAbstracts,
5281
- layers: layersForService.layers,
5283
+ layers: service.layers,
5282
5284
  scope: 'user'
5283
5285
  });
5284
5286
  setIsLoading(false);
@@ -5300,9 +5302,12 @@ const ServicePopupUnwrapped = ({
5300
5302
  }
5301
5303
  };
5302
5304
  const onBlurServiceUrl = () => {
5303
- if (!errors[fields.serviceUrl.name]) {
5304
- fetchServiceData(getValues(fields.serviceUrl.name));
5305
- }
5305
+ trigger(fields.serviceUrl.name).then(() => {
5306
+ const hasValue = getValues(fields.serviceUrl.name);
5307
+ if (!errors[fields.serviceUrl.name] && hasValue) {
5308
+ fetchServiceData(getValues(fields.serviceUrl.name));
5309
+ }
5310
+ });
5306
5311
  };
5307
5312
  const onKeyDownServiceUrl = event => {
5308
5313
  if (event.key === 'Enter') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/layer-select",
3
- "version": "9.10.2",
3
+ "version": "9.11.0",
4
4
  "description": "GeoWeb layer select library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {