Skip to content

Commit

Permalink
Restored geosolutions-it#3525 and removed duplications
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Mar 7, 2019
1 parent 6895104 commit 50ba62b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
3 changes: 1 addition & 2 deletions web/client/epics/mapexport.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ const {EXPORT_MAP} = require('../actions/mapexport');
const { setControlProperty } = require('../actions/controls');

const { mapSelector } = require('../selectors/map');
const { mapInfoConfigurationSelector } = require('../selectors/mapInfo');
const { layersSelector, groupsSelector } = require('../selectors/layers');
const { mapOptionsToSaveSelector } = require('../selectors/mapsave');
const textSearchConfigSelector = state => state.searchconfig && state.searchconfig.textSearchConfig;

const PersistMap = {
mapstore2: (state) => JSON.stringify(MapUtils.saveMapConfiguration(mapSelector(state), layersSelector(state), groupsSelector(state), textSearchConfigSelector(state), mapOptionsToSaveSelector(state), mapInfoConfigurationSelector(state)))
mapstore2: (state) => JSON.stringify(MapUtils.saveMapConfiguration(mapSelector(state), layersSelector(state), groupsSelector(state), textSearchConfigSelector(state), mapOptionsToSaveSelector(state)))
};


Expand Down
11 changes: 4 additions & 7 deletions web/client/plugins/Save.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ const ConfigUtils = require('../utils/ConfigUtils');
const {mapSelector} = require('../selectors/map');
const {layersSelector, groupsSelector} = require('../selectors/layers');
const {mapOptionsToSaveSelector} = require('../selectors/mapsave');
const {mapInfoConfigurationSelector} = require('../selectors/mapInfo');
const MapUtils = require('../utils/MapUtils');
const showSelector = state => state.controls && state.controls.save && state.controls.save.enabled;
const textSearchConfigSelector = state => state.searchconfig && state.searchconfig.textSearchConfig;

