mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-12 06:06:06 +00:00
Add entity display label util function
Condense message and tooltip text for for the untagged feature issue Use lighter border color for error issues
This commit is contained in:
@@ -4,6 +4,7 @@ export { utilCleanTags } from './clean_tags';
|
||||
export { utilDisplayName } from './util';
|
||||
export { utilDisplayNameForPath } from './util';
|
||||
export { utilDisplayType } from './util';
|
||||
export { utilDisplayLabel } from './util';
|
||||
export { utilEditDistance } from './util';
|
||||
export { utilEntitySelector } from './util';
|
||||
export { utilEntityOrMemberSelector } from './util';
|
||||
|
||||
@@ -121,6 +121,22 @@ export function utilDisplayType(id) {
|
||||
}
|
||||
|
||||
|
||||
export function utilDisplayLabel(entity, context) {
|
||||
var displayName = utilDisplayName(entity);
|
||||
if (displayName) {
|
||||
// use the display name if there is one
|
||||
return displayName;
|
||||
}
|
||||
var preset = context.presets().match(entity, context.graph());
|
||||
if (preset && preset.name()) {
|
||||
// use the preset name if there is a match
|
||||
return preset.name();
|
||||
}
|
||||
// fallback to the display type (node/way/relation)
|
||||
return utilDisplayType(entity.id);
|
||||
}
|
||||
|
||||
|
||||
export function utilStringQs(str) {
|
||||
return str.split('&').reduce(function(obj, pair){
|
||||
var parts = pair.split('=');
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { t } from '../util/locale';
|
||||
import {
|
||||
utilDisplayName,
|
||||
utilDisplayType
|
||||
utilDisplayLabel
|
||||
} from '../util';
|
||||
import {
|
||||
ValidationIssueType,
|
||||
@@ -35,22 +34,12 @@ export function validationDisconnectedHighway(context) {
|
||||
var issues = [];
|
||||
for (var i = 0; i < changes.created.length; i++) {
|
||||
var entity = changes.created[i];
|
||||
|
||||
if (isDisconnectedHighway(entity, graph)) {
|
||||
var entityLabel = utilDisplayName(entity);
|
||||
if (!entityLabel) {
|
||||
var preset = context.presets().match(entity, graph);
|
||||
if (preset && preset.name()) {
|
||||
entityLabel = preset.name();
|
||||
} else {
|
||||
entityLabel = utilDisplayType(entity.id);
|
||||
}
|
||||
}
|
||||
|
||||
var entityLabel = utilDisplayLabel(entity, context);
|
||||
issues.push(new validationIssue({
|
||||
type: ValidationIssueType.disconnected_highway,
|
||||
severity: ValidationIssueSeverity.warning,
|
||||
message: t('issues.disconnected_highway.message', {entityLabel: entityLabel}),
|
||||
message: t('issues.disconnected_highway.message', {highway: entityLabel}),
|
||||
tooltip: t('issues.disconnected_highway.tooltip'),
|
||||
entities: [entity],
|
||||
}));
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import _without from 'lodash-es/without';
|
||||
import { t } from '../util/locale';
|
||||
import {
|
||||
utilDisplayLabel
|
||||
} from '../util';
|
||||
import {
|
||||
ValidationIssueType,
|
||||
ValidationIssueSeverity,
|
||||
validationIssue,
|
||||
} from './validation_issue';
|
||||
|
||||
export function validationMissingTag() {
|
||||
export function validationMissingTag(context) {
|
||||
|
||||
// Slightly stricter check than Entity#isUsed (#3091)
|
||||
function hasTags(entity, graph) {
|
||||
@@ -23,11 +26,12 @@ export function validationMissingTag() {
|
||||
geometry = change.geometry(graph);
|
||||
|
||||
if (types.indexOf(geometry) !== -1 && !hasTags(change, graph)) {
|
||||
var entityLabel = utilDisplayLabel(change, context);
|
||||
issues.push(new validationIssue({
|
||||
type: ValidationIssueType.missing_tag,
|
||||
severity: ValidationIssueSeverity.error,
|
||||
message: t('issues.untagged_' + geometry + '.message'),
|
||||
tooltip: t('issues.untagged_' + geometry + '.tooltip'),
|
||||
message: t('issues.untagged_feature.message', {feature: entityLabel}),
|
||||
tooltip: t('issues.untagged_feature.tooltip'),
|
||||
entities: [change],
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user