Skip to content

Commit 4e3e942

Browse files
committed
show (route) relation colours in lists and comboboxes
1 parent 5ef9928 commit 4e3e942

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
4040
#### :tada: New Features
4141
* Show a _remaining input length_ indicator and a warning if the maximum for OSM tags (typically, 255 characters) is exceeded ([#9390], [#9392] thanks [@alanb43], [#7943], [#9374])
4242
#### :sparkles: Usability & Accessibility
43+
* Show the color of (route) relations in the form of small colored circles in relation membership section and feature search results ([#9424])
4344
#### :white_check_mark: Validation
4445
#### :bug: Bugfixes
4546
* Fix bug which made it impossible to change an object's preset from a sub-preset to the respective parents preset (e.g. from Driveway to Service Road) ([#9372])
@@ -65,6 +66,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
6566
[#9397]: https://github.com/openstreetmap/iD/issues/9397
6667
[#9413]: https://github.com/openstreetmap/iD/pull/9413
6768
[#9423]: https://github.com/openstreetmap/iD/pull/9423
69+
[#9424]: https://github.com/openstreetmap/iD/pull/9424
6870
[@alanb43]: https://github.com/alanb43
6971
[@Rewinteer]: https://github.com/Rewinteer
7072

css/80_app.css

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ a.hide-toggle {
14121412
.ideditor[dir='rtl'] .field-label .label-text {
14131413
padding: 5px 10px 4px 0;
14141414
}
1415-
.field-label .label-text span {
1415+
.field-label .label-text {
14161416
white-space: nowrap;
14171417
}
14181418

@@ -2748,12 +2748,39 @@ img.tag-reference-wiki-image {
27482748
font-weight: normal;
27492749
padding-left: 10px;
27502750
}
2751+
.section-raw-member-editor .member-row .member-entity-name.has-colour::before,
2752+
.section-raw-membership-editor .member-row .member-entity-name.has-colour::before,
2753+
.feature-list .entity-name.has-colour::before,
2754+
.combobox-parent-relation .has-colour::before {
2755+
display: inline-block;
2756+
content: '';
2757+
margin-left: -5px;
2758+
margin-right: 5px;
2759+
border-style: solid;
2760+
border-width: 4px;
2761+
border-radius: 4px;
2762+
border-color: inherit;
2763+
}
2764+
.combobox-parent-relation .has-colour::before {
2765+
margin-left: 2px;
2766+
}
27512767

27522768
.ideditor[dir='rtl'] .section-raw-member-editor .member-row .member-entity-name,
27532769
.ideditor[dir='rtl'] .section-raw-membership-editor .member-row .member-entity-name {
27542770
padding-left:0;
27552771
padding-right: 10px;
27562772
}
2773+
.ideditor[dir='rtl'] .section-raw-member-editor .member-row .member-entity-name.has-colour::before,
2774+
.ideditor[dir='rtl'] .section-raw-membership-editor .member-row .member-entity-name.has-colour::before,
2775+
.ideditor[dir='rtl'] .feature-list .entity-name.has-colour::before {
2776+
margin-left: 5px;
2777+
margin-right: -5px;
2778+
}
2779+
.ideditor[dir='rtl'] .combobox-parent-relation .has-colour::before {
2780+
margin-left: 5px;
2781+
margin-right: 2px;
2782+
}
2783+
27572784

27582785
.form-field-input-member > input.member-role {
27592786
border-radius: 0 0 4px 4px;

modules/ui/feature_list.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ export function uiFeatureList(context) {
310310
label
311311
.append('span')
312312
.attr('class', 'entity-name')
313+
.classed('has-colour', d => d.entity && d.entity.type === 'relation' && d.entity.tags.colour)
314+
.style('border-color', d => d.entity && d.entity.type === 'relation' && d.entity.tags.colour)
313315
.text(function(d) { return d.name; });
314316

315317
enter

modules/ui/sections/raw_member_editor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ export function uiSectionRawMemberEditor(context) {
198198
labelLink
199199
.append('span')
200200
.attr('class', 'member-entity-name')
201+
.classed('has-colour', d => d.member.type === 'relation' && d.member.tags.colour)
202+
.style('border-color', d => d.member.type === 'relation' && d.member.tags.colour)
201203
.text(function(d) { return utilDisplayName(d.member); });
202204

203205
label

modules/ui/sections/raw_membership_editor.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,53 @@ export function uiSectionRawMembershipEditor(context) {
239239

240240
var graph = context.graph();
241241

242-
function baseDisplayLabel(entity) {
242+
function baseDisplayValue(entity) {
243243
var matched = presetManager.match(entity, graph);
244244
var presetName = (matched && matched.name()) || t('inspector.relation');
245245
var entityName = utilDisplayName(entity) || '';
246246

247247
return presetName + ' ' + entityName;
248248
}
249249

250+
function baseDisplayLabel(entity) {
251+
var matched = presetManager.match(entity, graph);
252+
var presetName = (matched && matched.name()) || t('inspector.relation');
253+
var entityName = utilDisplayName(entity) || '';
254+
255+
return selection => {
256+
selection
257+
.append('b')
258+
.text(presetName + ' ');
259+
selection
260+
.append('span')
261+
.classed('has-colour', entity.tags.colour)
262+
.style('border-color', entity.tags.colour)
263+
.text(entityName);
264+
};
265+
}
266+
250267
var explicitRelation = q && context.hasEntity(q.toLowerCase());
251268
if (explicitRelation && explicitRelation.type === 'relation' && explicitRelation.id !== entityID) {
252269
// loaded relation is specified explicitly, only show that
253270

254271
result.push({
255272
relation: explicitRelation,
256-
value: baseDisplayLabel(explicitRelation) + ' ' + explicitRelation.id
273+
value: baseDisplayValue(explicitRelation) + ' ' + explicitRelation.id,
274+
display: baseDisplayLabel(explicitRelation)
257275
});
258276
} else {
259277

260278
context.history().intersects(context.map().extent()).forEach(function(entity) {
261279
if (entity.type !== 'relation' || entity.id === entityID) return;
262280

263-
var value = baseDisplayLabel(entity);
281+
var value = baseDisplayValue(entity);
264282
if (q && (value + ' ' + entity.id).toLowerCase().indexOf(q.toLowerCase()) === -1) return;
265283

266-
result.push({ relation: entity, value: value });
284+
result.push({
285+
relation: entity,
286+
value,
287+
display: baseDisplayLabel(entity)
288+
});
267289
});
268290

269291
result.sort(function(a, b) {
@@ -349,6 +371,8 @@ export function uiSectionRawMembershipEditor(context) {
349371
labelLink
350372
.append('span')
351373
.attr('class', 'member-entity-name')
374+
.classed('has-colour', d => d.relation.tags.colour)
375+
.style('border-color', d => d.relation.tags.colour)
352376
.text(function(d) { return utilDisplayName(d.relation); });
353377

354378
labelEnter

0 commit comments

Comments
 (0)