Skip to content

Commit

Permalink
[Maps] clean-up unsaved state check (#61705) (#61859)
Browse files Browse the repository at this point in the history
* [Maps] clean-up unsaved state check (#61535)

* close layer panel in functional test

* skip vector styling test

* skip saved object management test

* skip all of group 7 tests

* turn back on group 7, skip full screen

* turn on all tests except full screen

* unskip all tests and resolve root problem

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
nreese and elasticmachine authored Mar 30, 2020
1 parent 2d6f2dc commit 62f6cc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 8 additions & 2 deletions x-pack/legacy/plugins/maps/public/angular/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,15 @@ app.controller(
const layerListConfigOnly = copyPersistentState(layerList);

const savedLayerList = savedMap.getLayerList();
const oldConfig = savedLayerList ? savedLayerList : initialLayerListConfig;

return !_.isEqual(layerListConfigOnly, oldConfig);
return !savedLayerList
? !_.isEqual(layerListConfigOnly, initialLayerListConfig)
: // 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.
!_.isEqual(JSON.parse(JSON.stringify(layerListConfigOnly)), savedLayerList);
}

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 62f6cc5

Please sign in to comment.