Rename for consistency, add logic to prevent flip if all of object not visible and if linked to hidden. Label does not render for message when not enabled

This commit is contained in:
Jon D
2016-11-06 11:15:15 +00:00
parent 23990214be
commit 73f3069c59
7 changed files with 34 additions and 14 deletions
+1 -1
View File
@@ -31,4 +31,4 @@ export { actionRotateWay } from './rotate_way';
export { actionSplit } from './split';
export { actionStraighten } from './straighten';
export { actionUnrestrictTurn } from './unrestrict_turn';
export { actionReflect } from './flip';
export { actionReflect } from './reflect.js';
@@ -3,7 +3,7 @@ import _ from 'lodash';
Only operates on "area" ways
*/
export function actionFlip(wayId) {
export function actionReflect(wayId) {
return function (graph) {
const targetWay = graph.entity(wayId);
+1
View File
@@ -9,3 +9,4 @@ export { operationReverse } from './reverse';
export { operationRotate } from './rotate';
export { operationSplit } from './split';
export { operationStraighten } from './straighten';
export { operationReflect } from './reflect';
+12 -3
View File
@@ -2,11 +2,14 @@ import { t } from '../util/locale';
import { actionReflect } from '../actions/index';
export function operationReflect(selectedIDs, context) {
var entityId = selectedIDs[0];
const entityId = selectedIDs[0];
const entity = context.entity(entityId);
const extent = entity.extent(context.graph());
const action = actionReflect(entityId);
var operation = function() {
context.perform(
actionReflect(entityId, false),
action,
t('operations.reflect.annotation')
);
};
@@ -17,7 +20,13 @@ export function operationReflect(selectedIDs, context) {
};
operation.disabled = function() {
return false;
if (extent.percentContainedIn(context.extent()) < 0.8) {
return 'too_large';
} else if (context.hasHiddenConnections(entityId)) {
return 'connected_to_hidden';
} else {
return false;
}
};
operation.tooltip = function() {