Rename rendererMap.editable function to more precise rendererMap.editableDataEnabled

Make coreContext.editable function also account for whether user is in modeSave
This commit is contained in:
Quincy Morgan
2019-12-12 16:06:28 -05:00
parent 960d0d58a9
commit 9d936b4aea
10 changed files with 25 additions and 21 deletions

View File

@@ -137,7 +137,7 @@ export function coreContext() {
context.loadTiles = function(projection, callback) {
var handle = window.requestIdleCallback(function() {
_deferred.delete(handle);
if (connection && context.editable()) {
if (connection && context.editableDataEnabled()) {
var cid = connection.getConnectionId();
connection.loadTiles(projection, afterLoad(cid, callback));
}
@@ -148,7 +148,7 @@ export function coreContext() {
context.loadTileAtLoc = function(loc, callback) {
var handle = window.requestIdleCallback(function() {
_deferred.delete(handle);
if (connection && context.editable()) {
if (connection && context.editableDataEnabled()) {
var cid = connection.getConnectionId();
connection.loadTileAtLoc(loc, afterLoad(cid, callback));
}
@@ -346,7 +346,15 @@ export function coreContext() {
context.map = function() { return map; };
context.layers = function() { return map.layers; };
context.surface = function() { return map.surface; };
context.editable = function() { return map.editable(); };
context.editableDataEnabled = function() { return map.editableDataEnabled(); };
context.editable = function() {
// don't allow editing during save
var mode = context.mode();
if (!mode || mode.id === 'save') return false;
return map.editableDataEnabled();
};
context.surfaceRect = function() {
return map.surface.node().getBoundingClientRect();
};

View File

@@ -93,7 +93,7 @@ export function rendererFeatures(context) {
enable: function() { this.enabled = true; this.currentMax = this.defaultMax; },
disable: function() { this.enabled = false; this.currentMax = 0; },
hidden: function() {
return !context.editable() ||
return !context.editableDataEnabled() ||
(this.count === 0 && !this.enabled) ||
this.count > this.currentMax * _cullFactor;
},

View File

@@ -167,14 +167,14 @@ export function rendererMap(context) {
_mouseEvent = d3_event;
})
.on('mouseover.vertices', function() {
if (map.editable() && !_isTransformed) {
if (map.editableDataEnabled() && !_isTransformed) {
var hover = d3_event.target.__data__;
surface.call(drawVertices.drawHover, context.graph(), hover, map.extent());
dispatch.call('drawn', this, { full: false });
}
})
.on('mouseout.vertices', function() {
if (map.editable() && !_isTransformed) {
if (map.editableDataEnabled() && !_isTransformed) {
var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
surface.call(drawVertices.drawHover, context.graph(), hover, map.extent());
dispatch.call('drawn', this, { full: false });
@@ -182,7 +182,7 @@ export function rendererMap(context) {
});
context.on('enter.map', function() {
if (map.editable() && !_isTransformed) {
if (map.editableDataEnabled() && !_isTransformed) {
// redraw immediately any objects affected by a change in selectedIDs.
var graph = context.graph();
var selectedAndParents = {};
@@ -580,7 +580,7 @@ export function rendererMap(context) {
}
// OSM
if (map.editable()) {
if (map.editableDataEnabled()) {
context.loadTiles(projection);
drawEditable(difference, extent);
} else {
@@ -915,7 +915,8 @@ export function rendererMap(context) {
};
map.editable = function() {
map.editableDataEnabled = function() {
var layer = context.layers().layer('osm');
if (!layer || !layer.enabled()) return false;

View File

@@ -23,8 +23,7 @@ export function uiToolAddFavorite(context) {
}
function osmEditable() {
var mode = context.mode();
return context.editable() && mode && mode.id !== 'save';
return context.editable();
}
function toggleMode(d) {

View File

@@ -23,8 +23,7 @@ export function uiToolAddRecent(context) {
}
function osmEditable() {
var mode = context.mode();
return context.editable() && mode && mode.id !== 'save';
return context.editable();
}
function toggleMode(d) {

View File

@@ -51,8 +51,7 @@ export function uiToolOldDrawModes(context) {
}
function osmEditable() {
var mode = context.mode();
return context.editable() && mode && mode.id !== 'save';
return context.editable();
}
modes.forEach(function(mode) {

View File

@@ -194,8 +194,7 @@ export function uiToolSearchAdd(context) {
};
function osmEditable() {
var mode = context.mode();
return context.editable() && mode && mode.id !== 'save';
return context.editable();
}
function updateEnabledState() {

View File

@@ -33,8 +33,7 @@ export function uiToolUndoRedo(context) {
function editable() {
var mode = context.mode();
return context.editable() && mode && mode.id !== 'save';
return context.editable();
}

View File

@@ -194,7 +194,7 @@ export function validationDisconnectedWay() {
// make sure the vertex is actually visible and editable
var map = context.map();
if (!map.editable() || !map.trimmedExtent().contains(vertex.loc)) {
if (!context.editable() || !map.trimmedExtent().contains(vertex.loc)) {
map.zoomToEase(vertex);
}

View File

@@ -220,7 +220,7 @@ export function validationImpossibleOneway() {
function continueDrawing(way, vertex, context) {
// make sure the vertex is actually visible and editable
var map = context.map();
if (!map.editable() || !map.trimmedExtent().contains(vertex.loc)) {
if (!context.editable() || !map.trimmedExtent().contains(vertex.loc)) {
map.zoomToEase(vertex);
}