Allow configuration of entry width
This commit is contained in:
@@ -16,7 +16,8 @@ public partial class DropdownEntryViewModel :
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
DropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
|
||||
double width,
|
||||
DropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, width)
|
||||
{
|
||||
SelectedItem = selectedItem;
|
||||
}
|
||||
@@ -31,7 +32,8 @@ public partial class DropdownEntryViewModel :
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
|
||||
object value,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, width)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,12 @@ public class DropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
}
|
||||
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
DropdownValueViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
|
||||
|
||||
if (serviceFactory.Create<DropdownEntryViewModel>([values, .. args.Parameters, configuration, label, value ?? "", selected])
|
||||
if (serviceFactory.Create<DropdownEntryViewModel>([values, .. args.Parameters, configuration, label, value, width, selected])
|
||||
is DropdownEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -26,12 +26,19 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
object value,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
State = state;
|
||||
Width = width;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
|
||||
public ItemEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -42,10 +49,13 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
|
||||
object value,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
State = state;
|
||||
Width = width;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
|
||||
@@ -22,4 +22,7 @@ public record ItemEntryConfiguration :
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public object? Value { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Width { get; set; } = 296;
|
||||
}
|
||||
@@ -12,7 +12,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) :
|
||||
object value,
|
||||
double width) :
|
||||
Observable<string, object>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
@@ -22,8 +23,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private ItemState state = state;
|
||||
|
||||
protected override void OnValueChanged() =>
|
||||
configuration.Value = Value;
|
||||
[ObservableProperty]
|
||||
private double width = width;
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||
Task.FromResult(State = ItemState.Write);
|
||||
@@ -43,4 +44,7 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged() =>
|
||||
configuration.Value = Value;
|
||||
}
|
||||
@@ -13,7 +13,8 @@ public partial class MaskedTextEntryViewModel(IServiceProvider provider,
|
||||
ItemEntryConfiguration configuration,
|
||||
string pattern,
|
||||
string key,
|
||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string pattern = pattern;
|
||||
|
||||
@@ -10,7 +10,11 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
{
|
||||
if (args.Value is MaskedTextEntryConfiguration configuration)
|
||||
{
|
||||
if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, configuration.Label, configuration.Value])
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, label, value, width])
|
||||
is MaskedTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -11,5 +11,6 @@ public partial class MultilineTextEntryViewModel(IServiceProvider provider,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ public class MultilineTextEntryViewModelHandler(IServiceFactory serviceFactory)
|
||||
{
|
||||
if (args.Value is MultilineTextEntryConfiguration configuration)
|
||||
{
|
||||
if (serviceFactory.Create<MultilineTextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<MultilineTextEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||
is MultilineTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -11,4 +11,5 @@ public partial class PasswordEntryViewModel(IServiceProvider provider,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
@@ -10,7 +10,11 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
{
|
||||
if (args.Value is PasswordEntryConfiguration configuration)
|
||||
{
|
||||
if (serviceFactory.Create<PasswordEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<PasswordEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||
is PasswordEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
@@ -11,4 +11,5 @@ public partial class TextEntryViewModel(IServiceProvider provider,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
@@ -10,7 +10,11 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
{
|
||||
if (args.Value is TextEntryConfiguration configuration)
|
||||
{
|
||||
if (serviceFactory.Create<TextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<TextEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||
is TextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
|
||||
Reference in New Issue
Block a user