Repository navigation
#12951 False save button activation happens on map first load - #12952
Conversation
dsuren1
left a comment
There was a problem hiding this comment.
@Binabh
The approach of adding includes creates some friction and adds maintenance overhead, especially since it introduces a second list of layer properties that needs to stay in sync with saveLayer.
Would it be possible to reuse the existing saveLayer/formatting logic for the comparison instead? This would give us a single source of truth and also avoid potential differences such as the WMTS matrixIds/tileMatrixSet transformations.
Please check my suggested approach, I haven't completely tested it, and see if it handles all the cases. Thanks!
| const includes = { | ||
| // Compare the layer configuration fields persisted by saveLayer in LayersUtils. | ||
| 'root.map.layers[]': [ | ||
| 'id', | ||
| 'features', | ||
| 'format', | ||
| 'thumbURL', | ||
| 'group', | ||
| 'search', | ||
| 'fields', | ||
| 'source', | ||
| 'name', | ||
| 'opacity', | ||
| 'provider', | ||
| 'description', | ||
| 'styles', | ||
| 'style', | ||
| 'styleName', | ||
| 'layerFilter', | ||
| 'title', | ||
| 'transparent', | ||
| 'tiled', | ||
| 'type', | ||
| 'url', | ||
| 'bbox', | ||
| 'visibility', | ||
| 'singleTile', | ||
| 'allowedSRS', | ||
| 'requestEncoding', | ||
| 'dimensions', | ||
| 'maxZoom', | ||
| 'maxNativeZoom', | ||
| 'maxResolution', | ||
| 'minResolution', | ||
| 'disableResolutionLimits', | ||
| 'hideLoading', | ||
| 'handleClickOnLayer', | ||
| 'queryable', | ||
| 'featureInfo', | ||
| 'catalogURL', | ||
| 'capabilitiesURL', | ||
| 'serverType', | ||
| 'useForElevation', | ||
| 'hidden', | ||
| 'origin', | ||
| 'thematic', | ||
| 'tooltipOptions', | ||
| 'tooltipPlacement', | ||
| 'legendOptions', | ||
| 'tileSize', | ||
| 'version', | ||
| 'expanded', | ||
| 'enableInteractiveLegend', | ||
| 'enableDynamicLegend', | ||
| 'sources', | ||
| 'heightOffset', | ||
| 'params', | ||
| 'extendedParams', | ||
| 'localizedLayerStyles', | ||
| 'options', | ||
| 'credits', | ||
| 'security', | ||
| 'tileGrids', | ||
| 'tileGridStrategy', | ||
| 'tileGridCacheSupport', | ||
| 'rowViewer', | ||
| 'forceProxy', | ||
| 'disableFeaturesEditing', | ||
| 'pointCloudShading', | ||
| 'sourceMetadata', | ||
| 'enableImageryOverlay', | ||
| 'strategy', | ||
| 'geometryType', | ||
| 'maxRecordCount', | ||
| 'maxFeaturesInView', | ||
| 'cropToProjectionExtent', | ||
| 'coalesce' | ||
| ] | ||
| }; | ||
| const excludes = {}; |
There was a problem hiding this comment.
| const includes = { | |
| // Compare the layer configuration fields persisted by saveLayer in LayersUtils. | |
| 'root.map.layers[]': [ | |
| 'id', | |
| 'features', | |
| 'format', | |
| 'thumbURL', | |
| 'group', | |
| 'search', | |
| 'fields', | |
| 'source', | |
| 'name', | |
| 'opacity', | |
| 'provider', | |
| 'description', | |
| 'styles', | |
| 'style', | |
| 'styleName', | |
| 'layerFilter', | |
| 'title', | |
| 'transparent', | |
| 'tiled', | |
| 'type', | |
| 'url', | |
| 'bbox', | |
| 'visibility', | |
| 'singleTile', | |
| 'allowedSRS', | |
| 'requestEncoding', | |
| 'dimensions', | |
| 'maxZoom', | |
| 'maxNativeZoom', | |
| 'maxResolution', | |
| 'minResolution', | |
| 'disableResolutionLimits', | |
| 'hideLoading', | |
| 'handleClickOnLayer', | |
| 'queryable', | |
| 'featureInfo', | |
| 'catalogURL', | |
| 'capabilitiesURL', | |
| 'serverType', | |
| 'useForElevation', | |
| 'hidden', | |
| 'origin', | |
| 'thematic', | |
| 'tooltipOptions', | |
| 'tooltipPlacement', | |
| 'legendOptions', | |
| 'tileSize', | |
| 'version', | |
| 'expanded', | |
| 'enableInteractiveLegend', | |
| 'enableDynamicLegend', | |
| 'sources', | |
| 'heightOffset', | |
| 'params', | |
| 'extendedParams', | |
| 'localizedLayerStyles', | |
| 'options', | |
| 'credits', | |
| 'security', | |
| 'tileGrids', | |
| 'tileGridStrategy', | |
| 'tileGridCacheSupport', | |
| 'rowViewer', | |
| 'forceProxy', | |
| 'disableFeaturesEditing', | |
| 'pointCloudShading', | |
| 'sourceMetadata', | |
| 'enableImageryOverlay', | |
| 'strategy', | |
| 'geometryType', | |
| 'maxRecordCount', | |
| 'maxFeaturesInView', | |
| 'cropToProjectionExtent', | |
| 'coalesce' | |
| ] | |
| }; | |
| const excludes = {}; | |
| const excludes = { | |
| 'root.map.layers[]': ['apiKey', 'time', 'args', 'fixed'] | |
| }; |
| @@ -1199,7 +1280,7 @@ export const compareMapChanges = (map1 = {}, map2 = {}) => { | |||
| return (value || []).filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid')); | |||
There was a problem hiding this comment.
| return (value || []).filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid')); | |
| const layers = (value || []) | |
| .filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid')) | |
| .map(saveLayer); | |
| return formatLayersForSave(layers).formattedLayers; |
| } | ||
| }; | ||
| const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, excludes, parsers }, 'root'); | ||
| const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, includes, excludes, parsers }, 'root'); |
There was a problem hiding this comment.
| const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, includes, excludes, parsers }, 'root'); | |
| const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, excludes, parsers }, 'root'); |
There was a problem hiding this comment.
create a function of this logic as formatLayersForSave that returns { formattedLayers, sources } and reuse it
| if (includes[parentPath]?.length && !includes[parentPath].includes(key)) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
| if (includes[parentPath]?.length && !includes[parentPath].includes(key)) { | |
| return false; | |
| } |
| * @returns {boolean} True if the field should be included, false otherwise. | ||
| */ | ||
| export const filterFieldByRules = (path, key, value, { pickedFields = [], excludes = {} }) => { | ||
| export const filterFieldByRules = (path, key, value, { pickedFields = [], includes = {}, excludes = {} }) => { |
There was a problem hiding this comment.
| export const filterFieldByRules = (path, key, value, { pickedFields = [], includes = {}, excludes = {} }) => { | |
| export const filterFieldByRules = (path, key, value, { pickedFields = [], excludes = {} }) => { |
| export const compareMapChanges = (map1 = {}, map2 = {}) => { | ||
| const pickedFields = [ | ||
| 'root.map.layers', | ||
| 'root.map.sources', |
There was a problem hiding this comment.
@Binabh Could you please check if source can be avoided. As @allyoucanmap suggested this could be compute expensive.
|
@dsuren1 Yes that could be removed. I have verified also. Also I have re-requested your review. Thank You! |
|
@Binabh Some tests are failing. Kindly address it. Thanks! |
|
@ElenaGallo Kindly test it in DEV. Thanks! |
|
fwiw i can confirm that (when backported on 2025.02), in my limited testing it fixes georchestra/mapstore2-georchestra#816 for me. much appreciated. |
|
Request failed due to following response errors:
|
|
Request failed due to following response errors:
|
|
Request failed due to following response errors:
|
Description
Change comparison logic to add includes rules and check map comparison based on includes fields.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
What is the current behavior?
#12951
What is the new behavior?
Unsaved state is not falsely triggered
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)