Editing WIP
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
BorderThickness="1,1,0,0"
|
BorderThickness="1,1,0,0"
|
||||||
CornerRadius="8 0 0 0">
|
CornerRadius="8 0 0 0">
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
<Border Grid.Row="0" Padding="4">
|
<Border Grid.Row="0" Padding="4" Height="44">
|
||||||
<ContentControl>
|
<ContentControl>
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
|
|||||||
@@ -11,15 +11,33 @@
|
|||||||
DisplayName="{Binding Value}" />
|
DisplayName="{Binding Value}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
MaxWidth="360"
|
MaxWidth="360"
|
||||||
IsVisible="{Binding !Immutable}"
|
IsReadOnly="{Binding Immutable, Mode=TwoWay}"
|
||||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||||
TextAlignment="Center"
|
TextAlignment="Center"
|
||||||
Watermark="Enter name" />
|
Watermark="Enter name">
|
||||||
<SelectableTextBlock
|
<TextBox.Styles>
|
||||||
MaxWidth="360"
|
<Style Selector="TextBox[IsReadOnly=True]">
|
||||||
IsVisible="{Binding Immutable}"
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
SelectionBrush="Red"
|
<Setter Property="Background" Value="Transparent" />
|
||||||
Text="{Binding Value}"
|
<Style Selector="^:pointerover">
|
||||||
TextAlignment="Center" />
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundPointerOver}" />
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundFocused}" />
|
||||||
|
<Style Selector="^ /template/ TextBlock#PART_Watermark">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundFocused}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ public class AggerateItemViewModelHandler(IMediator mediator,
|
|||||||
{
|
{
|
||||||
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
public Task Handle(AggerateEventArgs<IItemEntryViewModel> args)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemHeaderViewModel>(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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ public partial class EditItemActionViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Invoke() => Publisher.Publish(Edit.As<Item>(), nameof(ItemViewModel));
|
public void Invoke() => Publisher.Publish(Edit.As<Item>());
|
||||||
}
|
}
|
||||||
+1
-1
@@ -4,6 +4,6 @@ public record Item
|
|||||||
{
|
{
|
||||||
public Guid Id { get; init; }
|
public Guid Id { get; init; }
|
||||||
|
|
||||||
public string Name { get; init; } = "";
|
public string? Name { get; init; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public record ItemConfiguration
|
public record ItemConfiguration
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = "";
|
public string? Name { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public record ItemHeaderConfiguration
|
public record ItemHeaderConfiguration
|
||||||
{
|
{
|
||||||
public string Name { get; init; } = "";
|
public string? Name { get; init; } = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ public partial class ItemHeaderViewModel(IServiceProvider provider,
|
|||||||
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, IRemovable
|
INotificationHandler<EditEventArgs<Item>>,
|
||||||
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
|
INotificationHandler<CancelEventArgs<Item>>,
|
||||||
|
IItemEntryViewModel
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool immutable = immutable;
|
private bool immutable = immutable;
|
||||||
@@ -24,11 +27,15 @@ public partial class ItemHeaderViewModel(IServiceProvider provider,
|
|||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<ItemHeaderConfiguration> Handle(ConfirmEventArgs<Item> args,
|
public Task<ItemHeaderConfiguration> Handle(ConfirmEventArgs<Item> args,
|
||||||
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value });
|
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value });
|
||||||
|
|
||||||
|
public Task Handle(EditEventArgs<Item> args) =>
|
||||||
|
Task.FromResult(Immutable = false);
|
||||||
|
|
||||||
|
public Task Handle(CancelEventArgs<Item> args) =>
|
||||||
|
Task.FromResult(Immutable = true);
|
||||||
|
|
||||||
|
public Task Handle(ConfirmEventArgs<Item> args) =>
|
||||||
|
Task.FromResult(Immutable = true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Aggerate(nameof(ItemViewModel))]
|
|
||||||
public partial class ItemViewModel :
|
public partial class ItemViewModel :
|
||||||
ObservableCollection<IItemEntryViewModel>,
|
ObservableCollection<IItemEntryViewModel>,
|
||||||
INotificationHandler<EditEventArgs<Item>>,
|
INotificationHandler<EditEventArgs<Item>>,
|
||||||
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
INotificationHandler<CancelEventArgs<Item>>
|
INotificationHandler<CancelEventArgs<Item>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@@ -43,6 +43,8 @@ public partial class ItemViewModel :
|
|||||||
Favourite = favourite;
|
Favourite = favourite;
|
||||||
Archived = archived;
|
Archived = archived;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
|
Add<ItemHeaderViewModel>(immutable, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; }
|
public IContentTemplate Template { get; set; }
|
||||||
@@ -69,6 +71,18 @@ public partial class ItemViewModel :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task Handle(ConfirmEventArgs<Item> args)
|
||||||
|
{
|
||||||
|
Publisher.Publish(Notify.As(Factory.Create<CommandCollection>(new List<IDisposable>
|
||||||
|
{
|
||||||
|
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||||
|
Factory.Create<EditItemActionViewModel>(),
|
||||||
|
Factory.Create<ArchiveItemActionViewModel>(),
|
||||||
|
})));
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
public override Task OnActivated()
|
public override Task OnActivated()
|
||||||
{
|
{
|
||||||
if (!Immutable)
|
if (!Immutable)
|
||||||
|
|||||||
Reference in New Issue
Block a user