const selector = createSelector(
mapSelector, mapOptionsToSaveSelector, layersSelector, groupsSelector, showSelector, textSearchConfigSelector, mapInfoConfigurationSelector,
(map, additionalOptions, layers, groups, show, textSearchConfig, mapInfoConfiguration) => ({
mapSelector, mapOptionsToSaveSelector, layersSelector, groupsSelector, showSelector, textSearchConfigSelector,
(map, additionalOptions, layers, groups, show, textSearchConfig) => ({
currentZoomLvl: map && map.zoom,
show,
map,
additionalOptions,
mapId: map && map.mapId,
layers,
textSearchConfig,
groups,
mapInfoConfiguration
groups
}));

class Save extends React.Component {
Expand All @@ -53,7 +51,6 @@ class Save extends React.Component {
map: PropTypes.object,
layers: PropTypes.array,
groups: PropTypes.array,
mapInfoConfiguration: PropTypes.object,
params: PropTypes.object,
textSearchConfig: PropTypes.object
};
Expand Down Expand Up @@ -95,7 +92,7 @@ class Save extends React.Component {
goForTheUpdate = () => {
if (this.props.mapId) {
if (this.props.map && this.props.layers) {
const resultingmap = MapUtils.saveMapConfiguration(this.props.map, this.props.layers, this.props.groups, this.props.textSearchConfig, this.props.additionalOptions, this.props.mapInfoConfiguration);
const resultingmap = MapUtils.saveMapConfiguration(this.props.map, this.props.layers, this.props.groups, this.props.textSearchConfig, this.props.additionalOptions);
const {name, description} = this.props.map.info;
this.props.onMapSave({id: this.props.mapId, data: resultingmap, metadata: {name, description}, category: "MAP"});
this.props.onClose();
Expand Down
11 changes: 4 additions & 7 deletions web/client/plugins/SaveAs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ const selector = createSelector(
groupsSelector,
mapOptionsToSaveSelector,
saveAsStateSelector,
mapInfoConfigurationSelector,
(map, layers, groups, additionalOptions, saveAsState, mapInfoConfiguration) => ({
(map, layers, groups, additionalOptions, saveAsState) => ({
currentZoomLvl: map && map.zoom,
map,
layers,
groups,
additionalOptions,
...saveAsState,
mapInfoConfiguration
...saveAsState
}));

class SaveAs extends React.Component {
Expand Down Expand Up @@ -78,8 +76,7 @@ class SaveAs extends React.Component {
metadataChanged: PropTypes.func,
onMapSave: PropTypes.func,
loadMapInfo: PropTypes.func,
textSearchConfig: PropTypes.object,
mapInfoConfiguration: PropTypes.object
textSearchConfig: PropTypes.object
};

static contextTypes = {
Expand Down Expand Up @@ -144,7 +141,7 @@ class SaveAs extends React.Component {

// this method creates the content for the Map Resource
createV2Map = () => {
return MapUtils.saveMapConfiguration(this.props.map, this.props.layers, this.props.groups, this.props.textSearchConfig, this.props.additionalOptions, this.props.mapInfoConfiguration);
return MapUtils.saveMapConfiguration(this.props.map, this.props.layers, this.props.groups, this.props.textSearchConfig, this.props.additionalOptions);
};

saveMap = (id, name, description) => {
Expand Down
5 changes: 4 additions & 1 deletion web/client/selectors/mapsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
const {createStructuredSelector} = require('reselect');
const {servicesSelector, selectedServiceSelector} = require('./catalog');
const {getFloatingWidgets, getCollapsedState, getFloatingWidgetsLayout} = require('./widgets');
const { mapInfoConfigurationSelector } = require('./mapInfo');


const mapOptionsToSaveSelector = createStructuredSelector({
catalogServices: createStructuredSelector({
Expand All @@ -19,6 +21,7 @@ const mapOptionsToSaveSelector = createStructuredSelector({
widgets: getFloatingWidgets,
layouts: getFloatingWidgetsLayout,
collapsed: getCollapsedState
})
}),
mapInfoConfiguration: mapInfoConfigurationSelector
});
module.exports = {mapOptionsToSaveSelector};
10 changes: 5 additions & 5 deletions web/client/utils/__tests__/MapUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ describe('Test the MapUtils', () => {
units: 'm',
zoom: 10
},
mapInfoConfiguration: undefined,
version: 2
});
});
Expand Down Expand Up @@ -716,7 +715,6 @@ describe('Test the MapUtils', () => {
units: 'm',
zoom: 10
},
mapInfoConfiguration: undefined,
version: 2
});
});
Expand Down Expand Up @@ -976,7 +974,6 @@ describe('Test the MapUtils', () => {
}
}
},
mapInfoConfiguration: undefined,
version: 2
});
});
Expand Down Expand Up @@ -1031,7 +1028,7 @@ describe('Test the MapUtils', () => {
units: 'm',
zoom: 10
};
const saved = saveMapConfiguration(mapConfig, flat, groups, '', {}, {infoFormat: "text/html", showEmptyMessageGFI: false});
const saved = saveMapConfiguration(mapConfig, flat, groups, '', { mapInfoConfiguration: {infoFormat: "text/html", showEmptyMessageGFI: false}});
expect(saved).toEqual({
map: {
center: {crs: 'EPSG:4326', x: 0, y: 0},
Expand All @@ -1050,11 +1047,13 @@ describe('Test the MapUtils', () => {
thumbURL: undefined,
availableStyles: undefined,
bbox: {},
requestEncoding: undefined,
capabilitiesURL: undefined,
description: undefined,
dimensions: [],
nativeCrs: undefined,
features: undefined,
queryable: undefined,
featureInfo: undefined,
format: undefined,
group: undefined,
Expand Down Expand Up @@ -1106,7 +1105,8 @@ describe('Test the MapUtils', () => {
}
}
}
}, mapInfoConfiguration: {
},
mapInfoConfiguration: {
infoFormat: "text/html",
showEmptyMessageGFI: false
},
Expand Down

0 comments on commit 50ba62b

Please sign in to comment.