Skip to content

Commit

Permalink
Ability to create permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mricca committed Nov 11, 2016
1 parent fe704ac commit 69f474e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/client/actions/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

var axios = require('../libs/ajax');
var ConfigUtils = require('../utils/ConfigUtils');

const MAP_CONFIG_LOADED = 'MAP_CONFIG_LOADED';
const MAP_CONFIG_LOAD_ERROR = 'MAP_CONFIG_LOAD_ERROR';
Expand All @@ -31,10 +32,14 @@ function configureError(e) {
};
}

function loadMapConfig(configName, mapId) {
function loadMapConfig(configName, mapId, permalinkObj) {
return (dispatch) => {
return axios.get(configName).then((response) => {
if (typeof response.data === 'object') {
if (permalinkObj) {
ConfigUtils.setPermalinkLayersVisibility(response.data.map.layers, permalinkObj.permalinkLayers.layers);
assign(response.data.map, permalinkObj.permalinkExtent);
}
dispatch(configureMap(response.data, mapId));
} else {
try {
Expand Down
5 changes: 5 additions & 0 deletions web/client/utils/ConfigUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ var ConfigUtils = {
},
getConfigProp: function(prop) {
return defaultConfig[prop];
},
setPermalinkLayersVisibility: function(originalLayers, newLayers) {
return originalLayers.map((originalLayer) => {
return assign({}, originalLayer, newLayers.find((layer) => originalLayer.id === layer ? originalLayer.visibility = true : originalLayer.visibility = false));
});
}
};

Expand Down

0 comments on commit 69f474e

Please sign in to comment.