postit: fix rdv date picker binding
This commit is contained in:
parent
92e82edf72
commit
bf569a4ac5
3 changed files with 37 additions and 1 deletions
|
|
@ -135,6 +135,25 @@ public class BillingCommandPageViewModelTests
|
||||||
Assert.Contains("Position sélectionnée", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Position sélectionnée", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void EventDateSelection_round_trips_with_EventDate_for_DatePicker_binding()
|
||||||
|
{
|
||||||
|
var api = new RecordingApi();
|
||||||
|
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||||
|
var vm =
|
||||||
|
new CommandFormSummary { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }
|
||||||
|
.CreateCommandPageViewModel(
|
||||||
|
new ActivityInfo { Code = "dev", Name = "Développement" },
|
||||||
|
new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" },
|
||||||
|
client) as RdvViewModel;
|
||||||
|
|
||||||
|
var selected = new DateTimeOffset(2026, 9, 7, 14, 30, 0, TimeSpan.FromHours(2));
|
||||||
|
vm!.EventDateSelection = selected;
|
||||||
|
|
||||||
|
Assert.Equal(selected.LocalDateTime, vm.EventDate);
|
||||||
|
Assert.Equal(vm.EventDate, vm.EventDateSelection!.Value.LocalDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ApplyResolvedAddress_populates_empty_address_directly()
|
public void ApplyResolvedAddress_populates_empty_address_directly()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,18 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial DateTime EventDate { get; set; }
|
public partial DateTime EventDate { get; set; }
|
||||||
|
|
||||||
|
public DateTimeOffset? EventDateSelection
|
||||||
|
{
|
||||||
|
get => new(EventDate);
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (!value.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EventDate = value.Value.LocalDateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RdvViewModel(ActivityInfo activity, ActivityUserDisplayItem performer, CommandFormSummary form, BillingApiClient billingClient)
|
public RdvViewModel(ActivityInfo activity, ActivityUserDisplayItem performer, CommandFormSummary form, BillingApiClient billingClient)
|
||||||
: base(activity, performer, form, billingClient)
|
: base(activity, performer, form, billingClient)
|
||||||
{
|
{
|
||||||
|
|
@ -206,6 +218,11 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
OnPropertyChanged(nameof(HasSuggestedAddressPanel));
|
OnPropertyChanged(nameof(HasSuggestedAddressPanel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnEventDateChanged(DateTime value)
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(EventDateSelection));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override async Task SubmitAsync()
|
protected override async Task SubmitAsync()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding ActivityLabel}" IsReadOnly="True" Margin="0,0,0,8" />
|
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding ActivityLabel}" IsReadOnly="True" Margin="0,0,0,8" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="4" Text="Date" VerticalAlignment="Center" Margin="0,0,12,8" />
|
<TextBlock Grid.Row="4" Text="Date" VerticalAlignment="Center" Margin="0,0,12,8" />
|
||||||
<DatePicker Grid.Row="4" Grid.Column="1" DayFormat="ddd dd" SelectedDate="{Binding EventDate, Mode=TwoWay}" Margin="0,0,0,8" />
|
<DatePicker Grid.Row="4" Grid.Column="1" DayFormat="ddd dd" SelectedDate="{Binding EventDateSelection, Mode=TwoWay}" Margin="0,0,0,8" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="5"
|
<TextBlock Grid.Row="5"
|
||||||
Text="Motif"
|
Text="Motif"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue