@@ -12,6 +12,7 @@ import { actionDeleteMembers } from '../../actions/delete_members';
1212
1313import { modeSelect } from '../../modes/select' ;
1414import { osmEntity , osmRelation } from '../../osm' ;
15+ import { isColourValid } from '../../osm/tags' ;
1516import { services } from '../../services' ;
1617import { svgIcon } from '../../svg/icon' ;
1718import { uiCombobox } from '../combobox' ;
@@ -239,31 +240,53 @@ export function uiSectionRawMembershipEditor(context) {
239240
240241 var graph = context . graph ( ) ;
241242
242- function baseDisplayLabel ( entity ) {
243+ function baseDisplayValue ( entity ) {
243244 var matched = presetManager . match ( entity , graph ) ;
244245 var presetName = ( matched && matched . name ( ) ) || t ( 'inspector.relation' ) ;
245246 var entityName = utilDisplayName ( entity ) || '' ;
246247
247248 return presetName + ' ' + entityName ;
248249 }
249250
251+ function baseDisplayLabel ( entity ) {
252+ var matched = presetManager . match ( entity , graph ) ;
253+ var presetName = ( matched && matched . name ( ) ) || t ( 'inspector.relation' ) ;
254+ var entityName = utilDisplayName ( entity ) || '' ;
255+
256+ return selection => {
257+ selection
258+ . append ( 'b' )
259+ . text ( presetName + ' ' ) ;
260+ selection
261+ . append ( 'span' )
262+ . classed ( 'has-colour' , entity . tags . colour && isColourValid ( entity . tags . colour ) )
263+ . style ( 'border-color' , entity . tags . colour )
264+ . text ( entityName ) ;
265+ } ;
266+ }
267+
250268 var explicitRelation = q && context . hasEntity ( q . toLowerCase ( ) ) ;
251269 if ( explicitRelation && explicitRelation . type === 'relation' && explicitRelation . id !== entityID ) {
252270 // loaded relation is specified explicitly, only show that
253271
254272 result . push ( {
255273 relation : explicitRelation ,
256- value : baseDisplayLabel ( explicitRelation ) + ' ' + explicitRelation . id
274+ value : baseDisplayValue ( explicitRelation ) + ' ' + explicitRelation . id ,
275+ display : baseDisplayLabel ( explicitRelation )
257276 } ) ;
258277 } else {
259278
260279 context . history ( ) . intersects ( context . map ( ) . extent ( ) ) . forEach ( function ( entity ) {
261280 if ( entity . type !== 'relation' || entity . id === entityID ) return ;
262281
263- var value = baseDisplayLabel ( entity ) ;
282+ var value = baseDisplayValue ( entity ) ;
264283 if ( q && ( value + ' ' + entity . id ) . toLowerCase ( ) . indexOf ( q . toLowerCase ( ) ) === - 1 ) return ;
265284
266- result . push ( { relation : entity , value : value } ) ;
285+ result . push ( {
286+ relation : entity ,
287+ value,
288+ display : baseDisplayLabel ( entity )
289+ } ) ;
267290 } ) ;
268291
269292 result . sort ( function ( a , b ) {
@@ -349,6 +372,8 @@ export function uiSectionRawMembershipEditor(context) {
349372 labelLink
350373 . append ( 'span' )
351374 . attr ( 'class' , 'member-entity-name' )
375+ . classed ( 'has-colour' , d => d . relation . tags . colour && isColourValid ( d . relation . tags . colour ) )
376+ . style ( 'border-color' , d => d . relation . tags . colour )
352377 . text ( function ( d ) { return utilDisplayName ( d . relation ) ; } ) ;
353378
354379 labelEnter
0 commit comments