Skip to content

Commit

Permalink
Value takes precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
blanchg committed Oct 24, 2023
1 parent 018b3ef commit 92d09c5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
16 changes: 9 additions & 7 deletions BlazorAppTest/Pages/HxInputDate_Issue621_Test.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@
<HxInputDate Label="No DisplayMonth" @bind-Value="value1"/>
<HxInputDate Label="Next Month Value" @bind-Value="nextMonth" />
<HxInputDate Label="Next Month Display Month" @bind-Value="value2" CalendarDisplayMonth="@nextMonth" />
<HxInputDateRange Label="DateRange No DisplayMonth" @bind-Value="Holidays" />
<HxInputDateRange Label="DateRange From DisplayMonth" @bind-Value="Unset" FromCalendarDisplayMonth="@nextMonthNextYear" />
<HxInputDateRange Label="DateRange To DisplayMonth" @bind-Value="Unset" ToCalendarDisplayMonth="@nextMonthNextYear" />
<HxInputDateRange Label="DateRange Both DisplayMonth" @bind-Value="Unset" FromCalendarDisplayMonth="@nextMonth" ToCalendarDisplayMonth="@nextMonthNextYear"/>
<HxInputDateRange Label="DateRange No DisplayMonth" @bind-Value="holidays" />
<HxInputDateRange Label="DateRange From DisplayMonth" @bind-Value="unset1" FromCalendarDisplayMonth="@nextMonthNextYear" />
<HxInputDateRange Label="DateRange To DisplayMonth" @bind-Value="unset2" ToCalendarDisplayMonth="@nextMonthNextYear" />
<HxInputDateRange Label="DateRange Both DisplayMonth" @bind-Value="unset3" FromCalendarDisplayMonth="@nextMonth" ToCalendarDisplayMonth="@nextMonthNextYear"/>

@code {
private DateTime nextMonth;
private DateTime nextMonthNextYear;
private DateTime value1;
private DateTime value2;

private DateTimeRange Holidays;
private DateTimeRange Unset;
private DateTimeRange holidays;
private DateTimeRange unset1;
private DateTimeRange unset2;
private DateTimeRange unset3;

protected override async Task OnInitializedAsync()
{
nextMonth = DateTime.Now.AddDays(1-DateTime.Now.Day).AddMonths(1);
nextMonthNextYear = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddYears(1);
Holidays = new DateTimeRange
holidays = new DateTimeRange
{
StartDate = nextMonth,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@if (EnabledEffective)
{
<div class="hx-input-date-calendar">
<HxCalendar Value="@GetDateTimeFromValue(Value)" ValueChanged="HandleCalendarValueChangedAsync" MinDate="@MinDateEffective" MaxDate="@MaxDateEffective" DateCustomizationProvider="GetCalendarDateCustomization" KeyboardNavigation="false" DisplayMonth="@CalendarDisplayMonth" />
<HxCalendar Value="@GetDateTimeFromValue(Value)" ValueChanged="HandleCalendarValueChangedAsync" MinDate="@MinDateEffective" MaxDate="@MaxDateEffective" DateCustomizationProvider="GetCalendarDateCustomization" KeyboardNavigation="false" DisplayMonth="@GetCalendarDisplayMonthEffective" />
</div>
<div class="hx-input-date-dropdown-buttons">
@if (ShowClearButtonEffective)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public partial class HxInputDateInternal<TValue> : InputBase<TValue>, IAsyncDisp
protected bool RenderPredefinedDates => ShowPredefinedDatesEffective && (this.PredefinedDatesEffective != null) && PredefinedDatesEffective.Any();
protected bool RenderIcon => CalendarIconEffective is not null && !HasInputGroupsEffective;

protected DateTime GetCalendarDisplayMonthEffective => GetDateTimeFromValue(CurrentValue) ?? CalendarDisplayMonth;

private TValue previousValue;

private bool previousParsingAttemptFailed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@if (EnabledEffective)
{
<div class="hx-input-date-range-calendar">
<HxCalendar Value="@Value.StartDate" ValueChanged="HandleFromCalendarValueChangedAsync" MinDate="@MinDateEffective" MaxDate="@MaxDateEffective" DateCustomizationProvider="GetCalendarDateCustomizationFrom" KeyboardNavigation="false" DisplayMonth="@FromCalendarDisplayMonth"/>
<HxCalendar Value="@Value.StartDate" ValueChanged="HandleFromCalendarValueChangedAsync" MinDate="@MinDateEffective" MaxDate="@MaxDateEffective" DateCustomizationProvider="GetCalendarDateCustomizationFrom" KeyboardNavigation="false" DisplayMonth="@GetFromCalendarDisplayMonthEffective" />
</div>
<div class="hx-input-date-range-buttons">
@if (ShowClearButtonEffective)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ public partial class HxInputDateRangeInternal : InputBase<DateTimeRange>, IAsync
private HxDropdownToggleElement fromDropdownToggleElement;
private HxDropdownToggleElement toDropdownToggleElement;

private DateTime GetFromCalendarDisplayMonthEffective => CurrentValue.StartDate ?? FromCalendarDisplayMonth;

private DateTime GetToCalendarDisplayMonthEffective
{
get
{
if (CurrentValue.EndDate != null)
{
return CurrentValue.EndDate.Value;
}
if (CurrentValue.StartDate != null && CurrentValue.StartDate != default)
{
if (ToCalendarDisplayMonth != default && ToCalendarDisplayMonth > CurrentValue.StartDate)
Expand Down

0 comments on commit 92d09c5

Please sign in to comment.