Skip to content

Commit

Permalink
[Maps] clean-up unsaved state check (elastic#61535)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 27, 2020
1 parent a8558f9 commit ab4449a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion x-pack/legacy/plugins/maps/public/angular/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,12 @@ app.controller(
const savedLayerList = savedMap.getLayerList();
const oldConfig = savedLayerList ? savedLayerList : initialLayerListConfig;

return !_.isEqual(layerListConfigOnly, oldConfig);
// savedMap stores layerList as a JSON string using JSON.stringify.
// JSON.stringify removes undefined properties from objects.
// savedMap.getLayerList converts the JSON string back into Javascript array of objects.
// Need to perform the same process for layerListConfigOnly to compare apples to apples
// and avoid undefined properties in layerListConfigOnly triggering unsaved changes.
return !_.isEqual(JSON.parse(JSON.stringify(layerListConfigOnly)), oldConfig);
}

function isOnMapNow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ export function DynamicColorForm({
};
if (type === COLOR_MAP_TYPE.ORDINAL) {
newColorOptions.useCustomColorRamp = useCustomColorMap;
newColorOptions.customColorRamp = customColorMap;
newColorOptions.color = color;
if (customColorMap) {
newColorOptions.customColorRamp = customColorMap;
}
if (color) {
newColorOptions.color = color;
}
} else {
newColorOptions.useCustomColorPalette = useCustomColorMap;
newColorOptions.customColorPalette = customColorMap;
newColorOptions.colorCategory = color;
if (customColorMap) {
newColorOptions.customColorPalette = customColorMap;
}
if (color) {
newColorOptions.colorCategory = color;
}
}

onDynamicStyleChange(styleProperty.getStyleName(), newColorOptions);
Expand Down

0 comments on commit ab4449a

Please sign in to comment.