substitute 'info' for 'data' (so I can use 'info' for an info drawer)

This commit is contained in:
Bryan Housel
2019-04-15 11:08:09 -04:00
parent f6708fd84c
commit 294ce00211
7 changed files with 37 additions and 30 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ export function validationIssue(attrs) {
this.tooltip = attrs.tooltip; // required - localized string
this.entities = attrs.entities; // optional - array of entities
this.loc = attrs.loc; // optional - expect a [lon, lat] array
this.info = attrs.info; // optional - object containing arbitrary extra information
this.data = attrs.data; // optional - object containing extra data for the fixes
this.fixes = attrs.fixes; // optional - array of validationIssueFix objects
this.hash = attrs.hash; // optional - string to further differentiate the issue
+3 -3
View File
@@ -47,8 +47,8 @@ export function validationAlmostJunction() {
title: t('issues.fix.connect_features.title'),
onClick: function() {
var endNode = this.issue.entities[1];
var targetEdge = this.issue.info.edge;
var crossLoc = this.issue.info.cross_loc;
var targetEdge = this.issue.data.edge;
var crossLoc = this.issue.data.cross_loc;
var edgeNodes = [context.graph().entity(targetEdge[0]), context.graph().entity(targetEdge[1])];
var closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
@@ -94,7 +94,7 @@ export function validationAlmostJunction() {
tooltip: t('issues.almost_junction.highway-highway.tip'),
entities: [entity, node, edgeHighway],
loc: extendableNodeInfo.node.loc,
info: {
data: {
edge: extendableNodeInfo.edge,
cross_loc: extendableNodeInfo.cross_loc
},
+7 -4
View File
@@ -431,8 +431,8 @@ export function validationCrossingWays() {
title: t('issues.fix.connect_features.title'),
onClick: function() {
var loc = this.issue.loc;
var connectionTags = this.issue.info.connectionTags;
var edges = this.issue.info.edges;
var connectionTags = this.issue.data.connectionTags;
var edges = this.issue.data.edges;
context.perform(
function actionConnectCrossingWays(graph) {
@@ -500,9 +500,12 @@ export function validationCrossingWays() {
type: type,
severity: 'warning',
message: t('issues.crossing_ways.message', messageDict),
tooltip: t('issues.crossing_ways.'+crossingTypeID+'.tip'),
tooltip: t('issues.crossing_ways.' + crossingTypeID + '.tip'),
entities: entities,
info: { edges: crossing.edges, connectionTags: connectionTags },
data: {
edges: crossing.edges,
connectionTags: connectionTags
},
loc: crossing.crossPoint,
fixes: fixes
});
+8 -6
View File
@@ -11,9 +11,8 @@ export function validationMissingRole() {
var issues = [];
if (entity.type === 'way') {
context.graph().parentRelations(entity).forEach(function(relation) {
if (!relation.isMultipolygon()) {
return;
}
if (!relation.isMultipolygon()) return;
var member = relation.memberById(entity.id);
if (member && isMissingRole(member)) {
issues.push(makeIssue(entity, relation, member, context));
@@ -31,6 +30,7 @@ export function validationMissingRole() {
return issues;
};
function isMissingRole(member) {
return !member.role || !member.role.trim().length;
}
@@ -45,7 +45,9 @@ export function validationMissingRole() {
}),
tooltip: t('issues.missing_role.multipolygon.tip'),
entities: [relation, way],
info: {member: member},
data: {
member: member
},
fixes: [
makeAddRoleFix('inner', context),
makeAddRoleFix('outer', context),
@@ -54,7 +56,7 @@ export function validationMissingRole() {
title: t('issues.fix.remove_from_relation.title'),
onClick: function() {
context.perform(
actionDeleteMember(this.issue.entities[0].id, this.issue.info.member.index),
actionDeleteMember(this.issue.entities[0].id, this.issue.data.member.index),
t('operations.delete_member.annotation')
);
}
@@ -67,7 +69,7 @@ export function validationMissingRole() {
return new validationIssueFix({
title: t('issues.fix.set_as_' + role + '.title'),
onClick: function() {
var oldMember = this.issue.info.member;
var oldMember = this.issue.data.member;
var member = { id: this.issue.entities[1].id, type: oldMember.type, role: role };
context.perform(
actionChangeMember(this.issue.entities[0].id, member, oldMember.index),
+2 -2
View File
@@ -68,7 +68,7 @@ export function validationOutdatedTags() {
message: t('issues.outdated_tags.message', { feature: utilDisplayLabel(entity, context) }),
tooltip: tooltip, // t('issues.outdated_tags.tip'),
entities: [entity],
info: {
data: {
tagDiff: tagDiff,
newTags: newTags
},
@@ -78,7 +78,7 @@ export function validationOutdatedTags() {
title: t('issues.fix.upgrade_tags.title'),
onClick: function() {
var entityID = this.issue.entities[0].id;
var newTags = this.issue.info.newTags;
var newTags = this.issue.data.newTags;
context.perform(
actionChangeTags(entityID, newTags),
t('issues.fix.upgrade_tags.annotation')
+4 -2
View File
@@ -63,7 +63,9 @@ export function validationPrivateData() {
}),
tooltip: t('issues.private_data.tip'),
entities: [entity],
info: { privateKeys: privateKeys },
data: {
privateKeys: privateKeys
},
fixes: [
new validationIssueFix({
auto: true,
@@ -72,7 +74,7 @@ export function validationPrivateData() {
onClick: function() {
var entity = this.issue.entities[0];
var tags = Object.assign({}, entity.tags); // shallow copy
var privateKeys = this.issue.info.privateKeys;
var privateKeys = this.issue.data.privateKeys;
for (var index in privateKeys) {
delete tags[privateKeys[index]];
}
+12 -12
View File
@@ -157,13 +157,13 @@ describe('iD.validations.almost_junction', function () {
expect(issue.loc[0]).to.eql(22.42357);
expect(issue.loc[1]).to.eql(0);
expect(issue.info.edge).to.have.lengthOf(2);
expect(issue.info.edge[0]).to.eql('n-3');
expect(issue.info.edge[1]).to.eql('n-4');
expect(issue.data.edge).to.have.lengthOf(2);
expect(issue.data.edge[0]).to.eql('n-3');
expect(issue.data.edge[1]).to.eql('n-4');
expect(issue.info.cross_loc).to.have.lengthOf(2);
expect(issue.info.cross_loc[0]).to.eql(22.42356);
expect(issue.info.cross_loc[1]).to.eql(0);
expect(issue.data.cross_loc).to.have.lengthOf(2);
expect(issue.data.cross_loc[0]).to.eql(22.42356);
expect(issue.data.cross_loc[1]).to.eql(0);
expect(issue.fixes).to.have.lengthOf(2);
issue.fixes[0].onClick();
@@ -186,13 +186,13 @@ describe('iD.validations.almost_junction', function () {
expect(issue.loc[0]).to.eql(22.42357);
expect(issue.loc[1]).to.eql(0);
expect(issue.info.edge).to.have.lengthOf(2);
expect(issue.info.edge[0]).to.eql('n-3');
expect(issue.info.edge[1]).to.eql('n-4');
expect(issue.data.edge).to.have.lengthOf(2);
expect(issue.data.edge[0]).to.eql('n-3');
expect(issue.data.edge[1]).to.eql('n-4');
expect(issue.info.cross_loc).to.have.lengthOf(2);
expect(issue.info.cross_loc[0]).to.eql(22.42356);
expect(issue.info.cross_loc[1]).to.eql(0);
expect(issue.data.cross_loc).to.have.lengthOf(2);
expect(issue.data.cross_loc[0]).to.eql(22.42356);
expect(issue.data.cross_loc[1]).to.eql(0);
expect(issue.fixes).to.have.lengthOf(2);
issue.fixes[1].onClick();