33using Alidade . Osm . Models . Nsi ;
44using Alidade . Osm . Models . Tagging ;
55using Microsoft . AspNetCore . Components . Web ;
6+ using Alidade . Handlers . Map ;
7+ using Alidade . Handlers . Selection ;
8+ using Alidade . Osm . Handlers . Editing ;
9+ using Alidade . Osm . Handlers . Tagging ;
610
711namespace Alidade . Components . Panels ;
812
@@ -22,7 +26,8 @@ public partial class InspectorPanel(
2226 /// <summary>
2327 /// When set, the panel is pinned to this element and does not follow selection changes.
2428 /// </summary>
25- [ Parameter ] public OsmElementRef ? PinnedRef { get ; set ; }
29+ [ Parameter ]
30+ public OsmElementRef ? PinnedRef { get ; set ; }
2631
2732 private bool IsPinned => PinnedRef is not null ;
2833
@@ -259,9 +264,12 @@ OsmElementTypes.Relation when buf.Relations.TryGetValue(_targetRef.Id, out OsmRe
259264 RefreshPreset ( ) ;
260265 }
261266
262- private void ApplyPreset ( Preset preset )
267+ private async Task ApplyPreset ( Preset preset )
263268 {
264- if ( _targetRef is null ) return ;
269+ if ( _targetRef is null )
270+ {
271+ return ;
272+ }
265273
266274 EditBufferState buf = editBufferState . State ;
267275 IReadOnlyDictionary < string , string > ? currentTags = _targetRef . Type switch
@@ -272,15 +280,18 @@ OsmElementTypes.Relation when buf.Relations.TryGetValue(_targetRef.Id, out OsmRe
272280 _ => null
273281 } ;
274282
275- if ( currentTags is null ) return ;
283+ if ( currentTags is null )
284+ {
285+ return ;
286+ }
276287
277- Dictionary < string , string > merged = new ( currentTags ) ;
278- foreach ( ( string k , string v ) in preset . Tags )
288+ Dictionary < string , string > ? merged = await mediator . Send ( new MergePresetTags . Query ( currentTags , preset ) ) ;
289+ if ( merged is null )
279290 {
280- if ( v != "*" ) merged [ k ] = v ;
291+ return ;
281292 }
282293
283- _ = mediator . Send ( new UpdateTags . Command ( _targetRef , currentTags , merged ) ) ;
294+ await mediator . Send ( new UpdateTags . Command ( _targetRef , currentTags , merged ) ) ;
284295 _activePreset = preset ;
285296 _query = string . Empty ;
286297 _isSearching = false ;
@@ -292,19 +303,19 @@ private void PinCurrent()
292303 {
293304 if ( _targetRef is not null )
294305 {
295- _ = mediator . Send ( new Handlers . Map . PinInspector . Command ( _targetRef ) ) ;
306+ _ = mediator . Send ( new PinInspector . Command ( _targetRef ) ) ;
296307 }
297308 }
298309
299310 private void OnClose ( )
300311 {
301312 if ( IsPinned )
302313 {
303- _ = mediator . Send ( new Handlers . Map . UnpinInspector . Command ( PinnedRef ! ) ) ;
314+ _ = mediator . Send ( new UnpinInspector . Command ( PinnedRef ! ) ) ;
304315 }
305316 else
306317 {
307- _ = mediator . Send ( new Handlers . Selection . ClearSelection . Command ( ) ) ;
318+ _ = mediator . Send ( new ClearSelection . Command ( ) ) ;
308319 }
309320 }
310321
0 commit comments