Convert lodah-es and d3 to named imports for operations

This commit is contained in:
Bryan Housel
2017-09-25 13:58:53 -04:00
parent 914ef0236a
commit 3def4db09f
10 changed files with 53 additions and 36 deletions
+5 -4
View File
@@ -1,7 +1,8 @@
import _ from 'lodash';
import _uniq from 'lodash-es/uniq';
import { t } from '../util/locale';
import { actionCircularize } from '../actions/index';
import { behaviorOperation } from '../behavior/index';
import { actionCircularize } from '../actions';
import { behaviorOperation } from '../behavior';
export function operationCircularize(selectedIDs, context) {
@@ -20,7 +21,7 @@ export function operationCircularize(selectedIDs, context) {
operation.available = function() {
return selectedIDs.length === 1 &&
entity.type === 'way' &&
_.uniq(entity.nodes).length > 1;
_uniq(entity.nodes).length > 1;
};
+7 -5
View File
@@ -1,14 +1,16 @@
import _ from 'lodash';
import _extend from 'lodash-es/extend';
import _groupBy from 'lodash-es/groupBy';
import { t } from '../util/locale';
import { modeDrawLine } from '../modes/index';
import { behaviorOperation } from '../behavior/index';
import { modeDrawLine } from '../modes';
import { behaviorOperation } from '../behavior';
export function operationContinue(selectedIDs, context) {
var graph = context.graph(),
entities = selectedIDs.map(function(id) { return graph.entity(id); }),
geometries = _.extend({ line: [], vertex: [] },
_.groupBy(entities, function(entity) { return entity.geometry(graph); })),
geometries = _extend({ line: [], vertex: [] },
_groupBy(entities, function(entity) { return entity.geometry(graph); })),
vertex = geometries.vertex[0];
+5 -4
View File
@@ -1,4 +1,5 @@
import _ from 'lodash';
import _some from 'lodash-es/some';
import { t } from '../util/locale';
import { actionDeleteMultiple } from '../actions';
import { behaviorOperation } from '../behavior';
@@ -64,11 +65,11 @@ export function operationDelete(selectedIDs, context) {
var reason;
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
reason = 'too_large';
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
} else if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
} else if (_.some(selectedIDs, protectedMember)) {
} else if (_some(selectedIDs, protectedMember)) {
reason = 'part_of_relation';
} else if (_.some(selectedIDs, incompleteRelation)) {
} else if (_some(selectedIDs, incompleteRelation)) {
reason = 'incomplete_relation';
}
return reason;
+7 -4
View File
@@ -1,11 +1,14 @@
import _ from 'lodash';
import _filter from 'lodash-es/filter';
import _some from 'lodash-es/some';
import _without from 'lodash-es/without';
import { t } from '../util/locale';
import { actionDisconnect } from '../actions/index';
import { behaviorOperation } from '../behavior/index';
export function operationDisconnect(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function(entityId) {
var vertices = _filter(selectedIDs, function(entityId) {
return context.geometry(entityId) === 'vertex';
});
@@ -13,7 +16,7 @@ export function operationDisconnect(selectedIDs, context) {
action = actionDisconnect(entityId);
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
action.limitWays(_without(selectedIDs, entityId));
}
@@ -29,7 +32,7 @@ export function operationDisconnect(selectedIDs, context) {
operation.disabled = function() {
var reason;
if (_.some(selectedIDs, context.hasHiddenConnections)) {
if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
}
return action.disabled(context.graph()) || reason;
+4 -3
View File
@@ -1,4 +1,5 @@
import _ from 'lodash';
import _some from 'lodash-es/some';
import { t } from '../util/locale';
import { behaviorOperation } from '../behavior/index';
import { geoExtent } from '../geo/index';
@@ -27,9 +28,9 @@ export function operationMove(selectedIDs, context) {
var reason;
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
reason = 'too_large';
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
} else if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
} else if (_.some(selectedIDs, incompleteRelation)) {
} else if (_some(selectedIDs, incompleteRelation)) {
reason = 'incomplete_relation';
}
return reason;
+3 -2
View File
@@ -1,4 +1,5 @@
import _ from 'lodash';
import _uniq from 'lodash-es/uniq';
import { t } from '../util/locale';
import { actionOrthogonalize } from '../actions/index';
import { behaviorOperation } from '../behavior/index';
@@ -21,7 +22,7 @@ export function operationOrthogonalize(selectedIDs, context) {
return selectedIDs.length === 1 &&
entity.type === 'way' &&
entity.isClosed() &&
_.uniq(entity.nodes).length > 2;
_uniq(entity.nodes).length > 2;
};
+6 -4
View File
@@ -1,4 +1,6 @@
import _ from 'lodash';
import _some from 'lodash-es/some';
import _uniqBy from 'lodash-es/uniqBy';
import { t } from '../util/locale';
import { actionReflect } from '../actions';
import { behaviorOperation } from '../behavior';
@@ -33,7 +35,7 @@ export function operationReflect(selectedIDs, context, axis) {
operation.available = function() {
var nodes = utilGetAllNodes(selectedIDs, context.graph());
return _.uniqBy(nodes, function(n) { return n.loc; }).length >= 3;
return _uniqBy(nodes, function(n) { return n.loc; }).length >= 3;
};
@@ -41,9 +43,9 @@ export function operationReflect(selectedIDs, context, axis) {
var reason;
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
reason = 'too_large';
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
} else if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
} else if (_.some(selectedIDs, incompleteRelation)) {
} else if (_some(selectedIDs, incompleteRelation)) {
reason = 'incomplete_relation';
}
return reason;
+6 -4
View File
@@ -1,4 +1,6 @@
import _ from 'lodash';
import _some from 'lodash-es/some';
import _uniqBy from 'lodash-es/uniqBy';
import { t } from '../util/locale';
import { behaviorOperation } from '../behavior';
import { geoExtent } from '../geo';
@@ -20,7 +22,7 @@ export function operationRotate(selectedIDs, context) {
operation.available = function() {
var nodes = utilGetAllNodes(selectedIDs, context.graph());
return _.uniqBy(nodes, function(n) { return n.loc; }).length >= 2;
return _uniqBy(nodes, function(n) { return n.loc; }).length >= 2;
};
@@ -28,9 +30,9 @@ export function operationRotate(selectedIDs, context) {
var reason;
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
reason = 'too_large';
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
} else if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
} else if (_.some(selectedIDs, incompleteRelation)) {
} else if (_some(selectedIDs, incompleteRelation)) {
reason = 'incomplete_relation';
}
return reason;
+7 -4
View File
@@ -1,4 +1,7 @@
import _ from 'lodash';
import _filter from 'lodash-es/filter';
import _some from 'lodash-es/some';
import _without from 'lodash-es/without';
import { t } from '../util/locale';
import { actionSplit } from '../actions/index';
import { behaviorOperation } from '../behavior/index';
@@ -6,7 +9,7 @@ import { modeSelect } from '../modes/index';
export function operationSplit(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function(entityId) {
var vertices = _filter(selectedIDs, function(entityId) {
return context.geometry(entityId) === 'vertex';
});
@@ -16,7 +19,7 @@ export function operationSplit(selectedIDs, context) {
if (vertices.length === 1) {
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
action.limitWays(_without(selectedIDs, entityId));
}
ways = action.ways(context.graph());
}
@@ -35,7 +38,7 @@ export function operationSplit(selectedIDs, context) {
operation.disabled = function() {
var reason;
if (_.some(selectedIDs, context.hasHiddenConnections)) {
if (_some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
}
return action.disabled(context.graph()) || reason;
+3 -2
View File
@@ -1,4 +1,5 @@
import _ from 'lodash';
import _uniq from 'lodash-es/uniq';
import { t } from '../util/locale';
import { actionStraighten } from '../actions/index';
import { behaviorOperation } from '../behavior/index';
@@ -19,7 +20,7 @@ export function operationStraighten(selectedIDs, context) {
return selectedIDs.length === 1 &&
entity.type === 'way' &&
!entity.isClosed() &&
_.uniq(entity.nodes).length > 2;
_uniq(entity.nodes).length > 2;
};