Make it possible to remove enteries
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reflection;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
@@ -7,6 +8,7 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
|
||||
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
|
||||
IMediator mediator,
|
||||
IServiceFactory serviceFactory,
|
||||
IDisposer disposer,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivationEventArgs<ItemSectionViewModel>>
|
||||
{
|
||||
@@ -39,6 +41,12 @@ public class ItemContentViewModelActivationHandler(IDecoratorService<Item<(Guid,
|
||||
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||
{
|
||||
// Should this be here?
|
||||
disposer.Add(entryViewModel, Disposable.Create(() =>
|
||||
{
|
||||
configurationSection.Entries.Remove(entryConfiguration);
|
||||
}));
|
||||
|
||||
publisher.Publish(Create.As(entryViewModel), id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Wallet;
|
||||
public partial class ItemEntryViewModel<TValue> :
|
||||
Observable<string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
IRemovable,
|
||||
IHandler<ValidateEventArgs<ItemEntry>, bool>,
|
||||
INotificationHandler<ConfirmEventArgs<ItemEntry>>,
|
||||
INotificationHandler<UpdateEventArgs<ItemEntry>>,
|
||||
@@ -69,6 +70,8 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> Handle(ValidateEventArgs<ItemEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -80,6 +83,9 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Remove() => Dispose();
|
||||
|
||||
[RelayCommand]
|
||||
private void Copy() => Publisher.Publish(Write.As(new Clipboard<object>($"{Value}")));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user