Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] clean-up unsaved state check #61535

Merged
merged 1 commit into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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