diff --git a/web/client/components/TOC/fragments/settings/WMSCacheOptions.jsx b/web/client/components/TOC/fragments/settings/WMSCacheOptions.jsx
index 0df967a465..599faa43dc 100644
--- a/web/client/components/TOC/fragments/settings/WMSCacheOptions.jsx
+++ b/web/client/components/TOC/fragments/settings/WMSCacheOptions.jsx
@@ -189,12 +189,14 @@ const infoText = {
* @prop {object} layer layer configuration
* @prop {boolean} disableTileGrids disable tile grids toolbar
* @prop {function} onChange callback triggered after changing the form
+ * @prop {string} owner the owner component name like: 'background-dialog'
*/
function WMSCacheOptions({
layer = {},
projection,
onChange,
- disableTileGrids
+ disableTileGrids,
+ owner = ""
}) {
const [tileGridLoading, setTileGridLoading] = useState(false);
@@ -266,8 +268,41 @@ function WMSCacheOptions({
.finally(() => setTimeout(() => setTileGridLoading(false), 500));
};
+ const handleGetTileGridSettings = () => {
+ const newTileGridStrategy = layer.tileGridStrategy !== 'custom'
+ ? 'custom'
+ : undefined;
+ const promise = newTileGridStrategy === 'custom'
+ && ((layer?.tileGrids?.length || 0) === 0 || !layer?.tileGridCacheSupport)
+ ? onTileMatrixSetsFetch(layer)
+ : Promise.resolve(undefined);
+ return promise.then(({ tileGrids, tileGridCacheSupport } = {}) => {
+ const hasTileGrids = (tileGrids?.length || 0) > 0;
+ const tileGridStrategy = hasTileGrids
+ ? newTileGridStrategy
+ : undefined;
+ let tileChangedData = {
+ tileGridCacheSupport,
+ tileGridStrategy,
+ tileGrids
+ };
+ if (owner === 'background-dialog' && newTileGridStrategy === 'custom') {
+ tileChangedData = {
+ ...tileChangedData, tiled: true, tileGridStrategy: 'custom'
+ }
+ }
+ handleOnChange(tileChangedData);
+ });
+ };
+
const InfoText = infoText[layer.tileGridStrategy] || infoText.standard;
+ // fetching grid data in case background layers
+ React.useEffect(() => {
+ if (layer.remoteTileGrids && owner === 'background-dialog') {
+ handleGetTileGridSettings();
+ }
+ }, [])
return (
@@ -320,26 +355,7 @@ function WMSCacheOptions({
glyph={layer.tileGridStrategy === 'custom' ? 'grid-custom' : 'grid-regular'}
bsStyle={layer.tileGridStrategy === 'custom' ? 'success' : 'primary'}
className="square-button-md"
- onClick={() => {
- const newTileGridStrategy = layer.tileGridStrategy !== 'custom'
- ? 'custom'
- : undefined;
- const promise = newTileGridStrategy === 'custom'
- && ((layer?.tileGrids?.length || 0) === 0 || !layer?.tileGridCacheSupport)
- ? onTileMatrixSetsFetch(layer)
- : Promise.resolve(undefined);
- return promise.then(({ tileGrids, tileGridCacheSupport } = {}) => {
- const hasTileGrids = (tileGrids?.length || 0) > 0;
- const tileGridStrategy = hasTileGrids
- ? newTileGridStrategy
- : undefined;
- handleOnChange({
- tileGridCacheSupport,
- tileGridStrategy,
- tileGrids
- });
- });
- }}
+ onClick={handleGetTileGridSettings}
/>
}
diff --git a/web/client/components/background/BackgroundDialog.jsx b/web/client/components/background/BackgroundDialog.jsx
index e719a69ed4..53c4c99d29 100644
--- a/web/client/components/background/BackgroundDialog.jsx
+++ b/web/client/components/background/BackgroundDialog.jsx
@@ -184,6 +184,7 @@ export default class BackgroundDialog extends React.Component {
projection={this.props.projection}
onChange={value => this.setState(value)}
disableTileGrids={this.props.disableTileGrids}
+ owner={"background-dialog"}
/>
}