Skip to content

Commit

Permalink
working on suppressing drawing for non-active layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Grossman committed May 13, 2019
1 parent ce6f3cf commit 8d9ab10
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
4 changes: 2 additions & 2 deletions modules/Hoot/ui/sidebar/layerAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default class LayerAdd extends SidebarForm {
name: d ? d.name : this.selectedLayer.name,
id: d ? d.id : this.selectedLayer.id,
refType: this.formMeta.refType,
activeLayer: d ? this.checkActiveLayers() : this.selectedLayer.activeLayer,
activeLayer: d ? d.activeLayer : this.selectedLayer.activeLayer,
color
};

Expand All @@ -213,7 +213,7 @@ export default class LayerAdd extends SidebarForm {
Hoot.events.emit( 'load-layer' );

// return this.checkForReview( layer );
this.checkActiveLayers();
//this.checkActiveLayers();
}

checkActiveLayers() {
Expand Down
6 changes: 3 additions & 3 deletions modules/Hoot/ui/sidebar/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ export default class Sidebar {
referenceState = referenceActive;

if (secondaryState) {
secondaryState.activeLayer = false;
referenceState.activeLayer = true;
secondaryState.activeLayer = false;
referenceState.activeLayer = true;
}
else {
referenceState.activeLayer = true;
referenceState.activeLayer = true;
}
changeActive.selectedLayer = referenceState;
});
Expand Down
34 changes: 24 additions & 10 deletions modules/behavior/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { behaviorHover } from './hover';
import { behaviorTail } from './tail';
import { geoChooseEdge, geoVecLength } from '../geo';
import { utilKeybinding, utilRebind } from '../util';
import _find from 'lodash-es/find';


var _usedTails = {};
var _disableSpace = false;
var _lastSpace = null;


export function behaviorDraw(context) {
var dispatch = d3_dispatch(
'move', 'click', 'clickWay', 'clickNode', 'undo', 'cancel', 'finish'
Expand Down Expand Up @@ -124,19 +124,33 @@ export function behaviorDraw(context) {
function click() {
var d = datum();
var target = d && d.properties && d.properties.entity;
var _activeLayer = _find( Hoot.layers.loadedLayers, function(a, b) { return a.activeLayer === true ? a : null; });

if (target && target.type === 'node') { // Snap to a node
dispatch.call('clickNode', this, target, d);
return;
if (_activeLayer.id === Number(target.mapId)) {
console.log(target.name + ' (' + target.id + ')' + ' is an active layer' );
dispatch.call('clickNode', this, target, d);
return;
} else {
return ({ message: 'Selected layer is not active', status: -2 }, target.name);
}
// dispatch.call('clickNode', this, target, d);
// return;

} else if (target && target.type === 'way') { // Snap to a way
var choice = geoChooseEdge(
context.childNodes(target), context.mouse(), context.projection, context.activeID()
);
if (choice) {
var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
dispatch.call('clickWay', this, choice.loc, edge, d);
return;
// eslint-disable-next-line radix
if (_activeLayer.id === Number(target.mapId)) {
console.log(target.id + ' is an active layer' );
var choice = geoChooseEdge(
context.childNodes(target), context.mouse(), context.projection, context.activeID()
);
if (choice) {
var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
dispatch.call('clickWay', this, choice.loc, edge, d);
return;
}
} else {
return ({ message: 'Selected layer is not active', status: -2 }, target.name);
}
}
dispatch.call('click', this, context.map().mouseCoordinates(), d);
Expand Down
2 changes: 1 addition & 1 deletion modules/services/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ export default {
filterChanges: function( changes ) {
let ways = _filter( _flatten( _map( changes, featArr => featArr ) ), feat => feat.type !== 'node' ),
checkLayers = Hoot.layers.loadedLayers,
visLayers = _map( _filter( _values( checkLayers ), layer => layer.visible ), layer => layer.id ),
visLayers = _map( _filter( _values( checkLayers ), layer => layer.visible ), layer => layer.id ),
activeLayer = _find(checkLayers, function(a, b) { return a.activeLayer === true ? a : null; }),
defaultMapId;

Expand Down
2 changes: 0 additions & 2 deletions modules/ui/raw_membership_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import { svgIcon } from '../svg';
import { uiDisclosure } from './disclosure';
import { utilDisplayName, utilNoAuto, utilHighlightEntity } from '../util';


export function uiRawMembershipEditor(context) {
var taginfo = services.taginfo;
var _entityID;
var _showBlank;


function selectRelation(d) {
d3_event.preventDefault();

Expand Down

0 comments on commit 8d9ab10

Please sign in to comment.