forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: stefano bovio <[email protected]>
- Loading branch information
1 parent
17901a7
commit 49ba48b
Showing
7 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
geonode_mapstore_client/client/js/selectors/__tests__/mapsave-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2021, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import { | ||
mapSaveSelector | ||
} from '../mapsave'; | ||
|
||
describe('mapsave selector', () => { | ||
it('should keep the available styles property', () => { | ||
const state = { | ||
map: { | ||
present: {} | ||
}, | ||
layers: { | ||
flat: [{ id: '01', availableStyles: [{ name: 'style' }] }] | ||
} | ||
}; | ||
const data = mapSaveSelector(state); | ||
expect(data.map.layers[0].availableStyles).toEqual([ | ||
{ name: 'style' } | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { mapSaveSelector as msMapSaveSelector } from '@mapstore/framework/selectors/mapsave'; | ||
import { layersSelector } from '@mapstore/framework/selectors/layers'; | ||
|
||
/* | ||
* this map save selector is extending the default properties available in the final map data blob | ||
* eg. availableStyles property | ||
*/ | ||
export const mapSaveSelector = (state) => { | ||
const layersState = layersSelector(state); | ||
const { map, ...data } = msMapSaveSelector(state); | ||
return { | ||
...data, | ||
map: { | ||
...map, | ||
layers: (map?.layers || []).map((layer) => { | ||
const layerState = layersState.find((lState) => lState.id === layer.id); | ||
if (layerState) { | ||
const { availableStyles } = layerState; | ||
return { | ||
...layer, | ||
availableStyles | ||
}; | ||
} | ||
return layer; | ||
}) | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
export const LayoutSections = { | ||
// we need a constant to prevent infinite loop in the epics that update the layout | ||
PANEL: 'PANEL' | ||
}; |