mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
fix dependency cycle caused by utilDisplayLabel importing presetManager
This commit is contained in:
@@ -5,8 +5,9 @@ import { select as d3_select } from 'd3-selection';
|
||||
import { geoSphericalDistance } from '../geo';
|
||||
import { modeBrowse } from '../modes/browse';
|
||||
import { modeSelect, modeSelectNote } from '../modes';
|
||||
import { utilDisplayLabel, utilObjectOmit, utilQsString, utilStringQs } from '../util';
|
||||
import { utilObjectOmit, utilQsString, utilStringQs } from '../util';
|
||||
import { utilArrayIdentical } from '../util/array';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { t } from '../core/localizer';
|
||||
import { prefs } from '../core/preferences';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { modeSelect } from '../modes/select';
|
||||
import { geoExtent, geoVecSubtract } from '../geo';
|
||||
import { t } from '../core/localizer';
|
||||
import { uiCmd } from '../ui/cmd';
|
||||
import { utilDisplayLabel } from '../util/util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
|
||||
// see also `behaviorPaste`
|
||||
export function operationPaste(context) {
|
||||
|
||||
@@ -19,7 +19,6 @@ export { utilDetect } from './detect';
|
||||
export { utilDisplayName } from './util';
|
||||
export { utilDisplayNameForPath } from './util';
|
||||
export { utilDisplayType } from './util';
|
||||
export { utilDisplayLabel } from './util';
|
||||
export { utilEntityRoot } from './util';
|
||||
export { utilEditDistance } from './util';
|
||||
export { utilEntityAndDeepMemberIDs } from './util';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { remove as removeDiacritics } from 'diacritics';
|
||||
import { fixRTLTextForSvg, rtlRegex } from './svg_paths_rtl_fix';
|
||||
|
||||
import { presetManager } from '../presets';
|
||||
import { t, localizer } from '../core/localizer';
|
||||
import { utilArrayUnion } from './array';
|
||||
import { utilDetect } from './detect';
|
||||
@@ -244,32 +243,6 @@ export function utilDisplayType(id) {
|
||||
}
|
||||
|
||||
|
||||
// `utilDisplayLabel`
|
||||
// Returns a string suitable for display
|
||||
// By default returns something like name/ref, fallback to preset type, fallback to OSM type
|
||||
// "Main Street" or "Tertiary Road"
|
||||
// If `verbose=true`, include both preset name and feature name.
|
||||
// "Tertiary Road Main Street"
|
||||
//
|
||||
export function utilDisplayLabel(entity, graphOrGeometry, verbose) {
|
||||
var result;
|
||||
var displayName = utilDisplayName(entity);
|
||||
var preset = typeof graphOrGeometry === 'string' ?
|
||||
presetManager.matchTags(entity.tags, graphOrGeometry) :
|
||||
presetManager.match(entity, graphOrGeometry);
|
||||
var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
|
||||
|
||||
if (verbose) {
|
||||
result = [presetName, displayName].filter(Boolean).join(' ');
|
||||
} else {
|
||||
result = displayName || presetName;
|
||||
}
|
||||
|
||||
// Fallback to the OSM type (node/way/relation)
|
||||
return result || utilDisplayType(entity.id);
|
||||
}
|
||||
|
||||
|
||||
export function utilEntityRoot(entityType) {
|
||||
return {
|
||||
node: 'n',
|
||||
|
||||
33
modules/util/utilDisplayLabel.js
Normal file
33
modules/util/utilDisplayLabel.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { presetManager } from '../presets';
|
||||
import { utilDisplayName, utilDisplayType } from './util';
|
||||
|
||||
/**
|
||||
* `utilDisplayLabel` returns a string suitable for display
|
||||
*
|
||||
* By default returns something like name/ref, fallback to preset type, fallback to OSM type
|
||||
* "Main Street" or "Tertiary Road"
|
||||
*
|
||||
* If `verbose=true`, include both preset name and feature name.
|
||||
* "Tertiary Road Main Street"
|
||||
* @param {osmEntity} entity
|
||||
* @param {string | unknown} graphOrGeometry
|
||||
* @param {boolean} [verbose]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function utilDisplayLabel(entity, graphOrGeometry, verbose) {
|
||||
var result;
|
||||
var displayName = utilDisplayName(entity);
|
||||
var preset = typeof graphOrGeometry === 'string' ?
|
||||
presetManager.matchTags(entity.tags, graphOrGeometry) :
|
||||
presetManager.match(entity, graphOrGeometry);
|
||||
var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
|
||||
|
||||
if (verbose) {
|
||||
result = [presetName, displayName].filter(Boolean).join(' ');
|
||||
} else {
|
||||
result = displayName || presetName;
|
||||
}
|
||||
|
||||
// Fallback to the OSM type (node/way/relation)
|
||||
return result || utilDisplayType(entity.id);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { actionAddMidpoint } from '../actions/add_midpoint';
|
||||
import { actionChangeTags } from '../actions/change_tags';
|
||||
import { actionMergeNodes } from '../actions/merge_nodes';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { osmRoutableHighwayTagValues } from '../osm/tags';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { services } from '../services';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { actionMergeNodes } from '../actions/merge_nodes';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { t } from '../core/localizer';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { osmPathHighwayTagValues } from '../osm/tags';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { geoAngle, geoExtent, geoLatToMeters, geoLonToMeters, geoLineIntersectio
|
||||
import { osmNode } from '../osm/node';
|
||||
import { osmFlowingWaterwayTagValues, osmPathHighwayTagValues, osmRailwayTrackTagValues, osmRoutableHighwayTagValues } from '../osm/tags';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { t, localizer } from '../core/localizer';
|
||||
import { modeDrawLine } from '../modes/draw_line';
|
||||
import { operationDelete } from '../operations/delete';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { osmRoutableHighwayTagValues } from '../osm/tags';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { services } from '../services';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { t, localizer } from '../core/localizer';
|
||||
import { modeDrawLine } from '../modes/draw_line';
|
||||
import { actionReverse } from '../actions/reverse';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { osmFlowingWaterwayTagValues, osmOneWayTags, osmRoutableHighwayTagValues } from '../osm/tags';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { services } from '../services';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue } from '../core/validation';
|
||||
|
||||
export function validationFormatting() {
|
||||
|
||||
@@ -10,7 +10,8 @@ import { osmNodeGeometriesForTags, osmTagSuggestingArea } from '../osm/tags';
|
||||
import { presetManager } from '../presets';
|
||||
import { geoHasSelfIntersections, geoSphericalDistance } from '../geo';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel, utilTagText } from '../util';
|
||||
import { utilTagText } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { actionChangeMember } from '../actions/change_member';
|
||||
import { actionDeleteMember } from '../actions/delete_member';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { operationDelete } from '../operations/delete';
|
||||
import { osmIsInterestingTag } from '../osm/tags';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { actionChangeTags } from '../actions/change_tags';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { osmMutuallyExclusiveTagPairs } from '../osm/tags';
|
||||
|
||||
@@ -90,4 +90,4 @@ export function validationMutuallyExclusiveTags(/* context */) {
|
||||
validation.type = type;
|
||||
|
||||
return validation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import { actionUpgradeTags } from '../actions/upgrade_tags';
|
||||
import { fileFetcher } from '../core';
|
||||
import { presetManager } from '../presets';
|
||||
import { services } from '../services';
|
||||
import { utilDisplayLabel, utilHashcode, utilTagDiff } from '../util';
|
||||
import { utilHashcode, utilTagDiff } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { actionChangeTags } from '../actions/change_tags';
|
||||
import { t } from '../core/localizer';
|
||||
import { utilDisplayLabel, utilTagDiff } from '../util';
|
||||
import { utilTagDiff } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { t } from '../core/localizer';
|
||||
//import { actionChangeTags } from '../actions/change_tags';
|
||||
import { actionOrthogonalize } from '../actions/orthogonalize';
|
||||
import { geoOrthoCanOrthogonalize } from '../geo/ortho';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
import { utilDisplayLabel } from '../util/utilDisplayLabel';
|
||||
import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
import { services } from '../services';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user