Add supported for key mediator handelrs
This commit is contained in:
@@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Toolkit.Avalonia;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
@@ -69,6 +70,15 @@ public partial class App : Application
|
||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
||||
|
||||
services.AddTransient<IItemConfigurationCollection, ItemConfigurationCollection>(provider =>
|
||||
{
|
||||
IEnumerable<IConfigurationDescriptor<ItemConfiguration>> items =
|
||||
provider.GetServices<IConfigurationDescriptor<ItemConfiguration>>() ??
|
||||
Enumerable.Empty<IConfigurationDescriptor<ItemConfiguration>>();
|
||||
|
||||
return new ItemConfigurationCollection(items.ToDictionary(x => x.Name, x => (Func<ItemConfiguration>)(() => x.Value)));
|
||||
});
|
||||
|
||||
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
||||
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||
|
||||
@@ -100,6 +110,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
|
||||
services.AddHandler<AggerateItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
@@ -112,10 +123,18 @@ public partial class App : Application
|
||||
|
||||
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
||||
|
||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||
|
||||
services.AddTemplate<AddItemNavigationViewModel, AddItemNavigationView>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<EmptyItemCollectionViewModel, EmptyItemCollectionView>("EmptyItemCollection");
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
services.AddTemplate<ItemContentViewModel, ItemContentView>();
|
||||
|
||||
services.AddHandler<AggregateItemContentViewModelHandler>();
|
||||
services.AddHandler<AggregateItemContentFromCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||
|
||||
@@ -127,12 +146,10 @@ public partial class App : Application
|
||||
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
||||
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
||||
|
||||
services.AddTemplate<EmptyItemCollectionViewModel, EmptyItemCollectionView>("EmptyItemCollection");
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
services.AddTemplate<ItemContentViewModel, ItemContentView>();
|
||||
services.AddTemplate<AddItemNavigationViewModel, AddItemNavigationView>();
|
||||
|
||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||
services.AddTemplate<ItemTextEntryViewModel, ItemTextEntryView>();
|
||||
services.AddTemplate<ItemPasswordEntryViewModel, ItemPasswordEntryView>();
|
||||
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
||||
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
||||
|
||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
||||
@@ -142,6 +159,11 @@ public partial class App : Application
|
||||
services.AddHandler<FavouriteItemHandler>();
|
||||
services.AddHandler<UnfavouriteItemHandler>();
|
||||
|
||||
services.AddHandler<ItemTextEntryViewModelHandler>(nameof(TextEntryConfiguration));
|
||||
services.AddHandler<ItemPasswordEntryViewModelHandler>(nameof(PasswordEntryConfiguration));
|
||||
services.AddHandler<ItemMaskedTextEntryViewModelHandler>(nameof(MaskedTextEntryConfiguration));
|
||||
services.AddHandler<ItemDropdownEntryViewModelHandler>(nameof(DropdownEntryConfiguration));
|
||||
|
||||
services.AddHandler<ItemCreatedHandler>(ServiceLifetime.Singleton);
|
||||
services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton);
|
||||
});
|
||||
|
||||
@@ -3,24 +3,12 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel">
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel"
|
||||
ListBoxExtension.IsItemInvokedEnabled="True">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<DataTriggerBehavior
|
||||
Binding="{Binding Selected}"
|
||||
ComparisonCondition="Equal"
|
||||
Value="True">
|
||||
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static ListBoxExtension.ItemInvokedEvent}">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</DataTriggerBehavior>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
<Grid Background="Transparent" ColumnDefinitions="Auto,*">
|
||||
<PersonPicture
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Bitvault.Avalonia.ItemDropdownEntryView">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class ItemDropdownEntryView : UserControl
|
||||
{
|
||||
public ItemDropdownEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Bitvault.Avalonia.ItemMaskedTextEntryView">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class ItemMaskedTextEntryView : UserControl
|
||||
{
|
||||
public ItemMaskedTextEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:False}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Bitvault.Avalonia.ItemPasswordEntryView">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class ItemPasswordEntryView : UserControl
|
||||
{
|
||||
public ItemPasswordEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Bitvault.Avalonia.ItemTextEntryView">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class ItemTextEntryView : UserControl
|
||||
{
|
||||
public ItemTextEntryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
||||
public class AggregateItemCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
@@ -10,9 +10,9 @@ public class AggregateItemCategoryViewModelHandler(IEnumerable<IConfigurationDes
|
||||
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
||||
{
|
||||
bool selected = true;
|
||||
foreach (IConfigurationDescriptor<ItemConfiguration> descriptor in descriptors)
|
||||
foreach (KeyValuePair<string, Func<ItemConfiguration>> configuration in configurations)
|
||||
{
|
||||
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(descriptor.Name, selected)
|
||||
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(configuration.Key, selected)
|
||||
is ItemCategoryNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel, string>>
|
||||
{
|
||||
public async Task Handle(AggerateEventArgs<IItemEntryViewModel, string> args)
|
||||
{
|
||||
if (args.Value is string category)
|
||||
{
|
||||
if (configurations.TryGetValue(category, out Func<ItemConfiguration>? factory))
|
||||
{
|
||||
if (factory.Invoke() is ItemConfiguration configuration)
|
||||
{
|
||||
foreach (ItemSectionConfiguration section in configuration.Sections)
|
||||
{
|
||||
foreach (ItemEntryConfiguration entryConfiguration in section.Entries)
|
||||
{
|
||||
var dod = await mediator.Handle<ItemEntryConfiguration, IItemEntryViewModel?>(entryConfiguration,
|
||||
entryConfiguration.GetType().Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,18 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggregateItemContentViewModelHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
IMediator mediator,
|
||||
public class AggregateItemContentViewModelHandler(IMediator mediator,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
||||
{
|
||||
var d = valueStore;
|
||||
//if (serviceFactory.Create<ItemHeaderViewModel>(false) is ItemHeaderViewModel viewModel)
|
||||
//wModel>(false) is ItemHeaderViewModel viewModel)
|
||||
//{
|
||||
// publisher.Publish(Create.As<IItemEntryViewModel>(viewModel), nameof(ItemViewModel));
|
||||
//}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,32 +8,31 @@ public class AggerateItemViewModelHandler(IMediator mediator,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher,
|
||||
LockerViewModelConfiguration dd) :
|
||||
INotificationHandler<AggregateEventArgs<ItemNavigationViewModel,
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration>>
|
||||
{
|
||||
public async Task Handle(AggregateEventArgs<ItemNavigationViewModel,
|
||||
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
LockerViewModelConfiguration> args)
|
||||
{
|
||||
var ddddd = dd;
|
||||
if (args.Options is LockerViewModelConfiguration configuration)
|
||||
if (args.Value is LockerViewModelConfiguration configuration)
|
||||
{
|
||||
cache.Clear();
|
||||
bool selected = true;
|
||||
|
||||
if (await mediator.Handle<RequestEventArgs<QueryLockerConfiguration>,
|
||||
IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)>>(Request.As(new QueryLockerConfiguration
|
||||
IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>>(Request.As(new QueryLockerConfiguration
|
||||
{
|
||||
Filter = configuration.Filter,
|
||||
Query = configuration.Query
|
||||
})) is IReadOnlyCollection<(Guid Id, string Name, bool Favourite, bool Archived)> results)
|
||||
})) is IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)> results)
|
||||
{
|
||||
foreach ((Guid Id, string Name, bool Favourite, bool Archived) in results)
|
||||
foreach ((Guid Id, string Name, string Category, bool Favourite, bool Archived) in results)
|
||||
{
|
||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
|
||||
|
||||
if (serviceFactory.Create<ItemNavigationViewModel>(Id, Name, "Description", selected, Favourite, Archived) is ItemNavigationViewModel viewModel)
|
||||
if (serviceFactory.Create<ItemNavigationViewModel>(Id, Name, "Description", Category, selected, Favourite, Archived) is ItemNavigationViewModel viewModel)
|
||||
{
|
||||
Item<(Guid, string)> item = new((Id, Name));
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IItemConfigurationCollection :
|
||||
IReadOnlyDictionary<string, Func<ItemConfiguration>>;
|
||||
@@ -1,6 +1,4 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public interface IItemEntryViewModel :
|
||||
IDisposable
|
||||
{
|
||||
}
|
||||
IDisposable;
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||
[Notification(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
@@ -71,6 +71,6 @@ public partial class ItemCollectionViewModel :
|
||||
return base.OnActivated();
|
||||
}
|
||||
|
||||
protected override AggregateExpression CreateAggregateExpression() =>
|
||||
protected override AggregateExpression BuildAggregateExpression() =>
|
||||
new(Aggregate.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public record ItemConfiguration
|
||||
{
|
||||
public IList<ItemSectionConfiguration>? Sections { get; set; }
|
||||
public IList<ItemSectionConfiguration> Sections { get; set; } = new List<ItemSectionConfiguration>();
|
||||
|
||||
public static ItemConfiguration Identity => new()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemConfigurationCollection(IDictionary<string, Func<ItemConfiguration>> dictionary) :
|
||||
ReadOnlyDictionary<string, Func<ItemConfiguration>>(dictionary),
|
||||
IItemConfigurationCollection;
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
//[Aggerate(nameof(ItemContentViewModel))]
|
||||
public partial class ItemContentViewModel :
|
||||
ObservableCollection<IItemEntryViewModel>,
|
||||
public partial class ItemContentViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory, IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state = ItemState.Read) :
|
||||
ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||
{
|
||||
public ItemContentViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory, IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state = ItemState.Read) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
|
||||
{
|
||||
if (args.Value is ItemCategory<string> category)
|
||||
{
|
||||
if (category.Value is string value)
|
||||
{
|
||||
Fetch(() => new AggregateExpression(new AggerateEventArgs<IItemEntryViewModel, string>(value)), true);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) :
|
||||
Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel;
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<DropdownEntryConfiguration, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(DropdownEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>() is ItemDropdownEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>,
|
||||
IItemEntryViewModel
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? category;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel;
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<MaskedTextEntryConfiguration, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(MaskedTextEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>() is ItemMaskedTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
Guid id,
|
||||
string? name = "",
|
||||
string? description = "",
|
||||
string name = "",
|
||||
string description = "",
|
||||
string category = "",
|
||||
bool selected = false,
|
||||
bool favourite = false,
|
||||
bool archived = false) :
|
||||
@@ -30,6 +31,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool archived = archived;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? category = category;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? description = description;
|
||||
|
||||
@@ -48,8 +52,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected = selected;
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
public bool Attached { get; set; }
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||
Task.Run(Dispose);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel;
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemPasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<PasswordEntryConfiguration, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(PasswordEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>() is ItemPasswordEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IItemEntryViewModel;
|
||||
@@ -0,0 +1,18 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ItemTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<TextEntryConfiguration, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(TextEntryConfiguration args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (serviceFactory.Create<ItemTextEntryViewModel>() is ItemTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Bitvault;
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.New))]
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.Write))]
|
||||
public partial class ItemViewModel :
|
||||
ObservableCollection<IItemEntryViewModel>,
|
||||
ObservableCollection,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(typeof(CreateEventArgs<IMainNavigationViewModel>), nameof(MainViewModel))]
|
||||
[Notification(typeof(CreateEventArgs<IMainNavigationViewModel>), nameof(MainViewModel))]
|
||||
public partial class MainViewModel :
|
||||
ObservableCollection<IMainNavigationViewModel>
|
||||
{
|
||||
|
||||
@@ -6,12 +6,12 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<RequestEventArgs<QueryLockerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>>
|
||||
IHandler<RequestEventArgs<QueryLockerConfiguration>, IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>>
|
||||
{
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryLockerConfiguration> args,
|
||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryLockerConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
||||
List<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)> items = [];
|
||||
|
||||
if (args.Value is QueryLockerConfiguration queryConfiguration)
|
||||
{
|
||||
@@ -47,6 +47,7 @@ public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactor
|
||||
{
|
||||
x.Id,
|
||||
x.Name,
|
||||
x.Category,
|
||||
Favourite = x.State == 1,
|
||||
Archived = x.State == 2
|
||||
}).ToListAsync();
|
||||
@@ -54,7 +55,7 @@ public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactor
|
||||
|
||||
foreach (var result in results.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
items.Add(new(result.Id, result.Name, result.Favourite, result.Archived));
|
||||
items.Add(new(result.Id, result.Name, result.Category, result.Favourite, result.Archived));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user