Got adding working again
This commit is contained in:
@@ -68,7 +68,8 @@ public partial class App : Application
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddHandler<QueryContainerHandler>(ServiceLifetime.Singleton);
|
services.AddHandler<QueryContainerHandler>();
|
||||||
|
services.AddHandler<CreateItemHander>();
|
||||||
|
|
||||||
services.AddHandler<OpenContainerHandler>();
|
services.AddHandler<OpenContainerHandler>();
|
||||||
|
|
||||||
@@ -91,6 +92,7 @@ public partial class App : Application
|
|||||||
|
|
||||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||||
|
services.AddHandler<AggerateItemViewModelHandler>();
|
||||||
|
|
||||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||||
|
|
||||||
@@ -111,6 +113,8 @@ public partial class App : Application
|
|||||||
services.AddHandler<UnarchiveItemHandler>(ServiceLifetime.Scoped);
|
services.AddHandler<UnarchiveItemHandler>(ServiceLifetime.Scoped);
|
||||||
services.AddHandler<FavouriteItemHandler>(ServiceLifetime.Scoped);
|
services.AddHandler<FavouriteItemHandler>(ServiceLifetime.Scoped);
|
||||||
services.AddHandler<UnfavouriteItemHandler>(ServiceLifetime.Scoped);
|
services.AddHandler<UnfavouriteItemHandler>(ServiceLifetime.Scoped);
|
||||||
|
|
||||||
|
services.AddHandler<ItemActivatedHandler>(ServiceLifetime.Singleton);
|
||||||
});
|
});
|
||||||
})!);
|
})!);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
HotKey="Delete"
|
HotKey="Delete"
|
||||||
ToolTip.Tip="Archive">
|
ToolTip.Tip="Archive">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
Foreground="{DynamicResource IconForegroundBrush}"
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
ToolTip.Tip="Save">
|
ToolTip.Tip="Save">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -4,5 +4,16 @@
|
|||||||
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:ContainerHeaderViewModel">
|
x:DataType="vm:ContainerHeaderViewModel">
|
||||||
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}" />
|
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<Grid ColumnDefinitions="Auto,6,*" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.Styles>
|
||||||
|
<Style Selector="ContentPresenter">
|
||||||
|
<Setter Property="Grid.Column" Value="{ReflectionBinding Index}" />
|
||||||
|
</Style>
|
||||||
|
</ItemsControl.Styles>
|
||||||
|
</ItemsControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -4,14 +4,17 @@
|
|||||||
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:ContainerViewModel">
|
x:DataType="vm:ContainerViewModel">
|
||||||
<Grid ColumnDefinitions="320,Auto,*" RowDefinitions="Auto,*">
|
<Grid
|
||||||
|
x:Name="Container"
|
||||||
|
ColumnDefinitions="320,Auto,*,Auto"
|
||||||
|
Grid.IsSharedSizeScope="True"
|
||||||
|
RowDefinitions="Auto,*">
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="Title"
|
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.ColumnSpan="3"
|
Grid.ColumnSpan="3"
|
||||||
Height="44"
|
Height="44"
|
||||||
ColumnDefinitions="*, Auto">
|
Margin="8,0,0,0">
|
||||||
<ContentControl Grid.Column="0" VerticalAlignment="Center">
|
<ContentControl VerticalAlignment="Center">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
<NavigateAction Region="{Binding $self}" Route="ContainerHeader" />
|
<NavigateAction Region="{Binding $self}" Route="ContainerHeader" />
|
||||||
@@ -42,6 +45,7 @@
|
|||||||
<Border
|
<Border
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
|
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
|
||||||
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
||||||
BorderThickness="1,1,0,0"
|
BorderThickness="1,1,0,0"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public partial class ContainerView : UserControl
|
|||||||
|
|
||||||
if (VisualRoot is AppWindow appWindow)
|
if (VisualRoot is AppWindow appWindow)
|
||||||
{
|
{
|
||||||
Title.ColumnDefinitions[1].Width = new GridLength(appWindow.TitleBar.RightInset, GridUnitType.Pixel);
|
Container.ColumnDefinitions[3].Width = new GridLength(appWindow.TitleBar.RightInset, GridUnitType.Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,33 @@
|
|||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:CreateItemActionViewModel">
|
x:DataType="vm:CreateItemActionViewModel">
|
||||||
<Button
|
<Button
|
||||||
Grid.Column="1"
|
Height="32"
|
||||||
Width="{StaticResource ButtonWidth}"
|
MinWidth="144"
|
||||||
Height="{StaticResource ButtonHeight}"
|
HorizontalContentAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
Classes="accent"
|
||||||
Content=""
|
CornerRadius="16"
|
||||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||||
FontSize="16"
|
ToolTip.Tip="New Item">
|
||||||
ToolTip.Tip="Add item">
|
<Grid ColumnDefinitions="Auto,8,*">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="-6,3,0,0"
|
||||||
|
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||||
|
FontSize="16"
|
||||||
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
|
Text="" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="0,2,0,0"
|
||||||
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
|
Text="New Item" />
|
||||||
|
</Grid>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<EventTriggerBehavior EventName="Click">
|
<EventTriggerBehavior EventName="Click">
|
||||||
|
<NavigateAction
|
||||||
|
Region="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
|
||||||
|
Route="ItemCommandHeader"
|
||||||
|
Scope="self" />
|
||||||
<NavigateAction
|
<NavigateAction
|
||||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||||
Route="Item"
|
Route="Item"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
Foreground="{DynamicResource IconForegroundBrush}"
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
ToolTip.Tip="Delete">
|
ToolTip.Tip="Delete">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
Foreground="{DynamicResource IconForegroundBrush}"
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
ToolTip.Tip="Cancel">
|
ToolTip.Tip="Cancel">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
Foreground="{DynamicResource IconForegroundBrush}"
|
Foreground="{DynamicResource IconForegroundBrush}"
|
||||||
ToolTip.Tip="Edit">
|
ToolTip.Tip="Edit">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
Route="Item"
|
Route="Item"
|
||||||
Scope="self">
|
Scope="self">
|
||||||
<NavigateAction.ParameterBindings>
|
<NavigateAction.ParameterBindings>
|
||||||
|
<ParameterBinding Key="Immutable" Value="{x:True}" />
|
||||||
<ParameterBinding Key="Archived" Value="{Binding Archived}" />
|
<ParameterBinding Key="Archived" Value="{Binding Archived}" />
|
||||||
<ParameterBinding Key="Favourite" Value="{Binding Favourite}" />
|
<ParameterBinding Key="Favourite" Value="{Binding Favourite}" />
|
||||||
</NavigateAction.ParameterBindings>
|
</NavigateAction.ParameterBindings>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
MaxWidth="500"
|
MaxWidth="500"
|
||||||
CornerRadius="16"
|
CornerRadius="16"
|
||||||
Text="{Binding Value}"
|
Text="{Binding Value}"
|
||||||
|
TextBlock.TextAlignment="Center"
|
||||||
Watermark="Search">
|
Watermark="Search">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<KeyBindingTriggerBehaviour Gesture="Enter">
|
<KeyBindingTriggerBehaviour Gesture="Enter">
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ public class AggerateContainerViewModelHandler(IMediator mediator,
|
|||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
ICache<Item> cache,
|
ICache<Item> cache,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<Aggerate<ItemNavigationViewModel, ContainerViewModelConfiguration>>
|
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel, ContainerViewModelConfiguration>>
|
||||||
{
|
{
|
||||||
public async Task Handle(Aggerate<ItemNavigationViewModel,
|
public async Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||||
ContainerViewModelConfiguration> args)
|
ContainerViewModelConfiguration> args)
|
||||||
{
|
{
|
||||||
if (args.Options is ContainerViewModelConfiguration configuration)
|
if (args.Options is ContainerViewModelConfiguration configuration)
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class AggerateItemViewModelHandler(IMediator mediator,
|
||||||
|
IServiceFactory serviceFactory,
|
||||||
|
IPublisher publisher) :
|
||||||
|
INotificationHandler<AggerateEventArgs<IItemEntryViewModel>>
|
||||||
|
{
|
||||||
|
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
||||||
|
{
|
||||||
|
if (serviceFactory.Create<ItemHeaderViewModel>(false) is ItemHeaderViewModel viewModel)
|
||||||
|
{
|
||||||
|
publisher.Publish(Create.As<IItemEntryViewModel>(viewModel), nameof(ItemViewModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class ConfirmItemHandler(IMediator mediator) :
|
public class ConfirmItemHandler(IMediator mediator,
|
||||||
|
IPublisher publisher) :
|
||||||
INotificationHandler<ConfirmEventArgs<Item>>
|
INotificationHandler<ConfirmEventArgs<Item>>
|
||||||
{
|
{
|
||||||
public async Task Handle(ConfirmEventArgs<Item> args)
|
public async Task Handle(ConfirmEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
(bool result, int index) result = await mediator.Handle<CreateEventArgs<ItemConfiguration>,
|
|
||||||
(bool, int)>(new CreateEventArgs<ItemConfiguration>(new ItemConfiguration()));
|
|
||||||
|
|
||||||
ItemHeaderConfiguration? configuration = await mediator.Handle<ConfirmEventArgs<Item>,
|
ItemHeaderConfiguration? configuration = await mediator.Handle<ConfirmEventArgs<Item>,
|
||||||
ItemHeaderConfiguration>(args);
|
ItemHeaderConfiguration>(args);
|
||||||
|
|
||||||
|
(bool Success, int Id, string Name) result = await mediator.Handle<CreateEventArgs<ItemConfiguration>,
|
||||||
|
(bool, int, string)>(new CreateEventArgs<ItemConfiguration>(new ItemConfiguration { Name = configuration?.Name }));
|
||||||
|
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
publisher.Publish(Activated.As(new Item { Id = result.Id, Name = result.Name }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,9 @@ public partial class ContainerHeaderViewModel :
|
|||||||
{
|
{
|
||||||
Template = template;
|
Template = template;
|
||||||
|
|
||||||
Add<SearchContainerActionViewModel>();
|
Add<CreateItemActionViewModel>(0);
|
||||||
|
Add<SearchContainerActionViewModel>(2);
|
||||||
//Add<CreateItemActionViewModel>(scope: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
|
|
||||||
//public Task Handle(RequestEventArgs<Filter<string>> args)
|
|
||||||
//{
|
|
||||||
// if (args.Value is Filter<string> filter)
|
|
||||||
// {
|
|
||||||
// Value = filter.Value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
|
||||||
[Enumerate(nameof(ContainerViewModel))]
|
[Aggerate(nameof(ContainerViewModel))]
|
||||||
public partial class ContainerViewModel(IServiceProvider provider,
|
public partial class ContainerViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@@ -13,7 +13,7 @@ public partial class ContainerViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
NamedComponent named,
|
NamedComponent named,
|
||||||
ContainerViewModelConfiguration configuration) : Toolkit.Foundation.ObservableCollection<ItemNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
ContainerViewModelConfiguration configuration) : ObservableCollection<ItemNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||||
INotificationHandler<NotifyEventArgs<Search>>
|
INotificationHandler<NotifyEventArgs<Search>>
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ public partial class ContainerViewModel(IServiceProvider provider,
|
|||||||
if (args.Value is Filter filter)
|
if (args.Value is Filter filter)
|
||||||
{
|
{
|
||||||
configuration = configuration with { Filter = filter.Value };
|
configuration = configuration with { Filter = filter.Value };
|
||||||
Aggerate();
|
BeginAggregation();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -49,12 +49,12 @@ public partial class ContainerViewModel(IServiceProvider provider,
|
|||||||
if (args.Value is Search search)
|
if (args.Value is Search search)
|
||||||
{
|
{
|
||||||
configuration = configuration with { Query = search.Value };
|
configuration = configuration with { Query = search.Value };
|
||||||
Aggerate();
|
BeginAggregation();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IAggerate OnAggerate(object? key) =>
|
protected override IAggerate OnPrepareAggregation(object? key) =>
|
||||||
AggerateEventArgs<ItemNavigationViewModel>.With(configuration) with { Key = key };
|
Aggerate.With<ItemNavigationViewModel, ContainerViewModelConfiguration>(configuration) with { Key = key };
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,11 @@ public partial class CreateItemActionViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
NamedComponent named) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
NamedComponent named,
|
||||||
|
int index) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private int index = index;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string named = $"{named}";
|
private string named = $"{named}";
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ using Toolkit.Foundation;
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class CreateItemHander(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class CreateItemHander(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||||
IHandler<CreateEventArgs<ItemConfiguration>, (bool, int)>
|
IHandler<CreateEventArgs<ItemConfiguration>, (bool, int, string?)>
|
||||||
{
|
{
|
||||||
public async Task<(bool, int)> Handle(CreateEventArgs<ItemConfiguration> args,
|
public async Task<(bool, int, string?)> Handle(CreateEventArgs<ItemConfiguration> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (args.Value is ItemConfiguration configuration)
|
if (args.Value is ItemConfiguration configuration)
|
||||||
@@ -27,7 +27,7 @@ public class CreateItemHander(IDbContextFactory<ContainerDbContext> dbContextFac
|
|||||||
|
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
{
|
{
|
||||||
return (false, -1);
|
return (true, result.Entity.Id, result.Entity.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -36,6 +36,6 @@ public class CreateItemHander(IDbContextFactory<ContainerDbContext> dbContextFac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (false, -1);
|
return (false, -1, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public interface IItemEntryViewModel :
|
||||||
|
IDisposable
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,3 +4,28 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class ItemActivatedHandler(IServiceProvider serviceProvider,
|
||||||
|
ICache<Item> cache,
|
||||||
|
IPublisher publisher) :
|
||||||
|
INotificationHandler<ActivatedEventArgs<Item>>
|
||||||
|
{
|
||||||
|
public Task Handle(ActivatedEventArgs<Item> args)
|
||||||
|
{
|
||||||
|
if (args.Value is Item item)
|
||||||
|
{
|
||||||
|
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||||
|
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||||
|
|
||||||
|
cache.Add(item);
|
||||||
|
int index = cache.IndexOf(item);
|
||||||
|
|
||||||
|
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description " + 1, true)
|
||||||
|
is ItemNavigationViewModel viewModel)
|
||||||
|
{
|
||||||
|
publisher.Publish(Insert.As(index, viewModel), nameof(ContainerViewModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
|
|||||||
public Task Handle(NotifyEventArgs<CommandCollection> args)
|
public Task Handle(NotifyEventArgs<CommandCollection> args)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (args.Value is CommandCollection commandCollection)
|
if (args.Value is CommandCollection commandCollection)
|
||||||
{
|
{
|
||||||
foreach (IDisposable command in commandCollection)
|
foreach (IDisposable command in commandCollection)
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public partial class ItemHeaderViewModel(IServiceProvider provider,
|
|||||||
bool immutable,
|
bool immutable,
|
||||||
string? value = null) : Observable<string, string>(provider, factory, mediator, publisher, subscriber, disposer, value),
|
string? value = null) : Observable<string, string>(provider, factory, mediator, publisher, subscriber, disposer, value),
|
||||||
IHandler<ValidationEventArgs<Item>, bool>,
|
IHandler<ValidationEventArgs<Item>, bool>,
|
||||||
IHandler<ConfirmEventArgs<Item>, ItemHeaderConfiguration>
|
IHandler<ConfirmEventArgs<Item>, ItemHeaderConfiguration>,
|
||||||
|
IItemEntryViewModel
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool immutable = immutable;
|
private bool immutable = immutable;
|
||||||
@@ -20,7 +21,6 @@ public partial class ItemHeaderViewModel(IServiceProvider provider,
|
|||||||
public Task<bool> Handle(ValidationEventArgs<Item> args,
|
public Task<bool> Handle(ValidationEventArgs<Item> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// we need to work on the local validation layer
|
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
string name,
|
string name,
|
||||||
string description,
|
string description,
|
||||||
bool selected,
|
bool selected,
|
||||||
bool favourite,
|
bool favourite = false,
|
||||||
bool archived) :
|
bool archived = false) :
|
||||||
Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
INotificationHandler<ArchiveEventArgs<Item>>,
|
INotificationHandler<ArchiveEventArgs<Item>>,
|
||||||
INotificationHandler<UnarchiveEventArgs<Item>>,
|
INotificationHandler<UnarchiveEventArgs<Item>>,
|
||||||
|
|||||||
+41
-18
@@ -3,14 +3,21 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
[Aggerate(nameof(ItemViewModel))]
|
||||||
public partial class ItemViewModel :
|
public partial class ItemViewModel :
|
||||||
ObservableCollection<IDisposable>,
|
ObservableCollection<IItemEntryViewModel>,
|
||||||
INotificationHandler<EditEventArgs<Item>>,
|
INotificationHandler<EditEventArgs<Item>>,
|
||||||
INotificationHandler<CancelEventArgs<Item>>
|
INotificationHandler<CancelEventArgs<Item>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool archived;
|
private bool archived;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool favourite;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool immutable;
|
||||||
|
|
||||||
public ItemViewModel(IServiceProvider provider,
|
public ItemViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@@ -18,28 +25,14 @@ public partial class ItemViewModel :
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
|
bool immutable = true,
|
||||||
bool favourite = false,
|
bool favourite = false,
|
||||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
Template = template;
|
Template = template;
|
||||||
|
Immutable = immutable;
|
||||||
|
Favourite = favourite;
|
||||||
Archived = archived;
|
Archived = archived;
|
||||||
|
|
||||||
if (!Archived)
|
|
||||||
{
|
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
|
||||||
{
|
|
||||||
Factory.Create<FavouriteItemActionViewModel>(favourite),
|
|
||||||
Factory.Create<EditItemActionViewModel>(),
|
|
||||||
Factory.Create<ArchiveItemActionViewModel>(),
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
|
||||||
{
|
|
||||||
Factory.Create<UnarchiveItemActionViewModel>(),
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
@@ -65,4 +58,34 @@ public partial class ItemViewModel :
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task OnActivated()
|
||||||
|
{
|
||||||
|
if (!Immutable)
|
||||||
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
Factory.Create<ConfirmItemActionViewModel>(),
|
||||||
|
Factory.Create<DismissItemActionViewModel>(),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
else if (Archived)
|
||||||
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
Factory.Create<UnarchiveItemActionViewModel>(),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||||
|
Factory.Create<EditItemActionViewModel>(),
|
||||||
|
Factory.Create<ArchiveItemActionViewModel>(),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnActivated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Enumerate(nameof(MainViewModel))]
|
[Aggerate(nameof(MainViewModel))]
|
||||||
public partial class MainViewModel :
|
public partial class MainViewModel :
|
||||||
ObservableCollection<IMainNavigationViewModel>
|
ObservableCollection<IMainNavigationViewModel>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public record QueryContainerConfiguration
|
|||||||
public string? Filter { get; set; }
|
public string? Filter { get; set; }
|
||||||
|
|
||||||
public string? Query { get; set; }
|
public string? Query { get; set; }
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,21 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public class QueryItemHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||||
|
IHandler<RequestEventArgs<QueryItemConfiguration>, (int Id, string? Name)>
|
||||||
|
{
|
||||||
|
public Task<(int Id, string? Name)> Handle(RequestEventArgs<QueryItemConfiguration> args,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record QueryItemConfiguration
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||||
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(int Id, string? Name, bool Favourite, bool Archived)>>
|
IHandler<RequestEventArgs<QueryContainerConfiguration>, IReadOnlyCollection<(int Id, string? Name, bool Favourite, bool Archived)>>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
@@ -8,8 +9,12 @@ public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer,
|
||||||
|
int index) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private int index = index;
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||||
nameof(ContainerViewModel));
|
nameof(ContainerViewModel));
|
||||||
|
|||||||
Reference in New Issue
Block a user