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 Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Toolkit.Avalonia;
|
using Toolkit.Avalonia;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
@@ -69,6 +70,15 @@ public partial class App : Application
|
|||||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||||
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
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<SecurityKey>, ValueStore<SecurityKey>>();
|
||||||
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||||
|
|
||||||
@@ -100,6 +110,7 @@ public partial class App : Application
|
|||||||
|
|
||||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||||
|
|
||||||
services.AddHandler<AggerateItemViewModelHandler>();
|
services.AddHandler<AggerateItemViewModelHandler>();
|
||||||
|
|
||||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||||
@@ -112,10 +123,18 @@ public partial class App : Application
|
|||||||
|
|
||||||
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
services.AddHandler<AggregateItemCategoryViewModelHandler>();
|
||||||
|
|
||||||
|
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||||
|
|
||||||
|
services.AddTemplate<AddItemNavigationViewModel, AddItemNavigationView>();
|
||||||
|
|
||||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||||
|
services.AddTemplate<EmptyItemCollectionViewModel, EmptyItemCollectionView>("EmptyItemCollection");
|
||||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||||
|
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||||
|
services.AddTemplate<ItemContentViewModel, ItemContentView>();
|
||||||
|
|
||||||
services.AddHandler<AggregateItemContentViewModelHandler>();
|
services.AddHandler<AggregateItemContentViewModelHandler>();
|
||||||
|
services.AddHandler<AggregateItemContentFromCategoryViewModelHandler>();
|
||||||
|
|
||||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||||
|
|
||||||
@@ -127,12 +146,10 @@ public partial class App : Application
|
|||||||
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
||||||
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
||||||
|
|
||||||
services.AddTemplate<EmptyItemCollectionViewModel, EmptyItemCollectionView>("EmptyItemCollection");
|
services.AddTemplate<ItemTextEntryViewModel, ItemTextEntryView>();
|
||||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
services.AddTemplate<ItemPasswordEntryViewModel, ItemPasswordEntryView>();
|
||||||
services.AddTemplate<ItemContentViewModel, ItemContentView>();
|
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
||||||
services.AddTemplate<AddItemNavigationViewModel, AddItemNavigationView>();
|
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
||||||
|
|
||||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
|
||||||
|
|
||||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
||||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
||||||
@@ -142,6 +159,11 @@ public partial class App : Application
|
|||||||
services.AddHandler<FavouriteItemHandler>();
|
services.AddHandler<FavouriteItemHandler>();
|
||||||
services.AddHandler<UnfavouriteItemHandler>();
|
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<ItemCreatedHandler>(ServiceLifetime.Singleton);
|
||||||
services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton);
|
services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,24 +3,12 @@
|
|||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:ItemCategoryNavigationViewModel">
|
x:DataType="vm:ItemCategoryNavigationViewModel"
|
||||||
|
ListBoxExtension.IsItemInvokedEnabled="True">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static ListBoxExtension.ItemInvokedEvent}">
|
||||||
<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">
|
|
||||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||||
</DataTriggerBehavior>
|
</AttachedEventTriggerBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
<Grid Background="Transparent" ColumnDefinitions="Auto,*">
|
<Grid Background="Transparent" ColumnDefinitions="Auto,*">
|
||||||
<PersonPicture
|
<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'}"
|
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||||
Route="Item"
|
Route="Item"
|
||||||
Scope="self">
|
Scope="self">
|
||||||
|
<Parameter Key="FromCategory" Value="{x:False}" />
|
||||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||||
<Parameter Key="Name" Value="{Binding Name}" />
|
<Parameter Key="Name" Value="{Binding Name}" />
|
||||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
<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;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggregateItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
public class AggregateItemCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||||
@@ -10,9 +10,9 @@ public class AggregateItemCategoryViewModelHandler(IEnumerable<IConfigurationDes
|
|||||||
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
||||||
{
|
{
|
||||||
bool selected = true;
|
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)
|
is ItemCategoryNavigationViewModel viewModel)
|
||||||
{
|
{
|
||||||
publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel));
|
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;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggregateItemContentViewModelHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
public class AggregateItemContentViewModelHandler(IMediator mediator,
|
||||||
IMediator mediator,
|
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel>>
|
INotificationHandler<AggerateEventArgs<IItemEntryViewModel>>
|
||||||
{
|
{
|
||||||
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
||||||
{
|
{
|
||||||
var d = valueStore;
|
//wModel>(false) is ItemHeaderViewModel viewModel)
|
||||||
//if (serviceFactory.Create<ItemHeaderViewModel>(false) is ItemHeaderViewModel viewModel)
|
|
||||||
//{
|
//{
|
||||||
// publisher.Publish(Create.As<IItemEntryViewModel>(viewModel), nameof(ItemViewModel));
|
// publisher.Publish(Create.As<IItemEntryViewModel>(viewModel), nameof(ItemViewModel));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,32 +8,31 @@ public class AggerateItemViewModelHandler(IMediator mediator,
|
|||||||
ICache<Item<(Guid, string)>> cache,
|
ICache<Item<(Guid, string)>> cache,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
LockerViewModelConfiguration dd) :
|
LockerViewModelConfiguration dd) :
|
||||||
INotificationHandler<AggregateEventArgs<ItemNavigationViewModel,
|
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||||
LockerViewModelConfiguration>>
|
LockerViewModelConfiguration>>
|
||||||
{
|
{
|
||||||
public async Task Handle(AggregateEventArgs<ItemNavigationViewModel,
|
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||||
LockerViewModelConfiguration> args)
|
LockerViewModelConfiguration> args)
|
||||||
{
|
{
|
||||||
var ddddd = dd;
|
if (args.Value is LockerViewModelConfiguration configuration)
|
||||||
if (args.Options is LockerViewModelConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
cache.Clear();
|
cache.Clear();
|
||||||
bool selected = true;
|
bool selected = true;
|
||||||
|
|
||||||
if (await mediator.Handle<RequestEventArgs<QueryLockerConfiguration>,
|
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,
|
Filter = configuration.Filter,
|
||||||
Query = configuration.Query
|
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();
|
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||||
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
|
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));
|
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;
|
namespace Bitvault;
|
||||||
|
|
||||||
public interface IItemEntryViewModel :
|
public interface IItemEntryViewModel :
|
||||||
IDisposable
|
IDisposable;
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Aggerate(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
[Notification(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Aggerate(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
@@ -71,6 +71,6 @@ public partial class ItemCollectionViewModel :
|
|||||||
return base.OnActivated();
|
return base.OnActivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override AggregateExpression CreateAggregateExpression() =>
|
protected override AggregateExpression BuildAggregateExpression() =>
|
||||||
new(Aggregate.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
new(Aggregate.As<ItemNavigationViewModel, LockerViewModelConfiguration>(configuration));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public record ItemConfiguration
|
public record ItemConfiguration
|
||||||
{
|
{
|
||||||
public IList<ItemSectionConfiguration>? Sections { get; set; }
|
public IList<ItemSectionConfiguration> Sections { get; set; } = new List<ItemSectionConfiguration>();
|
||||||
|
|
||||||
public static ItemConfiguration Identity => new()
|
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;
|
namespace Bitvault;
|
||||||
|
|
||||||
//[Aggerate(nameof(ItemContentViewModel))]
|
public partial class ItemContentViewModel(IServiceProvider provider,
|
||||||
public partial class ItemContentViewModel :
|
IServiceFactory factory, IMediator mediator,
|
||||||
ObservableCollection<IItemEntryViewModel>,
|
IPublisher publisher,
|
||||||
|
ISubscription subscriber,
|
||||||
|
IDisposer disposer,
|
||||||
|
IContentTemplate template,
|
||||||
|
ItemState state = ItemState.Read) :
|
||||||
|
ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
IItemEntryViewModel,
|
IItemEntryViewModel,
|
||||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||||
{
|
{
|
||||||
public ItemContentViewModel(IServiceProvider provider,
|
public IContentTemplate Template { get; set; } = template;
|
||||||
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 Task Handle(NotifyEventArgs<ItemCategory<string>> args)
|
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;
|
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<UpdateEventArgs<Item>>,
|
||||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
INotificationHandler<CancelEventArgs<Item>>,
|
INotificationHandler<CancelEventArgs<Item>>,
|
||||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>,
|
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||||
IItemEntryViewModel
|
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? category;
|
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,
|
IContentTemplate template,
|
||||||
NamedComponent named,
|
NamedComponent named,
|
||||||
Guid id,
|
Guid id,
|
||||||
string? name = "",
|
string name = "",
|
||||||
string? description = "",
|
string description = "",
|
||||||
|
string category = "",
|
||||||
bool selected = false,
|
bool selected = false,
|
||||||
bool favourite = false,
|
bool favourite = false,
|
||||||
bool archived = false) :
|
bool archived = false) :
|
||||||
@@ -30,6 +31,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool archived = archived;
|
private bool archived = archived;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string? category = category;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? description = description;
|
private string? description = description;
|
||||||
|
|
||||||
@@ -48,8 +52,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool selected = selected;
|
private bool selected = selected;
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; } = template;
|
|
||||||
public bool Attached { get; set; }
|
public bool Attached { get; set; }
|
||||||
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
public Task Handle(ArchiveEventArgs<Item> args) =>
|
public Task Handle(ArchiveEventArgs<Item> args) =>
|
||||||
Task.Run(Dispose);
|
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.New))]
|
||||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.Write))]
|
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemState.Write))]
|
||||||
public partial class ItemViewModel :
|
public partial class ItemViewModel :
|
||||||
ObservableCollection<IItemEntryViewModel>,
|
ObservableCollection,
|
||||||
INotificationHandler<UpdateEventArgs<Item>>,
|
INotificationHandler<UpdateEventArgs<Item>>,
|
||||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
INotificationHandler<CancelEventArgs<Item>>
|
INotificationHandler<CancelEventArgs<Item>>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Aggerate(typeof(CreateEventArgs<IMainNavigationViewModel>), nameof(MainViewModel))]
|
[Notification(typeof(CreateEventArgs<IMainNavigationViewModel>), nameof(MainViewModel))]
|
||||||
public partial class MainViewModel :
|
public partial class MainViewModel :
|
||||||
ObservableCollection<IMainNavigationViewModel>
|
ObservableCollection<IMainNavigationViewModel>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
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)
|
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)
|
if (args.Value is QueryLockerConfiguration queryConfiguration)
|
||||||
{
|
{
|
||||||
@@ -47,6 +47,7 @@ public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactor
|
|||||||
{
|
{
|
||||||
x.Id,
|
x.Id,
|
||||||
x.Name,
|
x.Name,
|
||||||
|
x.Category,
|
||||||
Favourite = x.State == 1,
|
Favourite = x.State == 1,
|
||||||
Archived = x.State == 2
|
Archived = x.State == 2
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
@@ -54,7 +55,7 @@ public class QueryLockerHandler(IDbContextFactory<LockerContext> dbContextFactor
|
|||||||
|
|
||||||
foreach (var result in results.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase))
|
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