Massive improvements to notes/commenting
This commit is contained in:
@@ -30,5 +30,17 @@ public partial class CommentEntryCollectionViewModel(IServiceProvider provider,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnStateChanged()
|
||||||
|
{
|
||||||
|
if (State is ItemState.Write)
|
||||||
|
{
|
||||||
|
Add<CreateCommentEntryViewModel>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemoveAt(Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,18 @@ public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFacto
|
|||||||
if (args.Sender is CommentEntryCollectionConfiguration configuration)
|
if (args.Sender is CommentEntryCollectionConfiguration configuration)
|
||||||
{
|
{
|
||||||
string? label = configuration.Label;
|
string? label = configuration.Label;
|
||||||
List<Comment> value = new List<Comment>();
|
List<Comment> values = configuration.Value is not null ? new List<Comment>(configuration.Value) : [];
|
||||||
double? width = configuration.Width;
|
double? width = configuration.Width;
|
||||||
|
|
||||||
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
|
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
|
||||||
[.. args.Parameters, configuration, label, value, false, false, width])
|
[.. args.Parameters, configuration, label, values, false, false, width])
|
||||||
is CommentEntryCollectionViewModel viewModel)
|
is CommentEntryCollectionViewModel viewModel)
|
||||||
{
|
{
|
||||||
|
foreach (Comment value in values.OrderByDescending(x => x.DateTime))
|
||||||
|
{
|
||||||
|
viewModel.Add<CommentEntryViewModel>(value.DateTime, value.Text);
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.Add<CreateCommentEntryViewModel>();
|
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,22 +77,36 @@ public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
|||||||
Track(nameof(Value), () => Value, x => Value = x);
|
Track(nameof(Value), () => Value, x => Value = x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
public Task Handle(UpdateEventArgs<Item> args)
|
||||||
Task.FromResult(State = ItemState.Write);
|
{
|
||||||
|
State = ItemState.Write;
|
||||||
|
OnStateChanged();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
public Task Handle(CancelEventArgs<Item> args)
|
public Task Handle(CancelEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
Revert();
|
Revert();
|
||||||
|
|
||||||
State = ItemState.Read;
|
State = ItemState.Read;
|
||||||
|
OnStateChanged();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnStateChanged()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Task Handle(ConfirmEventArgs<Item> args)
|
public Task Handle(ConfirmEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
Commit();
|
Commit();
|
||||||
|
|
||||||
State = ItemState.Read;
|
State = ItemState.Read;
|
||||||
|
OnStateChanged();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user