From d2534e060f54e1c98df96ac7ed746bb9a9b108ba Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Mon, 24 Oct 2016 14:53:49 +0200 Subject: [PATCH] Add option to control layer insertion position in addLayer action --- web/client/actions/layers.js | 5 +++-- web/client/reducers/layers.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/client/actions/layers.js b/web/client/actions/layers.js index 39a09d2381a..2ba8370d22e 100644 --- a/web/client/actions/layers.js +++ b/web/client/actions/layers.js @@ -126,10 +126,11 @@ function layerError(layerId) { }; } -function addLayer(layer) { +function addLayer(layer, foreground = false) { return { type: ADD_LAYER, - layer + layer, + foreground }; } diff --git a/web/client/reducers/layers.js b/web/client/reducers/layers.js index 56dd093296c..7d6a596c425 100644 --- a/web/client/reducers/layers.js +++ b/web/client/reducers/layers.js @@ -252,7 +252,8 @@ function layers(state = [], action) { if (groupName !== "background") { let node = getNode(newGroups, groupName ); if (node) { - newGroups = deepChange(state.groups, groupName, 'nodes', node.nodes.concat(newLayer.id)); + let newLayerIds = action.foreground ? [newLayer.id].concat(node.nodes) : node.nodes.concat([newLayer.id]); + newGroups = deepChange(state.groups, groupName, 'nodes', newLayerIds); } else { const newGroup = LayersUtils.getLayersByGroup([newLayer]); newGroups = newGroup.concat(newGroups);