Interactive interface for browsing global, full-resolution satellite imagery
change to moveBefore/pushToBottom instead of replacing layer list
Mike McGanndc767ad2d9c5
diff --git a/web/js/components/sidebar/products/layer-list.js b/web/js/components/sidebar/products/layer-list.jsindex f9a1be89a..c03328ab3 100644--- a/web/js/components/sidebar/products/layer-list.js+++ b/web/js/components/sidebar/products/layer-list.js@@ -64,12 +64,21 @@ class LayerList extends React.Component {if (result.source.index === result.destination.index) {return;}+ const regex = new RegExp('-' + layerGroupName + '$');+ const layerId = result.draggableId.replace(regex, '');const newLayerArray = reorder(layers,result.source.index,result.destination.index);- replaceSubGroup(newLayerArray, layerGroupName, groupId);+ // In the new ordering, find the layer right after the layer that just+ // moved. Leave null if moved to the end of the list.+ let nextLayerId = null;+ const nextIndex = result.destination.index + 1;+ if (nextIndex < newLayerArray.length) {+ nextLayerId = newLayerArray[nextIndex].id;+ }+ replaceSubGroup(layerId, nextLayerId, layerGroupName, groupId);}render() {const { groupId, title, layerGroupName } = this.props;diff --git a/web/js/layers/model.js b/web/js/layers/model.jsindex a0566f491..0dcc65211 100644--- a/web/js/layers/model.js+++ b/web/js/layers/model.js@@ -302,15 +302,13 @@ export function layersModel(models, config) {self.events.trigger('update');self.events.trigger('change');};- self.replaceSubGroup = function(newSubGroup, activeLayerString, subGroup) {+ self.replaceSubGroup = function(layerId, nextLayerId, activeLayerString, subGroup) {activeLayerString = activeLayerString || self.activeLayers;- var layers = self.get({ group: 'all' }, self[activeLayerString]);- var baseLayers =- subGroup === 'baselayers' ? newSubGroup : layers.baselayers;- var overlays = subGroup === 'overlays' ? newSubGroup : layers.overlays;- self[activeLayerString] = overlays.concat(baseLayers);- self.events.trigger('update');- self.events.trigger('change');+ if (nextLayerId) {+ self.moveBefore(layerId, nextLayerId, activeLayerString);+ } else {+ self.pushToBottom(layerId, activeLayerString);+ }};self.clear = function(projId, activeLayerString) {activeLayerString = activeLayerString || self.activeLayers;